diff options
Diffstat (limited to 'fortran')
33 files changed, 1599 insertions, 258 deletions
diff --git a/fortran/robodoc.rc b/fortran/robodoc.rc index 07b8b35..b24e4f9 100644 --- a/fortran/robodoc.rc +++ b/fortran/robodoc.rc @@ -132,10 +132,7 @@ ignore files: *.o *e *.mod - *_F90.f90 *.c accept files: - *_F03.f90 - *_F90.f90 - *.f90 + *.F90 *.h diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index dc884d5..8ebbbd0 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -139,7 +139,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) TARGET_C_PROPERTIES (${HDF5_F90_C_LIBSH_TARGET} SHARED " " " ") target_link_libraries (${HDF5_F90_C_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${LINK_SHARED_LIBS}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIBSH_TARGET}") - H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIBSH_TARGET} ${HDF5_F90_C_LIB_NAME} SHARED) + H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIBSH_TARGET} ${HDF5_F90_C_LIB_NAME} SHARED ${HDF5_F_PACKAGE_SOVERSION}) set_target_properties (${HDF5_F90_C_LIBSH_TARGET} PROPERTIES FOLDER libraries/fortran LINKER_LANGUAGE C @@ -161,6 +161,7 @@ set (f90_F_BASE_SRCS # normal distribution ${HDF5_F90_SRC_SOURCE_DIR}/H5f90global.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5fortkit.F90 ${HDF5_F90_SRC_SOURCE_DIR}/H5_ff.F90 ${HDF5_F90_SRC_SOURCE_DIR}/H5Aff.F90 ${HDF5_F90_SRC_SOURCE_DIR}/H5Dff.F90 @@ -234,7 +235,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) target_link_libraries (${HDF5_F90_LIBSH_TARGET} ${MPI_Fortran_LIBRARIES}) endif (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIBSH_TARGET}") - H5_SET_LIB_OPTIONS (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_LIB_NAME} SHARED) + H5_SET_LIB_OPTIONS (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_LIB_NAME} SHARED ${HDF5_F_PACKAGE_SOVERSION}) set_target_properties (${HDF5_F90_LIBSH_TARGET} PROPERTIES FOLDER libraries/fortran LINKER_LANGUAGE Fortran diff --git a/fortran/src/H5Dff.F90 b/fortran/src/H5Dff.F90 index e44d90e..cb0b292 100644 --- a/fortran/src/H5Dff.F90 +++ b/fortran/src/H5Dff.F90 @@ -4,7 +4,7 @@ ! MODULE H5D ! ! FILE -! fortran/src/H5Dff.f90 +! fortran/src/H5Dff.F90 ! ! PURPOSE ! This file contains Fortran interfaces for H5D functions. @@ -172,7 +172,7 @@ MODULE H5D MODULE PROCEDURE h5dfill_integer MODULE PROCEDURE h5dfill_c_float MODULE PROCEDURE h5dfill_c_double -#ifdef H5_FORTRAN_HAVE_C_LONG_DOUBLE +#if H5_FORTRAN_C_LONG_DOUBLE_IS_UNIQUE!=0 MODULE PROCEDURE h5dfill_c_long_double #endif MODULE PROCEDURE h5dfill_char @@ -1753,7 +1753,7 @@ CONTAINS END SUBROUTINE h5dfill_c_double -#ifdef H5_FORTRAN_HAVE_C_LONG_DOUBLE +#if H5_FORTRAN_C_LONG_DOUBLE_IS_UNIQUE!=0 SUBROUTINE h5dfill_c_long_double(fill_value, space_id, buf, hdferr) IMPLICIT NONE REAL(KIND=C_LONG_DOUBLE), INTENT(IN), TARGET :: fill_value ! Fill value diff --git a/fortran/src/H5Eff.F90 b/fortran/src/H5Eff.F90 index a2efe61..7a0b15b 100644 --- a/fortran/src/H5Eff.F90 +++ b/fortran/src/H5Eff.F90 @@ -4,7 +4,7 @@ ! MODULE H5E ! ! FILE -! fortran/src/H5Eff.f90 +! fortran/src/H5Eff.F90 ! ! PURPOSE ! This Module contains Fortran interfaces for H5E functions. diff --git a/fortran/src/H5Fff.F90 b/fortran/src/H5Fff.F90 index 165fba0..77d5c58 100644 --- a/fortran/src/H5Fff.F90 +++ b/fortran/src/H5Fff.F90 @@ -485,10 +485,10 @@ CONTAINS END SUBROUTINE h5fget_access_plist_f -!****s* H5F/h5fis_hdf5_f +!****s* H5F/h5fis_accessible_f ! ! NAME -! h5fis_hdf5_f +! h5fis_accessible_f ! ! PURPOSE ! Determines whether a file is in the HDF5 format. @@ -508,33 +508,42 @@ CONTAINS ! port). February 28, 2001 ! ! SOURCE - SUBROUTINE h5fis_hdf5_f(name, status, hdferr) + SUBROUTINE h5fis_accessible_f(name, status, hdferr, access_prp) IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: name ! Name of the file LOGICAL, INTENT(OUT) :: status ! Indicates if file ! is an HDF5 file INTEGER, INTENT(OUT) :: hdferr ! Error code + INTEGER(HID_T), OPTIONAL, INTENT(IN) :: access_prp + ! File access property list + ! identifier !***** + INTEGER(HID_T) :: access_prp_default INTEGER :: namelen ! Length of the name character string INTEGER :: flag ! "TRUE/FALSE" flag from C routine ! to define status value. INTERFACE - INTEGER FUNCTION h5fis_hdf5_c(name, namelen, flag) BIND(C,NAME='h5fis_hdf5_c') + INTEGER FUNCTION h5fis_accessible_c(name, namelen, & + access_prp_default, flag) BIND(C,NAME='h5fis_accessible_c') IMPORT :: C_CHAR + IMPORT :: HID_T IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name INTEGER :: namelen INTEGER :: flag - END FUNCTION h5fis_hdf5_c + INTEGER(HID_T), INTENT(IN) :: access_prp_default + END FUNCTION h5fis_accessible_c END INTERFACE + access_prp_default = H5P_DEFAULT_F + IF (PRESENT(access_prp)) access_prp_default = access_prp namelen = LEN_TRIM(name) - hdferr = h5fis_hdf5_c(name, namelen, flag) + hdferr = h5fis_accessible_c(name, namelen, access_prp_default, flag) status = .TRUE. IF (flag .EQ. 0) status = .FALSE. - END SUBROUTINE h5fis_hdf5_f + END SUBROUTINE h5fis_accessible_f !****s* H5F/h5fclose_f ! ! NAME diff --git a/fortran/src/H5Gff.F90 b/fortran/src/H5Gff.F90 index 2e002b5..30076a4 100644 --- a/fortran/src/H5Gff.F90 +++ b/fortran/src/H5Gff.F90 @@ -4,7 +4,7 @@ ! MODULE H5G ! ! FILE -! fortran/src/H5Gff.f90 +! fortran/src/H5Gff.F90 ! ! PURPOSE ! This file contains Fortran interfaces for H5G functions. diff --git a/fortran/src/H5Off.F90 b/fortran/src/H5Off.F90 index da940df..8d4fb16 100644 --- a/fortran/src/H5Off.F90 +++ b/fortran/src/H5Off.F90 @@ -4,7 +4,7 @@ ! MODULE H5O ! ! FILE -! fortran/src/H5Off.f90 +! fortran/src/H5Off.F90 ! ! PURPOSE ! This file contains Fortran interfaces for H5O functions. diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index 523ed0b..3989512 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -5273,7 +5273,7 @@ h5pget_file_image_c(hid_t_f *fapl_id, void **buf_ptr, size_t_f *buf_len_ptr) *buf_len_ptr=(size_t_f)c_buf_len_ptr; ret_value = 0; - if(c_buf_ptr) HDfree(c_buf_ptr); + if(c_buf_ptr) H5free_memory(c_buf_ptr); return ret_value; } diff --git a/fortran/src/H5Pff.F90 b/fortran/src/H5Pff.F90 index 97f907b..e052ea0 100644 --- a/fortran/src/H5Pff.F90 +++ b/fortran/src/H5Pff.F90 @@ -42,7 +42,8 @@ MODULE H5P USE, INTRINSIC :: ISO_C_BINDING USE H5GLOBAL - + USE H5fortkit + INTERFACE h5pset_fapl_multi_f MODULE PROCEDURE h5pset_fapl_multi_l MODULE PROCEDURE h5pset_fapl_multi_s @@ -7319,8 +7320,704 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) hdferr = h5pget_mpio_actual_io_mode_c(dxpl_id, actual_io_mode) END SUBROUTINE h5pget_mpio_actual_io_mode_f + +!****s* H5P/h5pset_all_coll_metadata_ops_f +! NAME +! h5pset_all_coll_metadata_ops_f +! +! PURPOSE +! Sets requirement whether HDF5 metadata read operations using the access property +! list are required to be collective or independent. If collective requirement is +! selected, the HDF5 library will optimize the metadata reads improving performance. +! The default setting is independent (false). +! +! INPUTS +! plist_id - File access property list identifier. +! is_collective - Indicates if metadata writes are collective or not. +! OUTPUTS +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! Feb, 10 2016 +! +! HISTORY +! +! SOURCE + SUBROUTINE h5pset_all_coll_metadata_ops_f(plist_id, is_collective, hdferr) + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN) :: plist_id + LOGICAL, INTENT(IN) :: is_collective + INTEGER, INTENT(OUT) :: hdferr +!***** + LOGICAL(C_BOOL) :: c_is_collective + + INTERFACE + INTEGER FUNCTION h5pset_all_coll_metadata_ops(plist_id, is_collective) BIND(C, NAME='H5Pset_all_coll_metadata_ops') + IMPORT :: HID_T, C_BOOL + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN), VALUE :: plist_id + LOGICAL(C_BOOL), INTENT(IN), VALUE :: is_collective + END FUNCTION h5pset_all_coll_metadata_ops + END INTERFACE + + ! Transfer value of Fortran LOGICAL to C c_bool type + c_is_collective = is_collective + + hdferr = INT(H5Pset_all_coll_metadata_ops(plist_id, c_is_collective)) + + END SUBROUTINE h5pset_all_coll_metadata_ops_f + +!****s* H5P/h5pget_all_coll_metadata_ops_f +! NAME +! h5pget_all_coll_metadata_ops_f +! +! PURPOSE +! Retrieves metadata read mode from the access property list. +! +! INPUTS +! plist_id - File access property list identifier. +! OUTPUTS +! is_collective - Collective access setting. +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! Feb, 10 2016 +! +! HISTORY +! +! SOURCE + SUBROUTINE h5pget_all_coll_metadata_ops_f(plist_id, is_collective, hdferr) + + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN) :: plist_id + LOGICAL, INTENT(OUT) :: is_collective + INTEGER, INTENT(OUT) :: hdferr +!***** + LOGICAL(C_BOOL) :: c_is_collective + + INTERFACE + INTEGER FUNCTION h5pget_all_coll_metadata_ops(plist_id, is_collective) BIND(C, NAME='H5Pget_all_coll_metadata_ops') + IMPORT :: HID_T, C_BOOL + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN), VALUE :: plist_id + LOGICAL(C_BOOL), INTENT(OUT) :: is_collective + END FUNCTION h5pget_all_coll_metadata_ops + END INTERFACE + + hdferr = INT(H5Pget_all_coll_metadata_ops(plist_id, c_is_collective)) + + ! Transfer value of C c_bool type to Fortran LOGICAL + is_collective = c_is_collective + + END SUBROUTINE h5pget_all_coll_metadata_ops_f + +!****s* H5P/h5pset_coll_metadata_write_f +! NAME +! h5pset_coll_metadata_write_f +! +! PURPOSE +! Sets metadata writes to collective or independent. Default setting is independent (false). +! +! INPUTS +! fapl_id - File access property list identifier. +! is_collective - Indicates if metadata writes are collective or not. +! OUTPUTS +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! Feb, 10 2016 +! +! HISTORY +! +! SOURCE + SUBROUTINE h5pset_coll_metadata_write_f(plist_id, is_collective, hdferr) + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN) :: plist_id + LOGICAL, INTENT(IN) :: is_collective + INTEGER, INTENT(OUT) :: hdferr +!***** + LOGICAL(C_BOOL) :: c_is_collective + + INTERFACE + INTEGER FUNCTION h5pset_coll_metadata_write(plist_id, is_collective) BIND(C, NAME='H5Pset_coll_metadata_write') + IMPORT :: HID_T, C_BOOL + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN), VALUE :: plist_id + LOGICAL(C_BOOL), INTENT(IN), VALUE :: is_collective + END FUNCTION h5pset_coll_metadata_write + END INTERFACE + + ! Transfer value of Fortran LOGICAL to C c_bool type + c_is_collective = is_collective + + hdferr = INT(H5Pset_coll_metadata_write(plist_id, c_is_collective)) + + END SUBROUTINE h5pset_coll_metadata_write_f + +!****s* H5P/h5pget_coll_metadata_write_f +! NAME +! h5pget_coll_metadata_write_f +! +! PURPOSE +! Retrieves metadata write mode from the file access property list. +! +! INPUTS +! plist_id - File access property list identifier. +! OUTPUTS +! is_collective - Collective access setting. +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! Feb, 10 2016 +! +! HISTORY +! +! SOURCE + SUBROUTINE h5pget_coll_metadata_write_f(plist_id, is_collective, hdferr) + + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN) :: plist_id + LOGICAL, INTENT(OUT) :: is_collective + INTEGER, INTENT(OUT) :: hdferr +!***** + LOGICAL(C_BOOL) :: c_is_collective + + INTERFACE + INTEGER FUNCTION h5pget_coll_metadata_write(plist_id, is_collective) BIND(C, NAME='H5Pget_coll_metadata_write') + IMPORT :: HID_T, C_BOOL + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN), VALUE :: plist_id + LOGICAL(C_BOOL), INTENT(OUT) :: is_collective + END FUNCTION h5pget_coll_metadata_write + END INTERFACE + + hdferr = INT(H5Pget_coll_metadata_write(plist_id, c_is_collective)) + + ! Transfer value of C c_bool type to Fortran LOGICAL + is_collective = c_is_collective + + END SUBROUTINE h5pget_coll_metadata_write_f + #endif +! +! V I R T U A L D A T S E T S +! + +!****s* H5P/h5pset_virtual_view_f +! NAME +! h5pset_virtual_view_f +! +! PURPOSE +! Sets the view of the virtual dataset (VDS) to include or exclude missing mapped elements. +! +! INPUTS +! dapl_id - Identifier of the virtual dataset access property list. +! view - Flag specifying the extent of the data to be included in the view. +! Valid values are: +! H5D_VDS_FIRST_MISSING_F +! H5D_VDS_LAST_AVAILABLE_F +! +! OUTPUTS +! +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! Nov 2, 2015 +! +! +! SOURCE + SUBROUTINE h5pset_virtual_view_f(dapl_id, view, hdferr) + IMPLICIT NONE + + INTEGER(HID_T), INTENT(IN) :: dapl_id + INTEGER , INTENT(IN) :: view + INTEGER , INTENT(OUT) :: hdferr + +!***** + INTERFACE + INTEGER FUNCTION h5pset_virtual_view(dapl_id, view) BIND(C,NAME='H5Pset_virtual_view') + IMPORT :: HID_T, ENUM_T + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN), VALUE :: dapl_id + INTEGER(ENUM_T), INTENT(IN), VALUE :: view + END FUNCTION h5pset_virtual_view + END INTERFACE + + hdferr = INT( h5pset_virtual_view(dapl_id, INT(view,ENUM_T)) ) + + END SUBROUTINE h5pset_virtual_view_f + +!****s* H5P/h5pget_virtual_view_f +! NAME +! h5pget_virtual_view_f +! +! PURPOSE +! Retrieves the view of a virtual dataset accessed with dapl_id. +! +! INPUTS +! dapl_id - Dataset access property list identifier for the virtual dataset +! +! OUTPUTS +! view - The flag specifying the view of the virtual dataset. +! Valid values are: +! H5D_VDS_FIRST_MISSING_F +! H5D_VDS_LAST_AVAILABLE_F +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! Nov 2, 2015 +! +! SOURCE + SUBROUTINE h5pget_virtual_view_f(dapl_id, view, hdferr) + IMPLICIT NONE + + INTEGER(HID_T), INTENT(IN) :: dapl_id + INTEGER , INTENT(INOUT) :: view + INTEGER , INTENT(OUT) :: hdferr +!***** + INTEGER(ENUM_T) :: view_enum + INTERFACE + INTEGER FUNCTION h5pget_virtual_view(dapl_id, view) BIND(C,NAME='H5Pget_virtual_view') + IMPORT :: HID_T, ENUM_T + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN), VALUE :: dapl_id + INTEGER(ENUM_T), INTENT(OUT) :: view + END FUNCTION h5pget_virtual_view + END INTERFACE + + hdferr = INT( h5pget_virtual_view(dapl_id, view_enum) ) + view = INT(view_enum) + + END SUBROUTINE h5pget_virtual_view_f + +!****s* H5P/h5pset_virtual_printf_gap_f +! NAME +! h5pset_virtual_printf_gap_f +! +! PURPOSE +! Sets the maximum number of missing source files and/or datasets with the printf-style names +! when getting the extent of an unlimited virtual dataset. +! +! INPUTS +! dapl_id - Dataset access property list identifier for the virtual dataset. +! gap_size - Maximum number of files and/or datasets allowed to be missing for determining +! the extent of an unlimited virtual dataset with printf-style mappings. +! +! OUTPUTS +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! Nov 2, 2015 +! +! HISTORY +! +! SOURCE + SUBROUTINE h5pset_virtual_printf_gap_f(dapl_id, gap_size, hdferr) + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN) :: dapl_id + INTEGER(HSIZE_T), INTENT(IN) :: gap_size + INTEGER , INTENT(OUT) :: hdferr +!***** + INTERFACE + INTEGER FUNCTION h5pset_virtual_printf_gap(dapl_id, gap_size) BIND(C,NAME='H5Pset_virtual_printf_gap') + IMPORT :: HID_T, HSIZE_T + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN), VALUE :: dapl_id + INTEGER(HSIZE_T), INTENT(IN), VALUE :: gap_size + END FUNCTION h5pset_virtual_printf_gap + END INTERFACE + + hdferr = INT( h5pset_virtual_printf_gap(dapl_id, gap_size) ) + + END SUBROUTINE h5pset_virtual_printf_gap_f + +!****s* H5P/h5pget_virtual_printf_gap_f +! NAME +! h5pget_virtual_printf_gap_f +! +! PURPOSE +! Returns the maximum number of missing source files and/or datasets with the +! printf-style names when getting the extent for an unlimited virtual dataset. +! +! INPUTS +! dapl_id - Dataset access property list identifier for the virtual dataset +! +! OUTPUTS +! gap_size - Maximum number of the files and/or datasets allowed to be missing for +! determining the extent of an unlimited virtual dataset with printf-style mappings. +! hdferr - Returns 0 if successful and -1 if fails +! +! AUTHOR +! M. Scot Breitenfeld +! Nov 2, 2015 +! +! HISTORY +! +! SOURCE + SUBROUTINE h5pget_virtual_printf_gap_f(dapl_id, gap_size, hdferr) + IMPLICIT NONE + + INTEGER(HID_T) , INTENT(IN) :: dapl_id + INTEGER(HSIZE_T), INTENT(OUT) :: gap_size + INTEGER , INTENT(OUT) :: hdferr +!***** + INTERFACE + INTEGER FUNCTION h5pget_virtual_printf_gap(dapl_id, gap_size) BIND(C,NAME='H5Pget_virtual_printf_gap') + IMPORT :: HID_T, HSIZE_T + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN), VALUE :: dapl_id + INTEGER(HSIZE_T), INTENT(OUT) :: gap_size + END FUNCTION h5pget_virtual_printf_gap + END INTERFACE + + hdferr = INT( h5pget_virtual_printf_gap(dapl_id, gap_size) ) + + END SUBROUTINE h5pget_virtual_printf_gap_f + +!****s* H5P/h5pset_virtual_f +! NAME +! h5pset_virtual_f +! +! PURPOSE +! Sets the mapping between virtual and source datasets. +! +! INPUTS +! dcpl_id - The identifier of the dataset creation property list that will be +! used when creating the virtual dataset. +! vspace_id - The dataspace identifier with the selection within the virtual +! dataset applied, possibly an unlimited selection. +! src_file_name - The name of the HDF5 file where the source dataset is located. +! src_dset_name - The path to the HDF5 dataset in the file specified by src_file_name. +! src_space_id - The source dataset’s dataspace identifier with a selection applied, possibly an unlimited selection +! +! OUTPUTS +! hdferr - Returns 0 if successful and -1 if fails + +! AUTHOR +! M. Scot Breitenfeld +! Nov 2, 2015 +! +! HISTORY +! +! SOURCE + SUBROUTINE h5pset_virtual_f(dcpl_id, vspace_id, src_file_name, src_dset_name, src_space_id, hdferr) + IMPLICIT NONE + + INTEGER(HID_T), INTENT(IN) :: dcpl_id + INTEGER(HID_T), INTENT(IN) :: vspace_id + CHARACTER(LEN=*), INTENT(IN) :: src_file_name + CHARACTER(LEN=*), INTENT(IN) :: src_dset_name + INTEGER(HID_T), INTENT(IN) :: src_space_id + INTEGER, INTENT(OUT) :: hdferr +!***** + CHARACTER(LEN=LEN_TRIM(src_file_name)+1,KIND=C_CHAR) :: c_src_file_name + CHARACTER(LEN=LEN_TRIM(src_dset_name)+1,KIND=C_CHAR) :: c_src_dset_name + + INTERFACE + INTEGER FUNCTION h5pset_virtual(dcpl_id, vspace_id, c_src_file_name, c_src_dset_name, src_space_id) & + BIND(C,NAME='H5Pset_virtual') + IMPORT :: C_CHAR + IMPORT :: HID_T + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN), VALUE :: dcpl_id + INTEGER(HID_T), INTENT(IN), VALUE :: vspace_id + CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: c_src_file_name + CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: c_src_dset_name + INTEGER(HID_T), INTENT(IN), VALUE :: src_space_id + END FUNCTION h5pset_virtual + END INTERFACE + + c_src_file_name = TRIM(src_file_name)//C_NULL_CHAR + c_src_dset_name = TRIM(src_dset_name)//C_NULL_CHAR + + hdferr = h5pset_virtual(dcpl_id, vspace_id, c_src_file_name, c_src_dset_name, src_space_id) + + END SUBROUTINE h5pset_virtual_f + +!****s* H5P/h5pget_virtual_count_f +! NAME +! h5pget_virtual_count_f +! +! PURPOSE +! Gets the number of mappings for the virtual dataset. +! +! INPUTS +! dcpl_id - The identifier of the virtual dataset creation property list. +! +! OUTPUTS +! count - The number of mappings. +! hdferr - Returns 0 if successful and -1 if fails +! AUTHOR +! M. Scot Breitenfeld +! Nov 2, 2015 +! +! HISTORY +! +! SOURCE + SUBROUTINE h5pget_virtual_count_f(dcpl_id, count, hdferr) + + IMPLICIT NONE + + INTEGER(HID_T), INTENT(IN) :: dcpl_id + INTEGER(SIZE_T), INTENT(OUT) :: count + INTEGER, INTENT(OUT) :: hdferr +!***** + INTERFACE + INTEGER(HID_T) FUNCTION h5pget_virtual_count(dcpl_id, count) BIND(C,NAME='H5Pget_virtual_count') + IMPORT :: HID_T, SIZE_T + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN), VALUE :: dcpl_id + INTEGER(SIZE_T), INTENT(OUT) :: count + END FUNCTION h5pget_virtual_count + END INTERFACE + + hdferr = INT( h5pget_virtual_count(dcpl_id, count)) + + END SUBROUTINE h5pget_virtual_count_f + +!****s* H5P/h5pget_virtual_vspace_f +! NAME +! h5pget_virtual_vspace_f +! +! PURPOSE +! Gets a dataspace identifier for the selection within the virtual dataset used in the mapping. +! +! INPUTS +! dcpl_id - The identifier of the virtual dataset creation property list. +! index - Mapping index. +! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), +! where count is the number of mappings returned by h5pget_virtual_count. +! +! OUTPUTS +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! Nov 2, 2015 +! +! HISTORY +! +! SOURCE + SUBROUTINE h5pget_virtual_vspace_f(dcpl_id, index, ds_id, hdferr) + IMPLICIT NONE + + INTEGER(HID_T) , INTENT(IN) :: dcpl_id + INTEGER(SIZE_T), INTENT(IN) :: index + INTEGER(HID_T) , INTENT(OUT) :: ds_id + INTEGER, INTENT(OUT) :: hdferr + +!***** + INTERFACE + INTEGER(HID_T) FUNCTION h5pget_virtual_vspace(dcpl_id, index) BIND(C,NAME='H5Pget_virtual_vspace') + IMPORT :: HID_T, SIZE_T + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN), VALUE :: dcpl_id + INTEGER(SIZE_T), INTENT(IN), VALUE :: index + END FUNCTION h5pget_virtual_vspace + END INTERFACE + + ds_id = h5pget_virtual_vspace(dcpl_id, index) + + hdferr = 0 + IF(ds_id.LT.0) hdferr = -1 + +END SUBROUTINE h5pget_virtual_vspace_f + +!****s* H5P/h5pget_virtual_srcspace_f +! NAME +! h5pget_virtual_srcspace_f +! +! PURPOSE +! Gets a dataspace identifier for the selection within the source dataset used in the mapping. +! +! INPUTS +! dcpl_id - The identifier of the virtual dataset creation property list. +! index - Mapping index. +! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), +! where count is the number of mappings returned by h5pget_virtual_count. +! +! +! OUTPUTS +! ds_id - dataspace identifier +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! Nov 2, 2015 +! +! HISTORY +! +! SOURCE +SUBROUTINE h5pget_virtual_srcspace_f(dcpl_id, index, ds_id, hdferr) + IMPLICIT NONE + + INTEGER(HID_T) , INTENT(IN) :: dcpl_id + INTEGER(SIZE_T), INTENT(IN) :: index + INTEGER(HID_T) , INTENT(OUT) :: ds_id + INTEGER, INTENT(OUT) :: hdferr + +!***** + INTERFACE + INTEGER(HID_T) FUNCTION h5pget_virtual_srcspace(dcpl_id, index) BIND(C,NAME='H5Pget_virtual_srcspace') + IMPORT :: HID_T, SIZE_T + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN), VALUE :: dcpl_id + INTEGER(SIZE_T), INTENT(IN), VALUE :: index + END FUNCTION h5pget_virtual_srcspace + END INTERFACE + + ds_id = h5pget_virtual_srcspace(dcpl_id, index) + + hdferr = 0 + IF(ds_id.LT.0) hdferr = -1 + +END SUBROUTINE h5pget_virtual_srcspace_f + +!****s* H5P/h5pget_virtual_filename_f +! NAME +! h5pget_virtual_filename_f +! +! PURPOSE +! Gets the filename of a source dataset used in the mapping. +! +! INPUTS +! dcpl_id - The identifier of the virtual dataset creation property list. +! index - Mapping index. +! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), +! where count is the number of mappings returned by h5pget_virtual_count. +! +! OUTPUTS +! name - A buffer containing the name of the file containing the source dataset. +! hdferr - Returns 0 if successful and -1 if fails. +! +! Optional parameters: +! name_len - The size of name needed to hold the filename. (OUT) +! +! AUTHOR +! M. Scot Breitenfeld +! Nov 2, 2015 +! +! HISTORY +! +! SOURCE +SUBROUTINE h5pget_virtual_filename_f(dcpl_id, index, name, hdferr, name_len) + + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN) :: dcpl_id + INTEGER(SIZE_T) , INTENT(IN) :: index + CHARACTER(LEN=*), INTENT(OUT) :: name + INTEGER, INTENT(OUT) :: hdferr + INTEGER(SIZE_T), OPTIONAL :: name_len +!***** + + CHARACTER(LEN=1,KIND=C_CHAR), DIMENSION(1:LEN(name)+1), TARGET :: c_name + TYPE(C_PTR) :: f_ptr + + INTERFACE + INTEGER(SIZE_T) FUNCTION h5pget_virtual_filename(dcpl_id, index, name, size) BIND(C, NAME='H5Pget_virtual_filename') + IMPORT :: HID_T, SIZE_T, C_PTR, C_CHAR + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN), VALUE :: dcpl_id + INTEGER(SIZE_T), INTENT(IN), VALUE :: index + TYPE(C_PTR), VALUE :: name + INTEGER(SIZE_T), INTENT(IN), VALUE :: size + END FUNCTION h5pget_virtual_filename + END INTERFACE + + hdferr = 0 + IF(PRESENT(name_len))THEN + name_len = INT(h5pget_virtual_filename(dcpl_id, index, C_NULL_PTR, 0_SIZE_T), SIZE_T) + IF(name_len.LT.0) hdferr = -1 + ELSE + f_ptr = C_LOC(c_name(1)(1:1)) + + IF(INT(h5pget_virtual_filename(dcpl_id, index, f_ptr, INT(LEN(name)+1,SIZE_T)), SIZE_T).LT.0)THEN + hdferr = -1 + ELSE + CALL HD5c2fstring(name,c_name,LEN(name)) + ENDIF + + ENDIF + +END SUBROUTINE h5pget_virtual_filename_f + +!****s* H5P/h5pget_virtual_dsetname_f +! NAME +! h5pget_virtual_dsetname_f +! +! PURPOSE +! Gets the name of a source dataset used in the mapping. +! +! INPUTS +! dcpl_id - The identifier of the virtual dataset creation property list. +! index - Mapping index. +! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), +! where count is the number of mappings returned by h5pget_virtual_count. +! +! OUTPUTS +! name - A buffer containing the name of the source dataset. +! hdferr - Returns 0 if successful and -1 if fails. +! +! Optional parameters: +! name_len - The size of name needed to hold the source dataset name. (OUT) +! +! AUTHOR +! M. Scot Breitenfeld +! January 28, 2016 +! +! HISTORY +! +! SOURCE +SUBROUTINE h5pget_virtual_dsetname_f(dcpl_id, index, name, hdferr, name_len) + + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN) :: dcpl_id + INTEGER(SIZE_T) , INTENT(IN) :: index + CHARACTER(LEN=*), INTENT(OUT) :: name + INTEGER, INTENT(OUT) :: hdferr + INTEGER(SIZE_T), OPTIONAL :: name_len +!***** + + CHARACTER(LEN=1,KIND=C_CHAR), DIMENSION(1:LEN(name)+1), TARGET :: c_name + TYPE(C_PTR) :: f_ptr + + INTERFACE + INTEGER(SIZE_T) FUNCTION h5pget_virtual_dsetname(dcpl_id, index, name, size) BIND(C, NAME='H5Pget_virtual_dsetname') + IMPORT :: HID_T, SIZE_T, C_PTR, C_CHAR + IMPLICIT NONE + INTEGER(HID_T) , INTENT(IN), VALUE :: dcpl_id + INTEGER(SIZE_T), INTENT(IN), VALUE :: index + TYPE(C_PTR), VALUE :: name + INTEGER(SIZE_T), INTENT(IN), VALUE :: size + END FUNCTION h5pget_virtual_dsetname + END INTERFACE + + hdferr = 0 + IF(PRESENT(name_len))THEN + name_len = INT(h5pget_virtual_dsetname(dcpl_id, index, C_NULL_PTR, 0_SIZE_T), SIZE_T) + IF(name_len.LT.0) hdferr = -1 + ELSE + f_ptr = C_LOC(c_name(1)(1:1)) + + IF(INT(h5pget_virtual_dsetname(dcpl_id, index, f_ptr, INT(LEN(name)+1,SIZE_T)), SIZE_T).LT.0)THEN + hdferr = -1 + ELSE + CALL HD5c2fstring(name,c_name,LEN(name)) + ENDIF + + ENDIF + +END SUBROUTINE h5pget_virtual_dsetname_f + + END MODULE H5P diff --git a/fortran/src/H5Rff.F90 b/fortran/src/H5Rff.F90 index a90bd9a..7ba91c4 100644 --- a/fortran/src/H5Rff.F90 +++ b/fortran/src/H5Rff.F90 @@ -4,7 +4,7 @@ ! MODULE H5R ! ! FILE -! fortran/src/H5Rff.f90 +! fortran/src/H5Rff.F90 ! ! PURPOSE ! This file contains Fortran interfaces for H5R functions. diff --git a/fortran/src/H5Sff.F90 b/fortran/src/H5Sff.F90 index aeb3314..cb1388e 100644 --- a/fortran/src/H5Sff.F90 +++ b/fortran/src/H5Sff.F90 @@ -4,7 +4,7 @@ ! MODULE H5S ! ! FILE -! fortran/src/H5Sff.f90 +! fortran/src/H5Sff.F90 ! ! PURPOSE ! This file contains Fortran interfaces for H5S functions. @@ -41,7 +41,7 @@ !***** MODULE H5S - USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR, C_INT USE H5GLOBAL CONTAINS @@ -1232,7 +1232,7 @@ CONTAINS ENDIF ! Case of optional parameters. ! - ! Find the rank of the dataspace to allocate memery for + ! Find the rank of the dataspace to allocate memory for ! default stride and block arrays. ! CALL h5sget_simple_extent_ndims_f(space_id, rank, hdferr) @@ -1378,7 +1378,7 @@ CONTAINS ! endif ! Case of optional parameters. ! - ! Find the rank of the dataspace to allocate memery for + ! Find the rank of the dataspace to allocate memory for ! default stride and block arrays. ! ! CALL h5sget_simple_extent_ndims_f(space_id, rank, hdferr) @@ -1751,4 +1751,118 @@ CONTAINS END SUBROUTINE h5sextent_equal_f +! +!****s* H5S/h5sget_regular_hyperslab_f +! +! NAME +! h5sget_regular_hyperslab_f +! +! PURPOSE +! Retrieves a regular hyperslab selection. +! +! INPUTS +! space_id - The identifier of the dataspace. +! OUTPUTS +! start - Offset of the start of the regular hyperslab. +! stride - Stride of the regular hyperslab. +! count - Number of blocks in the regular hyperslab. +! block - Size of a block in the regular hyperslab. +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! January, 28 2016 +! SOURCE + SUBROUTINE h5sget_regular_hyperslab_f(space_id, start, stride, count, block, hdferr) + + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN) :: space_id + INTEGER(HSIZE_T), INTENT(OUT), DIMENSION(*), TARGET :: start + INTEGER(HSIZE_T), INTENT(OUT), DIMENSION(*), TARGET :: stride + INTEGER(HSIZE_T), INTENT(OUT), DIMENSION(*), TARGET :: count + INTEGER(HSIZE_T), INTENT(OUT), DIMENSION(*), TARGET :: block + INTEGER, INTENT(OUT) :: hdferr +!***** + TYPE(C_PTR) :: start_c, stride_c, count_c, block_c + INTEGER :: n + + INTERFACE + INTEGER FUNCTION h5sget_regular_hyperslab(space_id, start, stride, count, block) BIND(C,NAME='H5Sget_regular_hyperslab') + IMPORT :: HID_T, C_PTR + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN), VALUE :: space_id + TYPE(C_PTR), VALUE :: start, stride, count, block + END FUNCTION h5sget_regular_hyperslab + END INTERFACE + + hdferr = 0 + + start_c = C_LOC(start(1)) + stride_c = C_LOC(stride(1)) + count_c = C_LOC(count(1)) + block_c = C_LOC(block(1)) + + IF(INT(h5sget_regular_hyperslab(space_id, start_c, stride_c, count_c, block_c)).LT.0) hdferr = -1 + + ! Reverse the C arrays description values of the hyperslab because + ! the hyperslab was for a C stored hyperslab + + CALL H5Sget_simple_extent_ndims_f(space_id,n,hdferr) + IF(hdferr.LT.0.OR.n.EQ.0)THEN + hdferr=-1 + ELSE + start(1:n) = start(n:1:-1) + stride(1:n) = stride(n:1:-1) + count(1:n) = count(n:1:-1) + block(1:n) = block(n:1:-1) + ENDIF + + END SUBROUTINE h5sget_regular_hyperslab_f + +!****s* H5S/h5sis_regular_hyperslab_f +! +! NAME +! h5sis_regular_hyperslab_f +! +! PURPOSE +! Retrieves a regular hyperslab selection. +! +! INPUTS +! space_id - The identifier of the dataspace. +! OUTPUTS +! IsRegular - TRUE or FALSE for hyperslab selection if successful. +! hdferr - Returns 0 if successful and -1 if fails. +! +! AUTHOR +! M. Scot Breitenfeld +! January, 28 2016 +! SOURCE + SUBROUTINE h5sis_regular_hyperslab_f(space_id, IsRegular, hdferr) + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN) :: space_id + LOGICAL :: IsRegular + INTEGER, INTENT(OUT) :: hdferr +!***** + INTEGER(C_INT) :: status + + INTERFACE + INTEGER(C_INT) FUNCTION H5Sis_regular_hyperslab(space_id) BIND(C,NAME='H5Sis_regular_hyperslab') + IMPORT :: HID_T, C_INT + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN), VALUE :: space_id + END FUNCTION H5Sis_regular_hyperslab + END INTERFACE + + status = H5Sis_regular_hyperslab(space_id) + + hdferr = 0 + IsRegular = .FALSE. + IF(status.GT.0)THEN + IsRegular = .TRUE. + ELSE IF(status.LT.0)THEN + hdferr = -1 + ENDIF + + END SUBROUTINE H5Sis_regular_hyperslab_f + END MODULE H5S diff --git a/fortran/src/H5_buildiface.F90 b/fortran/src/H5_buildiface.F90 index 9a42cbf..4b00d80 100644 --- a/fortran/src/H5_buildiface.F90 +++ b/fortran/src/H5_buildiface.F90 @@ -4,7 +4,7 @@ ! Executable: H5_buildiface ! ! FILE -! fortran/src/H5_buildiface.f90 +! fortran/src/H5_buildiface.F90 ! ! PURPOSE ! This stand alone program is used at build time to generate the module @@ -60,13 +60,6 @@ PROGRAM H5_buildiface H5_H5CONFIG_F_IKIND INTEGER :: i, j, k - INTEGER :: ji, jr, jd -#ifdef H5_FORTRAN_HAVE_C_LONG_DOUBLE - REAL(KIND=C_LONG_DOUBLE) :: c_longdble -#endif - REAL(KIND=C_DOUBLE) :: c_dble - REAL(KIND=C_FLOAT) :: c_flt - INTEGER :: sizeof_var CHARACTER(LEN=2) :: chr2 ! subroutine rank of array being passed in CHARACTER(LEN=2), DIMENSION(1:8), PARAMETER :: chr_rank=(/"_0","_1","_2","_3","_4","_5","_6","_7"/) @@ -404,7 +397,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' INTEGER(HID_T) , INTENT(IN) :: attr_id' WRITE(11,'(A)') ' INTEGER(HID_T) , INTENT(IN) :: memtype_id' WRITE(11,'(A)') ' INTEGER(HSIZE_T) , INTENT(IN), DIMENSION(*) :: dims' - WRITE(11,'(A)') ' INTEGER(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(INOUT)'//TRIM(rank_dim_line(j))//', TARGET :: buf' + WRITE(11,'(A)') ' INTEGER(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf' WRITE(11,'(A)') ' INTEGER , INTENT(OUT) :: hdferr' WRITE(11,'(A)') ' TYPE(C_PTR) :: f_ptr' @@ -717,45 +710,9 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' file_space_id_default, xfer_prp_default, f_ptr)' WRITE(11,'(A)') ' END SUBROUTINE h5dread_ckind_rank'//chr_rank(j) ENDDO -! +!********************** ! h5dwrite_f - -!****s* H5D (F03)/h5dwrite_f_F03 -! -! NAME -! h5dwrite_f_F03 -! -! PURPOSE -! Writes raw data from a dataset into a buffer. -! -! Inputs: -! dset_id - Identifier of the dataset to write to. -! mem_type_id - Identifier of the memory datatype. -! buf - Buffer with data to be written to the file. -! -! Outputs: -! hdferr - Returns 0 if successful and -1 if fails -! -! Optional parameters: -! mem_space_id - Identifier of the memory dataspace. -! file_space_id - Identifier of the dataset's dataspace in the file. -! xfer_prp - Identifier of a transfer property list for this I/O operation. -! -! AUTHOR -! M. Scot Breitenfeld -! September 17, 2011 -! -! Fortran2003 Interface: -!! SUBROUTINE h5dwrite_f(dset_id, mem_type_id, buf, hdferr, & -!! mem_space_id, file_space_id, xfer_prp) -!! INTEGER(HID_T), INTENT(IN) :: dset_id -!! INTEGER(HID_T), INTENT(IN) :: mem_type_id -!! TYPE(C_PTR) , INTENT(IN) :: buf -!! INTEGER , INTENT(OUT) :: hdferr -!! INTEGER(HID_T), INTENT(IN) , OPTIONAL :: mem_space_id -!! INTEGER(HID_T), INTENT(IN) , OPTIONAL :: file_space_id -!! INTEGER(HID_T), INTENT(IN) , OPTIONAL :: xfer_prp -!***** +!********************** DO i = 1, num_rkinds k = rkind(i) WRITE(chr2,'(I2)') k diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c index f3bc42f..d7b952d 100644 --- a/fortran/src/H5_f.c +++ b/fortran/src/H5_f.c @@ -476,6 +476,10 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5d_flags[22] = (int_f)H5D_MPIO_CHUNK_COLLECTIVE; h5d_flags[23] = (int_f)H5D_MPIO_CHUNK_MIXED; h5d_flags[24] = (int_f)H5D_MPIO_CONTIGUOUS_COLLECTIVE; + h5d_flags[25] = (int_f)H5D_VDS_ERROR; + h5d_flags[26] = (int_f)H5D_VDS_FIRST_MISSING; + h5d_flags[27] = (int_f)H5D_VDS_LAST_AVAILABLE; + h5d_flags[28] = (int_f)H5D_VIRTUAL; /* * H5E flags diff --git a/fortran/src/H5f90.h b/fortran/src/H5f90.h index c45cfcb..7082d1d 100644 --- a/fortran/src/H5f90.h +++ b/fortran/src/H5f90.h @@ -22,7 +22,7 @@ #include "H5f90i.h" #include "H5f90proto.h" -/* Constants used in H5Rff.f90 and H5Rf.c files */ +/* Constants used in H5Rff.F90 and H5Rf.c files */ #define REF_REG_BUF_LEN_F 3 /* Constants used in H5Gf.c files */ diff --git a/fortran/src/H5f90global.F90 b/fortran/src/H5f90global.F90 index 947eff4..eb7f99f 100644 --- a/fortran/src/H5f90global.F90 +++ b/fortran/src/H5f90global.F90 @@ -4,7 +4,7 @@ ! MODULE H5GLOBAL ! ! FILE -! src/fortran/H5f90global.f90 +! src/fortran/H5f90global.F90 ! ! PURPOSE ! This module is used to pass C stubs for H5 Fortran APIs. The C stubs are @@ -46,12 +46,19 @@ MODULE H5GLOBAL IMPLICIT NONE + ! Enumerate data type that is interoperable with C. + ENUM, BIND(C) + ENUMERATOR :: enum_dtype + END ENUM + INTEGER, PARAMETER :: ENUM_T = KIND(enum_dtype) + + ! Definitions for reference datatypes. ! If you change the value of these parameters, do not forget to change corresponding ! values in the H5f90.h file. INTEGER, PARAMETER :: REF_REG_BUF_LEN = 3 - ! Parameters used in the function 'h5kind_to_type' located in H5_ff.f90. + ! Parameters used in the function 'h5kind_to_type' located in H5_ff.F90. ! The flag is used to tell the function whether the kind input variable ! is for a REAL or INTEGER data type. @@ -366,11 +373,11 @@ MODULE H5GLOBAL EQUIVALENCE(H5G_flags(10), H5G_STORAGE_TYPE_SYMBOL_TABLE_F) EQUIVALENCE(H5G_flags(11), H5G_STORAGE_TYPE_COMPACT_F) EQUIVALENCE(H5G_flags(12), H5G_STORAGE_TYPE_DENSE_F) + ! ! H5D flags declaration ! - - INTEGER, PARAMETER :: H5D_FLAGS_LEN = 25 + INTEGER, PARAMETER :: H5D_FLAGS_LEN = 29 INTEGER :: H5D_flags(H5D_FLAGS_LEN) INTEGER, PARAMETER :: H5D_SIZE_FLAGS_LEN = 2 INTEGER(SIZE_T) :: H5D_size_flags(H5D_SIZE_FLAGS_LEN) @@ -418,6 +425,10 @@ MODULE H5GLOBAL INTEGER :: H5D_MPIO_CHUNK_COLLECTIVE_F INTEGER :: H5D_MPIO_CHUNK_MIXED_F INTEGER :: H5D_MPIO_CONTIG_COLLECTIVE_F + INTEGER :: H5D_VDS_ERROR_F + INTEGER :: H5D_VDS_FIRST_MISSING_F + INTEGER :: H5D_VDS_LAST_AVAILABLE_F + INTEGER :: H5D_VIRTUAL_F EQUIVALENCE(H5D_flags(1), H5D_COMPACT_F) EQUIVALENCE(H5D_flags(2), H5D_CONTIGUOUS_F) @@ -449,6 +460,10 @@ MODULE H5GLOBAL EQUIVALENCE(H5D_flags(23), H5D_MPIO_CHUNK_COLLECTIVE_F) EQUIVALENCE(H5D_flags(24), H5D_MPIO_CHUNK_MIXED_F) EQUIVALENCE(H5D_flags(25), H5D_MPIO_CONTIG_COLLECTIVE_F) + EQUIVALENCE(H5D_flags(26), H5D_VDS_ERROR_F) + EQUIVALENCE(H5D_flags(27), H5D_VDS_FIRST_MISSING_F) + EQUIVALENCE(H5D_flags(28), H5D_VDS_LAST_AVAILABLE_F) + EQUIVALENCE(H5D_flags(29), H5D_VIRTUAL_F) EQUIVALENCE(H5D_size_flags(1), H5D_CHUNK_CACHE_NSLOTS_DFLT_F) EQUIVALENCE(H5D_size_flags(2), H5D_CHUNK_CACHE_NBYTES_DFLT_F) @@ -993,7 +1008,6 @@ CONTAINS IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: f_string CHARACTER(KIND=C_CHAR, LEN=*), INTENT(OUT) :: c_string - INTEGER(SIZE_T) :: c_len, f_len c_string = TRIM(f_string)//C_NULL_CHAR diff --git a/fortran/src/H5fortkit.F90 b/fortran/src/H5fortkit.F90 new file mode 100644 index 0000000..3062c28 --- /dev/null +++ b/fortran/src/H5fortkit.F90 @@ -0,0 +1,66 @@ +!****h* ROBODoc/H5fortkit +! +! NAME +! MODULE H5fortkit +! +! FILE +! fortran/src/H5fortkit.F90 +! +! PURPOSE +! Routines to deal with C-FORTRAN issues. +! +! COPYRIGHT +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! All rights reserved. * +! * +! This file is part of HDF5. The full HDF5 copyright notice, including * +! terms governing use, modification, and redistribution, is contained in * +! the files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +!***** +MODULE H5fortkit + +CONTAINS + +!****if* H5fortkit/HD5c2fstring +! NAME +! HD5c2fstring +! INPUTS +! cstring - C string stored as a string array of size 'len' of string size LEN=1 +! len - length of Fortran string +! OUTPUT +! fstring - Fortran string array of LEN=1 +! PURPOSE +! Copies a Fortran array of strings having a length of one to a fortran string and removes the C Null +! terminator. The Null terminator is returned from C when calling the C APIs directly. +! +! The fortran standard does not allow C_LOC to be used on a character string of +! length greater than one, which is why we use the array of characters instead. +! +! SOURCE + SUBROUTINE HD5c2fstring(fstring,cstring,len) +!***** + IMPLICIT NONE + + INTEGER :: i + INTEGER :: len + CHARACTER(LEN=len) :: fstring + CHARACTER(LEN=1), DIMENSION(1:len) :: cstring + + fstring = '' + DO i = 1, len + IF (cstring(i)(1:1)==CHAR(0)) EXIT + fstring(i:i) = cstring(i)(1:1) + END DO + + END SUBROUTINE HD5c2fstring + +END MODULE H5fortkit diff --git a/fortran/src/H5match_types.c b/fortran/src/H5match_types.c index f995e83..98128db 100644 --- a/fortran/src/H5match_types.c +++ b/fortran/src/H5match_types.c @@ -52,7 +52,7 @@ FILE * fort_header; void writeTypedef(const char* c_typedef, const char* c_type, int size); void writeTypedefDefault(const char* c_typedef, int size); void writeToFiles(const char* c_typedef, const char* fortran_type, const char* c_type, int size, int kind); -void writeToFilesChr(const char* c_typedef, const char* fortran_type, const char* c_type, int size, char* kind); +void writeToFilesChr(const char* c_typedef, const char* fortran_type, const char* c_type, int size, const char* kind); static void initCfile(void) @@ -140,7 +140,7 @@ void writeToFiles(const char* c_typedef, const char* fortran_type, const char* c fprintf(fort_header, " INTEGER, PARAMETER :: %s = %u\n", fortran_type, kind); fprintf(c_header, "typedef c_%s_%d %s;\n", c_typedef, size, c_type); } -void writeToFilesChr(const char* c_typedef, const char* fortran_type, const char* c_type, int size, char* kind) +void writeToFilesChr(const char* c_typedef, const char* fortran_type, const char* c_type, int size, const char* kind) { fprintf(fort_header, " INTEGER, PARAMETER :: %s = %s\n", fortran_type, kind); fprintf(c_header, "typedef c_%s_%d %s;\n", c_typedef, size, c_type); diff --git a/fortran/src/HDF5.F90 b/fortran/src/HDF5.F90 index 64f5be6..cbe4c83 100644 --- a/fortran/src/HDF5.F90 +++ b/fortran/src/HDF5.F90 @@ -4,7 +4,7 @@ ! MODULE HDF5 ! ! FILE -! src/fortran/src/HDF5.f90 +! src/fortran/src/HDF5.F90 ! ! PURPOSE ! This is the main module used for linking to the Fortran HDF library. diff --git a/fortran/src/Makefile.am b/fortran/src/Makefile.am index eb45f60..a271666 100644 --- a/fortran/src/Makefile.am +++ b/fortran/src/Makefile.am @@ -32,7 +32,7 @@ AM_FCLIBS=$(LIBHDF5) lib_LTLIBRARIES=libhdf5_fortran.la # Add libtool numbers to the HDF5 Fortran library (from config/lt_vers.am) -libhdf5_fortran_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS) +libhdf5_fortran_la_LDFLAGS= -version-info $(LT_F_VERS_INTERFACE):$(LT_F_VERS_REVISION):$(LT_F_VERS_AGE) $(AM_LDFLAGS) # Some Fortran compilers can't build shared libraries, so sometimes we # want to build a shared C library and a static Fortran library. If so, @@ -46,9 +46,9 @@ endif libhdf5_fortran_la_SOURCES=H5f90global.F90 \ H5fortran_types.F90 H5_ff.F90 H5Aff.F90 H5Dff.F90 H5Eff.F90 \ H5Fff.F90 H5Gff.F90 H5Iff.F90 H5Lff.F90 H5Off.F90 H5Pff.F90 H5Rff.F90 H5Sff.F90 \ - H5Tff.F90 H5Zff.F90 H5_gen.f90 \ + H5Tff.F90 H5Zff.F90 H5_gen.F90 H5fortkit.F90 \ H5f90kit.c H5_f.c H5Af.c H5Df.c H5Ef.c H5Ff.c H5Gf.c \ - H5If.c H5Lf.c H5Of.c H5Pf.c H5Rf.c H5Sf.c H5Tf.c H5Zf.c HDF5.f90 + H5If.c H5Lf.c H5Of.c H5Pf.c H5Rf.c H5Sf.c H5Tf.c H5Zf.c HDF5.F90 # HDF5 Fortran library depends on HDF5 Library. libhdf5_fortran_la_LIBADD=$(LIBHDF5) @@ -153,7 +153,7 @@ H5Gff.lo: $(srcdir)/H5Gff.F90 H5f90global.lo H5Iff.lo: $(srcdir)/H5Iff.F90 H5f90global.lo H5Lff.lo: $(srcdir)/H5Lff.F90 H5f90global.lo H5Off.lo: $(srcdir)/H5Off.F90 H5f90global.lo -H5Pff.lo: $(srcdir)/H5Pff.F90 H5f90global.lo +H5Pff.lo: $(srcdir)/H5Pff.F90 H5f90global.lo H5fortkit.lo H5Rff.lo: $(srcdir)/H5Rff.F90 H5f90global.lo H5Sff.lo: $(srcdir)/H5Sff.F90 H5f90global.lo H5Tff.lo: $(srcdir)/H5Tff.F90 H5f90global.lo diff --git a/fortran/src/hdf5_fortrandll.def.in b/fortran/src/hdf5_fortrandll.def.in index 66ab50c..d394884 100644 --- a/fortran/src/hdf5_fortrandll.def.in +++ b/fortran/src/hdf5_fortrandll.def.in @@ -318,12 +318,26 @@ H5P_mp_H5PREGISTER_PTR H5P_mp_H5PINSERT_PTR H5P_mp_H5PGET_FILE_IMAGE_F H5P_mp_H5PSET_FILE_IMAGE_F +H5P_mp_H5PSET_VIRTUAL_VIEW_F +H5P_mp_H5PGET_VIRTUAL_VIEW_F +H5P_mp_H5PSET_VIRTUAL_PRINTF_GAP_F +H5P_mp_H5PGET_VIRTUAL_PRINTF_GAP_F +H5P_mp_H5PSET_VIRTUAL_F +H5P_mp_H5PGET_VIRTUAL_COUNT_F +H5P_mp_H5PGET_VIRTUAL_VSPACE_F +H5P_mp_H5PGET_VIRTUAL_SRCSPACE_F +H5P_mp_H5PGET_VIRTUAL_FILENAME_F +H5P_mp_H5PGET_VIRTUAL_DSETNAME_F ; Parallel @H5_NOPAREXP@H5P_mp_H5PSET_FAPL_MPIO_F @H5_NOPAREXP@H5P_mp_H5PGET_FAPL_MPIO_F @H5_NOPAREXP@H5P_mp_H5PSET_DXPL_MPIO_F @H5_NOPAREXP@H5P_mp_H5PGET_DXPL_MPIO_F @H5_NOPAREXP@H5P_mp_H5PGET_MPIO_ACTUAL_IO_MODE_F +@H5_NOPAREXP@H5P_mp_H5PSET_ALL_COLL_METADATA_OPS_F +@H5_NOPAREXP@H5P_mp_H5PGET_ALL_COLL_METADATA_OPS_F +@H5_NOPAREXP@H5P_mp_H5PSET_COLL_METADATA_WRITE_F +@H5_NOPAREXP@H5P_mp_H5PGET_COLL_METADATA_WRITE_F ; H5R H5R_mp_H5RCREATE_OBJECT_F H5R_mp_H5RCREATE_REGION_F @@ -367,6 +381,8 @@ H5S_mp_H5SGET_SELECT_TYPE_F H5S_mp_H5SDECODE_F H5S_mp_H5SENCODE_F H5S_mp_H5SEXTENT_EQUAL_F +H5S_mp_H5SGET_REGULAR_HYPERSLAB_F +H5S_mp_H5SIS_REGULAR_HYPERSLAB_F ; H5T H5T_mp_H5TOPEN_F H5T_mp_H5TCOMMIT_F diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index 0cbd17f..005a5c8 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -65,7 +65,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ${HDF5_F90_C_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET} ) - H5_SET_LIB_OPTIONS (${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_C_TEST_LIB_NAME} SHARED) + H5_SET_LIB_OPTIONS (${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_C_TEST_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) set_target_properties (${HDF5_F90_C_TEST_LIBSH_TARGET} PROPERTIES FOLDER libraries/test/fortran LINKER_LANGUAGE C @@ -128,7 +128,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ) - H5_SET_LIB_OPTIONS (${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_TEST_LIB_NAME} SHARED) + H5_SET_LIB_OPTIONS (${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_TEST_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) target_include_directories (${HDF5_F90_TEST_LIBSH_TARGET} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) set_target_properties (${HDF5_F90_TEST_LIBSH_TARGET} PROPERTIES FOLDER libraries/test/fortran diff --git a/fortran/test/H5_test_buildiface.F90 b/fortran/test/H5_test_buildiface.F90 index 30687df..8b27a96 100644 --- a/fortran/test/H5_test_buildiface.F90 +++ b/fortran/test/H5_test_buildiface.F90 @@ -1,10 +1,10 @@ -!****p* Program/H5_buildiface +!****p* Program/H5_test_buildiface ! ! NAME -! Executable: H5_buildiface +! Executable: H5_test_buildiface ! ! FILE -! fortran/src/H5_buildiface.f90 +! fortran/src/H5_test_buildiface.F90 ! ! PURPOSE ! This stand alone program is used at build time to generate the program @@ -60,38 +60,7 @@ PROGRAM H5_test_buildiface H5_H5CONFIG_F_IKIND INTEGER :: i, j, k - INTEGER :: ji, jr, jd -#ifdef H5_FORTRAN_HAVE_C_LONG_DOUBLE - REAL(KIND=C_LONG_DOUBLE) :: c_longdble -#endif - REAL(KIND=C_DOUBLE) :: c_dble - REAL(KIND=C_FLOAT) :: c_flt - INTEGER :: sizeof_var CHARACTER(LEN=2) :: chr2 -! subroutine rank of array being passed in - CHARACTER(LEN=2), DIMENSION(1:8), PARAMETER :: chr_rank=(/"_0","_1","_2","_3","_4","_5","_6","_7"/) -! rank definitions - CHARACTER(LEN=70), DIMENSION(1:8), PARAMETER :: rank_dim_line=(/ & - ' ', & - ', DIMENSION(dims(1)) ', & - ', DIMENSION(dims(1),dims(2)) ', & - ', DIMENSION(dims(1),dims(2),dims(3)) ', & - ', DIMENSION(dims(1),dims(2),dims(3),dims(4)) ', & - ', DIMENSION(dims(1),dims(2),dims(3),dims(4),dims(5)) ', & - ', DIMENSION(dims(1),dims(2),dims(3),dims(4),dims(5),dims(6)) ', & - ', DIMENSION(dims(1),dims(2),dims(3),dims(4),dims(5),dims(6),dims(7))' & - /) -! pointer to the buffer - CHARACTER(LEN=37), DIMENSION(1:8), PARAMETER :: f_ptr_line=(/ & - ' f_ptr = C_LOC(buf) ', & - ' f_ptr = C_LOC(buf(1)) ', & - ' f_ptr = C_LOC(buf(1,1)) ', & - ' f_ptr = C_LOC(buf(1,1,1)) ', & - ' f_ptr = C_LOC(buf(1,1,1,1)) ', & - ' f_ptr = C_LOC(buf(1,1,1,1,1)) ', & - ' f_ptr = C_LOC(buf(1,1,1,1,1,1)) ', & - ' f_ptr = C_LOC(buf(1,1,1,1,1,1,1))' & - /) ! Generate Fortran Check routines for the tests KIND interfaces. diff --git a/fortran/test/fortranlib_test_F03.F90 b/fortran/test/fortranlib_test_F03.F90 index 5b386b9..070cd73 100644 --- a/fortran/test/fortranlib_test_F03.F90 +++ b/fortran/test/fortranlib_test_F03.F90 @@ -174,6 +174,14 @@ PROGRAM fortranlibtest_F03 CALL test_get_file_image(ret_total_error) CALL write_test_status(ret_total_error, ' Testing get file image ', total_error) +! write(*,*) +! write(*,*) '=========================================' +! write(*,*) 'Testing VDS ' +! write(*,*) '=========================================' + + ret_total_error = 0 + CALL test_vds(ret_total_error) + CALL write_test_status(ret_total_error, ' Testing vds ', total_error) WRITE(*,*) diff --git a/fortran/test/tH5D.F90 b/fortran/test/tH5D.F90 index c9ba952..849f5eb 100644 --- a/fortran/test/tH5D.F90 +++ b/fortran/test/tH5D.F90 @@ -530,7 +530,6 @@ CONTAINS INTEGER(hid_t) :: file, fcpl, dataset, space INTEGER :: i, j, n, ios INTEGER(hsize_t), DIMENSION(1:2) :: dims - INTEGER :: f INTEGER(haddr_t) :: offset INTEGER, DIMENSION(1:dset_dim1,1:dset_dim2), TARGET :: rdata, data_in INTEGER :: error diff --git a/fortran/test/tH5F.F90 b/fortran/test/tH5F.F90 index 020d2c8..6a58368 100644 --- a/fortran/test/tH5F.F90 +++ b/fortran/test/tH5F.F90 @@ -194,15 +194,15 @@ CONTAINS ! !test whether files are in hdf5 format ! - CALL h5fis_hdf5_f(fix_filename1, status, error) - CALL check("h5fis_hdf5_f",error,total_error) + CALL h5fis_accessible_f(fix_filename1, status, error) + CALL check("h5fis_accessible_f",error,total_error) IF ( .NOT. status ) THEN write(*,*) "File ", fix_filename1, " is not in hdf5 format" stop END IF - CALL h5fis_hdf5_f(fix_filename2, status, error) - CALL check("h5fis_hdf5_f",error,total_error) + CALL h5fis_accessible_f(fix_filename2, status, error) + CALL check("h5fis_accessible_f",error,total_error) IF ( .NOT. status ) THEN write(*,*) "File ", fix_filename2, " is not in hdf5 format" stop diff --git a/fortran/test/tH5F_F03.F90 b/fortran/test/tH5F_F03.F90 index 9e23d19..e70c1aa 100644 --- a/fortran/test/tH5F_F03.F90 +++ b/fortran/test/tH5F_F03.F90 @@ -1,7 +1,7 @@ -!****h* root/fortran/test/tH5F_F03.f90 +!****h* root/fortran/test/tH5F_F03 ! ! NAME -! tH5F_F03.f90 +! tH5F_F03.F90 ! ! FUNCTION ! Test FORTRAN HDF5 H5F APIs which are dependent on FORTRAN 2003 @@ -62,7 +62,7 @@ SUBROUTINE test_get_file_image(total_error) INTEGER(hid_t) :: dset_id = -1 ! Dataset identifier INTEGER(hid_t) :: space_id = -1 ! Dataspace identifier INTEGER(hsize_t), DIMENSION(1:2) :: dims ! Dataset dimensions - INTEGER(size_t) :: itmp_a, itmp_b ! General purpose integers + INTEGER(size_t) :: itmp_a ! General purpose integer INTEGER(size_t) :: image_size ! Size of image TYPE(C_PTR) :: f_ptr ! Pointer INTEGER(hid_t) :: fapl ! File access property diff --git a/fortran/test/tH5P_F03.F90 b/fortran/test/tH5P_F03.F90 index 8982fc2..18af36b 100644 --- a/fortran/test/tH5P_F03.F90 +++ b/fortran/test/tH5P_F03.F90 @@ -1,7 +1,7 @@ -!****h* root/fortran/test/tH5P_F03.f90 +!****h* root/fortran/test/TH5P_F03 ! ! NAME -! tH5P_F03.f90 +! tH5P_F03.F90 ! ! FUNCTION ! Test FORTRAN HDF5 H5P APIs which are dependent on FORTRAN 2003 @@ -110,7 +110,6 @@ SUBROUTINE test_create(total_error) INTEGER :: error INTEGER(SIZE_T) :: h5off TYPE(C_PTR) :: f_ptr - LOGICAL :: differ1, differ2 CHARACTER(LEN=1) :: cfill INTEGER :: ifill REAL :: rfill @@ -617,4 +616,473 @@ SUBROUTINE external_test_offset(cleanup,total_error) CALL check("h5_cleanup_f", error, total_error) END SUBROUTINE external_test_offset + +!------------------------------------------------------------------------- +! NAME +! test_vds +! +! FUNCTION +! Tests VDS API wrappers +! +! RETURNS: +! Success: 0 +! Failure: number of errors +! +! FORTRAN Programmer: M. Scot Breitenfeld +! February 1, 2016 +! +!------------------------------------------------------------------------- +! +SUBROUTINE test_vds(total_error) + + USE ISO_C_BINDING + IMPLICIT NONE + + INTEGER, INTENT(INOUT) :: total_error + + INTEGER, PARAMETER :: int_kind_8 = SELECTED_INT_KIND(9) !should map to INTEGER*4 on most modern processors + INTEGER, PARAMETER :: int_kind_16 = SELECTED_INT_KIND(18) !should map to INTEGER*8 on most modern processors + + CHARACTER(LEN=6), PARAMETER :: VFILENAME="vds.h5" + CHARACTER(LEN=3), PARAMETER :: DATASET="VDS" + INTEGER :: VDSDIM0 + INTEGER, PARAMETER :: VDSDIM1 = 10 + INTEGER, PARAMETER :: VDSDIM2 = 15 + + INTEGER :: DIM0 + INTEGER, PARAMETER :: DIM0_1= 4 ! Initial size of the source datasets + INTEGER, PARAMETER :: DIM1 = 10 + INTEGER, PARAMETER :: DIM2 = 15 + INTEGER, PARAMETER :: RANK = 3 + INTEGER(hsize_t), PARAMETER :: PLANE_STRIDE = 4 + + CHARACTER(LEN=4), DIMENSION(1:PLANE_STRIDE) :: SRC_FILE = (/"a.h5","b.h5","c.h5","d.h5"/) + CHARACTER(LEN=3), DIMENSION(1:PLANE_STRIDE) :: SRC_DATASET = (/"AAA","BBB","CCC","DDD"/) + + + INTEGER(hid_t) :: vfile, file, src_space, mem_space, vspace, vdset, dset !Handles + INTEGER(hid_t) :: dcpl, dapl + INTEGER :: error + INTEGER(hsize_t), DIMENSION(1:3) :: vdsdims = (/4*DIM0_1, VDSDIM1, VDSDIM2/), & + vdsdims_max, & + dims = (/DIM0_1, DIM1, DIM2/), & + memdims = (/DIM0_1, DIM1, DIM2/), & + extdims = (/0, DIM1, DIM2/), & ! Dimensions of the extended source datasets + chunk_dims = (/DIM0_1, DIM1, DIM2/), & + dims_max, & + vdsdims_out, vdsdims_max_out, & + start, & ! Hyperslab parameters + stride, & + count, & + src_count, block + INTEGER(hsize_t), DIMENSION(1:2,1:3) :: vdsdims_out_correct + + INTEGER(hsize_t), DIMENSION(1:3) :: start_out, & !Hyperslab PARAMETER out + stride_out, count_out, block_out + INTEGER(hsize_t), DIMENSION(1:3,1:PLANE_STRIDE) :: start_correct + + INTEGER :: i, j + INTEGER :: layout ! Storage layout + INTEGER(size_t) :: num_map ! Number of mappings + INTEGER(size_t) :: len ! Length of the string also a RETURN value + ! Different sized character buffers + CHARACTER(len=LEN(SRC_FILE(1))-3) :: SRC_FILE_LEN_TINY + CHARACTER(len=LEN(SRC_FILE(1))-1) :: SRC_FILE_LEN_SMALL + CHARACTER(len=LEN(SRC_FILE(1))) :: SRC_FILE_LEN_EXACT + CHARACTER(len=LEN(SRC_FILE(1))+1) :: SRC_FILE_LEN_LARGE + CHARACTER(len=LEN(SRC_FILE(1))+10) :: SRC_FILE_LEN_HUGE + CHARACTER(len=LEN(SRC_DATASET(1))) :: SRC_DATASET_LEN_EXACT + + INTEGER(HID_T) :: space_out + + INTEGER :: s_type, virtual_view + INTEGER :: type1, type2 + + INTEGER, DIMENSION(DIM0_1*DIM1*DIM2), TARGET :: wdata + TYPE(C_PTR) :: f_ptr + INTEGER(SIZE_T) :: nsize + LOGICAL :: IsRegular + INTEGER(HSIZE_T) :: gap_size + + ! For testing against + vdsdims_out_correct(1,1) = DIM0_1*5 + vdsdims_out_correct(2,1) = DIM0_1*8 + vdsdims_out_correct(1:2,2) = VDSDIM1 + vdsdims_out_correct(1:2,3) = VDSDIM2 + + VDSDIM0 = H5S_UNLIMITED_F + DIM0 = H5S_UNLIMITED_F + vdsdims_max = (/VDSDIM0, VDSDIM1, VDSDIM2/) + dims_max = (/DIM0, DIM1, DIM2/) + + ! + ! Create source files and datasets. + ! + DO i = 1, PLANE_STRIDE + ! + ! Initialize data for i-th source dataset. + DO j = 1, DIM0_1*DIM1*DIM2 + wdata(j) = i + ENDDO + ! + ! Create the source files and datasets. Write data to each dataset and + ! close all resources. + CALL h5fcreate_f(SRC_FILE(i), H5F_ACC_TRUNC_F, file, error) + CALL check("h5fcreate_f", error, total_error) + + CALL h5screate_simple_f(RANK, dims, src_space, error, dims_max) + CALL check("h5screate_simple_f", error, total_error) + CALL h5pcreate_f(H5P_DATASET_CREATE_F, dcpl, error) + CALL check("h5pcreate_f", error, total_error) + CALL h5pset_chunk_f(dcpl, RANK, chunk_dims, error) + CALL check("h5pset_chunk_f",error, total_error) + + CALL h5dcreate_f(file, SRC_DATASET(i), H5T_NATIVE_INTEGER, src_space, dset, error, dcpl, H5P_DEFAULT_F, H5P_DEFAULT_F) + CALL check("h5dcreate_f",error, total_error) + f_ptr = C_LOC(wdata(1)) + CALL H5Dwrite_f(dset, H5T_NATIVE_INTEGER, f_ptr, error) + CALL check("H5Dwrite_f",error, total_error) + CALL H5Sclose_f(src_space, error) + CALL check("H5Sclose_f",error, total_error) + CALL H5Pclose_f(dcpl, error) + CALL check("H5Pclose_f",error, total_error) + CALL H5Dclose_f(dset, error) + CALL check("H5Dclose_f",error, total_error) + CALL H5Fclose_f(file, error) + CALL check("H5Fclose_f",error, total_error) + ENDDO + + CALL h5fcreate_f(VFILENAME, H5F_ACC_TRUNC_F, vfile, error) + CALL check("h5fcreate_f", error, total_error) + + ! Create VDS dataspace. + CALL H5Screate_simple_f(RANK, vdsdims, vspace, error, vdsdims_max) + CALL check("H5Screate_simple_f", error, total_error) + + ! Create dataspaces for the source dataset. + CALL H5Screate_simple_f(RANK, dims, src_space, error, dims_max) + CALL check("H5Screate_simple_f", error, total_error) + + ! Create VDS creation property + CALL H5Pcreate_f (H5P_DATASET_CREATE_F, dcpl, error) + CALL check("H5Pcreate_f", error, total_error) + + ! Initialize hyperslab values + start(1:3) = 0 + stride(1:3) = (/PLANE_STRIDE,1_hsize_t,1_hsize_t/) ! we will select every fifth plane in VDS + count(1:3) = (/H5S_UNLIMITED_F,1_hsize_t,1_hsize_t/) + src_count(1:3) = (/H5S_UNLIMITED_F,1_hsize_t,1_hsize_t/) + block(1:3) = (/1, DIM1, DIM2/) + + ! + ! Build the mappings + ! + start_correct = 0 + CALL H5Sselect_hyperslab_f(src_space, H5S_SELECT_SET_F, start, src_count, error, block=block) + CALL check("H5Sselect_hyperslab_f", error, total_error) + DO i = 1, PLANE_STRIDE + start_correct(1,i) = start(1) + CALL H5Sselect_hyperslab_f(vspace, H5S_SELECT_SET_F, start, count, error, stride=stride, block=block) + CALL check("H5Sselect_hyperslab_f", error, total_error) + + IF(i.eq.1)THEN ! check src_file and src_dataset with trailing blanks + CALL H5Pset_virtual_f (dcpl, vspace, SRC_FILE(i)//" ", SRC_DATASET(i)//" ", src_space, error) + ELSE + CALL H5Pset_virtual_f (dcpl, vspace, SRC_FILE(i), SRC_DATASET(i), src_space, error) + ENDIF + CALL check("H5Pset_virtual_f", error, total_error) + start(1) = start(1) + 1 + ENDDO + + CALL H5Sselect_none_f(vspace, error) + CALL check("H5Sselect_none_f", error, total_error) + + ! Create a virtual dataset + CALL H5Dcreate_f(vfile, DATASET, H5T_NATIVE_INTEGER, vspace, vdset, error, dcpl, H5P_DEFAULT_F, H5P_DEFAULT_F) + CALL check("H5Dcreate_f", error, total_error) + CALL H5Sclose_f(vspace, error) + CALL check("H5Sclose_f", error, total_error) + CALL H5Sclose_f(src_space, error) + CALL check("H5Sclose_f", error, total_error) + CALL H5Pclose_f(dcpl, error) + CALL check("H5Pclose_f", error, total_error) + + ! Let's add data to the source datasets and check new dimensions for VDS + ! We will add only one plane to the first source dataset, two planes to the + ! second one, three to the third, and four to the forth. + + DO i = 1, PLANE_STRIDE + ! + ! Initialize data for i-th source dataset. + DO j = 1, i*DIM1*DIM2 + wdata(j) = 10*i + ENDDO + + ! + ! Open the source files and datasets. Append data to each dataset and + ! close all resources. + CALL H5Fopen_f (SRC_FILE(i), H5F_ACC_RDWR_F, file, error) + CALL check("H5Fopen_f", error, total_error) + CALL H5Dopen_f (file, SRC_DATASET(i), dset, error) + CALL check("H5Dopen_f", error, total_error) + extdims(1) = DIM0_1+i + CALL H5Dset_extent_f(dset, extdims, error) + CALL check("H5Dset_extent_f", error, total_error) + CALL H5Dget_space_f(dset, src_space, error) + CALL check("H5Dget_space_f", error, total_error) + + start(1:3) = (/DIM0_1,0,0/) + count(1:3) = 1 + block(1:3) = (/i, DIM1, DIM2/) + + memdims(1) = i + + CALL H5Screate_simple_f(RANK, memdims, mem_space, error) + CALL check("H5Screate_simple_f", error, total_error) + + CALL H5Sselect_hyperslab_f(src_space, H5S_SELECT_SET_F, start,count, error,block=block) + CALL check("H5Sselect_hyperslab_f", error, total_error) + f_ptr = C_LOC(wdata(1)) + CALL H5Dwrite_f(dset, H5T_NATIVE_INTEGER, f_ptr, error, mem_space, src_space, H5P_DEFAULT_F) + CALL check("H5Dwrite_f", error, total_error) + CALL H5Sclose_f(src_space, error) + CALL check("H5Sclose_f", error, total_error) + call H5Dclose_f(dset, error) + CALL check("H5Dclose_f", error, total_error) + call H5Fclose_f(file, error) + CALL check("H5Fclose_f", error, total_error) + ENDDO + + call H5Dclose_f(vdset, error) + CALL check("H5Dclose_f", error, total_error) + call H5Fclose_f(vfile, error) + CALL check("H5Fclose_f", error, total_error) + + ! + ! begin the read section + ! + ! Open file and dataset using the default properties. + CALL H5Fopen_f(VFILENAME, H5F_ACC_RDONLY_F, vfile, error) + CALL check("H5Fopen_f", error, total_error) + + ! + ! Open VDS using different access properties to use max or + ! min extents depending on the sizes of the underlying datasets + CALL H5Pcreate_f(H5P_DATASET_ACCESS_F, dapl, error) + CALL check("H5Pcreate_f", error, total_error) + + DO i = 1, 2 + + IF(i.NE.1)THEN + CALL H5Pset_virtual_view_f(dapl, H5D_VDS_LAST_AVAILABLE_F, error) + CALL check("H5Pset_virtual_view_f", error, total_error) + ELSE + CALL H5Pset_virtual_view_f(dapl, H5D_VDS_FIRST_MISSING_F, error) + CALL check("H5Pset_virtual_view_f", error, total_error) + ENDIF + + CALL H5Dopen_f(vfile, DATASET, vdset, error, dapl) + CALL check("H5Dopen_f", error, total_error) + + ! Let's get space of the VDS and its dimension we should get 32(or 20)x10x10 + CALL H5Dget_space_f(vdset, vspace, error) + CALL check("H5Dget_space_f", error, total_error) + CALL H5Sget_simple_extent_dims_f(vspace, vdsdims_out, vdsdims_max_out, error) + CALL check("H5Sget_simple_extent_dims_f", error, total_error) + + ! check VDS dimensions + DO j = 1, RANK + IF(vdsdims_out(j).NE.vdsdims_out_correct(i,j))THEN + total_error = total_error + 1 + EXIT + ENDIF + ENDDO + + CALL H5Pget_virtual_view_f(dapl, virtual_view, error) + CALL check("h5pget_virtual_view_f", error, total_error) + + IF(i.EQ.1)THEN + IF(virtual_view .NE. H5D_VDS_FIRST_MISSING_F)THEN + total_error = total_error + 1 + ENDIF + ELSE + IF(virtual_view .NE. H5D_VDS_LAST_AVAILABLE_F)THEN + total_error = total_error + 1 + ENDIF + + ENDIF + + ! Close + CALL H5Dclose_f(vdset, error) + CALL check("H5Dclose_f", error, total_error) + CALL H5Sclose_f(vspace, error) + CALL check("H5Sclose_f", error, total_error) + ENDDO + + CALL H5Dopen_f(vfile, DATASET, vdset, error) + CALL check("H5Dopen_f", error, total_error) + + ! + ! Get creation property list and mapping properties. + ! + CALL H5Dget_create_plist_f (vdset, dcpl, error) + CALL check("H5Dget_create_plist_f", error, total_error) + + ! + ! Get storage layout. + CALL H5Pget_layout_f(dcpl, layout, error) + CALL check("H5Pget_layout_f", error, total_error) + + IF (H5D_VIRTUAL_F .NE. layout) THEN + PRINT*,"Wrong layout found" + total_error = total_error + 1 + ENDIF + + ! + ! Find number of mappings. + + CALL H5Pget_virtual_count_f(dcpl, num_map, error) + CALL check("H5Pget_virtual_count_f", error, total_error) + + IF(num_map.NE.4_size_t)THEN + PRINT*,"Number of mappings is incorrect" + total_error = total_error + 1 + ENDIF + ! + ! Get mapping parameters for each mapping. + ! + DO i = 1, num_map + CALL H5Pget_virtual_vspace_f(dcpl, INT(i-1,size_t), vspace, error) + CALL check("H5Pget_virtual_vspace_f", error, total_error) + + CALL h5sget_select_type_f(vspace, s_type, error) + CALL check("h5sget_select_type_f", error, total_error) + IF(s_type.EQ.H5S_SEL_HYPERSLABS_F)THEN + CALL H5Sis_regular_hyperslab_f(vspace, IsRegular, error) + CALL check("H5Sis_regular_hyperslab_f", error, total_error) + + IF(IsRegular)THEN + CALL H5Sget_regular_hyperslab_f(vspace, start_out, stride_out, count_out, block_out, error) + CALL check("H5Sget_regular_hyperslab_f", error, total_error) + DO j = 1, 3 + IF(start_out(j).NE.start_correct(j,i) .OR. & + stride_out(j).NE.stride(j).OR. & + count_out(j).NE.src_count(j))THEN + total_error = total_error + 1 + EXIT + ENDIF + ENDDO + ENDIF + END IF + + ! Get source file name + CALL H5Pget_virtual_filename_f(dcpl, INT(i-1, size_t), SRC_FILE_LEN_EXACT, error, nsize) + CALL check("H5Pget_virtual_count_f", error, total_error) + + IF(nsize.NE.LEN(SRC_FILE_LEN_EXACT))THEN + PRINT*,"virtual filenname size is incorrect" + total_error = total_error + 1 + ENDIF + ! check passing a buffer that is very small + CALL H5Pget_virtual_filename_f(dcpl, INT(i-1, size_t), SRC_FILE_LEN_TINY, error) + CALL check("H5Pget_virtual_filename_f", error, total_error) + IF(SRC_FILE_LEN_TINY.NE.SRC_FILE(i)(1:LEN(SRC_FILE_LEN_TINY)))THEN + PRINT*,"virtual filenname returned is incorrect" + total_error = total_error + 1 + ENDIF + ! check passing a buffer that small by one + CALL H5Pget_virtual_filename_f(dcpl, INT(i-1, size_t), SRC_FILE_LEN_SMALL, error) + CALL check("H5Pget_virtual_filename_f", error, total_error) + IF(SRC_FILE_LEN_SMALL.NE.SRC_FILE(i)(1:LEN(SRC_FILE_LEN_SMALL)))THEN + PRINT*,"virtual filenname returned is incorrect" + total_error = total_error + 1 + ENDIF + ! check passing a buffer that is exact + CALL H5Pget_virtual_filename_f(dcpl, INT(i-1, size_t), SRC_FILE_LEN_EXACT, error) + CALL check("H5Pget_virtual_filename_f", error, total_error) + IF(SRC_FILE_LEN_EXACT.NE.SRC_FILE(i)(1:LEN(SRC_FILE_LEN_EXACT)))THEN + PRINT*,"virtual filenname returned is incorrect" + total_error = total_error + 1 + ENDIF + ! check passing a buffer that bigger by one + CALL H5Pget_virtual_filename_f(dcpl, INT(i-1, size_t), SRC_FILE_LEN_LARGE, error) + CALL check("H5Pget_virtual_filename_f", error, total_error) + IF(SRC_FILE_LEN_LARGE(1:LEN(SRC_FILE_LEN_EXACT)).NE.SRC_FILE(i)(1:LEN(SRC_FILE_LEN_EXACT)).AND. & + SRC_FILE_LEN_LARGE(LEN(SRC_FILE_LEN_EXACT):).NE.'')THEN + PRINT*,"virtual filenname returned is incorrect" + total_error = total_error + 1 + ENDIF + ! check passing a buffer that is very big + CALL H5Pget_virtual_filename_f(dcpl, INT(i-1, size_t), SRC_FILE_LEN_HUGE, error) + CALL check("H5Pget_virtual_filename_f", error, total_error) + IF(SRC_FILE_LEN_HUGE(1:LEN(SRC_FILE_LEN_EXACT)).NE.SRC_FILE(i)(1:LEN(SRC_FILE_LEN_EXACT)).AND. & + SRC_FILE_LEN_HUGE(LEN(SRC_FILE_LEN_EXACT):).NE.'')THEN + PRINT*,"virtual filenname returned is incorrect" + total_error = total_error + 1 + ENDIF + ! Get source dataset name + CALL H5Pget_virtual_dsetname_f(dcpl, INT(i-1, size_t), SRC_DATASET_LEN_EXACT, error, nsize) + CALL check("H5Pget_virtual_dsetname_f", error, total_error) + + CALL H5Pget_virtual_dsetname_f(dcpl, INT(i-1, size_t), SRC_DATASET_LEN_EXACT, error) + CALL check("H5Pget_virtual_dsetname_f", error, total_error) + IF(SRC_DATASET_LEN_EXACT(1:LEN(SRC_DATASET_LEN_EXACT)).NE.SRC_DATASET(i)(1:LEN(SRC_DATASET_LEN_EXACT)).AND. & + SRC_DATASET_LEN_EXACT(LEN(SRC_DATASET_LEN_EXACT):).NE.'')THEN + PRINT*,"virtual dataset returned is incorrect" + total_error = total_error + 1 + ENDIF + + CALL h5pget_virtual_srcspace_f(dcpl, INT(i-1,size_t), space_out, error) + CALL check("H5Pget_virtual_srcspace_f", error, total_error) + + CALL h5sget_select_type_f(space_out, type1, error) + CALL check("H5Sget_select_type_f", error, total_error) + CALL h5sget_select_type_f(vspace, type2, error) + CALL check("H5Sget_select_type_f", error, total_error) + + IF(type1.NE.type2)THEN + total_error = total_error + 1 + ENDIF + + ENDDO + ! + ! Close and release resources. + + ! Clear virtual layout in DCPL + CALL h5pset_layout_f(dcpl, H5D_VIRTUAL_F,error) + CALL check("H5Pset_layout_f", error, total_error) + + CALL H5Pclose_f(dcpl, error) + CALL check("H5Pclose_f", error, total_error) + CALL H5Dclose_f(vdset, error) + CALL check("H5Dclose_f", error, total_error) + + ! Reopen VDS with printf gap set to 1 + + CALL H5Pset_virtual_printf_gap_f(dapl, 1_hsize_t, error) + CALL check("H5Pset_virtual_printf_gap_f", error, total_error) + + CALL H5Dopen_f(vfile, DATASET, vdset, error, dapl) + CALL check("H5Dopen_f", error, total_error) + + CALL H5Pget_virtual_printf_gap_f(dapl, gap_size, error) + CALL check("H5Pget_virtual_printf_gap_f", error, total_error) + + IF(gap_size.NE.1_hsize_t)THEN + PRINT*,"gapsize is incorrect" + total_error = total_error + 1 + ENDIF + + CALL H5Dclose_f(vdset, error) + CALL check("H5Dclose_f", error, total_error) + CALL H5Sclose_f(vspace, error) + CALL check("H5Sclose_f", error, total_error) + CALL H5Pclose_f(dapl, error) + CALL check("H5Pclose_f", error, total_error) + CALL H5Fclose_f(vfile, error) + CALL check("H5Fclose_f", error, total_error) + +END SUBROUTINE test_vds + + END MODULE TH5P_F03 diff --git a/fortran/test/tHDF5.F90 b/fortran/test/tHDF5.F90 index d12bb25..e9e0892 100644 --- a/fortran/test/tHDF5.F90 +++ b/fortran/test/tHDF5.F90 @@ -1,4 +1,4 @@ -!****h* ROBODoc/HDF5 +!****h* ROBODoc/THDF5 ! ! NAME ! MODULE THDF5 diff --git a/fortran/test/tHDF5_1_8.F90 b/fortran/test/tHDF5_1_8.F90 index 9d1c3ec..6a3f74b 100644 --- a/fortran/test/tHDF5_1_8.F90 +++ b/fortran/test/tHDF5_1_8.F90 @@ -1,4 +1,4 @@ -!****h* ROBODoc/HDF5 +!****h* ROBODoc/THDF5_1_8 ! ! NAME ! MODULE THDF5_1_8 diff --git a/fortran/test/tHDF5_F03.F90 b/fortran/test/tHDF5_F03.F90 index 3dbec11..b3b1885 100644 --- a/fortran/test/tHDF5_F03.F90 +++ b/fortran/test/tHDF5_F03.F90 @@ -1,4 +1,4 @@ -!****h* ROBODoc/HDF5 +!****h* ROBODoc/THDF5_F03 ! ! NAME ! MODULE THDF5_F03 diff --git a/fortran/test/tf.F90 b/fortran/test/tf.F90 index 7d67f30..e9baf43 100644 --- a/fortran/test/tf.F90 +++ b/fortran/test/tf.F90 @@ -89,7 +89,7 @@ CONTAINS error_string = skip ENDIF - WRITE(*, fmt = '(A, T72, A)') test_title, error_string + WRITE(*, fmt = '(A, T80, A)') test_title, error_string IF(test_result.GT.0) total_error = total_error + test_result @@ -336,7 +336,7 @@ CONTAINS IMPLICIT NONE TYPE(comp_datatype), INTENT(in) :: a -#ifdef H5_FORTRAN_FORTRAN_HAVE_C_SIZEOF +#ifdef H5_FORTRAN_HAVE_C_SIZEOF H5_SIZEOF_CMPD = C_SIZEOF(a) #else H5_SIZEOF_CMPD = SIZEOF(a) diff --git a/fortran/testpar/hyper.f90 b/fortran/testpar/hyper.f90 index a2e2e07..28c0b53 100644 --- a/fortran/testpar/hyper.f90 +++ b/fortran/testpar/hyper.f90 @@ -14,9 +14,9 @@ ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -!////////////////////////////////////////////////////////// +! ! writes/reads dataset by hyperslabs -!////////////////////////////////////////////////////////// +! SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) USE HDF5 @@ -52,14 +52,15 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) CHARACTER(len=80) :: filename ! filename INTEGER :: i INTEGER :: actual_io_mode ! The type of I/O performed by this process - - !////////////////////////////////////////////////////////// + LOGICAL :: is_coll + LOGICAL :: is_coll_true = .TRUE. + ! ! initialize the array data between the processes (3) ! for the 12 size array we get ! p0 = 1,2,3,4 ! p1 = 5,6,7,8 ! p2 = 9,10,11,12 - !////////////////////////////////////////////////////////// + ! ALLOCATE(wbuf(0:length-1),stat=hdferror) IF (hdferror /= 0) THEN @@ -81,17 +82,16 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) wbuf(i) = i ENDDO - !////////////////////////////////////////////////////////// + ! ! HDF5 I/O - !////////////////////////////////////////////////////////// + ! dims(1) = length cdims(1) = length/mpi_size ! define chunks as the number of processes - !////////////////////////////////////////////////////////// + ! ! setup file access property list with parallel I/O access - !////////////////////////////////////////////////////////// - + ! CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl_id, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) @@ -106,14 +106,67 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) nerrors = nerrors + 1 ENDIF - !////////////////////////////////////////////////////////// + ! ! create the file collectively - !////////////////////////////////////////////////////////// - + ! CALL h5_fixname_f("parf1", filename, fapl_id, hdferror) - CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, hdferror, access_prp = fapl_id) - CALL check("h5fcreate_f", hdferror, nerrors) + IF(do_collective)THEN + ! verify settings for file access properties + + ! Collective metadata writes + CALL h5pget_coll_metadata_write_f(fapl_id, is_coll, hdferror) + CALL check("h5pget_coll_metadata_write_f", hdferror, nerrors) + IF(is_coll .NEQV. .FALSE.)THEN + PRINT*, "Incorrect property setting for coll metadata writes" + nerrors = nerrors + 1 + ENDIF + + ! Collective metadata read API calling requirement + CALL h5pget_all_coll_metadata_ops_f(fapl_id, is_coll, hdferror) + CALL check("h5pget_all_coll_metadata_ops_f", hdferror, nerrors) + IF(is_coll .NEQV. .FALSE.)THEN + PRINT*, "Incorrect property setting for coll metadata API calls requirement" + nerrors = nerrors + 1 + ENDIF + + ! Collective metadata writes + CALL h5pset_coll_metadata_write_f(fapl_id, .TRUE., hdferror) + CALL check("h5pset_coll_metadata_write_f", hdferror, nerrors) + ! Collective metadata READ API calling requirement + CALL h5pset_all_coll_metadata_ops_f(fapl_id, is_coll_true, hdferror) + CALL check("h5pset_all_coll_metadata_ops_f", hdferror, nerrors) + + CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, hdferror, access_prp = fapl_id) + CALL check("h5fcreate_f", hdferror, nerrors) + + ! close fapl and retrieve it from file + CALL h5pclose_f(fapl_id, hdferror) + CALL check("h5pclose_f", hdferror, nerrors) + CALL h5fget_access_plist_f(file_id, fapl_id, hdferror) + CALL check("h5fget_access_plist_f", hdferror, nerrors) + + ! verify settings for file access properties + + ! Collective metadata writes + CALL h5pget_coll_metadata_write_f(fapl_id, is_coll, hdferror) + CALL check("h5pget_coll_metadata_write_f", hdferror, nerrors) + IF(is_coll .NEQV. .TRUE.)THEN + PRINT*, "Incorrect property setting for coll metadata writes" + nerrors = nerrors + 1 + ENDIF + + ! Collective metadata read API calling requirement + CALL h5pget_all_coll_metadata_ops_f(fapl_id, is_coll, hdferror) + CALL check("h5pget_all_coll_metadata_ops_f", hdferror, nerrors) + IF(is_coll .NEQV. .TRUE.)THEN + PRINT*, "Incorrect property setting for coll metadata API calls requirement" + nerrors = nerrors + 1 + ENDIF + ELSE + CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, hdferror, access_prp = fapl_id) + CALL check("h5fcreate_f", hdferror, nerrors) + ENDIF CALL h5screate_simple_f(1, dims, fspace_id, hdferror) CALL check("h5screate_simple_f", hdferror, nerrors) @@ -121,9 +174,9 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) CALL h5screate_simple_f(1, dims, mspace_id, hdferror) CALL check("h5screate_simple_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! modify dataset creation properties to enable chunking - !////////////////////////////////////////////////////////// + ! CALL h5pcreate_f(H5P_DATASET_CREATE_F, dcpl_id, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) @@ -133,38 +186,38 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) CALL check("h5pset_chunk_f", hdferror, nerrors) ENDIF - !////////////////////////////////////////////////////////// + ! ! create the dataset - !////////////////////////////////////////////////////////// + ! CALL h5dcreate_f(file_id, "dset", H5T_NATIVE_INTEGER, fspace_id, dset_id, hdferror, dcpl_id) CALL check("h5dcreate_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! define hyperslab - !////////////////////////////////////////////////////////// + ! counti(1) = icount start(1) = istart - !////////////////////////////////////////////////////////// + ! ! select hyperslab in memory - !////////////////////////////////////////////////////////// + ! CALL h5sselect_hyperslab_f(mspace_id, H5S_SELECT_SET_F, start, counti, hdferror) CALL check("h5sselect_hyperslab_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! select hyperslab in the file - !////////////////////////////////////////////////////////// + ! CALL h5sselect_hyperslab_f(fspace_id, H5S_SELECT_SET_F, start, counti, hdferror) CALL check("h5sselect_hyperslab_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! create a property list for collective dataset write - !////////////////////////////////////////////////////////// + ! CALL h5pcreate_f(H5P_DATASET_XFER_F, dxpl_id, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) @@ -174,9 +227,9 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) CALL check("h5pset_dxpl_mpio_f", hdferror, nerrors) ENDIF - !////////////////////////////////////////////////////////// + ! ! write dataset - !////////////////////////////////////////////////////////// + ! CALL h5dwrite_f(dset_id,H5T_NATIVE_INTEGER,wbuf,dims,hdferror,file_space_id=fspace_id,mem_space_id=mspace_id,xfer_prp=dxpl_id) CALL check("h5dwrite_f", hdferror, nerrors) @@ -200,9 +253,9 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) ENDIF ENDIF - !////////////////////////////////////////////////////////// + ! ! close HDF5 I/O - !////////////////////////////////////////////////////////// + ! CALL h5pclose_f(fapl_id, hdferror) CALL check("h5pclose_f", hdferror, nerrors) @@ -225,9 +278,9 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) CALL h5fclose_f(file_id, hdferror) CALL check("h5fclose_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! reopen file with read access - !////////////////////////////////////////////////////////// + ! CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl_id, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) @@ -247,23 +300,23 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) CALL h5dopen_f(file_id, "dset", dset_id, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! select hyperslab in memory - !////////////////////////////////////////////////////////// + ! CALL h5sselect_hyperslab_f(mspace_id, H5S_SELECT_SET_F, start, counti, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! select hyperslab in the file - !////////////////////////////////////////////////////////// + ! CALL h5sselect_hyperslab_f(fspace_id, H5S_SELECT_SET_F, start, counti, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! create a property list for collective dataset read - !////////////////////////////////////////////////////////// + ! CALL h5pcreate_f(H5P_DATASET_XFER_F, dxpl_id, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) @@ -273,16 +326,16 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) CALL check("h5pcreate_f", hdferror, nerrors) ENDIF - !////////////////////////////////////////////////////////// + ! ! read dataset - !////////////////////////////////////////////////////////// + ! CALL h5dread_f(dset_id,H5T_NATIVE_INTEGER,rbuf,dims,hdferror,file_space_id=fspace_id,mem_space_id=mspace_id,xfer_prp=dxpl_id) CALL check("h5pcreate_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! close HDF5 I/O - !////////////////////////////////////////////////////////// + ! CALL h5pclose_f(fapl_id, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) @@ -302,9 +355,9 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) CALL h5fclose_f(file_id, hdferror) CALL check("h5pcreate_f", hdferror, nerrors) - !////////////////////////////////////////////////////////// + ! ! compare read and write data. each process compares a subset of the array - !////////////////////////////////////////////////////////// + ! DO i = istart, iend-1 IF( wbuf(i) /= rbuf(i)) THEN diff --git a/fortran/testpar/ptest.f90 b/fortran/testpar/ptest.f90 index 69594b0..82dcc09 100644 --- a/fortran/testpar/ptest.f90 +++ b/fortran/testpar/ptest.f90 @@ -13,29 +13,35 @@ ! access to either file, you may request a copy from help@hdfgroup.org. * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -!////////////////////////////////////////////////////////// +! ! main program for parallel HDF5 Fortran tests -!////////////////////////////////////////////////////////// +! PROGRAM parallel_test USE hdf5 + USE MPI + USE TH5_MISC IMPLICIT NONE - INCLUDE 'mpif.h' INTEGER :: mpierror ! MPI hdferror flag INTEGER :: hdferror ! HDF hdferror flag - LOGICAL :: do_collective ! use collective MPI I/O - LOGICAL :: do_chunk ! use chunking - INTEGER :: nerrors = 0 ! number of errors + INTEGER :: ret_total_error = 0 ! number of errors in subroutine + INTEGER :: total_error = 0 ! sum of the number of errors INTEGER :: mpi_size ! number of processes in the group of communicator INTEGER :: mpi_rank ! rank of the calling process in the communicator INTEGER :: length = 12000 ! length of array - - !////////////////////////////////////////////////////////// + INTEGER :: i,j + ! use collective MPI I/O + LOGICAL, DIMENSION(1:2) :: do_collective = (/.FALSE.,.TRUE./) + CHARACTER(LEN=11), DIMENSION(1:2) :: chr_collective =(/"independent", "collective "/) + ! use chunking + LOGICAL, DIMENSION(1:2) :: do_chunk = (/.FALSE.,.TRUE./) + CHARACTER(LEN=10), DIMENSION(1:2) :: chr_chunk =(/"contiguous", "chunk "/) + + ! ! initialize MPI - !////////////////////////////////////////////////////////// - + ! CALL mpi_init(mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_INIT *FAILED*" @@ -48,74 +54,40 @@ PROGRAM parallel_test IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_COMM_SIZE *FAILED* Process = ", mpi_rank ENDIF - !////////////////////////////////////////////////////////// + ! ! initialize the HDF5 fortran interface - !////////////////////////////////////////////////////////// - + ! CALL h5open_f(hdferror) - - !////////////////////////////////////////////////////////// - ! test write/read dataset by hyperslabs with independent MPI I/O - !////////////////////////////////////////////////////////// - - IF (mpi_rank == 0) WRITE(*,*) 'Writing/reading dataset by hyperslabs (contiguous layout, independent MPI I/O)' - - do_collective = .FALSE. - do_chunk = .FALSE. - CALL hyper(length, do_collective, do_chunk, mpi_size, mpi_rank, nerrors) - - !////////////////////////////////////////////////////////// - ! test write/read dataset by hyperslabs with collective MPI I/O - !////////////////////////////////////////////////////////// - - IF (mpi_rank == 0) WRITE(*,*) 'Writing/reading dataset by hyperslabs (contiguous layout, collective MPI I/O)' - - do_collective = .TRUE. - do_chunk = .FALSE. - CALL hyper(length, do_collective, do_chunk, mpi_size, mpi_rank, nerrors) - - !////////////////////////////////////////////////////////// - ! test write/read dataset by hyperslabs with independent MPI I/O - !////////////////////////////////////////////////////////// - - IF (mpi_rank == 0) WRITE(*,*) 'Writing/reading dataset by hyperslabs (chunk layout, independent MPI I/O)' - - do_collective = .FALSE. - do_chunk = .TRUE. - CALL hyper(length, do_collective, do_chunk, mpi_size, mpi_rank, nerrors) - - !////////////////////////////////////////////////////////// - ! test write/read dataset by hyperslabs with collective MPI I/O - !////////////////////////////////////////////////////////// - - IF (mpi_rank == 0) WRITE(*,*) 'Writing/reading dataset by hyperslabs (chunk layout, collective MPI I/O)' - - do_collective = .TRUE. - do_chunk = .TRUE. - CALL hyper(length, do_collective, do_chunk, mpi_size, mpi_rank, nerrors) - - !////////////////////////////////////////////////////////// + ! + ! test write/read dataset by hyperslabs (contiguous/chunk) with independent/collective MPI I/O + ! + DO i = 1, 2 + DO j = 1, 2 + ret_total_error = 0 + CALL hyper(length, do_collective(j), do_chunk(i), mpi_size, mpi_rank, ret_total_error) + IF(mpi_rank==0) CALL write_test_status(ret_total_error, & + "Writing/reading dataset by hyperslabs ("//TRIM(chr_chunk(i))//" layout, "//TRIM(chr_collective(j))//" MPI I/O)", & + total_error) + ENDDO + ENDDO + + ! ! test write/read several datasets (independent MPI I/O) - !////////////////////////////////////////////////////////// - - IF (mpi_rank == 0) WRITE(*,*) 'Writing/reading several datasets (contiguous layout, independent MPI I/O)' - - do_collective = .FALSE. - do_chunk = .FALSE. - CALL multiple_dset_write(length, do_collective, do_chunk, mpi_size, mpi_rank, nerrors) + ! + ret_total_error = 0 + CALL multiple_dset_write(length, do_collective(1), do_chunk(1), mpi_size, mpi_rank, ret_total_error) + IF(mpi_rank==0) CALL write_test_status(ret_total_error, & + 'Writing/reading several datasets (contiguous layout, independent MPI I/O)', total_error) - - !////////////////////////////////////////////////////////// + ! ! close HDF5 interface - !////////////////////////////////////////////////////////// - + ! CALL h5close_f(hdferror) - !////////////////////////////////////////////////////////// + ! ! close MPI - !////////////////////////////////////////////////////////// - - IF (nerrors == 0) THEN + ! + IF (total_error == 0) THEN CALL mpi_finalize(mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_FINALIZE *FAILED* Process = ", mpi_rank @@ -127,10 +99,7 @@ PROGRAM parallel_test WRITE(*,*) "MPI_ABORT *FAILED* Process = ", mpi_rank ENDIF ENDIF - - !////////////////////////////////////////////////////////// + ! ! end main program - !////////////////////////////////////////////////////////// - + ! END PROGRAM parallel_test - |