diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 934405444..3a0383600 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -71,8 +71,8 @@ ExternalProject_Add(libxc ExternalProject_Add(libtagarray PREFIX ${CMAKE_SOURCE_DIR}/external/libtagarray - URL https://github.com/foxtran/libtagarray/archive/refs/tags/v0.0.6.tar.gz - URL_HASH SHA256=9c844092f123276bb461e37e3451068c097b5a1fec9d65514ad3018baaeb2b32 + URL https://github.com/foxtran/libtagarray/archive/refs/tags/v0.0.7.tar.gz + URL_HASH SHA256=d37a1cd16f2f46c27daa57f4997d5c2f684ad46c0ca3ea958a5e578e409e5094 # GIT_REPOSITORY https://github.com/foxtran/libtagarray.git # GIT_TAG master BINARY_DIR ${CMAKE_BINARY_DIR}/external/libtagarray/src/libtagarray-build-${CMAKE_Fortran_COMPILER_ID} @@ -81,6 +81,7 @@ ExternalProject_Add(libtagarray INSTALL_COMMAND "" CMAKE_ARGS -DENABLE_FORTRAN=ON -DENABLE_TESTING=OFF + -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_GENERATOR:INTERNAL=${CMAKE_GENERATOR} diff --git a/source/c_interop.F90 b/source/c_interop.F90 index 104b66217..18953aadd 100644 --- a/source/c_interop.F90 +++ b/source/c_interop.F90 @@ -274,7 +274,7 @@ function oqp_get(c_handle, code, type_id, ndims, dims, v) result(n) bind(C, name type(c_ptr), intent(out) :: v integer(c_int32_t) :: type_id integer(c_int32_t) :: ndims - integer(c_int64_t) :: dims(TA_DIMENSIONS_LENGTH) + integer(c_int64_t) :: dims(TA_MAX_DIMENSIONS_LENGTH) type(information), pointer :: inf character(:), allocatable :: code_str @@ -311,11 +311,12 @@ function oqp_alloc(c_handle, tag, type_id, ndims, dims, v) result(n) bind(C, nam type(c_ptr), intent(out) :: v integer(c_int32_t) :: type_id integer(c_int32_t) :: ndims - integer(c_int64_t) :: dims(TA_DIMENSIONS_LENGTH) + integer(c_int64_t) :: dims(TA_MAX_DIMENSIONS_LENGTH) type(information), pointer :: inf character(:), allocatable :: tag_str integer(c_int64_t) :: data_size + integer(c_int32_t) :: status_ n = -1 if (.not.c_associated(c_handle%inf)) return @@ -323,11 +324,9 @@ function oqp_alloc(c_handle, tag, type_id, ndims, dims, v) result(n) bind(C, nam tag_str = trim(adjustl(c_f_char(tag))) - ! 1. check, if the data already exist, and clean it if yes - call inf%dat%remove_records([tag_str]) - ! 2. allocate the memory in container - call inf%dat%reserve_data(tag_str, type_id, product(dims(:ndims)), dims(:ndims)) - ! 3. Get the pointer to the freshly allocated data + ! 1. allocate the memory in container (override, if exists) + status_ = inf%dat%create(tag_str, type_id, dims(:ndims), override=.true._4) + ! 2. Get the pointer to the freshly allocated data n = tagarray_get_cptr(inf%dat, tag_str, v, type_id, ndims, dims, data_size) if (.not.c_associated(v)) n = -2 @@ -366,7 +365,7 @@ function oqp_del(c_handle, tag) result(n) bind(C, name='oqp_del') if (stat /= TA_OK) return n = -3 - call inf%dat%remove_records([tag_str]) + call inf%dat%erase([tag_str]) n = 0 diff --git a/source/modules/get_basis_overlap.F90 b/source/modules/get_basis_overlap.F90 index 54dcc46a5..619e5e833 100644 --- a/source/modules/get_basis_overlap.F90 +++ b/source/modules/get_basis_overlap.F90 @@ -60,6 +60,7 @@ end subroutine get_structures_ao_overlap_c !> Old MO energies (e_a_old) are taken from mol.data["OQP::E_MO_A_old"] !> subroutine get_structures_ao_overlap(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use precision, only: dp use io_constants, only: iw use oqp_tagarray_driver @@ -85,6 +86,7 @@ subroutine get_structures_ao_overlap(infos) integer :: i, nbf ! Tagarray definitions and data pointers + integer(c_int32_t) :: stat character(len=*), parameter :: tags_general(*) = (/ character(len=80) :: & OQP_XYZ_old, OQP_VEC_MO_A, OQP_E_MO_A, OQP_VEC_MO_A_old, OQP_E_MO_A_old /) character(len=*), parameter :: tags_alloc(*) = (/ character(len=80) :: & @@ -104,11 +106,11 @@ subroutine get_structures_ao_overlap(infos) nbf = basis%nbf ! Allocate and prepare data for output - call infos%dat%remove_records(tags_alloc) - call infos%dat%reserve_data(OQP_overlap_mo, TA_TYPE_REAL64, & - nbf*nbf, (/ nbf, nbf /), comment=OQP_overlap_mo_comment) - call infos%dat%reserve_data(OQP_overlap_ao, TA_TYPE_REAL64, & - nbf*nbf, (/ nbf, nbf /), comment=OQP_overlap_ao_comment) + call infos%dat%erase(tags_alloc) + stat = infos%dat%create(OQP_overlap_mo, TA_TYPE_REAL64, & + (/ nbf, nbf /), description=OQP_overlap_mo_comment) + stat = infos%dat%create(OQP_overlap_ao, TA_TYPE_REAL64, & + (/ nbf, nbf /), description=OQP_overlap_ao_comment) call data_has_tags(infos%dat, tags_alloc, module_name, subroutine_name, with_abort) call tagarray_get_data(infos%dat, OQP_overlap_mo, overlap_mo_out) call tagarray_get_data(infos%dat, OQP_overlap_ao, overlap_ao_out) diff --git a/source/modules/get_states_overlap.F90 b/source/modules/get_states_overlap.F90 index 9ec653586..e734570fe 100644 --- a/source/modules/get_states_overlap.F90 +++ b/source/modules/get_states_overlap.F90 @@ -35,6 +35,7 @@ end subroutine get_state_overlap_c !> subroutine get_states_overlap(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use precision, only: dp use io_constants, only: iw use oqp_tagarray_driver @@ -59,6 +60,7 @@ subroutine get_states_overlap(infos) real(kind=dp), allocatable, target :: bvec(:,:), bvec_old(:,:) ! Tagarray + integer(c_int32_t) :: stat character(len=*), parameter :: tags_general(*) = (/ character(len=80) :: & OQP_td_bvec_mo_old, OQP_td_bvec_mo, OQP_overlap_mo /) character(len=*), parameter :: tags_alloc(*) = (/ character(len=80) :: & @@ -83,13 +85,13 @@ subroutine get_states_overlap(infos) ndtlf = infos%tddft%tlf ! Allocate data for outputing in python level - call infos%dat%remove_records(tags_alloc) - call infos%dat%reserve_data(OQP_td_states_phase, ta_type_real64, & - nstates, (/ nstates /), comment=OQP_td_states_phase_comment) - call infos%dat%reserve_data(OQP_td_states_overlap, ta_type_real64, & - nstates*nstates, (/ nstates, nstates /), comment=OQP_td_states_overlap_comment) - call infos%dat%reserve_data(OQP_nac, ta_type_real64, & - nstates*nstates, (/ nstates, nstates /), comment=OQP_nac_comment) + call infos%dat%erase(tags_alloc) + stat = infos%dat%create(OQP_td_states_phase, ta_type_real64, & + (/ nstates /), description=OQP_td_states_phase_comment) + stat = infos%dat%create(OQP_td_states_overlap, ta_type_real64, & + (/ nstates, nstates /), description=OQP_td_states_overlap_comment) + stat = infos%dat%create(OQP_nac, ta_type_real64, & + (/ nstates, nstates /), description=OQP_nac_comment) ! Load data from python level call data_has_tags(infos%dat, tags_general, module_name, subroutine_name, with_abort) diff --git a/source/modules/guess_hcore.F90 b/source/modules/guess_hcore.F90 index 12aaa1f19..28ac308fb 100644 --- a/source/modules/guess_hcore.F90 +++ b/source/modules/guess_hcore.F90 @@ -16,6 +16,7 @@ subroutine guess_hcore_C(c_handle) bind(C, name="guess_hcore") end subroutine guess_hcore_C subroutine guess_hcore(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use precision, only: dp use types, only: information use io_constants, only: IW @@ -41,6 +42,7 @@ subroutine guess_hcore(infos) type(basis_set), pointer :: basis ! ! tagarray + integer(c_int32_t) :: stat real(kind=dp), contiguous, pointer :: & Hcore(:), Smat(:), & dmat_a(:), mo_a(:,:), mo_energy_a(:), & @@ -73,8 +75,8 @@ subroutine guess_hcore(infos) if (ok /= 0) call show_message('Cannot allocate memory', WITH_ABORT) ! clean data - call infos%dat%remove_records(tags_alpha) - call infos%dat%remove_records(tags_beta) + call infos%dat%erase(tags_alpha) + call infos%dat%erase(tags_beta) ! load general data call data_has_tags(infos%dat, tags_general, module_name, subroutine_name, WITH_ABORT) @@ -82,9 +84,9 @@ subroutine guess_hcore(infos) call tagarray_get_data(infos%dat, OQP_Hcore, hcore) ! allocate alpha - call infos%dat%reserve_data(OQP_DM_A, TA_TYPE_REAL64, nbf2, comment=OQP_DM_A_comment) - call infos%dat%reserve_data(OQP_E_MO_A, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_A_comment) - call infos%dat%reserve_data(OQP_VEC_MO_A, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_A_comment) + stat = infos%dat%create(OQP_DM_A, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_DM_A_comment) + stat = infos%dat%create(OQP_E_MO_A, TA_TYPE_REAL64, (/ nbf /), description=OQP_E_MO_A_comment) + stat = infos%dat%create(OQP_VEC_MO_A, TA_TYPE_REAL64, (/ nbf, nbf /), description=OQP_VEC_MO_A_comment) ! load alpha data call data_has_tags(infos%dat, tags_alpha, module_name, subroutine_name, WITH_ABORT) @@ -95,9 +97,9 @@ subroutine guess_hcore(infos) ! UHF/ROHF if (infos%control%scftype >= 2) then ! allocate beta - call infos%dat%reserve_data(OQP_DM_B, TA_TYPE_REAL64, nbf2, comment=OQP_DM_B_comment) - call infos%dat%reserve_data(OQP_E_MO_B, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_B_comment) - call infos%dat%reserve_data(OQP_VEC_MO_B, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_B_comment) + stat = infos%dat%create(OQP_DM_B, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_DM_B_comment) + stat = infos%dat%create(OQP_E_MO_B, TA_TYPE_REAL64, (/ nbf /), description=OQP_E_MO_B_comment) + stat = infos%dat%create(OQP_VEC_MO_B, TA_TYPE_REAL64, (/ nbf, nbf /), description=OQP_VEC_MO_B_comment) ! load beta call data_has_tags(infos%dat, tags_beta, module_name, subroutine_name, WITH_ABORT) diff --git a/source/modules/guess_huckel.F90 b/source/modules/guess_huckel.F90 index 6fc344e55..a57b1c954 100644 --- a/source/modules/guess_huckel.F90 +++ b/source/modules/guess_huckel.F90 @@ -16,6 +16,7 @@ subroutine guess_huckel_C(c_handle) bind(C, name="guess_huckel") end subroutine guess_huckel_C subroutine guess_huckel(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use precision, only: dp use types, only: information use io_constants, only: IW @@ -46,6 +47,7 @@ subroutine guess_huckel(infos) integer , parameter :: root = 0 type(par_env_t) :: pe ! tagarray + integer(c_int32_t) :: stat real(kind=dp), contiguous, pointer :: & Smat(:), & dmat_a(:), mo_a(:,:), mo_energy_a(:), & @@ -96,17 +98,17 @@ subroutine guess_huckel(infos) nbf2 =nbf*(nbf+1)/2 ! clean data - call infos%dat%remove_records(tags_alpha) - call infos%dat%remove_records(tags_beta) + call infos%dat%erase(tags_alpha) + call infos%dat%erase(tags_beta) ! load general data call data_has_tags(infos%dat, tags_general, module_name, subroutine_name, WITH_ABORT) call tagarray_get_data(infos%dat, OQP_SM, smat) ! allocate alpha - call infos%dat%reserve_data(OQP_DM_A, TA_TYPE_REAL64, nbf2, comment=OQP_DM_A_comment) - call infos%dat%reserve_data(OQP_E_MO_A, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_A_comment) - call infos%dat%reserve_data(OQP_VEC_MO_A, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_A_comment) + stat = infos%dat%create(OQP_DM_A, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_DM_A_comment) + stat = infos%dat%create(OQP_E_MO_A, TA_TYPE_REAL64, (/ nbf /), description=OQP_E_MO_A_comment) + stat = infos%dat%create(OQP_VEC_MO_A, TA_TYPE_REAL64, (/ nbf, nbf /), description=OQP_VEC_MO_A_comment) ! load alpha data call data_has_tags(infos%dat, tags_alpha, module_name, subroutine_name, WITH_ABORT) @@ -117,9 +119,9 @@ subroutine guess_huckel(infos) ! UHF/ROHF if (infos%control%scftype >= 2) then ! allocate beta - call infos%dat%reserve_data(OQP_DM_B, TA_TYPE_REAL64, nbf2, comment=OQP_DM_B_comment) - call infos%dat%reserve_data(OQP_E_MO_B, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_B_comment) - call infos%dat%reserve_data(OQP_VEC_MO_B, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_B_comment) + stat = infos%dat%create(OQP_DM_B, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_DM_B_comment) + stat = infos%dat%create(OQP_E_MO_B, TA_TYPE_REAL64, (/ nbf /), description=OQP_E_MO_B_comment) + stat = infos%dat%create(OQP_VEC_MO_B, TA_TYPE_REAL64, (/ nbf, nbf /), description=OQP_VEC_MO_B_comment) ! load beta call data_has_tags(infos%dat, tags_beta, module_name, subroutine_name, WITH_ABORT) diff --git a/source/modules/hf_energy.f90 b/source/modules/hf_energy.f90 index a1cc02c19..e62dbb78c 100644 --- a/source/modules/hf_energy.f90 +++ b/source/modules/hf_energy.f90 @@ -20,6 +20,7 @@ subroutine hf_energy_C(c_handle) bind(C, name="hf_energy") end subroutine hf_energy_C subroutine hf_energy(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use io_constants, only: iw use basis_tools, only: basis_set use messages, only: show_message @@ -42,6 +43,9 @@ subroutine hf_energy(infos) type(basis_set), pointer :: basis type(dft_grid_t) :: molGrid + ! tagarray + integer(c_int32_t) :: stat + urohf = infos%control%scftype == 2 .or. infos%control%scftype == 3 dft = infos%control%hamilton == 20 @@ -60,14 +64,14 @@ subroutine hf_energy(infos) nsh2 = (basis%nshell**2+basis%nshell)/2 ! clean data - call infos%dat%remove_records((/ character(len=80) :: OQP_FOCK_A, OQP_FOCK_B /)) + call infos%dat%erase((/ character(len=80) :: OQP_FOCK_A, OQP_FOCK_B /)) - call infos%dat%reserve_data(OQP_FOCK_A, TA_TYPE_REAL64, nbf2, comment=OQP_FOCK_A_comment) - call check_status(infos%dat%get_status(), module_name, subroutine_name, OQP_FOCK_A) + stat = infos%dat%create(OQP_FOCK_A, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_FOCK_A_comment) + call check_status(stat, module_name, subroutine_name, OQP_FOCK_A) if (urohf) then - call infos%dat%reserve_data(OQP_FOCK_B, TA_TYPE_REAL64, nbf2, comment=OQP_FOCK_B_comment) - call check_status(infos%dat%get_status(), module_name, subroutine_name, OQP_FOCK_B) + stat = infos%dat%create(OQP_FOCK_B, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_FOCK_B_comment) + call check_status(stat, module_name, subroutine_name, OQP_FOCK_B) end if ! Prepare dft grid diff --git a/source/modules/int1e.F90 b/source/modules/int1e.F90 index 51bc09ced..3078592f2 100644 --- a/source/modules/int1e.F90 +++ b/source/modules/int1e.F90 @@ -21,6 +21,7 @@ end subroutine int1e_C !> @brief Calculate the basic H, S, and T 1e-integrals subroutine int1e(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use types, only: information use oqp_tagarray_driver use precision, only: dp @@ -45,6 +46,7 @@ subroutine int1e(infos) integer :: i, nbf, nat, nbf2 ! tagarray + integer(c_int32_t) :: stat real(kind=dp), contiguous, pointer :: & hcore(:), tmat(:), smat(:) character(len=*), parameter :: tags_general(3) = (/ character(len=80) :: & @@ -79,11 +81,11 @@ subroutine int1e(infos) ! Allocate H, S and T matrices nbf2 = basis%nbf*(basis%nbf+1)/2 - call infos%dat%remove_records(tags_general) + call infos%dat%erase(tags_general) - call infos%dat%reserve_data(OQP_SM, TA_TYPE_REAL64, nbf2, comment=OQP_SM_comment) - call infos%dat%reserve_data(OQP_TM, TA_TYPE_REAL64, nbf2, comment=OQP_TM_comment) - call infos%dat%reserve_data(OQP_Hcore, TA_TYPE_REAL64, nbf2, comment=OQP_Hcore_comment) + stat = infos%dat%create(OQP_SM, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_SM_comment) + stat = infos%dat%create(OQP_TM, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_TM_comment) + stat = infos%dat%create(OQP_Hcore, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_Hcore_comment) call data_has_tags(infos%dat, tags_general, module_name, subroutine_name, WITH_ABORT) call tagarray_get_data(infos%dat, OQP_SM, smat) diff --git a/source/modules/tdhf_energy.F90 b/source/modules/tdhf_energy.F90 index a77e92452..e6de73944 100644 --- a/source/modules/tdhf_energy.F90 +++ b/source/modules/tdhf_energy.F90 @@ -15,6 +15,7 @@ subroutine tdhf_energy_C(c_handle) bind(C, name="tdhf_energy") end subroutine tdhf_energy_C subroutine tdhf_energy(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use io_constants, only: iw use oqp_tagarray_driver use types, only: information @@ -81,6 +82,7 @@ subroutine tdhf_energy(infos) logical :: dft ! tagarray + integer(c_int32_t) :: stat real(kind=dp), contiguous, pointer :: & mo_energy_a(:), mo_a(:,:), td_t(:,:), & xpy(:,:), xmy(:,:), td_energies(:) @@ -313,27 +315,27 @@ subroutine tdhf_energy(infos) vro(:,ist) = vro(:,ist) * norm end do - call infos%dat%remove_records(tags_alloc) + call infos%dat%erase(tags_alloc) - call infos%dat%reserve_data(OQP_td_t, & + stat = infos%dat%create(OQP_td_t, & TA_TYPE_REAL64, & - nbf2, [nbf2, 1], & - comment=OQP_td_t_comment) + [nbf2, 1], & + description=OQP_td_t_comment) - call infos%dat%reserve_data(OQP_td_xpy, & + stat = infos%dat%create(OQP_td_xpy, & TA_TYPE_REAL64, & - lexc*nstates, [lexc, nstates], & - comment="(X+Y) vector for target state in TD-DFT calculations") + [lexc, nstates], & + description="(X+Y) vector for target state in TD-DFT calculations") - call infos%dat%reserve_data(OQP_td_xmy, & + stat = infos%dat%create(OQP_td_xmy, & TA_TYPE_REAL64, & - lexc*nstates, [lexc, nstates], & - comment="(X-Y) vector for target state in TD-DFT calculations") + [lexc, nstates], & + description="(X-Y) vector for target state in TD-DFT calculations") - call infos%dat%reserve_data(OQP_td_energies, & + stat = infos%dat%create(OQP_td_energies, & TA_TYPE_REAL64, & - nstates, [nstates], & - comment=OQP_td_energies_comment) + [nstates], & + description=OQP_td_energies_comment) call tagarray_get_data(infos%dat, OQP_td_t, td_t) call tagarray_get_data(infos%dat, OQP_td_xpy, xpy) diff --git a/source/modules/tdhf_mrsf_energy.F90 b/source/modules/tdhf_mrsf_energy.F90 index eb315fe5b..ae1646c9b 100644 --- a/source/modules/tdhf_mrsf_energy.F90 +++ b/source/modules/tdhf_mrsf_energy.F90 @@ -16,6 +16,7 @@ subroutine tdhf_mrsf_energy_C(c_handle) bind(C, name="tdhf_mrsf_energy") end subroutine tdhf_mrsf_energy_C subroutine tdhf_mrsf_energy(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use io_constants, only: iw use oqp_tagarray_driver @@ -94,6 +95,7 @@ subroutine tdhf_mrsf_energy(infos) integer :: scf_type, mol_mult ! tagarray + integer(c_int32_t) :: stat real(kind=dp), contiguous, pointer :: & fock_a(:), dmat_a(:), mo_A(:,:), mo_energy_a(:), & fock_b(:), dmat_b(:), mo_b(:,:), mo_energy_b(:), & @@ -165,12 +167,14 @@ subroutine tdhf_mrsf_energy(infos) infos%tddft%nstate = nstates nvec = min(max(nstates,6), mxvec) - call infos%dat%remove_records(tags_alloc) + call infos%dat%erase(tags_alloc) - call infos%dat%reserve_data(OQP_td_bvec_mo, TA_TYPE_REAL64, & - xvec_dim*nstates, (/xvec_dim, nstates/), comment=OQP_td_bvec_mo_comment) - call infos%dat%reserve_data(OQP_td_t, TA_TYPE_REAL64, nbf2*2, (/ nbf2, 2 /), comment=OQP_td_t_comment) - call infos%dat%reserve_data(OQP_td_energies, TA_TYPE_REAL64, nstates, comment=OQP_td_energies_comment) + stat = infos%dat%create(OQP_td_bvec_mo, TA_TYPE_REAL64, & + (/xvec_dim, nstates/), description=OQP_td_bvec_mo_comment) + stat = infos%dat%create(OQP_td_t, TA_TYPE_REAL64, & + (/ nbf2, 2 /), description=OQP_td_t_comment) + stat = infos%dat%create(OQP_td_energies, TA_TYPE_REAL64, & + (/ nstates /), description=OQP_td_energies_comment) call data_has_tags(infos%dat, tags_alloc, module_name, subroutine_name, WITH_ABORT) call tagarray_get_data(infos%dat, OQP_td_bvec_mo, bvec_mo_out) diff --git a/source/modules/tdhf_mrsf_z_vector.F90 b/source/modules/tdhf_mrsf_z_vector.F90 index 29b7bfdfc..560edfcf0 100644 --- a/source/modules/tdhf_mrsf_z_vector.F90 +++ b/source/modules/tdhf_mrsf_z_vector.F90 @@ -16,6 +16,7 @@ subroutine tdhf_mrsf_z_vector_C(c_handle) bind(C, name="tdhf_mrsf_z_vector") end subroutine tdhf_mrsf_z_vector_C subroutine tdhf_mrsf_z_vector(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use precision, only: dp use io_constants, only: iw use oqp_tagarray_driver @@ -101,6 +102,7 @@ subroutine tdhf_mrsf_z_vector(infos) integer :: scf_type, mol_mult, target_state ! tagarray + integer(c_int32_t) :: stat real(kind=dp), contiguous, pointer :: & fock_a(:), mo_a(:,:), mo_energy_a(:), & fock_b(:), mo_b(:,:), & @@ -204,12 +206,12 @@ subroutine tdhf_mrsf_z_vector(infos) if( ok/=0 ) call show_message('Cannot allocate memory', with_abort) - call infos%dat%remove_records(tags_alloc) + call infos%dat%erase(tags_alloc) - call infos%dat%reserve_data(OQP_WAO, TA_TYPE_REAL64, nbf_tri, comment=OQP_WAO_comment) - call infos%dat%reserve_data(OQP_td_mrsf_density, TA_TYPE_REAL64, nbf*nbf*7, (/7, nbf, nbf /), comment=OQP_td_mrsf_density) - call infos%dat%reserve_data(OQP_td_p, TA_TYPE_REAL64, nbf_tri*2, (/ nbf_tri, 2 /), comment=OQP_td_p) - call infos%dat%reserve_data(OQP_td_abxc, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_td_abxc) + stat = infos%dat%create(OQP_WAO, TA_TYPE_REAL64, (/ nbf_tri /), description=OQP_WAO_comment) + stat = infos%dat%create(OQP_td_mrsf_density, TA_TYPE_REAL64, (/7, nbf, nbf /), description=OQP_td_mrsf_density) + stat = infos%dat%create(OQP_td_p, TA_TYPE_REAL64, (/ nbf_tri, 2 /), description=OQP_td_p) + stat = infos%dat%create(OQP_td_abxc, TA_TYPE_REAL64, (/ nbf, nbf /), description=OQP_td_abxc) call data_has_tags(infos%dat, tags_alloc, module_name, subroutine_name, WITH_ABORT) call tagarray_get_data(infos%dat, OQP_WAO, wao) diff --git a/source/modules/tdhf_sf_energy.F90 b/source/modules/tdhf_sf_energy.F90 index a62cb02e9..8f590a3da 100644 --- a/source/modules/tdhf_sf_energy.F90 +++ b/source/modules/tdhf_sf_energy.F90 @@ -16,6 +16,7 @@ subroutine tdhf_sf_energy_C(c_handle) bind(C, name="tdhf_sf_energy") end subroutine tdhf_sf_energy_C subroutine tdhf_sf_energy(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use io_constants, only: iw use oqp_tagarray_driver @@ -87,6 +88,7 @@ subroutine tdhf_sf_energy(infos) integer :: scf_type, mol_mult ! tagarray + integer(c_int32_t) :: stat real(kind=dp), contiguous, pointer :: & fock_a(:), dmat_a(:), mo_a(:,:), mo_energy_a(:), & fock_b(:), dmat_b(:), mo_b(:,:), mo_energy_b(:), & @@ -144,12 +146,14 @@ subroutine tdhf_sf_energy(infos) nvec = min(max(2*nstates, 5), mxvec) nmax = nvec - call infos%dat%remove_records(tags_alloc) + call infos%dat%erase(tags_alloc) - call infos%dat%reserve_data(OQP_td_bvec_mo, TA_TYPE_REAL64, & - xvec_dim*nstates, (/xvec_dim, nstates/), comment=OQP_td_bvec_mo_comment) - call infos%dat%reserve_data(OQP_td_t, TA_TYPE_REAL64, nbf2*2, (/ nbf2, 2 /), comment=OQP_td_t_comment) - call infos%dat%reserve_data(OQP_td_energies, TA_TYPE_REAL64, nstates, comment=OQP_td_energies_comment) + stat = infos%dat%create(OQP_td_bvec_mo, TA_TYPE_REAL64, & + (/xvec_dim, nstates/), description=OQP_td_bvec_mo_comment) + stat = infos%dat%create(OQP_td_t, TA_TYPE_REAL64, & + (/ nbf2, 2 /), description=OQP_td_t_comment) + stat = infos%dat%create(OQP_td_energies, TA_TYPE_REAL64, & + (/ nstates /), description=OQP_td_energies_comment) call data_has_tags(infos%dat, tags_alloc, module_name, subroutine_name, WITH_ABORT) call tagarray_get_data(infos%dat, OQP_td_bvec_mo, bvec_mo_out) diff --git a/source/modules/tdhf_sf_z_vector.F90 b/source/modules/tdhf_sf_z_vector.F90 index cb7348913..4ded73202 100644 --- a/source/modules/tdhf_sf_z_vector.F90 +++ b/source/modules/tdhf_sf_z_vector.F90 @@ -18,6 +18,7 @@ end subroutine tdhf_sf_z_vector_C subroutine tdhf_sf_z_vector(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use precision, only: dp use io_constants, only: iw use oqp_tagarray_driver @@ -89,6 +90,7 @@ subroutine tdhf_sf_z_vector(infos) integer :: scf_type, mol_mult ! tagarray + integer(c_int32_t) :: stat real(kind=dp), contiguous, pointer :: & fock_a(:), mo_a(:,:), mo_energy_a(:), td_abxc(:,:), & fock_b(:), mo_b(:,:), & @@ -168,11 +170,11 @@ subroutine tdhf_sf_z_vector(infos) if( ok/=0 ) call show_message('Cannot allocate memory', with_abort) - call infos%dat%remove_records(tags_alloc) + call infos%dat%erase(tags_alloc) - call infos%dat%reserve_data(OQP_WAO, TA_TYPE_REAL64, nbf_tri, comment=OQP_WAO_comment) - call infos%dat%reserve_data(OQP_td_p, TA_TYPE_REAL64, nbf_tri*2, (/ nbf_tri, 2 /), comment=OQP_td_p_comment) - call infos%dat%reserve_data(OQP_td_abxc, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_td_abxc) + stat = infos%dat%create(OQP_WAO, TA_TYPE_REAL64, (/ nbf_tri /), description=OQP_WAO_comment) + stat = infos%dat%create(OQP_td_p, TA_TYPE_REAL64, (/ nbf_tri, 2 /), description=OQP_td_p_comment) + stat = infos%dat%create(OQP_td_abxc, TA_TYPE_REAL64, (/ nbf, nbf /), description=OQP_td_abxc) call data_has_tags(infos%dat, tags_alloc, module_name, subroutine_name, WITH_ABORT) call tagarray_get_data(infos%dat, OQP_WAO, wao) diff --git a/source/modules/tdhf_z_vector.F90 b/source/modules/tdhf_z_vector.F90 index d04d4c5e4..ae55b77a8 100644 --- a/source/modules/tdhf_z_vector.F90 +++ b/source/modules/tdhf_z_vector.F90 @@ -52,6 +52,7 @@ subroutine tdhf_z_vector_C(c_handle) bind(C, name="tdhf_z_vector") !############################################################################### subroutine oqp_tdhf_z_vector(infos) + use, intrinsic :: iso_c_binding, only: c_int32_t use oqp_tagarray_driver use strings, only: Cstring, fstring @@ -103,6 +104,7 @@ subroutine oqp_tdhf_z_vector(infos) real(kind=dp) :: cnvtol, scale_exch ! tagarray + integer(c_int32_t) :: stat real(kind=dp), contiguous, pointer :: & mo_a(:,:), mo_energy_a(:), wao(:), td_p(:,:), td_t(:,:), & ta(:), xpy(:,:), xmy(:,:), td_energies(:) @@ -148,7 +150,7 @@ subroutine oqp_tdhf_z_vector(infos) if( ok/=0 ) call show_message('Cannot allocate memory', with_abort) - call infos%dat%remove_records([character(80) :: OQP_WAO, OQP_TD_P]) + call infos%dat%erase([character(80) :: OQP_WAO, OQP_TD_P]) call data_has_tags(infos%dat, tags_required, module_name, subroutine_name, WITH_ABORT) call tagarray_get_data(infos%dat, OQP_E_MO_A, mo_energy_a) @@ -288,7 +290,7 @@ subroutine oqp_tdhf_z_vector(infos) pa(:,:,1) = pa(:,:,1) + wrk1 ! T+Z ! Store relaxed difference density matrix P to global memory - call infos%dat%reserve_data(OQP_td_p, TA_TYPE_REAL64, nbf2, [nbf2, 1], comment=OQP_td_p_comment) + stat = infos%dat%create(OQP_td_p, TA_TYPE_REAL64, [nbf2, 1], description=OQP_td_p_comment) call tagarray_get_data(infos%dat, OQP_td_p, td_p) call pack_matrix(pa(:,:,1), td_p(:,1)) @@ -344,7 +346,7 @@ subroutine oqp_tdhf_z_vector(infos) call orthogonal_transform('t', nbf, mo_a, wmo) ! Store W to global memory - call infos%dat%reserve_data(OQP_WAO, TA_TYPE_REAL64, nbf2, comment=OQP_WAO_comment) + stat = infos%dat%create(OQP_WAO, TA_TYPE_REAL64, (/ nbf2 /), description=OQP_WAO_comment) call tagarray_get_data(infos%dat, OQP_WAO, wao) call pack_matrix(wmo, wao) wao = wao*0.5_dp diff --git a/source/tagarray_driver.F90 b/source/tagarray_driver.F90 index 836d931fc..ffae9a319 100644 --- a/source/tagarray_driver.F90 +++ b/source/tagarray_driver.F90 @@ -97,7 +97,17 @@ module oqp_tagarray_driver public :: ta_ok contains - function tagarray_get_cptr(container, tag, ptr, type_id, ndims, dims, data_size) result(res) + !> + !> @brief unpack record with tag `tag` and return its properties + !> + !> @param[inout] contains + !> @param[in] tag - tag + !> @param[out] type_id - type id + !> @param[out] ndims - number of dimensions + !> @param[out] dims - shape of data + !> @param[out] data_size - size of single element in bytes + !> + function tagarray_get_cptr(container, tag, ptr, type_id, ndims, dims, data_size) result(res) type(container_t), intent(inout) :: container character(len=*), intent(in) :: tag type(c_ptr), intent(out) :: ptr @@ -110,16 +120,19 @@ function tagarray_get_cptr(container, tag, ptr, type_id, ndims, dims, data_size) type(recordinfo_t) :: record_info ptr = c_null_ptr - record_info = container%get_record_info(tag) - res = container%get_status() + res = TA_CONTAINER_RECORD_NOT_FOUND + if (container%contains(tag)) then + record_info = container%get(tag) - if (res == TA_OK) then ptr = record_info%data - res = product(record_info%dimensions(1:record_info%n_dimensions)) + res = record_info%count if (present(type_id)) type_id = record_info%type_id - if (present(ndims )) ndims = record_info%n_dimensions - if (present(dims )) dims = record_info%dimensions - if (present(data_size )) data_size = record_info%data_length + if (present(ndims )) ndims = int(record_info%ndims, kind=c_int32_t) + if (present(dims )) then + dims = 0_c_int64_t + dims(1:record_info%ndims) = record_info%dims(1:record_info%ndims) + end if + if (present(data_size)) data_size = record_info%itemsize end if end function tagarray_get_cptr @@ -132,15 +145,18 @@ subroutine data_has_tags_location(container, tags, location, abort, status) character(len=*), intent(in) :: location logical, optional, intent(in) :: abort integer(c_int32_t), optional, intent(out) :: status - integer(c_int32_t) :: tag_id, status_ + integer(c_int32_t) :: tag_id logical :: abort_ + if (present(status)) status = TA_OK abort_ = WITHOUT_ABORT if (present(abort)) abort_ = abort - status_ = container%has_records(tags, tag_id) - if (status_ /= TA_OK) call show_message( & - location // ": " // get_status_message(status_, trim(tags(tag_id))), & + if (.not.container%contains(tags, tag_id)) then + call show_message( & + location // ": " // & + get_status_message(TA_CONTAINER_RECORD_NOT_FOUND, trim(tags(tag_id))), & abort_) - if (present(status)) status = status_ + if (present(status)) status = TA_CONTAINER_RECORD_NOT_FOUND + end if end subroutine data_has_tags_location subroutine data_has_tags_ms(container, tags, modulename, subroutinename, abort, status) use messages, only: show_message, WITHOUT_ABORT @@ -149,15 +165,18 @@ subroutine data_has_tags_ms(container, tags, modulename, subroutinename, abort, character(len=*), intent(in) :: modulename, subroutinename logical, optional, intent(in) :: abort integer(c_int32_t), optional, intent(out) :: status - integer(c_int32_t) :: tag_id, status_ + integer(c_int32_t) :: tag_id logical :: abort_ + if (present(status)) status = TA_OK abort_ = WITHOUT_ABORT if (present(abort)) abort_ = abort - status_ = container%has_records(tags, tag_id) - if (status_ /= TA_OK) call show_message( & - modulename // "::" // subroutinename // ": " // get_status_message(status_, trim(tags(tag_id))), & + if (.not.container%contains(tags, tag_id)) then + call show_message( & + modulename // "::" // subroutinename // ": " // & + get_status_message(TA_CONTAINER_RECORD_NOT_FOUND, trim(tags(tag_id))), & abort_) - if (present(status)) status = status_ + if (present(status)) status = TA_CONTAINER_RECORD_NOT_FOUND + end if end subroutine data_has_tags_ms subroutine check_status(status, modulename, subroutinename, tag, abort) use messages, only: show_message, WITHOUT_ABORT @@ -177,7 +196,7 @@ subroutine tagarray_get_data_int64_val(container, tag, ptr, status) integer(8), pointer :: ptr integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_VALUE(container, tag, TA_TYPE_INT64, ptr, status_) + TA_CONTAINER_GET_VALUE(container, tag, TA_TYPE_INT64, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_int64_val subroutine tagarray_get_data_int64_1d(container, tag, ptr, status) @@ -186,7 +205,7 @@ subroutine tagarray_get_data_int64_1d(container, tag, ptr, status) integer(8), pointer :: ptr(:) integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_DATA(container, tag, TA_TYPE_INT64, ptr, status_) + TA_CONTAINER_GET_ARRAY(container, tag, TA_TYPE_INT64, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_int64_1d subroutine tagarray_get_data_int64_2d(container, tag, ptr, status) @@ -195,7 +214,7 @@ subroutine tagarray_get_data_int64_2d(container, tag, ptr, status) integer(8), pointer :: ptr(:,:) integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_DATA(container, tag, TA_TYPE_INT64, ptr, status_) + TA_CONTAINER_GET_ARRAY(container, tag, TA_TYPE_INT64, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_int64_2d subroutine tagarray_get_data_int64_3d(container, tag, ptr, status) @@ -204,7 +223,7 @@ subroutine tagarray_get_data_int64_3d(container, tag, ptr, status) integer(8), pointer :: ptr(:,:,:) integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_DATA(container, tag, TA_TYPE_INT64, ptr, status_) + TA_CONTAINER_GET_ARRAY(container, tag, TA_TYPE_INT64, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_int64_3d subroutine tagarray_get_data_real64_val(container, tag, ptr, status) @@ -213,7 +232,7 @@ subroutine tagarray_get_data_real64_val(container, tag, ptr, status) real(8), pointer :: ptr integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_VALUE(container, tag, TA_TYPE_REAL64, ptr, status_) + TA_CONTAINER_GET_VALUE(container, tag, TA_TYPE_REAL64, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_real64_val subroutine tagarray_get_data_real64_1d(container, tag, ptr, status) @@ -222,7 +241,7 @@ subroutine tagarray_get_data_real64_1d(container, tag, ptr, status) real(8), pointer :: ptr(:) integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_DATA(container, tag, TA_TYPE_REAL64, ptr, status_) + TA_CONTAINER_GET_ARRAY(container, tag, TA_TYPE_REAL64, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_real64_1d subroutine tagarray_get_data_real64_2d(container, tag, ptr, status) @@ -231,7 +250,7 @@ subroutine tagarray_get_data_real64_2d(container, tag, ptr, status) real(8), pointer :: ptr(:,:) integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_DATA(container, tag, TA_TYPE_REAL64, ptr, status_) + TA_CONTAINER_GET_ARRAY(container, tag, TA_TYPE_REAL64, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_real64_2d subroutine tagarray_get_data_real64_3d(container, tag, ptr, status) @@ -240,7 +259,7 @@ subroutine tagarray_get_data_real64_3d(container, tag, ptr, status) real(8), pointer :: ptr(:,:,:) integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_DATA(container, tag, TA_TYPE_REAL64, ptr, status_) + TA_CONTAINER_GET_ARRAY(container, tag, TA_TYPE_REAL64, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_real64_3d @@ -250,7 +269,7 @@ subroutine tagarray_get_data_char8_val(container, tag, ptr, status) character(len=*, kind=c_char), pointer :: ptr integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_VALUE(container, tag, TA_TYPE_CHAR8, ptr, status_) + TA_CONTAINER_GET_VALUE(container, tag, TA_TYPE_CHAR8, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_char8_val @@ -260,7 +279,7 @@ subroutine tagarray_get_data_char8_1d(container, tag, ptr, status) character(len=*, kind=c_char), pointer :: ptr(:) integer(c_int32_t), optional, intent(out) :: status integer(c_int32_t) :: status_ - TA_GET_CONTAINER_DATA(container, tag, TA_TYPE_CHAR8, ptr, status_) + TA_CONTAINER_GET_ARRAY(container, tag, TA_TYPE_CHAR8, ptr, status_) if (present(status)) status = status_ end subroutine tagarray_get_data_char8_1d end module oqp_tagarray_driver