Skip to content

Commit 1299c3d

Browse files
karmachoiclaude
andauthored
Migrate to Open-Quantum-Platform/tagarray v1.0.0 (#232)
* Migrate to Open-Quantum-Platform/tagarray v1.0.0 Re-point libtagarray at OQP/tagarray v1.0.0 and migrate all call sites off the removed 0.0.x API (reserve_data/remove_records/has_records/get_record_info/ get_status) to create/erase/contains/get + recordinfo count/ndims/dims and the TA_CONTAINER_GET_* macros. - external/CMakeLists.txt: URL -> OQP/tagarray v1.0.0 (+SHA), drop obsolete default-integer-shapes patch, add CMAKE_POSITION_INDEPENDENT_CODE. - tagarray_driver.F90 + c_interop.F90: wrapper/C-interop ported to v1.0.0. - 23 modules: one-call c%alloc_or_die; hf_energy create() for C-filled Fock; int2e int64-shape create() for nbf**4 ERI. Supersedes stale PR #34. Verified: liboqp links and H2 MRSF-CIS reproduces S0 = -1.1150793163 Ha exactly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Address review: preserve input orbitals + ILP64 integer kind for libtagarray Codex review fixes (data erased by over-eager migration): - basis_projection: OQP::DM_A/E_MO_A/VEC_MO_A (and beta) are the converged initial-basis orbitals READ by corresponding_orbital_projection; the old reserve_data (no remove_records) preserved them. alloc_or_die overrides, so it erased the projection source. Revert those 6 tags to data_has_tags + tagarray_get_data (read, not reallocate). The *_tmp outputs stay alloc_or_die. - guess_json: the beta OQP::DM_B/E_MO_B/VEC_MO_B are loaded from the JSON guess and read by get_ab_initio_density for ROHF/UHF; read them, do not reallocate. ILP64 build fix (CI failure on -fdefault-integer-8 builds): - tagarray's c%alloc/alloc_or_die take default-INTEGER shapes and create takes a default-LOGICAL override; OpenQP promotes those to 8 bytes via add_compile_options(-fdefault-integer-8/-i8), which ExternalProject does not inherit, so libtagarray was built int4 -> alloc_or_die/override failed to resolve. Forward the same integer-8 flag to the libtagarray Fortran build so the kinds match (verified: the library builds cleanly under -fdefault-integer-8). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Migrate population_analysis + resp to tagarray v1.0.0 alloc_or_die These two modules came in from the main merge still using the removed reserve_data API (they store Mulliken/Lowdin/RESP atomic charges). Convert their single output-tag reserve_data + tagarray_get_data to the one-call alloc_or_die, matching the rest of the migration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Fix wheel link: resolve dftd4->LAPACK static link order (undefined ssytri_) dftd4/multicharge/mctc-lib reference BLAS/LAPACK symbols (e.g. ssytri_) but are linked after the static liblapack/libblas archives. With a static NetLib build the linker has already passed those archives, so the objects are never pulled in and liboqp.so gets an undefined symbol that only fails at load time (import oqp in the wheel smoke). The gcc-build jobs miss it because they never load the library, and main slips through on its warm externals cache; a fresh rebuild (forced here by the tagarray version bump) exposes it. Wrap the dispersion libs together with LAPACK/BLAS in a RESCAN link group so the cross-references resolve regardless of order (NetLib static only; shared BLAS/LAPACK such as macOS Accelerate is unaffected). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Fix: don't use RESCAN link group on Apple (ld64 lacks --start-group) $<LINK_GROUP:RESCAN> emits --start-group/--end-group, which is a GNU ld feature; Apple's ld64 rejects it. A macOS + from-source-NetLib-static build (LIBLAPACK set on Apple) would therefore fail to link -- and Linux-only CI never catches it. ld64 resolves cross-archive references by a global symbol scan anyway, so Apple just needs the plain link. Gate the RESCAN group on NOT APPLE. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent cd47005 commit 1299c3d

28 files changed

Lines changed: 176 additions & 331 deletions

external/CMakeLists.txt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(_OQP_EXTERNALS_CACHE_REVISION "1")
44
set(_OQP_LIBINT2_VERSION "2.7.1.1-am4")
55
set(_OQP_NLOPT_VERSION "2.9.1")
66
set(_OQP_LIBXC_VERSION "7.0.0")
7-
set(_OQP_TAGARRAY_VERSION "0.0.6")
7+
set(_OQP_TAGARRAY_VERSION "1.0.0")
88
set(_OQP_LIBECPINT_VERSION "1.0.7")
99
set(_OQP_LAPACK_VERSION "3.10.0")
1010
set(_OQP_OPENTRUSTREGION_VERSION "2.0.0")
@@ -296,23 +296,39 @@ oqp_reuse_or_build(libtagarray
296296
"${TAGARRAY_BUILD_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}tagarray${CMAKE_STATIC_LIBRARY_SUFFIX}"
297297
"${TAGARRAY_BUILD_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}tagarray_f${CMAKE_STATIC_LIBRARY_SUFFIX}"
298298
"${TAGARRAY_BUILD_DIR}/include/tagarray")
299+
# tagarray's high-level helpers (c%alloc / alloc_or_die) take default-INTEGER
300+
# shapes and a default-LOGICAL override, so the library must be built with the
301+
# same default integer kind as OpenQP. OpenQP promotes its default integer (and
302+
# logical) to 8 bytes for ILP64 via add_compile_options(-fdefault-integer-8 /
303+
# -i8), which ExternalProject does NOT inherit; forward it explicitly here so
304+
# the kinds match (otherwise alloc_or_die / create(override=...) fail to resolve
305+
# in ILP64 builds).
306+
set(_TAGARRAY_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
307+
if(LINALG_LIB_INT64)
308+
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Flang")
309+
string(APPEND _TAGARRAY_Fortran_FLAGS " -fdefault-integer-8")
310+
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel" OR "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "IntelLLVM")
311+
string(APPEND _TAGARRAY_Fortran_FLAGS " -i8")
312+
endif()
313+
endif()
299314
if(NOT TARGET libtagarray)
300315
ExternalProject_Add(libtagarray
301316
PREFIX ${TAGARRAY_PREFIX}
302-
URL https://github.com/foxtran/libtagarray/archive/refs/tags/v${_OQP_TAGARRAY_VERSION}.tar.gz
303-
URL_HASH SHA256=9c844092f123276bb461e37e3451068c097b5a1fec9d65514ad3018baaeb2b32
304-
# GIT_REPOSITORY https://github.com/foxtran/libtagarray.git
317+
URL https://github.com/Open-Quantum-Platform/tagarray/archive/refs/tags/v${_OQP_TAGARRAY_VERSION}.tar.gz
318+
URL_HASH SHA256=590896bcdaadca4c3466474d35eff06ed4090c42d37a3f8ddda0def83833c6c5
319+
# GIT_REPOSITORY https://github.com/Open-Quantum-Platform/tagarray.git
305320
# GIT_TAG master
306321
SOURCE_DIR ${TAGARRAY_SOURCE_DIR}
307322
BINARY_DIR ${TAGARRAY_BUILD_DIR}
308323
STAMP_DIR ${TAGARRAY_STAMP_DIR}
309324
UPDATE_COMMAND ""
310-
PATCH_COMMAND sh -c "grep -q reserve_data_default <SOURCE_DIR>/source/API/Fortran/container.f90 || patch -p1 -i ${CMAKE_SOURCE_DIR}/cmake/patches/libtagarray-v0.0.6-default-integer-shapes.patch"
311325
INSTALL_COMMAND ""
312326
CMAKE_ARGS -DENABLE_FORTRAN=ON
313327
-DENABLE_TESTING=OFF
328+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
314329
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
315330
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
331+
"-DCMAKE_Fortran_FLAGS=${_TAGARRAY_Fortran_FLAGS}"
316332
${OQP_EXTERNAL_GENERATOR_ARGS}
317333
)
318334
endif()

source/c_interop.F90

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function oqp_get(c_handle, code, type_id, ndims, dims, v) result(n) bind(C, name
276276
type(c_ptr), intent(out) :: v
277277
integer(c_int32_t) :: type_id
278278
integer(c_int32_t) :: ndims
279-
integer(c_int64_t) :: dims(TA_DIMENSIONS_LENGTH)
279+
integer(c_int64_t) :: dims(TA_MAX_DIMENSIONS_LENGTH)
280280

281281
type(information), pointer :: inf
282282
character(:), allocatable :: code_str
@@ -313,23 +313,22 @@ function oqp_alloc(c_handle, tag, type_id, ndims, dims, v) result(n) bind(C, nam
313313
type(c_ptr), intent(out) :: v
314314
integer(c_int32_t) :: type_id
315315
integer(c_int32_t) :: ndims
316-
integer(c_int64_t) :: dims(TA_DIMENSIONS_LENGTH)
316+
integer(c_int64_t) :: dims(TA_MAX_DIMENSIONS_LENGTH)
317317

318318
type(information), pointer :: inf
319319
character(:), allocatable :: tag_str
320320
integer(c_int64_t) :: data_size
321+
integer(c_int32_t) :: status_
321322

322323
n = -1
323324
if (.not.c_associated(c_handle%inf)) return
324325
call c_f_pointer(c_handle%inf, inf)
325326

326327
tag_str = trim(adjustl(c_f_char(tag)))
327328

328-
! 1. check, if the data already exist, and clean it if yes
329-
call inf%dat%remove_records([tag_str])
330-
! 2. allocate the memory in container
331-
call inf%dat%reserve_data(tag_str, type_id, product(dims(:ndims)), dims(:ndims))
332-
! 3. Get the pointer to the freshly allocated data
329+
! 1. allocate the memory in container (override, if it already exists)
330+
status_ = inf%dat%create(tag_str, type_id, dims(:ndims), override=.true.)
331+
! 2. Get the pointer to the freshly allocated data
333332
n = tagarray_get_cptr(inf%dat, tag_str, v, type_id, ndims, dims, data_size)
334333
if (.not.c_associated(v)) n = -2
335334

@@ -368,7 +367,7 @@ function oqp_del(c_handle, tag) result(n) bind(C, name='oqp_del')
368367
if (stat /= TA_OK) return
369368

370369
n = -3
371-
call inf%dat%remove_records([tag_str])
370+
call inf%dat%erase([tag_str])
372371

373372
n = 0
374373

source/modules/basis_projection.F90

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -145,44 +145,25 @@ subroutine proj_dm_newbas(infos)
145145
Dmat_a(nbf2), &
146146
Dmat_b(nbf2))
147147

148-
! allocate alpha
149-
call infos%dat%reserve_data(OQP_DM_A, TA_TYPE_REAL64, nbf2_alt, comment=OQP_DM_A_comment)
150-
call infos%dat%reserve_data(OQP_E_MO_A, TA_TYPE_REAL64, nbf_alt, comment=OQP_E_MO_A_comment)
151-
call infos%dat%reserve_data(OQP_VEC_MO_A, TA_TYPE_REAL64, nbf_alt*nbf_alt, (/ nbf_alt, nbf_alt /), comment=OQP_VEC_MO_A_comment)
152-
! load alpha data
148+
! Load the converged initial-basis orbitals/densities. These are INPUTS --
149+
! the projection source, read below through the *_alt pointers -- so they
150+
! must be retrieved, NOT reallocated (alloc_or_die would erase them).
153151
call data_has_tags(infos%dat, tags_alpha, module_name, subroutine_name, WITH_ABORT)
154152
call tagarray_get_data(infos%dat, OQP_DM_A, dmat_a_alt)
155153
call tagarray_get_data(infos%dat, OQP_E_MO_A, mo_energy_a_alt)
156154
call tagarray_get_data(infos%dat, OQP_VEC_MO_A, mo_a_alt)
157-
call infos%dat%reserve_data(OQP_DM_B, TA_TYPE_REAL64, nbf2_alt, comment=OQP_DM_B_comment)
158-
call infos%dat%reserve_data(OQP_E_MO_B, TA_TYPE_REAL64, nbf_alt, comment=OQP_E_MO_B_comment)
159-
call infos%dat%reserve_data(OQP_VEC_MO_B, TA_TYPE_REAL64, nbf_alt*nbf_alt, (/ nbf_alt, nbf_alt /), comment=OQP_VEC_MO_B_comment)
160-
! ! load beta
161155
call data_has_tags(infos%dat, tags_beta, module_name, subroutine_name, WITH_ABORT)
162156
call tagarray_get_data(infos%dat, OQP_DM_B, dmat_b_alt)
163157
call tagarray_get_data(infos%dat, OQP_E_MO_B, mo_energy_b_alt)
164158
call tagarray_get_data(infos%dat, OQP_VEC_MO_B, mo_b_alt)
165-
! clean data
166-
call infos%dat%remove_records(tags_alpha_tmp)
167-
call infos%dat%remove_records(tags_beta_tmp)
168159
! allocate alpha_tmp
169-
call infos%dat%reserve_data("OQP::DM_A_tmp", TA_TYPE_REAL64, nbf2, comment=OQP_DM_A_comment)
170-
call infos%dat%reserve_data("OQP::E_MO_A_tmp", TA_TYPE_REAL64, nbf, comment=OQP_E_MO_A_comment)
171-
call infos%dat%reserve_data("OQP::VEC_MO_A_tmp", TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_A_comment)
172-
! load alpha_tmp data
173-
call data_has_tags(infos%dat, tags_alpha, module_name, subroutine_name, WITH_ABORT)
174-
call tagarray_get_data(infos%dat, "OQP::DM_A_tmp", dmat_a)
175-
call tagarray_get_data(infos%dat, "OQP::E_MO_A_tmp", mo_energy_a)
176-
call tagarray_get_data(infos%dat, "OQP::VEC_MO_A_tmp", mo_a)
160+
call infos%dat%alloc_or_die("OQP::DM_A_tmp", (/ nbf2 /), dmat_a, description=OQP_DM_A_comment)
161+
call infos%dat%alloc_or_die("OQP::E_MO_A_tmp", (/ nbf /), mo_energy_a, description=OQP_E_MO_A_comment)
162+
call infos%dat%alloc_or_die("OQP::VEC_MO_A_tmp", (/ nbf, nbf /), mo_a, description=OQP_VEC_MO_A_comment)
177163
! allocate beta_tmp
178-
call infos%dat%reserve_data("OQP::DM_B_tmp", TA_TYPE_REAL64, nbf2, comment=OQP_DM_B_comment)
179-
call infos%dat%reserve_data("OQP::E_MO_B_tmp", TA_TYPE_REAL64, nbf, comment=OQP_E_MO_B_comment)
180-
call infos%dat%reserve_data("OQP::VEC_MO_B_tmp", TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_B_comment)
181-
! load beta_tmp
182-
call data_has_tags(infos%dat, tags_beta, module_name, subroutine_name, WITH_ABORT)
183-
call tagarray_get_data(infos%dat, "OQP::DM_B_tmp", dmat_b)
184-
call tagarray_get_data(infos%dat, "OQP::E_MO_B_tmp", mo_energy_b)
185-
call tagarray_get_data(infos%dat, "OQP::VEC_MO_B_tmp", mo_b)
164+
call infos%dat%alloc_or_die("OQP::DM_B_tmp", (/ nbf2 /), dmat_b, description=OQP_DM_B_comment)
165+
call infos%dat%alloc_or_die("OQP::E_MO_B_tmp", (/ nbf /), mo_energy_b, description=OQP_E_MO_B_comment)
166+
call infos%dat%alloc_or_die("OQP::VEC_MO_B_tmp", (/ nbf, nbf /), mo_b, description=OQP_VEC_MO_B_comment)
186167
!
187168
Dmat_b = 0_dp
188169
Dmat_a = 0_dp

source/modules/get_basis_overlap.F90

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,8 @@ subroutine get_structures_ao_overlap(infos)
104104
nbf = basis%nbf
105105

106106
! Allocate and prepare data for output
107-
call infos%dat%remove_records(tags_alloc)
108-
call infos%dat%reserve_data(OQP_overlap_mo, TA_TYPE_REAL64, &
109-
nbf*nbf, (/ nbf, nbf /), comment=OQP_overlap_mo_comment)
110-
call infos%dat%reserve_data(OQP_overlap_ao, TA_TYPE_REAL64, &
111-
nbf*nbf, (/ nbf, nbf /), comment=OQP_overlap_ao_comment)
112-
call data_has_tags(infos%dat, tags_alloc, module_name, subroutine_name, with_abort)
113-
call tagarray_get_data(infos%dat, OQP_overlap_mo, overlap_mo_out)
114-
call tagarray_get_data(infos%dat, OQP_overlap_ao, overlap_ao_out)
107+
call infos%dat%alloc_or_die(OQP_overlap_mo, (/ nbf, nbf /), overlap_mo_out, description=OQP_overlap_mo_comment)
108+
call infos%dat%alloc_or_die(OQP_overlap_ao, (/ nbf, nbf /), overlap_ao_out, description=OQP_overlap_ao_comment)
115109

116110
! Load data from python level
117111
call data_has_tags(infos%dat, tags_general, module_name, subroutine_name, with_abort)

source/modules/get_states_overlap.F90

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,16 @@ subroutine get_states_overlap(infos)
8383
ndtlf = infos%tddft%tlf
8484

8585
! Allocate data for outputing in python level
86-
call infos%dat%remove_records(tags_alloc)
87-
call infos%dat%reserve_data(OQP_td_states_phase, ta_type_real64, &
88-
nstates, (/ nstates /), comment=OQP_td_states_phase_comment)
89-
call infos%dat%reserve_data(OQP_td_states_overlap, ta_type_real64, &
90-
nstates*nstates, (/ nstates, nstates /), comment=OQP_td_states_overlap_comment)
91-
call infos%dat%reserve_data(OQP_nac, ta_type_real64, &
92-
nstates*nstates, (/ nstates, nstates /), comment=OQP_nac_comment)
86+
call infos%dat%alloc_or_die(OQP_td_states_phase, (/ nstates /), td_states_phase, description=OQP_td_states_phase_comment)
87+
call infos%dat%alloc_or_die(OQP_td_states_overlap, (/ nstates, nstates /), td_states_overlap, description=OQP_td_states_overlap_comment)
88+
call infos%dat%alloc_or_die(OQP_nac, (/ nstates, nstates /), nac_out, description=OQP_nac_comment)
9389

9490
! Load data from python level
9591
call data_has_tags(infos%dat, tags_general, module_name, subroutine_name, with_abort)
9692
call tagarray_get_data(infos%dat, OQP_td_bvec_mo, bvec_mo)
9793
call tagarray_get_data(infos%dat, OQP_overlap_mo, overlap_mo)
9894
call tagarray_get_data(infos%dat, OQP_td_bvec_mo_old, bvec_mo_old)
9995

100-
call data_has_tags(infos%dat, tags_alloc, module_name, subroutine_name, with_abort)
101-
call tagarray_get_data(infos%dat, OQP_td_states_phase, td_states_phase)
102-
call tagarray_get_data(infos%dat, OQP_td_states_overlap, td_states_overlap)
103-
call tagarray_get_data(infos%dat, OQP_nac, nac_out)
104-
10596
allocate(bvec(xvec_dim,nstates), &
10697
bvec_old(xvec_dim,nstates), &
10798
source=0.0_dp, stat=ok)

source/modules/guess_hcore.F90

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,38 +72,22 @@ subroutine guess_hcore(infos)
7272
allocate (qmat(nbf,nbf), stat=ok)
7373
if (ok /= 0) call show_message('Cannot allocate memory', WITH_ABORT)
7474

75-
! clean data
76-
call infos%dat%remove_records(tags_alpha)
77-
call infos%dat%remove_records(tags_beta)
78-
7975
! load general data
8076
call data_has_tags(infos%dat, tags_general, module_name, subroutine_name, WITH_ABORT)
8177
call tagarray_get_data(infos%dat, OQP_SM, smat)
8278
call tagarray_get_data(infos%dat, OQP_Hcore, hcore)
8379

8480
! allocate alpha
85-
call infos%dat%reserve_data(OQP_DM_A, TA_TYPE_REAL64, nbf2, comment=OQP_DM_A_comment)
86-
call infos%dat%reserve_data(OQP_E_MO_A, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_A_comment)
87-
call infos%dat%reserve_data(OQP_VEC_MO_A, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_A_comment)
88-
89-
! load alpha data
90-
call data_has_tags(infos%dat, tags_alpha, module_name, subroutine_name, WITH_ABORT)
91-
call tagarray_get_data(infos%dat, OQP_DM_A, dmat_a)
92-
call tagarray_get_data(infos%dat, OQP_E_MO_A, mo_energy_a)
93-
call tagarray_get_data(infos%dat, OQP_VEC_MO_A, mo_a)
81+
call infos%dat%alloc_or_die(OQP_DM_A, (/ nbf2 /), dmat_a, description=OQP_DM_A_comment)
82+
call infos%dat%alloc_or_die(OQP_E_MO_A, (/ nbf /), mo_energy_a, description=OQP_E_MO_A_comment)
83+
call infos%dat%alloc_or_die(OQP_VEC_MO_A, (/ nbf, nbf /), mo_a, description=OQP_VEC_MO_A_comment)
9484

9585
! UHF/ROHF
9686
if (infos%control%scftype >= 2) then
9787
! allocate beta
98-
call infos%dat%reserve_data(OQP_DM_B, TA_TYPE_REAL64, nbf2, comment=OQP_DM_B_comment)
99-
call infos%dat%reserve_data(OQP_E_MO_B, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_B_comment)
100-
call infos%dat%reserve_data(OQP_VEC_MO_B, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_B_comment)
101-
102-
! load beta
103-
call data_has_tags(infos%dat, tags_beta, module_name, subroutine_name, WITH_ABORT)
104-
call tagarray_get_data(infos%dat, OQP_DM_B, dmat_b)
105-
call tagarray_get_data(infos%dat, OQP_E_MO_B, mo_energy_b)
106-
call tagarray_get_data(infos%dat, OQP_VEC_MO_B, mo_b)
88+
call infos%dat%alloc_or_die(OQP_DM_B, (/ nbf2 /), dmat_b, description=OQP_DM_B_comment)
89+
call infos%dat%alloc_or_die(OQP_E_MO_B, (/ nbf /), mo_energy_b, description=OQP_E_MO_B_comment)
90+
call infos%dat%alloc_or_die(OQP_VEC_MO_B, (/ nbf, nbf /), mo_b, description=OQP_VEC_MO_B_comment)
10791
end if
10892

10993
! End of Readings.................................

source/modules/guess_huckel.F90

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -109,36 +109,20 @@ subroutine guess_huckel_driver(infos, modified)
109109
nbf = basis%nbf
110110
nbf2 = nbf*(nbf+1)/2
111111

112-
! clean data
113-
call infos%dat%remove_records(tags_alpha)
114-
call infos%dat%remove_records(tags_beta)
115-
116112
! load general data
117113
call tagarray_get_data(infos%dat, OQP_SM, smat)
118114

119115
! allocate alpha
120-
call infos%dat%reserve_data(OQP_DM_A, TA_TYPE_REAL64, nbf2, comment=OQP_DM_A_comment)
121-
call infos%dat%reserve_data(OQP_E_MO_A, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_A_comment)
122-
call infos%dat%reserve_data(OQP_VEC_MO_A, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_A_comment)
123-
124-
! load alpha data
125-
call data_has_tags(infos%dat, tags_alpha, module_name, subroutine_name, WITH_ABORT)
126-
call tagarray_get_data(infos%dat, OQP_DM_A, dmat_a)
127-
call tagarray_get_data(infos%dat, OQP_E_MO_A, mo_energy_a)
128-
call tagarray_get_data(infos%dat, OQP_VEC_MO_A, mo_a)
116+
call infos%dat%alloc_or_die(OQP_DM_A, (/ nbf2 /), dmat_a, description=OQP_DM_A_comment)
117+
call infos%dat%alloc_or_die(OQP_E_MO_A, (/ nbf /), mo_energy_a, description=OQP_E_MO_A_comment)
118+
call infos%dat%alloc_or_die(OQP_VEC_MO_A, (/ nbf, nbf /), mo_a, description=OQP_VEC_MO_A_comment)
129119

130120
! UHF/ROHF
131121
if (infos%control%scftype >= 2) then
132122
! allocate beta
133-
call infos%dat%reserve_data(OQP_DM_B, TA_TYPE_REAL64, nbf2, comment=OQP_DM_B_comment)
134-
call infos%dat%reserve_data(OQP_E_MO_B, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_B_comment)
135-
call infos%dat%reserve_data(OQP_VEC_MO_B, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_B_comment)
136-
137-
! load beta
138-
call data_has_tags(infos%dat, tags_beta, module_name, subroutine_name, WITH_ABORT)
139-
call tagarray_get_data(infos%dat, OQP_DM_B, dmat_b)
140-
call tagarray_get_data(infos%dat, OQP_E_MO_B, mo_energy_b)
141-
call tagarray_get_data(infos%dat, OQP_VEC_MO_B, mo_b)
123+
call infos%dat%alloc_or_die(OQP_DM_B, (/ nbf2 /), dmat_b, description=OQP_DM_B_comment)
124+
call infos%dat%alloc_or_die(OQP_E_MO_B, (/ nbf /), mo_energy_b, description=OQP_E_MO_B_comment)
125+
call infos%dat%alloc_or_die(OQP_VEC_MO_B, (/ nbf, nbf /), mo_b, description=OQP_VEC_MO_B_comment)
142126
end if
143127

144128
! Calculate Huckel MOs and the corresponding density matrix.

source/modules/guess_json.F90

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,9 @@ subroutine guess_json(infos)
9393
call tagarray_get_data(infos%dat, OQP_E_MO_A, mo_energy_a)
9494
call tagarray_get_data(infos%dat, OQP_VEC_MO_A, mo_a)
9595

96-
! allocate beta
97-
call data_has_tags(infos%dat, tags_beta, module_name, subroutine_name, WITH_ABORT)
98-
call infos%dat%reserve_data(OQP_DM_B, TA_TYPE_REAL64, nbf2, comment=OQP_DM_B_comment)
99-
call infos%dat%reserve_data(OQP_E_MO_B, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_B_comment)
100-
call infos%dat%reserve_data(OQP_VEC_MO_B, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_B_comment)
101-
102-
! load beta
96+
! Load beta orbitals from the JSON guess. For ROHF/UHF (scftype >= 2) these
97+
! are the supplied beta guess read by get_ab_initio_density below, so they
98+
! must be retrieved, NOT reallocated (alloc_or_die would discard the guess).
10399
call data_has_tags(infos%dat, tags_beta, module_name, subroutine_name, WITH_ABORT)
104100
call tagarray_get_data(infos%dat, OQP_DM_B, dmat_b)
105101
call tagarray_get_data(infos%dat, OQP_E_MO_B, mo_energy_b)

source/modules/guess_minao.F90

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,14 @@ subroutine guess_minao(infos)
131131
end do
132132

133133
! tagarray records
134-
call infos%dat%remove_records(tags_alpha)
135-
call infos%dat%remove_records(tags_beta)
136134
call tagarray_get_data(infos%dat, OQP_SM, smat)
137-
call infos%dat%reserve_data(OQP_DM_A, TA_TYPE_REAL64, nbf2, comment=OQP_DM_A_comment)
138-
call infos%dat%reserve_data(OQP_E_MO_A, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_A_comment)
139-
call infos%dat%reserve_data(OQP_VEC_MO_A, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_A_comment)
140-
call tagarray_get_data(infos%dat, OQP_DM_A, dmat_a)
141-
call tagarray_get_data(infos%dat, OQP_E_MO_A, mo_energy_a)
142-
call tagarray_get_data(infos%dat, OQP_VEC_MO_A, mo_a)
135+
call infos%dat%alloc_or_die(OQP_DM_A, (/ nbf2 /), dmat_a, description=OQP_DM_A_comment)
136+
call infos%dat%alloc_or_die(OQP_E_MO_A, (/ nbf /), mo_energy_a, description=OQP_E_MO_A_comment)
137+
call infos%dat%alloc_or_die(OQP_VEC_MO_A, (/ nbf, nbf /), mo_a, description=OQP_VEC_MO_A_comment)
143138
if (infos%control%scftype >= 2) then
144-
call infos%dat%reserve_data(OQP_DM_B, TA_TYPE_REAL64, nbf2, comment=OQP_DM_B_comment)
145-
call infos%dat%reserve_data(OQP_E_MO_B, TA_TYPE_REAL64, nbf, comment=OQP_E_MO_B_comment)
146-
call infos%dat%reserve_data(OQP_VEC_MO_B, TA_TYPE_REAL64, nbf*nbf, (/ nbf, nbf /), comment=OQP_VEC_MO_B_comment)
147-
call tagarray_get_data(infos%dat, OQP_DM_B, dmat_b)
148-
call tagarray_get_data(infos%dat, OQP_E_MO_B, mo_energy_b)
149-
call tagarray_get_data(infos%dat, OQP_VEC_MO_B, mo_b)
139+
call infos%dat%alloc_or_die(OQP_DM_B, (/ nbf2 /), dmat_b, description=OQP_DM_B_comment)
140+
call infos%dat%alloc_or_die(OQP_E_MO_B, (/ nbf /), mo_energy_b, description=OQP_E_MO_B_comment)
141+
call infos%dat%alloc_or_die(OQP_VEC_MO_B, (/ nbf, nbf /), mo_b, description=OQP_VEC_MO_B_comment)
150142
end if
151143

152144
! Canonical orthogonalizer Q from matrix_invsqrt (Q = U L^{-1/2}, so that

0 commit comments

Comments
 (0)