From b83d40d81f6f1160b1b89c6966c2dffbc7e5fb6a Mon Sep 17 00:00:00 2001 From: SY Wang Date: Thu, 5 Mar 2026 21:52:31 +0800 Subject: [PATCH] Toolchain: Updates of COSMA and HDF5 (#4910) --- src/hdf5_wrapper.F | 16 ++++- tests/QS/regtest-as-qcschema/TEST_FILES.toml | 9 +++ tests/QS/regtest-as-qcschema/be.inp | 69 +++++++++++++++++++ tests/QS/regtest-as-qcschema/h2o.inp | 66 ++++++++++++++++++ tests/TEST_DIRS | 1 + .../toolchain/scripts/stage4/install_cosma.sh | 12 ++-- .../toolchain/scripts/stage7/install_hdf5.sh | 35 +++++----- 7 files changed, 181 insertions(+), 27 deletions(-) create mode 100644 tests/QS/regtest-as-qcschema/TEST_FILES.toml create mode 100644 tests/QS/regtest-as-qcschema/be.inp create mode 100644 tests/QS/regtest-as-qcschema/h2o.inp diff --git a/src/hdf5_wrapper.F b/src/hdf5_wrapper.F index 959107acc0..f16e6a26b7 100644 --- a/src/hdf5_wrapper.F +++ b/src/hdf5_wrapper.F @@ -16,17 +16,19 @@ MODULE hdf5_wrapper #ifdef __HDF5 USE hdf5, ONLY: & h5aclose_f, h5acreate_f, h5aopen_f, h5aread_f, h5awrite_f, h5close_f, h5dclose_f, & - h5dcreate_f, h5dget_space_f, h5dopen_f, h5dread_f, h5dwrite_f, h5f_acc_rdonly_f, & + h5dcreate_f, h5dget_space_f, h5dopen_f, h5dread_f, h5dwrite_f, h5f_acc_rdonly_f, h5f_acc_rdwr_f, & h5f_acc_trunc_f, h5fclose_f, h5fcreate_f, h5fopen_f, h5gclose_f, h5gcreate_f, h5gopen_f, & h5open_f, h5s_scalar_f, h5sclose_f, h5screate_f, h5screate_simple_f, & h5sget_simple_extent_npoints_f, h5t_c_s1, h5t_cset_utf8_f, h5t_enum_f, h5t_native_double, & h5t_native_integer, h5t_str_nullpad_f, h5t_string, h5tclose_f, h5tcopy_f, h5tcreate_f, & + h5pcreate_f, h5pclose_f, h5pset_fapl_mpio_f, h5p_file_access_f, h5p_default_f, & h5tenum_insert_f, h5tset_cset_f, h5tset_size_f, h5tset_strpad_f, hid_t, hsize_t, size_t #endif USE iso_c_binding, ONLY: C_LOC, & c_ptr USE cp_log_handling, ONLY: cp_logger_get_default_io_unit USE kinds, ONLY: dp + USE message_passing, ONLY: mp_comm_world, mp_info_null #include "./base/base_uses.f90" IMPLICIT NONE @@ -71,8 +73,12 @@ CONTAINS INTEGER(KIND=hid_t), INTENT(OUT) :: file_id INTEGER :: error + INTEGER(KIND=hid_t) :: plist_id - CALL h5fcreate_f(filename, h5f_acc_trunc_f, file_id, error) + CALL h5pcreate_f(h5p_file_access_f, plist_id, error) + CALL h5pset_fapl_mpio_f(plist_id, mp_comm_world%get_handle(), mp_info_null%get_handle(), error) + CALL h5fcreate_f(filename, h5f_acc_trunc_f, file_id, error, access_prp=plist_id) + CALL h5pclose_f(plist_id, error) IF (error < 0) CPABORT('ERROR: failed to create HDF5 file') END SUBROUTINE h5fcreate @@ -87,8 +93,12 @@ CONTAINS INTEGER(KIND=hid_t), INTENT(OUT) :: file_id INTEGER :: error + INTEGER(KIND=hid_t) :: plist_id - CALL h5fopen_f(TRIM(filename), h5f_acc_rdonly_f, file_id, error) + CALL h5pcreate_f(h5p_file_access_f, plist_id, error) + CALL h5pset_fapl_mpio_f(plist_id, mp_comm_world%get_handle(), mp_info_null%get_handle(), error) + CALL h5fopen_f(filename, h5f_acc_rdwr_f, file_id, error, access_prp=plist_id) + CALL h5pclose_f(plist_id, error) IF (error < 0) CPABORT('ERROR: failed to open HDF5 file') END SUBROUTINE h5fopen diff --git a/tests/QS/regtest-as-qcschema/TEST_FILES.toml b/tests/QS/regtest-as-qcschema/TEST_FILES.toml new file mode 100644 index 0000000000..63de2b57ca --- /dev/null +++ b/tests/QS/regtest-as-qcschema/TEST_FILES.toml @@ -0,0 +1,9 @@ +# runs are executed in the same order as in this file +# the second field tells which test should be run in order to compare with the last available output +# e.g. 0 means do not compare anything, running is enough +# 1 compares the last total energy in the file +# for details see cp2k/tools/do_regtest +# +"h2o.inp" = [{matcher="E_total", tol=1e-12, ref=-17.12434837130648}] +"be.inp" = [{matcher="E_total", tol=1e-12, ref=-14.49107600944466}] +#EOF diff --git a/tests/QS/regtest-as-qcschema/be.inp b/tests/QS/regtest-as-qcschema/be.inp new file mode 100644 index 0000000000..5c2dc7e654 --- /dev/null +++ b/tests/QS/regtest-as-qcschema/be.inp @@ -0,0 +1,69 @@ +&GLOBAL + PRINT_LEVEL LOW + RUN_TYPE ENERGY +&END GLOBAL + +&FORCE_EVAL + METHOD Quickstep + &DFT + &ACTIVE_SPACE + ACTIVE_ELECTRONS 4 + ACTIVE_ORBITALS 3 + ORBITAL_SELECTION CANONICAL + QCSCHEMA be.h5 + &ERI + METHOD FULL_GPW + OPERATOR COULOMB + &END ERI + &ERI_GPW + PRINT_LEVEL LOW + &END ERI_GPW + &FCIDUMP + &END FCIDUMP + &END ACTIVE_SPACE + &MGRID + CUTOFF 300 + &END MGRID + &POISSON + PERIODIC NONE + POISSON_SOLVER ANALYTIC + &END POISSON + &QS + EPS_DEFAULT 1.0E-10 + &END QS + &SCF + ADDED_MOS 2 + EPS_SCF 1.0E-5 + SCF_GUESS ATOMIC + &OT OFF + MINIMIZER DIIS + PRECONDITIONER FULL_ALL + &END OT + &END SCF + &XC + &HF + &MEMORY + MAX_MEMORY 10 + &END MEMORY + &SCREENING + EPS_SCHWARZ 1.0E-10 + &END SCREENING + &END HF + &XC_FUNCTIONAL NONE + &END XC_FUNCTIONAL + &END XC + &END DFT + &SUBSYS + &CELL + ABC 10.0 10.0 10.0 + PERIODIC NONE + &END CELL + &COORD + Be 0.000000 0.000000 0.000000 + &END COORD + &KIND Be + BASIS_SET ORB DZV-GTH-PADE + POTENTIAL GTH-PBE + &END KIND + &END SUBSYS +&END FORCE_EVAL diff --git a/tests/QS/regtest-as-qcschema/h2o.inp b/tests/QS/regtest-as-qcschema/h2o.inp new file mode 100644 index 0000000000..07691c7fab --- /dev/null +++ b/tests/QS/regtest-as-qcschema/h2o.inp @@ -0,0 +1,66 @@ +&GLOBAL + PRINT_LEVEL LOW + PROJECT h2o + RUN_TYPE ENERGY +&END GLOBAL + +&FORCE_EVAL + METHOD Quickstep + &DFT + &ACTIVE_SPACE + ACTIVE_ELECTRONS 4 + ACTIVE_ORBITALS 6 + ORBITAL_SELECTION CANONICAL + QCSCHEMA h2o.h5 + &ERI + METHOD FULL_GPW + OPERATOR COULOMB + &END ERI + &ERI_GPW + PRINT_LEVEL MEDIUM + &END ERI_GPW + &FCIDUMP + &END FCIDUMP + &PRINT_ORBITAL_CUBES + ALIST 3 4 1 + BLIST + FILENAME Active_orbital + STRIDE 3 + &END PRINT_ORBITAL_CUBES + &END ACTIVE_SPACE + &MGRID + CUTOFF 200 + &END MGRID + &QS + EPS_DEFAULT 1.0E-8 + &END QS + &SCF + ADDED_MOS 4 + IGNORE_CONVERGENCE_FAILURE + MAX_SCF 4 + SCF_GUESS ATOMIC + &END SCF + &XC + &XC_FUNCTIONAL Pade + &END XC_FUNCTIONAL + &END XC + &END DFT + &SUBSYS + &CELL + ABC 6.0 6.0 6.0 + &END CELL + &COORD + H 0.000000 -0.757136 0.520545 + O 0.000000 0.000000 -0.065587 + H 0.000000 0.757136 0.520545 + &END COORD + &KIND H + BASIS_SET ORB DZV-GTH-PADE + POTENTIAL GTH-PADE-q1 + &END KIND + &KIND O + BASIS_SET ORB DZVP-GTH-PADE + POTENTIAL GTH-PADE-q6 + &END KIND + &END SUBSYS +&END FORCE_EVAL diff --git a/tests/TEST_DIRS b/tests/TEST_DIRS index a28af41668..0ab2761231 100644 --- a/tests/TEST_DIRS +++ b/tests/TEST_DIRS @@ -361,6 +361,7 @@ QS/regtest-tddfpt-prop QS/regtest-pao-3 QS/regtest-double-hybrid-stress-numer-laplace libxc !ifx QS/regtest-as libint !ifx +QS/regtest-as-qcschema hdf5 libint !ifx QS/regtest-double-hybrid-2 libint !ifx QS/regtest-sccs-2 FE/regtest-3 diff --git a/tools/toolchain/scripts/stage4/install_cosma.sh b/tools/toolchain/scripts/stage4/install_cosma.sh index a495da955b..c530a22c82 100755 --- a/tools/toolchain/scripts/stage4/install_cosma.sh +++ b/tools/toolchain/scripts/stage4/install_cosma.sh @@ -6,12 +6,12 @@ [ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0 SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")/.." && pwd -P)" -cosma_ver="2.7.0" -cosma_sha256="f4775d18379539d7bb5053bff8acb4e13d6ed31a9677f498d9099a7500488789" -costa_ver="2.2.2" -costa_sha256="e87bc37aad14ac0c5922237be5d5390145c9ac6aef0350ed17d86cb2d994e67c" -tiled_mm_ver="2.3.1" -tiled_mm_sha256="68914a483e62f796b790ea428210b1d5ef5943d6289e53d1aa62f56a20fbccc8" +cosma_ver="2.8.1" +cosma_sha256="563bb0785dca32ede780a05ad424db9b6d7f473a909ca423931b96204e2b5d9c" +costa_ver="2.3.0" +costa_sha256="0413311a2821d4cd1f3f026672a75a5b5a2956f61305c07d7fc14565a126b517" +tiled_mm_ver="2.3.2" +tiled_mm_sha256="1f91ca02f6ee8e400835fa90630618baf86a7b425b4bbbb4151068f72658b858" source "${SCRIPT_DIR}"/common_vars.sh source "${SCRIPT_DIR}"/tool_kit.sh diff --git a/tools/toolchain/scripts/stage7/install_hdf5.sh b/tools/toolchain/scripts/stage7/install_hdf5.sh index 38043e888d..46ac77b29d 100755 --- a/tools/toolchain/scripts/stage7/install_hdf5.sh +++ b/tools/toolchain/scripts/stage7/install_hdf5.sh @@ -6,8 +6,8 @@ [ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0 SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")/.." && pwd -P)" -hdf5_ver="1.14.6" -hdf5_sha256="e4defbac30f50d64e1556374aa49e574417c9e72c6b1de7a4ff88c4b1bea6e9b" +hdf5_ver="2.1.0" +hdf5_sha256="ce7f5515a95d588b8606c3fb50643f8b88ac52ffbbde9c63bb1edca6a256e964" source "${SCRIPT_DIR}"/common_vars.sh source "${SCRIPT_DIR}"/tool_kit.sh @@ -39,15 +39,19 @@ case "$with_hdf5" in cd hdf5-${hdf5_ver} mkdir build cd build - cmake \ + # Add "-DHDF5_ENABLE_ZLIB_SUPPORT=ON" because HDF5 2.x doesn't enable ZLIB support by default + CMAKE_OPTIONS="-DBUILD_TESTING=OFF -DHDF5_BUILD_FORTRAN=ON -DHDF5_ENABLE_ZLIB_SUPPORT=ON" + if [ "$(find_in_paths "libsz.*" $LIB_PATHS)" != "__FALSE__" ]; then + CMAKE_OPTIONS="${CMAKE_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT=ON" + fi + if [ "${MPI_MODE}" != "no" ]; then + CMAKE_OPTIONS="${CMAKE_OPTIONS} -DHDF5_ENABLE_PARALLEL=ON" + fi + cmake .. \ -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DHDF5_BUILD_FORTRAN=ON \ - -DHDF5_ENABLE_Z_LIB_SUPPORT=ON \ - .. > configure.log 2>&1 || tail_excerpt configure.log - make -j $(get_nprocs) > make.log 2>&1 || tail_excerpt make.log - make install > install.log 2>&1 || tail_excerpt install.log + ${CMAKE_OPTIONS} > configure.log 2>&1 || tail_excerpt configure.log + make install -j $(get_nprocs) > make.log 2>&1 || tail_excerpt make.log cd .. write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage7/$(basename ${SCRIPT_NAME})" fi @@ -91,10 +95,8 @@ if [ "${with_hdf5}" != "__DONTUSE__" ]; then else HDF5_LIBS="-lhdf5_fortran -lhdf5_f90cstub -lhdf5 -lz" fi - if [ -f "${pkg_install_dir}/lib/pkgconfig/hdf5.pc" ]; then - if [ -n "$(grep libsz ${pkg_install_dir}/lib/pkgconfig/hdf5.pc)" ]; then - HDF5_LIBS="${HDF5_LIBS} -lsz" - fi + if [ -n "$(grep "lsz" ${pkg_install_dir}/lib/pkgconfig/hdf5.pc)" ]; then + HDF5_LIBS="${HDF5_LIBS} -lsz" fi cat << EOF > "${BUILDDIR}/setup_hdf5" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" @@ -110,11 +112,8 @@ EOF else HDF5_LIBS="-lhdf5_fortran -lhdf5_hl -lhdf5 -lz" fi - if [ -f "${pkg_install_dir}/lib/pkgconfig/hdf5.pc" ]; then - if [ -n "$(grep libsz ${pkg_install_dir}/lib/pkgconfig/hdf5.pc)" ]; then - HDF5_LIBS="${HDF5_LIBS} -lsz" - fi - elif [ -n "$(grep -- "-lsz" ${pkg_install_dir}/lib/libhdf5.settings)" ]; then + if [ -n "$(grep "lsz" ${pkg_install_dir}/lib/pkgconfig/hdf5.pc)" ] || + [ -n "$(grep "lsz" ${pkg_install_dir}/lib/libhdf5.settings)" ]; then HDF5_LIBS="${HDF5_LIBS} -lsz" fi fi