Skip to content

Commit

Permalink
Sync the Fortran build changes
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnHDF committed Nov 15, 2023
1 parent da964ae commit 52aa450
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 38 deletions.
10 changes: 5 additions & 5 deletions config/cmake/examples/HDF5_Examples.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ endif()
set(ENV{HDF5_PLUGIN_PATH} "${INSTALLDIR}/lib/plugin")
set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACKAGE_NAME:STRING=@HDF5_PACKAGE@@HDF_PACKAGE_EXT@")
### use a toolchain file (supported everywhere) ####
if(NOT DEFINED CTEST_TOOLCHAIN_FILE)
set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=@CTEST_TOOLCHAIN_FILE@")
else()
set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=${CTEST_TOOLCHAIN_FILE}")
endif()
#if(NOT DEFINED CTEST_TOOLCHAIN_FILE)
# set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=@CTEST_TOOLCHAIN_FILE@")
#else()
# set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=${CTEST_TOOLCHAIN_FILE}")
#endif()

###############################################################################################################
# For any comments please contact [email protected]
Expand Down
6 changes: 3 additions & 3 deletions fortran/examples/ph5example.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PROGRAM DATASET
CHARACTER(LEN=8), PARAMETER :: dsetname = "IntArray" ! Dataset name

CHARACTER(LEN=100) :: filename ! File name
INTEGER :: fnamelen ! File name length
INTEGER :: fnamelen ! File name length
INTEGER(HID_T) :: file_id ! File identifier
INTEGER(HID_T) :: dset_id ! Dataset identifier
INTEGER(HID_T) :: filespace ! Dataspace identifier in file
Expand Down Expand Up @@ -76,9 +76,9 @@ PROGRAM DATASET
CALL get_environment_variable("HDF5_PARAPREFIX", filename)
fnamelen = LEN_TRIM(filename)
if ( fnamelen == 0 ) then
filename = default_fname
filename = default_fname
else
filename = filename(1:fnamelen) // "/" // default_fname
filename = filename(1:fnamelen) // "/" // default_fname
endif
print *, "Using filename = ", filename

