From 967ffb23fcb37d756e27952afc52a46e8dcd503a Mon Sep 17 00:00:00 2001 From: Stefano Battaglia Date: Fri, 25 Aug 2023 13:16:27 +0200 Subject: [PATCH] Fix compilation errors without HDF5 library (#2947) --- src/hdf5_wrapper.F | 29 ++++++++++++++++++----------- src/input_cp2k_dft.F | 8 ++++---- src/qs_active_space_methods.F | 18 +++++++++--------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/hdf5_wrapper.F b/src/hdf5_wrapper.F index 13fbd15c92..968c1f88d4 100644 --- a/src/hdf5_wrapper.F +++ b/src/hdf5_wrapper.F @@ -13,26 +13,31 @@ ! ************************************************************************************************** MODULE hdf5_wrapper - 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, & - 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, & - h5tenum_insert_f, h5tset_cset_f, h5tset_size_f, h5tset_strpad_f, hid_t, hsize_t, size_t - USE iso_c_binding, ONLY: C_LOC,& - c_ptr - USE kinds, ONLY: dp +#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, & + 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, & + 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 kinds, ONLY: dp #include "./base/base_uses.f90" IMPLICIT NONE CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'hdf5_wrapper' +#ifdef __HDF5 INTEGER, PARAMETER, PUBLIC :: hdf5_id = hid_t +#endif CONTAINS +#ifdef __HDF5 ! ************************************************************************************************** !> \brief Initialize the HDF5 fortran API ! ************************************************************************************************** @@ -759,4 +764,6 @@ CONTAINS END SUBROUTINE h5aread_double_scalar +#endif + END MODULE hdf5_wrapper diff --git a/src/input_cp2k_dft.F b/src/input_cp2k_dft.F index a3de6befba..caa9a84ebb 100644 --- a/src/input_cp2k_dft.F +++ b/src/input_cp2k_dft.F @@ -9183,10 +9183,10 @@ CONTAINS n_keywords=3, n_subsections=0, repeats=.FALSE.) NULLIFY (keyword) - CALL keyword_create(keyword, __LOCATION__, name="UNIX", & - description="Use a UNIX socket rather than an INET socket.", & - usage="unix LOGICAL", & - default_l_val=.TRUE., lone_keyword_l_val=.TRUE.) + CALL keyword_create(keyword, __LOCATION__, name="INET", & + description="Use an INET socket rather than a UNIX socket.", & + usage="INET ", & + default_l_val=.FALSE., lone_keyword_l_val=.TRUE.) CALL section_add_keyword(section, keyword) CALL keyword_release(keyword) diff --git a/src/qs_active_space_methods.F b/src/qs_active_space_methods.F index b2f5a5a03e..92435773a9 100644 --- a/src/qs_active_space_methods.F +++ b/src/qs_active_space_methods.F @@ -2482,9 +2482,9 @@ CONTAINS TYPE(section_vals_type), POINTER :: as_input CHARACTER(len=*), PARAMETER :: routineN = 'rsdft_embedding' + INTEGER :: handle #ifdef __NO_SOCKETS - INTEGER :: handle CALL timeset(routineN, handle) CPABORT("CP2K was compiled with the __NO_SOCKETS option!") MARK_USED(qs_env) @@ -2492,8 +2492,7 @@ CONTAINS MARK_USED(as_input) #else - INTEGER :: client_fd, handle, iter, iw, max_iter, & - socket_fd + INTEGER :: iw, client_fd, socket_fd, iter, max_iter LOGICAL :: converged, do_scf_embedding, ionode REAL(KIND=dp) :: alpha, delta_E, energy_corr, energy_new, & energy_old, energy_scf, eps_iter, t1, & @@ -2645,7 +2644,7 @@ CONTAINS CHARACTER(len=default_path_length) :: hostname INTEGER :: handle, iw, port, protocol - LOGICAL :: unix + LOGICAL :: inet TYPE(cp_logger_type), POINTER :: logger CALL timeset(routineN, handle) @@ -2653,12 +2652,13 @@ CONTAINS logger => cp_get_default_logger() iw = cp_logger_get_default_io_unit(logger) - socket_fd = 0 - protocol = 0 - ! protocol == 0 for UNIX, protocol > 0 for INET - CALL section_vals_val_get(as_input, "SOCKET%UNIX", l_val=unix) - IF (.NOT. unix) protocol = 1 + CALL section_vals_val_get(as_input, "SOCKET%INET", l_val=inet) + IF (inet) THEN + protocol = 1 + ELSE + protocol = 0 + END IF CALL section_vals_val_get(as_input, "SOCKET%HOST", c_val=hostname) CALL section_vals_val_get(as_input, "SOCKET%PORT", i_val=port)