Expand Down
41 changes: 31 additions & 10 deletions fortran/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ if (WIN32)
if (NOT H5_HAVE_PARALLEL)
set (H5_NOPAREXP ";")
endif ()
set (H5_NOSUBFILING ";") # Subfiling is not supported on Windows
set (H5_F03EXP ";")
if (NOT H5_FORTRAN_C_LONG_DOUBLE_IS_UNIQUE)
set (H5_DBL_NOT_UNIQUE_EXP ";")
endif ()
set (CMAKE_NO_DEPRECATED_SYMBOLS 0)
if (NOT H5_NO_DEPRECATED_SYMBOLS)
set (H5_NO_DEPRECATED_SYMBOLS ";")
set (CMAKE_NO_DEPRECATED_SYMBOLS 1)
set (DLL_NO_DEPRECATED_SYMBOLS ";")
endif ()
configure_file (${HDF5_F90_SRC_SOURCE_DIR}/hdf5_fortrandll.def.in ${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def @ONLY)
endif ()
Expand All @@ -25,15 +28,34 @@ endif ()

# Define Parallel variable for passing to H5config_f.inc.cmake
set (CMAKE_H5_HAVE_PARALLEL 0)
set (CMAKE_H5_HAVE_SUBFILING_VFD 0)
if (H5_HAVE_PARALLEL)
set (CMAKE_H5_HAVE_PARALLEL 1)
if (H5_HAVE_SUBFILING_VFD)
set (CMAKE_H5_HAVE_SUBFILING_VFD 1)
endif ()
endif ()

set (CMAKE_H5_HAVE_FLOAT128 0)
if (HAVE_FLOAT128)
if (H5_HAVE_FLOAT128)
set (CMAKE_H5_HAVE_FLOAT128 1)
endif ()

set (CMAKE_H5_FORTRAN_HAVE_STORAGE_SIZE 0)
if (H5_FORTRAN_HAVE_STORAGE_SIZE)
set (CMAKE_H5_FORTRAN_HAVE_STORAGE_SIZE 1)
endif ()

set (CMAKE_H5_FORTRAN_HAVE_SIZEOF 0)
if (H5_FORTRAN_HAVE_SIZEOF)
set (CMAKE_H5_FORTRAN_HAVE_SIZEOF 1)
endif ()

set (CMAKE_H5_FORTRAN_HAVE_C_SIZEOF 0)
if (H5_FORTRAN_HAVE_C_SIZEOF)
set (CMAKE_H5_FORTRAN_HAVE_C_SIZEOF 1)
endif ()

configure_file (${HDF5_F90_SRC_SOURCE_DIR}/H5config_f.inc.cmake ${HDF5_F90_BINARY_DIR}/H5config_f.inc @ONLY)
configure_file (${HDF5_F90_SRC_SOURCE_DIR}/H5fort_type_defines.h.cmake ${HDF5_F90_BINARY_DIR}/H5fort_type_defines.h @ONLY)

Expand Down Expand Up @@ -341,8 +363,6 @@ if (BUILD_STATIC_LIBS)
${LINK_Fortran_LIBS}
"$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}>"
)
# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS "$<$<STREQUAL:x${CMAKE_Fortran_SIMULATE_ID},xMSVC>:-SUBSYSTEM:CONSOLE>")
# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS "$<$<STREQUAL:x${CMAKE_Fortran_SIMULATE_ID},xMSVC>:${WIN_LINK_FLAGS}>")
if(MSVC)
set_property(TARGET ${HDF5_F90_LIB_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}")
endif()
Expand All @@ -358,7 +378,12 @@ if (BUILD_STATIC_LIBS)
endif ()

if (BUILD_SHARED_LIBS)
add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES_SHARED})
if(WIN32)
set(DLLDEF ${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def)
else()
set(DLLDEF "")
endif()
add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${DLLDEF} ${f90_F_SOURCES_SHARED})
target_include_directories (${HDF5_F90_LIBSH_TARGET}
PRIVATE "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${HDF5_INSTALL_MODULE_DIR}/shared>"
Expand All @@ -374,12 +399,8 @@ if (BUILD_SHARED_LIBS)
PUBLIC ${HDF5_F90_C_LIBSH_TARGET}
PRIVATE ${LINK_Fortran_LIBS} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}>"
)
# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS "$<$<STREQUAL:x${CMAKE_Fortran_SIMULATE_ID},xMSVC>:-SUBSYSTEM:CONSOLE>")
# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS "$<$<STREQUAL:x${CMAKE_Fortran_SIMULATE_ID},xMSVC>:${WIN_LINK_FLAGS}>")
# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS "$<$<STREQUAL:x${CMAKE_Fortran_SIMULATE_ID},xMSVC>:-DLL>")
# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS "$<$<STREQUAL:x${CMAKE_Fortran_SIMULATE_ID},xMSVC>:-DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def>")
if(MSVC)
set_property(TARGET ${HDF5_F90_LIBSH_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS} /DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def")
set_property(TARGET ${HDF5_F90_LIBSH_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}")
endif()
set_target_properties (${HDF5_F90_LIBSH_TARGET} PROPERTIES
FOLDER libraries/fortran
Expand Down
2 changes: 1 addition & 1 deletion fortran/src/H5_ff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ INTEGER(HID_T) FUNCTION h5kind_to_type(ikind, flag) RESULT(h5_type)
h5_type = H5T_NATIVE_REAL_C_LONG_DOUBLE
#endif
#if H5_PAC_FC_MAX_REAL_PRECISION > 28
#if H5_HAVE_FLOAT128 == 1
#ifdef H5_HAVE_FLOAT128
ELSE
h5_type = H5T_NATIVE_FLOAT_128
#endif
Expand Down
54 changes: 41 additions & 13 deletions fortran/src/H5config_f.inc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,54 @@
! fortran/src/H5config_f.inc. Generated from fortran/src/H5config_f.inc.in by configure

! Define if there is parallel support
#cmakedefine01 H5_HAVE_PARALLEL
#if H5_HAVE_PARALLEL == 0
#cmakedefine01 CMAKE_H5_HAVE_PARALLEL
#if CMAKE_H5_HAVE_PARALLEL == 0
#undef H5_HAVE_PARALLEL
#else
#define H5_HAVE_PARALLEL
#endif

! Define if there is subfiling support
#cmakedefine01 H5_HAVE_SUBFILING_VFD
#if H5_HAVE_SUBFILING_VFD == 0
#cmakedefine01 CMAKE_H5_HAVE_SUBFILING_VFD
#if CMAKE_H5_HAVE_SUBFILING_VFD == 0
#undef H5_HAVE_SUBFILING_VFD
#else
#define H5_HAVE_SUBFILING_VFD
#endif

! Define if on APPLE
#cmakedefine01 H5_HAVE_DARWIN
#if H5_HAVE_DARWIN == 0
#undef H5_HAVE_DARWIN
#else
#define H5_HAVE_DARWIN
#endif

! Define if the intrinsic function STORAGE_SIZE exists
#define H5_FORTRAN_HAVE_STORAGE_SIZE @H5_FORTRAN_HAVE_STORAGE_SIZE@
#cmakedefine01 CMAKE_H5_FORTRAN_HAVE_STORAGE_SIZE
#if CMAKE_H5_FORTRAN_HAVE_STORAGE_SIZE == 0
#undef H5_FORTRAN_HAVE_STORAGE_SIZE
#else
#define H5_FORTRAN_HAVE_STORAGE_SIZE
#endif

! Define if the intrinsic function SIZEOF exists
#define H5_FORTRAN_HAVE_SIZEOF @H5_FORTRAN_HAVE_SIZEOF@
#cmakedefine01 CMAKE_H5_FORTRAN_HAVE_SIZEOF
#if CMAKE_H5_FORTRAN_HAVE_SIZEOF == 0
#undef H5_FORTRAN_HAVE_SIZEOF
#else
#define H5_FORTRAN_HAVE_SIZEOF
#endif

! Define if the intrinsic function C_SIZEOF exists
#define H5_FORTRAN_HAVE_C_SIZEOF @H5_FORTRAN_HAVE_C_SIZEOF@
#cmakedefine01 CMAKE_H5_FORTRAN_HAVE_C_SIZEOF
#if CMAKE_H5_FORTRAN_HAVE_C_SIZEOF == 0
#undef H5_FORTRAN_HAVE_C_SIZEOF
#else
#define H5_FORTRAN_HAVE_C_SIZEOF
#endif

! Define if the intrinsic C_LONG_DOUBLE exists
! Define if the intrinsic function C_LONG_DOUBLE exists
#define H5_FORTRAN_HAVE_C_LONG_DOUBLE @H5_FORTRAN_HAVE_C_LONG_DOUBLE@

! Define if Fortran C_LONG_DOUBLE is different from C_DOUBLE
Expand All @@ -47,17 +68,22 @@
! Define if the intrinsic module ISO_FORTRAN_ENV exists
#define H5_HAVE_ISO_FORTRAN_ENV @H5_HAVE_ISO_FORTRAN_ENV@

! should this be ${HDF_PREFIX} instead of H5 MSB
! Define the size of C's double
#define H5_SIZEOF_DOUBLE @H5_SIZEOF_DOUBLE@

! should this be ${HDF_PREFIX} instead of H5 MSB
! Define the size of C's long double
#define H5_SIZEOF_LONG_DOUBLE @H5_SIZEOF_LONG_DOUBLE@

! Define the maximum decimal precision for reals
#define H5_PAC_FC_MAX_REAL_PRECISION @H5_PAC_FC_MAX_REAL_PRECISION@

! If C has quad precision
#define H5_HAVE_FLOAT128 @H5_HAVE_FLOAT128@
#cmakedefine01 CMAKE_H5_HAVE_FLOAT128
#if CMAKE_H5_HAVE_FLOAT128 == 0
#undef H5_HAVE_FLOAT128
#else
#define H5_HAVE_FLOAT128
#endif

! Define if INTEGER*16 is available
#define H5_HAVE_Fortran_INTEGER_SIZEOF_16 @H5_HAVE_Fortran_INTEGER_SIZEOF_16@
Expand All @@ -84,7 +110,9 @@
#define H5_Fortran_COMPILER_ID @CMAKE_Fortran_COMPILER_ID@

! Define if deprecated public API symbols are disabled
#cmakedefine01 H5_NO_DEPRECATED_SYMBOLS
#if H5_NO_DEPRECATED_SYMBOLS == 0
#cmakedefine01 CMAKE_NO_DEPRECATED_SYMBOLS
#if CMAKE_NO_DEPRECATED_SYMBOLS == 0
#undef H5_NO_DEPRECATED_SYMBOLS
#else
#define H5_NO_DEPRECATED_SYMBOLS
#endif
2 changes: 1 addition & 1 deletion fortran/src/H5config_f.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
! Define if the intrinsic module ISO_FORTRAN_ENV exists
#undef HAVE_ISO_FORTRAN_ENV

! Define the size of C's long double
! Define the size of C's double
#undef SIZEOF_DOUBLE

! Define the size of C's long double
Expand Down
10 changes: 5 additions & 5 deletions fortran/src/hdf5_fortrandll.def.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ H5A_mp_H5AREAD_CHAR_SCALAR
H5A_mp_H5ACREATE_F
H5A_mp_H5ACREATE_ASYNC_F
H5A_mp_H5AOPEN_NAME_F
@H5_NO_DEPRECATED_SYMBOLS@H5A_mp_H5AOPEN_IDX_F
@DLL_NO_DEPRECATED_SYMBOLS@H5A_mp_H5AOPEN_IDX_F
H5A_mp_H5AGET_SPACE_F
H5A_mp_H5AGET_TYPE_F
H5A_mp_H5AGET_NAME_F
Expand Down Expand Up @@ -421,10 +421,10 @@ H5P_mp_H5PGET_ACTUAL_SELECTION_IO_MODE_F
; Parallel
@H5_NOPAREXP@H5P_mp_H5PSET_FAPL_MPIO_F
@H5_NOPAREXP@H5P_mp_H5PGET_FAPL_MPIO_F
@H5_NOPAREXP@H5P_mp_H5PSET_FAPL_SUBFILING_F
@H5_NOPAREXP@H5P_mp_H5PGET_FAPL_SUBFILING_F
@H5_NOPAREXP@H5P_mp_H5PSET_FAPL_IOC_F
@H5_NOPAREXP@H5P_mp_H5PGET_FAPL_IOC_F
@H5_NOPAREXP@@H5_NOSUBFILING@H5P_mp_H5PSET_FAPL_SUBFILING_F
@H5_NOPAREXP@@H5_NOSUBFILING@H5P_mp_H5PGET_FAPL_SUBFILING_F
@H5_NOPAREXP@@H5_NOSUBFILING@H5P_mp_H5PSET_FAPL_IOC_F
@H5_NOPAREXP@@H5_NOSUBFILING@H5P_mp_H5PGET_FAPL_IOC_F
@H5_NOPAREXP@H5P_mp_H5PSET_MPI_PARAMS_F
@H5_NOPAREXP@H5P_mp_H5PGET_MPI_PARAMS_F
@H5_NOPAREXP@H5P_mp_H5PSET_DXPL_MPIO_F
Expand Down

0 comments on commit 52aa450

Please sign in to comment.