From 3e9c2a6a5cebf3e5f4db67ad6b3177be07ad171c Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Sun, 24 Mar 2024 20:07:01 -0700 Subject: [PATCH 01/17] Fixed a cache assert with too-large metadata objects (#4231) If the library tries to load a metadata object that is above the library's hard-coded limits, the size will trip an assert in debug builds. In HDF5 1.14.4, this can happen if you create a very large number of links in an old-style group that uses local heaps. The library will now emit a normal error when it tries to load a metadata object that is too large. Partially addresses GitHub #3762 --- release_docs/RELEASE.txt | 12 ++++++++++++ src/H5Centry.c | 15 +++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index fbd6b78e547..07b4d3bb4fd 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -693,6 +693,18 @@ Bug Fixes since HDF5-1.14.0 release Library ------- + - Fixed a cache assert with too-large metadata objects + + If the library tries to load a metadata object that is above the + library's hard-coded limits, the size will trip an assert in debug + builds. In HDF5 1.14.4, this can happen if you create a very large + number of links in an old-style group that uses local heaps. + + The library will now emit a normal error when it tries to load a + metadata object that is too large. + + Partially addresses GitHub #3762 + - Fixed an issue with the Subfiling VFD and multiple opens of a file diff --git a/src/H5Centry.c b/src/H5Centry.c index c6892e90e3c..a799c4bb97d 100644 --- a/src/H5Centry.c +++ b/src/H5Centry.c @@ -1216,10 +1216,9 @@ H5C__load_entry(H5F_t *f, assert((dirty == false) || (type->id == 5 || type->id == 6)); - entry->cache_ptr = f->shared->cache; - entry->addr = addr; - entry->size = len; - assert(entry->size < H5C_MAX_ENTRY_SIZE); + entry->cache_ptr = f->shared->cache; + entry->addr = addr; + entry->size = len; entry->image_ptr = image; entry->image_up_to_date = !dirty; entry->type = type; @@ -1289,6 +1288,14 @@ H5C__load_entry(H5F_t *f, H5C__RESET_CACHE_ENTRY_STATS(entry); + /* This is a temporary fix for a problem identified in GitHub #3762, where + * it looks like a local heap entry can grow to a size that is larger + * than the metadata cache will allow. This doesn't fix the underlying + * problem, but it at least prevents the library from crashing. + */ + if (entry->size >= H5C_MAX_ENTRY_SIZE) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "cache entry size is too large"); + ret_value = thing; done: From da60238e83a0b41e5872140997e151a2bbbc99d4 Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Sun, 24 Mar 2024 22:07:21 -0500 Subject: [PATCH 02/17] Set DXPL in API context for native VOL attribute I/O calls (#4228) --- src/H5VLint.c | 2 +- src/H5VLnative_attr.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/H5VLint.c b/src/H5VLint.c index feb2debd947..131856db5e6 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -2249,7 +2249,7 @@ H5VL_set_vol_wrapper(const H5VL_object_t *vol_obj) vol_wrap_ctx->obj_wrap_ctx = obj_wrap_ctx; } /* end if */ else - /* Incremeent ref count on existing wrapper context */ + /* Increment ref count on existing wrapper context */ vol_wrap_ctx->rc++; /* Save the wrapper context */ diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c index 50aca652b2f..bebd127df23 100644 --- a/src/H5VLnative_attr.c +++ b/src/H5VLnative_attr.c @@ -26,6 +26,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5Gprivate.h" /* Groups */ @@ -195,8 +196,7 @@ H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const cha *------------------------------------------------------------------------- */ herr_t -H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) +H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void H5_ATTR_UNUSED **req) { H5T_t *mem_type; /* Memory datatype */ herr_t ret_value; /* Return value */ @@ -206,6 +206,9 @@ H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t H5_ATTR_UNUS if (NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + /* Go write the actual data to the attribute */ if ((ret_value = H5A__read((H5A_t *)attr, mem_type, buf)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute"); @@ -224,8 +227,7 @@ H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t H5_ATTR_UNUS *------------------------------------------------------------------------- */ herr_t -H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) +H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void H5_ATTR_UNUSED **req) { H5T_t *mem_type; /* Memory datatype */ herr_t ret_value; /* Return value */ @@ -235,6 +237,9 @@ H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t H5_AT if (NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + /* Go write the actual data to the attribute */ if ((ret_value = H5A__write((H5A_t *)attr, mem_type, buf)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute"); From 30c1bbdfe78196eb2191c5c7e2ae890b0953e3bd Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Mon, 25 Mar 2024 01:15:01 -0500 Subject: [PATCH 03/17] Initialize a variable in C++ testhdf5's tattr.cpp (#4232) --- c++/test/tattr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 08914ca8a6e..5135e0c7fa7 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -1406,7 +1406,7 @@ test_attr_dtype_shared(FileAccPropList &fapl) SUBTEST("Shared Datatypes with Attributes"); try { - h5_stat_size_t empty_filesize; // Size of empty file + h5_stat_size_t empty_filesize = 0; // Size of empty file bool is_default_vfd_compat = false; // Create a file From 6837fe5bc85aab8d47e5f5b6d2d0bd4b097b2edf Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Mon, 25 Mar 2024 07:42:03 -0500 Subject: [PATCH 04/17] Addressed Fortran issues with promoted integers and reals via compilation flags, part 2 (#4221) * addressed issue wit promoted integers and reals * fixed h5fcreate_f * added option to use mpi_f08 * change the kind of logical in the parallel tests * addressed missing return value from callback --- HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 | 6 +- .../FORTRAN/H5PAR/ph5_f90_dataset.F90 | 7 +- .../FORTRAN/H5PAR/ph5_f90_file_create.F90 | 6 +- .../H5PAR/ph5_f90_filtered_writes_no_sel.F90 | 18 ++-- .../H5PAR/ph5_f90_hyperslab_by_chunk.F90 | 6 +- .../H5PAR/ph5_f90_hyperslab_by_col.F90 | 6 +- .../H5PAR/ph5_f90_hyperslab_by_pattern.F90 | 6 +- .../H5PAR/ph5_f90_hyperslab_by_row.F90 | 6 +- .../FORTRAN/H5PAR/ph5_f90_subfiling.F90 | 38 ++++---- HDF5Examples/FORTRAN/H5T/h5ex_t_enum_F03.F90 | 8 +- .../FORTRAN/H5T/h5ex_t_enumatt_F03.F90 | 7 +- config/cmake/HDF5UseFortran.cmake | 16 ++++ config/cmake/HDFUseFortran.cmake | 3 +- configure.ac | 12 ++- fortran/src/CMakeLists.txt | 5 + fortran/src/H5Eff.F90 | 15 ++- fortran/src/H5Fff.F90 | 6 +- fortran/src/H5Lff.F90 | 4 +- fortran/src/H5Pf.c | 26 ++--- fortran/src/H5Pff.F90 | 95 +++++++++++++------ fortran/src/H5Sf.c | 2 +- fortran/src/H5config_f.inc.cmake | 9 +- fortran/src/H5config_f.inc.in | 2 +- fortran/src/H5f90proto.h | 8 +- fortran/test/tH5A.F90 | 5 +- fortran/test/tH5E_F03.F90 | 3 +- fortran/test/tH5L_F03.F90 | 2 +- fortran/test/tH5O_F03.F90 | 8 +- fortran/test/tH5T_F03.F90 | 10 +- fortran/testpar/async.F90 | 90 +++++++++++++----- fortran/testpar/hyper.F90 | 4 +- fortran/testpar/mdset.F90 | 4 +- fortran/testpar/mpi_param.F90 | 69 ++++++++------ fortran/testpar/multidsetrw.F90 | 5 +- fortran/testpar/ptest.F90 | 20 ++-- fortran/testpar/subfiling.F90 | 62 ++++++++---- m4/aclocal_fc.f90 | 3 +- m4/aclocal_fc.m4 | 9 +- 38 files changed, 384 insertions(+), 227 deletions(-) diff --git a/HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 b/HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 index 198d437003a..ab401ce9164 100644 --- a/HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 +++ b/HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 @@ -84,7 +84,9 @@ RECURSIVE INTEGER(KIND=C_INT) FUNCTION op_func(loc_id, name, info, operator_data CHARACTER(LEN=10) :: space INTEGER :: spaces ! Number of whitespaces to prepend to output INTEGER :: len + INTEGER :: ret_val_func + ret_val_func = 0 ret_val = 0 name_string(1:10) = " " @@ -140,8 +142,8 @@ RECURSIVE INTEGER(KIND=C_INT) FUNCTION op_func(loc_id, name, info, operator_data ptr2 = C_LOC(nextod%recurs) funptr = C_FUNLOC(op_func) CALL h5literate_by_name_f(loc_id, name_string, H5_INDEX_NAME_F, H5_ITER_NATIVE_F, idx, & - funptr, ptr2, ret_val, status) - + funptr, ptr2, ret_val_func, status) + ret_val = INT(ret_val_func,C_INT) ENDIF WRITE(*,'(A)') space(1:spaces)//"}" RETURN diff --git a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_dataset.F90 b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_dataset.F90 index f7e4185411a..b5c43a88fa5 100644 --- a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_dataset.F90 +++ b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_dataset.F90 @@ -25,9 +25,10 @@ PROGRAM DATASET ! ! MPI definitions and calls. ! - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm, info - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, info + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank + comm = MPI_COMM_WORLD info = MPI_INFO_NULL CALL MPI_INIT(mpierror) diff --git a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_file_create.F90 b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_file_create.F90 index b5aa090e643..a6965a1f2a1 100644 --- a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_file_create.F90 +++ b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_file_create.F90 @@ -18,9 +18,9 @@ PROGRAM FILE_CREATE ! ! MPI definitions and calls. ! - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm, info - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, info + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank comm = MPI_COMM_WORLD info = MPI_INFO_NULL diff --git a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_filtered_writes_no_sel.F90 b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_filtered_writes_no_sel.F90 index ffec2fb54b2..4a34d1f2ed0 100644 --- a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_filtered_writes_no_sel.F90 +++ b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_filtered_writes_no_sel.F90 @@ -27,7 +27,7 @@ MODULE filter INTEGER , PARAMETER :: PATH_MAX = 512 ! Global variables - INTEGER :: mpi_rank, mpi_size + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank, mpi_size CONTAINS ! @@ -91,10 +91,11 @@ SUBROUTINE cleanup(filename) LOGICAL :: do_cleanup INTEGER :: status + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror CALL get_environment_variable("HDF5_NOCLEANUP", STATUS=status) IF(status.EQ.0)THEN - CALL MPI_File_delete(filename, MPI_INFO_NULL, status) + CALL MPI_File_delete(filename, MPI_INFO_NULL, mpierror) ENDIF END SUBROUTINE cleanup @@ -241,18 +242,19 @@ PROGRAM main USE filter IMPLICIT NONE - INTEGER :: comm = MPI_COMM_WORLD - INTEGER :: info = MPI_INFO_NULL + INTEGER(KIND=MPI_INTEGER_KIND) :: comm = MPI_COMM_WORLD + INTEGER(KIND=MPI_INTEGER_KIND) :: info = MPI_INFO_NULL INTEGER(hid_t) :: file_id INTEGER(hid_t) :: fapl_id INTEGER(hid_t) :: dxpl_id CHARACTER(LEN=PATH_MAX) :: par_prefix CHARACTER(LEN=PATH_MAX) :: filename INTEGER :: status + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror - CALL MPI_Init(status) - CALL MPI_Comm_size(comm, mpi_size, status) - CALL MPI_Comm_rank(comm, mpi_rank, status) + CALL MPI_Init(mpierror) + CALL MPI_Comm_size(comm, mpi_size, mpierror) + CALL MPI_Comm_rank(comm, mpi_rank, mpierror) ! ! Initialize HDF5 library and Fortran interfaces. @@ -349,6 +351,6 @@ PROGRAM main ! ------------------------------------ CALL cleanup(filename) - CALL MPI_Finalize(status) + CALL MPI_Finalize(mpierror) END PROGRAM main diff --git a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_chunk.F90 b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_chunk.F90 index 7be9389e77d..c4f67fee60c 100644 --- a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_chunk.F90 +++ b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_chunk.F90 @@ -34,9 +34,9 @@ PROGRAM DATASET_BY_CHUNK ! ! MPI definitions and calls. ! - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm, info - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, info + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank comm = MPI_COMM_WORLD info = MPI_INFO_NULL diff --git a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_col.F90 b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_col.F90 index c439d63829f..b7e0b25de16 100644 --- a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_col.F90 +++ b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_col.F90 @@ -30,9 +30,9 @@ PROGRAM DATASET_BY_COL ! ! MPI definitions and calls. ! - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm, info - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, info + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank comm = MPI_COMM_WORLD info = MPI_INFO_NULL CALL MPI_INIT(mpierror) diff --git a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_pattern.F90 b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_pattern.F90 index c7e8da13a7a..f94c8192d0c 100644 --- a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_pattern.F90 +++ b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_pattern.F90 @@ -36,9 +36,9 @@ PROGRAM DATASET_BY_PATTERN ! ! MPI definitions and calls. ! - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm, info - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, info + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank comm = MPI_COMM_WORLD info = MPI_INFO_NULL diff --git a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_row.F90 b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_row.F90 index 66d5b250258..f607b482561 100644 --- a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_row.F90 +++ b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_hyperslab_by_row.F90 @@ -35,9 +35,9 @@ PROGRAM DATASET_BY_ROW ! ! MPI definitions and calls. ! - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm, info - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, info + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank comm = MPI_COMM_WORLD info = MPI_INFO_NULL diff --git a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_subfiling.F90 b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_subfiling.F90 index fc30717e1b9..866200f3658 100644 --- a/HDF5Examples/FORTRAN/H5PAR/ph5_f90_subfiling.F90 +++ b/HDF5Examples/FORTRAN/H5PAR/ph5_f90_subfiling.F90 @@ -60,8 +60,8 @@ SUBROUTINE subfiling_write_default(fapl_id, mpi_size, mpi_rank) IMPLICIT NONE INTEGER(HID_T) :: fapl_id - INTEGER :: mpi_size - INTEGER :: mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank INTEGER, DIMENSION(:), ALLOCATABLE, TARGET :: wdata INTEGER(hsize_t), DIMENSION(1:EXAMPLE_DSET_DIMS) :: dset_dims @@ -171,8 +171,8 @@ SUBROUTINE subfiling_write_custom(fapl_id, mpi_size, mpi_rank) IMPLICIT NONE INTEGER(HID_T) :: fapl_id - INTEGER :: mpi_size - INTEGER :: mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank INTEGER, DIMENSION(:), ALLOCATABLE, TARGET :: wdata @@ -304,8 +304,8 @@ SUBROUTINE subfiling_write_precreate(fapl_id, mpi_size, mpi_rank) IMPLICIT NONE INTEGER(HID_T) :: fapl_id - INTEGER :: mpi_size - INTEGER :: mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank INTEGER, DIMENSION(:), ALLOCATABLE, TARGET :: wdata TYPE(H5FD_subfiling_config_t) :: subf_config @@ -320,6 +320,7 @@ SUBROUTINE subfiling_write_precreate(fapl_id, mpi_size, mpi_rank) INTEGER :: status INTEGER(SIZE_T) :: i TYPE(C_PTR) :: f_ptr + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! Make a copy of the FAPL so we don't disturb ! it for the other examples @@ -413,7 +414,7 @@ SUBROUTINE subfiling_write_precreate(fapl_id, mpi_size, mpi_rank) CALL H5Fclose_f(file_id, status) ENDIF - CALL MPI_Barrier(MPI_COMM_WORLD, status) + CALL MPI_Barrier(MPI_COMM_WORLD, mpierror) ! ! Use all MPI ranks to re-open the file and @@ -467,26 +468,27 @@ PROGRAM main USE SUBF IMPLICIT NONE - INTEGER :: comm = MPI_COMM_WORLD - INTEGER :: info = MPI_INFO_NULL + INTEGER(KIND=MPI_INTEGER_KIND) :: comm = MPI_COMM_WORLD + INTEGER(KIND=MPI_INTEGER_KIND) :: info = MPI_INFO_NULL INTEGER(HID_T) :: fapl_id - INTEGER :: mpi_size - INTEGER :: mpi_rank - INTEGER :: required - INTEGER :: provided + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: required + INTEGER(KIND=MPI_INTEGER_KIND) :: provided + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror INTEGER :: status ! HDF5 Subfiling VFD requires MPI_Init_thread with MPI_THREAD_MULTIPLE required = MPI_THREAD_MULTIPLE provided = 0 - CALL mpi_init_thread(required, provided, status) + CALL mpi_init_thread(required, provided, mpierror) IF (provided .NE. required) THEN WRITE(*,*) "MPI doesn't support MPI_Init_thread with MPI_THREAD_MULTIPLE *FAILED*" - CALL MPI_Abort(comm, -1, status) + CALL MPI_Abort(comm, -1_MPI_INTEGER_KIND, mpierror) ENDIF - CALL MPI_Comm_size(comm, mpi_size, status) - CALL MPI_Comm_rank(comm, mpi_rank, status) + CALL MPI_Comm_size(comm, mpi_size, mpierror) + CALL MPI_Comm_rank(comm, mpi_rank, mpierror) ! ! Initialize HDF5 library and Fortran interfaces. @@ -516,6 +518,6 @@ PROGRAM main IF(mpi_rank .EQ. 0) WRITE(*,"(A)") "PHDF5 example finished with no errors" - CALL MPI_Finalize(status) + CALL MPI_Finalize(mpierror) END PROGRAM main diff --git a/HDF5Examples/FORTRAN/H5T/h5ex_t_enum_F03.F90 b/HDF5Examples/FORTRAN/H5T/h5ex_t_enum_F03.F90 index b0ba276dfb9..dd480738f4d 100644 --- a/HDF5Examples/FORTRAN/H5T/h5ex_t_enum_F03.F90 +++ b/HDF5Examples/FORTRAN/H5T/h5ex_t_enum_F03.F90 @@ -74,14 +74,14 @@ PROGRAM main ! Insert enumerated value for memtype. ! val = i - CALL h5tenum_insert_f(memtype, TRIM(names(i+1)), val, hdferr) + f_ptr = C_LOC(val) + CALL h5tenum_insert_f(memtype, TRIM(names(i+1)), f_ptr, hdferr) ! ! Insert enumerated value for filetype. We must first convert ! the numerical value val to the base type of the destination. ! - f_ptr = C_LOC(val) CALL h5tconvert_f (M_BASET, F_BASET, INT(1,SIZE_T), f_ptr, hdferr) - CALL h5tenum_insert_f(filetype, TRIM(names(i+1)), val, hdferr) + CALL h5tenum_insert_f(filetype, TRIM(names(i+1)), f_ptr, hdferr) ENDDO ! ! Create dataspace. Setting maximum size to be the current size. @@ -129,7 +129,7 @@ PROGRAM main ! ! Get the name of the enumeration member. ! - CALL h5tenum_nameof_f( memtype, rdata(i,j), NAME_BUF_SIZE, name, hdferr) + CALL h5tenum_nameof_f( memtype, INT(rdata(i,j)), NAME_BUF_SIZE, name, hdferr) WRITE(*,'(" ", A6," ")', ADVANCE='NO') TRIM(NAME) ENDDO WRITE(*,'("]")') diff --git a/HDF5Examples/FORTRAN/H5T/h5ex_t_enumatt_F03.F90 b/HDF5Examples/FORTRAN/H5T/h5ex_t_enumatt_F03.F90 index ec641b3ede6..13a289bd786 100644 --- a/HDF5Examples/FORTRAN/H5T/h5ex_t_enumatt_F03.F90 +++ b/HDF5Examples/FORTRAN/H5T/h5ex_t_enumatt_F03.F90 @@ -75,14 +75,15 @@ PROGRAM main ! Insert enumerated value for memtype. ! val = i - CALL h5tenum_insert_f(memtype, TRIM(names(i+1)), val, hdferr) + f_ptr = C_LOC(val) + CALL h5tenum_insert_f(memtype, TRIM(names(i+1)), f_ptr, hdferr) ! ! Insert enumerated value for filetype. We must first convert ! the numerical value val to the base type of the destination. ! f_ptr = C_LOC(val) CALL h5tconvert_f(M_BASET, F_BASET, INT(1,SIZE_T), f_ptr, hdferr) - CALL h5tenum_insert_f(filetype, TRIM(names(i+1)), val, hdferr) + CALL h5tenum_insert_f(filetype, TRIM(names(i+1)), f_ptr, hdferr) ENDDO ! ! Create dataspace with a null dataspace. @@ -137,7 +138,7 @@ PROGRAM main ! ! Get the name of the enumeration member. ! - CALL h5tenum_nameof_f( memtype, rdata(i,j), NAME_BUF_SIZE, name, hdferr) + CALL h5tenum_nameof_f( memtype, INT(rdata(i,j)), NAME_BUF_SIZE, name, hdferr) WRITE(*,'(" ",A6," ")', ADVANCE='NO') TRIM(NAME) ENDDO WRITE(*,'("]")') diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index 73b4f742b48..f22d8d2c390 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -50,9 +50,15 @@ macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR1 else () set (_RUN_OUTPUT_VARIABLE "RUN_OUTPUT_STDOUT_VARIABLE") endif() + if (${FUNCTION_NAME} STREQUAL "SIZEOF NATIVE KINDs") + set(TMP_CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + else () + set(TMP_CMAKE_Fortran_FLAGS "") + endif () TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90 + CMAKE_FLAGS "${TMP_CMAKE_Fortran_FLAGS}" LINK_LIBRARIES "${HDF5_REQUIRED_LIBRARIES}" ${_RUN_OUTPUT_VARIABLE} OUTPUT_VAR ) @@ -111,6 +117,16 @@ else () set (${HDF_PREFIX}_FORTRAN_C_BOOL_IS_UNIQUE 0) endif () +# Check if the fortran compiler supports the intrinsic module "ISO_FORTRAN_ENV" (F08) + +READ_SOURCE("PROGRAM PROG_FC_ISO_FORTRAN_ENV" "END PROGRAM PROG_FC_ISO_FORTRAN_ENV" SOURCE_CODE) +check_fortran_source_compiles (${SOURCE_CODE} HAVE_ISO_FORTRAN_ENV SRC_EXT f90) +if (${HAVE_ISO_FORTRAN_ENV}) + set (${HDF_PREFIX}_HAVE_ISO_FORTRAN_ENV 1) +else () + set (${HDF_PREFIX}_HAVE_ISO_FORTRAN_ENV 0) +endif () + ## Set the sizeof function for use later in the fortran tests if (${HDF_PREFIX}_FORTRAN_HAVE_STORAGE_SIZE) set (FC_SIZEOF_A "STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)") diff --git a/config/cmake/HDFUseFortran.cmake b/config/cmake/HDFUseFortran.cmake index 2d53a506124..dd35c07531d 100644 --- a/config/cmake/HDFUseFortran.cmake +++ b/config/cmake/HDFUseFortran.cmake @@ -80,7 +80,8 @@ set (CHAR_ALLOC set (ISO_FORTRAN_ENV_CODE " PROGRAM main - USE, INTRINSIC :: ISO_FORTRAN_ENV + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : atomic_logical_kind + LOGICAL(KIND=atomic_logical_kind) :: state END PROGRAM " ) diff --git a/configure.ac b/configure.ac index 73ad0b5446f..f94dcf848bd 100644 --- a/configure.ac +++ b/configure.ac @@ -801,6 +801,15 @@ if test "X$HDF_FORTRAN" = "Xyes"; then ## See if the fortran compiler supports the intrinsic function "STORAGE_SIZE" PAC_PROG_FC_STORAGE_SIZE + ## -------------------------------------------------------------------- + ## Checking if the fortran compiler supports ISO_FORTRAN_ENV (Fortran 2008) + HAVE_ISO_FORTRAN_ENV="0" + PAC_PROG_FC_ISO_FORTRAN_ENV + if test "X$CHECK_ISO_FORTRAN_ENV" = "Xyes"; then + HAVE_ISO_FORTRAN_ENV="1" + AC_DEFINE([HAVE_ISO_FORTRAN_ENV], [1], [Define if Fortran supports ISO_FORTRAN_ENV (F08)]) + fi + ## Set the sizeof function for use later in the fortran tests if test "X$HAVE_STORAGE_SIZE_FORTRAN" = "Xyes";then FC_SIZEOF_A="STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)" @@ -817,8 +826,6 @@ if test "X$HDF_FORTRAN" = "Xyes"; then fi fi - ## See if the fortran compiler supports the intrinsic module "ISO_FORTRAN_ENV" - PAC_PROG_FC_ISO_FORTRAN_ENV ## Check KIND and size of native integer PAC_FC_NATIVE_INTEGER @@ -844,6 +851,7 @@ if test "X$HDF_FORTRAN" = "Xyes"; then AC_SUBST([FORTRAN_HAVE_C_LONG_DOUBLE]) AC_SUBST([FORTRAN_C_LONG_DOUBLE_IS_UNIQUE]) AC_SUBST([FORTRAN_C_BOOL_IS_UNIQUE]) + AC_SUBST([HAVE_ISO_FORTRAN_ENV]) AC_SUBST([H5CONFIG_F_NUM_RKIND]) AC_SUBST([H5CONFIG_F_RKIND]) AC_SUBST([H5CONFIG_F_RKIND_SIZEOF]) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index b2ac81ea0c6..80ee2889bc7 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -69,6 +69,11 @@ if (H5_FORTRAN_HAVE_C_SIZEOF) set (CMAKE_H5_FORTRAN_HAVE_C_SIZEOF 1) endif () +set (CMAKE_H5_HAVE_ISO_FORTRAN_ENV 0) +if (H5_HAVE_ISO_FORTRAN_ENV) + set (CMAKE_H5_HAVE_ISO_FORTRAN_ENV 1) +endif () + set (CMAKE_H5_FORTRAN_HAVE_CHAR_ALLOC 0) if (H5_FORTRAN_HAVE_CHAR_ALLOC) set (CMAKE_H5_FORTRAN_HAVE_CHAR_ALLOC 1) diff --git a/fortran/src/H5Eff.F90 b/fortran/src/H5Eff.F90 index 162a7508085..20f45473a3b 100644 --- a/fortran/src/H5Eff.F90 +++ b/fortran/src/H5Eff.F90 @@ -306,19 +306,16 @@ END SUBROUTINE h5eset_auto_f !! \param arg19 C style format control strings !! \param arg20 C style format control strings !! -!! \note \p arg[1-20] expects C-style format strings, similar to the -!! system and C functions printf() and fprintf(). -!! Furthermore, special characters, such as ANSI escapes, -!! will only be interpreted correctly if the Fortran equivalent -!! is used. For example, to print \p msg "TEXT" in red and has -!! a space after the text would be: +!! \note \p arg[1-20] expects C-style format strings, similar to the system and C functions printf() and fprintf(). +!! Furthermore, special characters, such as ANSI escapes, will only be interpreted correctly if the Fortran +!! equivalent is used. For example, to print \p msg "TEXT" in red would be: !!

!! \code -!! (..., "%s TEXT %s"//C_NEW_LINE, hdferr, ..., arg1=ACHAR(27)//"[31m", arg2=ACHAR(27)//"[0m" ) +!! (..., "%s TEXT %s", hdferr, ..., arg1=ACHAR(27)//"[31m"//C_NULL_CHAR, arg2=ACHAR(27)//"[0m"//C_NULL_CHAR ) !! \endcode !!
Using "\n" instead of C_NEW_LINE will not be interpereted correctly, and similarly, -!! using "\x1B" instead of ACHAR(27) -!! +!! using "\x1B" instead of ACHAR(27). Also, all \p arg[1-20] characters strings must be +!! NULL terminated. !! !! See C API: @ref H5Epush2() !! diff --git a/fortran/src/H5Fff.F90 b/fortran/src/H5Fff.F90 index e8b765b7696..0c8b1d84099 100644 --- a/fortran/src/H5Fff.F90 +++ b/fortran/src/H5Fff.F90 @@ -120,10 +120,10 @@ SUBROUTINE h5fcreate_f(name, access_flags, file_id, hdferr, & INTERFACE INTEGER(HID_T) FUNCTION H5Fcreate(name, access_flags, & creation_prp_default, access_prp_default) BIND(C,NAME='H5Fcreate') - IMPORT :: C_CHAR + IMPORT :: C_CHAR, C_INT IMPORT :: HID_T CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name - INTEGER, VALUE :: access_flags + INTEGER(C_INT), VALUE :: access_flags INTEGER(HID_T), VALUE :: creation_prp_default INTEGER(HID_T), VALUE :: access_prp_default END FUNCTION H5Fcreate @@ -137,7 +137,7 @@ END FUNCTION H5Fcreate IF (PRESENT(creation_prp)) creation_prp_default = creation_prp IF (PRESENT(access_prp)) access_prp_default = access_prp - file_id = h5fcreate(c_name, access_flags, & + file_id = h5fcreate(c_name, INT(access_flags, C_INT), & creation_prp_default, access_prp_default) hdferr = 0 diff --git a/fortran/src/H5Lff.F90 b/fortran/src/H5Lff.F90 index 004e5b23fdd..50a605a67db 100644 --- a/fortran/src/H5Lff.F90 +++ b/fortran/src/H5Lff.F90 @@ -1555,7 +1555,7 @@ INTEGER(C_INT) FUNCTION H5Lvisit(grp_id, idx_type, order, op, op_data) BIND(C, N END FUNCTION H5Lvisit END INTERFACE - return_value_c = INT(H5Lvisit(grp_id, INT(idx_type, C_INT), INT(order, C_INT), op, op_data)) + return_value_c = H5Lvisit(grp_id, INT(idx_type, C_INT), INT(order, C_INT), op, op_data) return_value = INT(return_value_c) IF(return_value.GE.0)THEN @@ -1624,7 +1624,7 @@ END FUNCTION H5Lvisit_by_name lapl_id_default = H5P_DEFAULT_F IF(PRESENT(lapl_id)) lapl_id_default = lapl_id - return_value_c = INT(H5Lvisit_by_name(loc_id, c_name, INT(idx_type, C_INT), INT(order, C_INT), op, op_data, lapl_id_default)) + return_value_c = H5Lvisit_by_name(loc_id, c_name, INT(idx_type, C_INT), INT(order, C_INT), op, op_data, lapl_id_default) return_value = INT(return_value_c) IF(return_value.GE.0)THEN diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index 87e6bfbebe6..17045a25570 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -2931,7 +2931,7 @@ h5pset_fapl_multi_c(hid_t_f *prp_id, int_f *memb_map, hid_t_f *memb_fapl, _fcd m * Check that we got correct values from Fortran for memb_addr array */ for (i = 0; i < H5FD_MEM_NTYPES; i++) { - if (memb_addr[i] >= 1.0f) + if (memb_addr[i] >= (real_f)1.0) return ret_value; } /* @@ -4598,7 +4598,7 @@ h5pget_file_image_c(hid_t_f *fapl_id, void **buf_ptr, size_t_f *buf_len_ptr) * SOURCE */ int_f -h5pset_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info) +h5pset_fapl_mpio_c(hid_t_f *prp_id, void *comm, void *info) /******/ { int ret_value = -1; @@ -4606,8 +4606,8 @@ h5pset_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info) herr_t ret; MPI_Comm c_comm; MPI_Info c_info; - c_comm = MPI_Comm_f2c(*comm); - c_info = MPI_Info_f2c(*info); + c_comm = MPI_Comm_f2c(*((int *)comm)); + c_info = MPI_Info_f2c(*((int *)info)); /* * Call H5Pset_mpi function. @@ -4633,7 +4633,7 @@ h5pset_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info) * SOURCE */ int_f -h5pget_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info) +h5pget_fapl_mpio_c(hid_t_f *prp_id, int *comm, int *info) /******/ { int ret_value = -1; @@ -4649,8 +4649,8 @@ h5pget_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info) ret = H5Pget_fapl_mpio(c_prp_id, &c_comm, &c_info); if (ret < 0) return ret_value; - *comm = (int_f)MPI_Comm_c2f(c_comm); - *info = (int_f)MPI_Info_c2f(c_info); + *comm = (int)MPI_Comm_c2f(c_comm); + *info = (int)MPI_Info_c2f(c_info); ret_value = 0; return ret_value; } @@ -4669,7 +4669,7 @@ h5pget_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info) * SOURCE */ int_f -h5pset_mpi_params_c(hid_t_f *prp_id, int_f *comm, int_f *info) +h5pset_mpi_params_c(hid_t_f *prp_id, void *comm, void *info) /******/ { int ret_value = -1; @@ -4677,8 +4677,8 @@ h5pset_mpi_params_c(hid_t_f *prp_id, int_f *comm, int_f *info) herr_t ret; MPI_Comm c_comm; MPI_Info c_info; - c_comm = MPI_Comm_f2c(*comm); - c_info = MPI_Info_f2c(*info); + c_comm = MPI_Comm_f2c(*((int *)comm)); + c_info = MPI_Info_f2c(*((int *)info)); /* * Call H5Pset_mpi_params. @@ -4705,7 +4705,7 @@ h5pset_mpi_params_c(hid_t_f *prp_id, int_f *comm, int_f *info) * SOURCE */ int_f -h5pget_mpi_params_c(hid_t_f *prp_id, int_f *comm, int_f *info) +h5pget_mpi_params_c(hid_t_f *prp_id, int *comm, int *info) /******/ { int ret_value = -1; @@ -4721,8 +4721,8 @@ h5pget_mpi_params_c(hid_t_f *prp_id, int_f *comm, int_f *info) ret = H5Pget_mpi_params(c_prp_id, &c_comm, &c_info); if (ret < 0) return ret_value; - *comm = (int_f)MPI_Comm_c2f(c_comm); - *info = (int_f)MPI_Info_c2f(c_info); + *comm = (int)MPI_Comm_c2f(c_comm); + *info = (int)MPI_Info_c2f(c_info); ret_value = 0; return ret_value; } diff --git a/fortran/src/H5Pff.F90 b/fortran/src/H5Pff.F90 index ab6765a8874..f5e50c90383 100644 --- a/fortran/src/H5Pff.F90 +++ b/fortran/src/H5Pff.F90 @@ -39,6 +39,13 @@ MODULE H5P +#ifdef H5_HAVE_PARALLEL +#ifdef H5_HAVE_MPI_F08 + USE MPI_F08, ONLY : MPI_INTEGER_KIND +#else + USE MPI, ONLY : MPI_INTEGER_KIND +#endif +#endif USE H5GLOBAL USE H5fortkit @@ -50,6 +57,7 @@ MODULE H5P PRIVATE h5pregister_integer, h5pregister_ptr PRIVATE h5pinsert_integer, h5pinsert_char, h5pinsert_ptr #ifdef H5_HAVE_PARALLEL + PRIVATE MPI_INTEGER_KIND PRIVATE h5pset_fapl_mpio_f90, h5pget_fapl_mpio_f90 #ifdef H5_HAVE_MPI_F08 PRIVATE h5pset_fapl_mpio_f08, h5pget_fapl_mpio_f08 @@ -5182,8 +5190,8 @@ END SUBROUTINE h5pget_file_image_f SUBROUTINE h5pset_fapl_mpio_f(prp_id, comm, info, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: comm - INTEGER, INTENT(IN) :: info + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(IN) :: comm + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(IN) :: info INTEGER, INTENT(OUT) :: hdferr END SUBROUTINE h5pset_fapl_mpio_f !> @@ -5213,17 +5221,17 @@ END SUBROUTINE h5pset_fapl_mpio_f SUBROUTINE h5pset_fapl_mpio_f90(prp_id, comm, info, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: comm - INTEGER, INTENT(IN) :: info + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(IN) :: comm + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(IN) :: info INTEGER, INTENT(OUT) :: hdferr INTERFACE INTEGER FUNCTION h5pset_fapl_mpio_c(prp_id, comm, info) & BIND(C,NAME='h5pset_fapl_mpio_c') - IMPORT :: HID_T + IMPORT :: HID_T, MPI_INTEGER_KIND IMPLICIT NONE INTEGER(HID_T) :: prp_id - INTEGER :: comm - INTEGER :: info + INTEGER(KIND=MPI_INTEGER_KIND) :: comm + INTEGER(KIND=MPI_INTEGER_KIND) :: info END FUNCTION h5pset_fapl_mpio_c END INTERFACE @@ -5240,7 +5248,7 @@ SUBROUTINE h5pset_fapl_mpio_f08(prp_id, comm, info, hdferr) TYPE(MPI_INFO), INTENT(IN) :: info INTEGER, INTENT(OUT) :: hdferr - CALL h5pset_fapl_mpio_f90(prp_id, comm%mpi_val, info%mpi_val, hdferr) + CALL h5pset_fapl_mpio_f90(prp_id, INT(comm%mpi_val,MPI_INTEGER_KIND), INT(info%mpi_val,MPI_INTEGER_KIND), hdferr) END SUBROUTINE h5pset_fapl_mpio_f08 #endif @@ -5298,21 +5306,28 @@ END SUBROUTINE h5pget_fapl_mpio_f SUBROUTINE h5pget_fapl_mpio_f90(prp_id, comm, info, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(OUT) :: comm - INTEGER, INTENT(OUT) :: info + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(OUT) :: comm + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(OUT) :: info INTEGER, INTENT(OUT) :: hdferr + + INTEGER(KIND=C_INT) :: c_comm + INTEGER(KIND=C_INT) :: c_info + INTERFACE INTEGER FUNCTION h5pget_fapl_mpio_c(prp_id, comm, info) & BIND(C,NAME='h5pget_fapl_mpio_c') - IMPORT :: HID_T + IMPORT :: HID_T, C_INT IMPLICIT NONE INTEGER(HID_T) :: prp_id - INTEGER :: comm - INTEGER :: info + INTEGER(KIND=C_INT) :: comm + INTEGER(KIND=C_INT) :: info END FUNCTION h5pget_fapl_mpio_c END INTERFACE - hdferr = h5pget_fapl_mpio_c(prp_id, comm, info) + hdferr = h5pget_fapl_mpio_c(prp_id, c_comm, c_info) + + comm = INT(c_comm,KIND=MPI_INTEGER_KIND) + info = INT(c_info,KIND=MPI_INTEGER_KIND) END SUBROUTINE h5pget_fapl_mpio_f90 @@ -5325,7 +5340,13 @@ SUBROUTINE h5pget_fapl_mpio_f08(prp_id, comm, info, hdferr) TYPE(MPI_INFO), INTENT(OUT) :: info INTEGER, INTENT(OUT) :: hdferr - CALL h5pget_fapl_mpio_f90(prp_id, comm%mpi_val, info%mpi_val, hdferr) + INTEGER(KIND=MPI_INTEGER_KIND) :: tmp_comm + INTEGER(KIND=MPI_INTEGER_KIND) :: tmp_info + + CALL h5pget_fapl_mpio_f90(prp_id, tmp_comm, tmp_info, hdferr) + + comm%mpi_val = tmp_comm + info%mpi_val = tmp_info END SUBROUTINE h5pget_fapl_mpio_f08 #endif @@ -5532,8 +5553,8 @@ END SUBROUTINE h5pget_mpio_no_collective_cause_f SUBROUTINE H5Pset_mpi_params_f(prp_id, comm, info, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER , INTENT(IN) :: comm - INTEGER , INTENT(IN) :: info + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(IN) :: comm + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(IN) :: info INTEGER , INTENT(OUT) :: hdferr END SUBROUTINE H5Pset_mpi_params_f !> @@ -5563,18 +5584,18 @@ END SUBROUTINE H5Pset_mpi_params_f SUBROUTINE H5Pset_mpi_params_f90(prp_id, comm, info, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER , INTENT(IN) :: comm - INTEGER , INTENT(IN) :: info + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(IN) :: comm + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(IN) :: info INTEGER , INTENT(OUT) :: hdferr INTERFACE INTEGER FUNCTION h5pset_mpi_params_c(prp_id, comm, info) & BIND(C,NAME='h5pset_mpi_params_c') - IMPORT :: HID_T + IMPORT :: HID_T, MPI_INTEGER_KIND IMPLICIT NONE INTEGER(HID_T) :: prp_id - INTEGER :: comm - INTEGER :: info + INTEGER(KIND=MPI_INTEGER_KIND) :: comm + INTEGER(KIND=MPI_INTEGER_KIND) :: info END FUNCTION H5pset_mpi_params_c END INTERFACE @@ -5614,8 +5635,8 @@ END SUBROUTINE H5Pset_mpi_params_f08 SUBROUTINE H5Pget_mpi_params_f(prp_id, comm, info, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER , INTENT(OUT) :: comm - INTEGER , INTENT(OUT) :: info + INTEGER, INTENT(OUT) :: comm + INTEGER, INTENT(OUT) :: info INTEGER , INTENT(OUT) :: hdferr END SUBROUTINE H5Pget_mpi_params_f !> @@ -5647,22 +5668,28 @@ END SUBROUTINE H5Pget_mpi_params_f SUBROUTINE H5Pget_mpi_params_f90(prp_id, comm, info, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER , INTENT(OUT) :: comm - INTEGER , INTENT(OUT) :: info + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(OUT) :: comm + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(OUT) :: info INTEGER , INTENT(OUT) :: hdferr + INTEGER(KIND=C_INT) :: c_comm + INTEGER(KIND=C_INT) :: c_info + INTERFACE INTEGER FUNCTION h5pget_mpi_params_c(prp_id, comm, info) & BIND(C,NAME='h5pget_mpi_params_c') - IMPORT :: HID_T + IMPORT :: HID_T, C_INT IMPLICIT NONE INTEGER(HID_T) :: prp_id - INTEGER :: comm - INTEGER :: info + INTEGER(KIND=C_INT) :: comm + INTEGER(KIND=C_INT) :: info END FUNCTION H5pget_mpi_params_c END INTERFACE - hdferr = H5Pget_mpi_params_c(prp_id, comm, info) + hdferr = H5Pget_mpi_params_c(prp_id, c_comm, c_info) + + comm = INT(c_comm,KIND=MPI_INTEGER_KIND) + info = INT(c_info,KIND=MPI_INTEGER_KIND) END SUBROUTINE H5Pget_mpi_params_f90 @@ -5675,7 +5702,13 @@ SUBROUTINE H5Pget_mpi_params_f08(prp_id, comm, info, hdferr) TYPE(MPI_INFO), INTENT(OUT) :: info INTEGER , INTENT(OUT) :: hdferr - CALL H5Pget_mpi_params_f90(prp_id, comm%mpi_val, info%mpi_val, hdferr) + INTEGER(KIND=MPI_INTEGER_KIND) :: tmp_comm + INTEGER(KIND=MPI_INTEGER_KIND) :: tmp_info + + CALL H5Pget_mpi_params_f90(prp_id, tmp_comm, tmp_info, hdferr) + + comm%mpi_val = tmp_comm + info%mpi_val = tmp_info END SUBROUTINE H5Pget_mpi_params_f08 #endif diff --git a/fortran/src/H5Sf.c b/fortran/src/H5Sf.c index 41616f81dff..22130fc9bd8 100644 --- a/fortran/src/H5Sf.c +++ b/fortran/src/H5Sf.c @@ -55,7 +55,7 @@ h5screate_simple_c(int_f *rank, hsize_t_f *dims, hsize_t_f *maxdims, hid_t_f *sp c_maxdims[i] = maxdims[*rank - i - 1]; } /* end for */ - c_space_id = H5Screate_simple(*rank, c_dims, c_maxdims); + c_space_id = H5Screate_simple((int)*rank, c_dims, c_maxdims); if (c_space_id < 0) HGOTO_DONE(FAIL); diff --git a/fortran/src/H5config_f.inc.cmake b/fortran/src/H5config_f.inc.cmake index 44da2befead..31c149883cf 100644 --- a/fortran/src/H5config_f.inc.cmake +++ b/fortran/src/H5config_f.inc.cmake @@ -79,8 +79,13 @@ ! Define if Fortran C_BOOL is different from default LOGICAL #define H5_FORTRAN_C_BOOL_IS_UNIQUE @H5_FORTRAN_C_BOOL_IS_UNIQUE@ -! Define if the intrinsic module ISO_FORTRAN_ENV exists -#define H5_HAVE_ISO_FORTRAN_ENV @H5_HAVE_ISO_FORTRAN_ENV@ +! Define if Fortran supports ISO_FORTRAN_ENV (F08) +#cmakedefine01 CMAKE_H5_HAVE_ISO_FORTRAN_ENV +#if CMAKE_H5_HAVE_ISO_FORTRAN_ENV == 0 +#undef H5_HAVE_ISO_FORTRAN_ENV +#else +#define H5_HAVE_ISO_FORTRAN_ENV +#endif ! Define the size of C's double #define H5_SIZEOF_DOUBLE @H5_SIZEOF_DOUBLE@ diff --git a/fortran/src/H5config_f.inc.in b/fortran/src/H5config_f.inc.in index cb2ec185735..6e465ca014b 100644 --- a/fortran/src/H5config_f.inc.in +++ b/fortran/src/H5config_f.inc.in @@ -47,7 +47,7 @@ ! Define if Fortran C_BOOL is different from default LOGICAL #undef FORTRAN_C_BOOL_IS_UNIQUE -! Define if the intrinsic module ISO_FORTRAN_ENV exists +! Define if Fortran supports ISO_FORTRAN_ENV (F08) #undef HAVE_ISO_FORTRAN_ENV ! Define the size of C's double diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index 0da371f5e17..71d914c1d26 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -518,10 +518,10 @@ H5_FCDLL int_f h5pget_chunk_cache_c(hid_t_f *dapl_id, size_t_f *rdcc_nslots, siz real_f *rdcc_w0); #ifdef H5_HAVE_PARALLEL H5_FCDLL int_f h5pget_mpio_actual_io_mode_c(hid_t_f *dxpl_id, int_f *actual_io_mode); -H5_FCDLL int_f h5pget_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info); -H5_FCDLL int_f h5pset_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info); -H5_FCDLL int_f h5pget_mpi_params_c(hid_t_f *prp_id, int_f *comm, int_f *info); -H5_FCDLL int_f h5pset_mpi_params_c(hid_t_f *prp_id, int_f *comm, int_f *info); +H5_FCDLL int_f h5pget_fapl_mpio_c(hid_t_f *prp_id, int *comm, int *info); +H5_FCDLL int_f h5pset_fapl_mpio_c(hid_t_f *prp_id, void *comm, void *info); +H5_FCDLL int_f h5pget_mpi_params_c(hid_t_f *prp_id, int *comm, int *info); +H5_FCDLL int_f h5pset_mpi_params_c(hid_t_f *prp_id, void *comm, void *info); H5_FCDLL int_f h5pget_dxpl_mpio_c(hid_t_f *prp_id, int_f *data_xfer_mode); H5_FCDLL int_f h5pset_dxpl_mpio_c(hid_t_f *prp_id, int_f *data_xfer_mode); #endif diff --git a/fortran/test/tH5A.F90 b/fortran/test/tH5A.F90 index 23b1addd3ce..ff7ee60053e 100644 --- a/fortran/test/tH5A.F90 +++ b/fortran/test/tH5A.F90 @@ -100,12 +100,11 @@ SUBROUTINE attribute_test(cleanup, total_error) CHARACTER(LEN=35), DIMENSION(2) :: aread_data ! Buffer to put read back ! string attr data CHARACTER :: attr_character_data = 'A' - REAL(KIND=Fortran_DOUBLE), DIMENSION(1) :: attr_double_data = 3.459D0 + REAL(KIND=Fortran_DOUBLE), DIMENSION(1) :: attr_double_data = 3.459_Fortran_DOUBLE REAL, DIMENSION(1) :: attr_real_data = 4.0 INTEGER, DIMENSION(1) :: attr_integer_data = 5 INTEGER(HSIZE_T), DIMENSION(7) :: data_dims - CHARACTER :: aread_character_data ! variable to put read back Character attr data INTEGER, DIMENSION(1) :: aread_integer_data ! variable to put read back integer attr data INTEGER, DIMENSION(1) :: aread_null_data = 7 ! variable to put read back null attr data @@ -577,8 +576,6 @@ SUBROUTINE attribute_test(cleanup, total_error) total_error = total_error +1 END IF - - CALL h5sclose_f(attr_space, error) CALL check("h5sclose_f",error,total_error) CALL h5sclose_f(attr2_space, error) diff --git a/fortran/test/tH5E_F03.F90 b/fortran/test/tH5E_F03.F90 index b538e20c530..7060d2ee617 100644 --- a/fortran/test/tH5E_F03.F90 +++ b/fortran/test/tH5E_F03.F90 @@ -298,7 +298,8 @@ SUBROUTINE test_error_stack(total_error) ! push a custom error message onto the stack CALL H5Epush_f(estack_id, file, func, line, & cls_id, major, minor, "%s ERROR TEXT %s %s %s", error, & - arg1=ACHAR(27)//"[31m", arg2=ACHAR(27)//"[0m", arg3=ACHAR(0), arg4=ACHAR(10) ) + arg1=ACHAR(27)//"[31m"//C_NULL_CHAR, arg2=ACHAR(27)//"[0m"//C_NULL_CHAR, & + arg3=ACHAR(0)//C_NULL_CHAR, arg4=ACHAR(10)//C_NULL_CHAR ) CALL check("H5Epush_f", error, total_error) CALL h5eget_num_f(estack_id, count, error) diff --git a/fortran/test/tH5L_F03.F90 b/fortran/test/tH5L_F03.F90 index a8345c3ca58..a4ece4d7fe4 100644 --- a/fortran/test/tH5L_F03.F90 +++ b/fortran/test/tH5L_F03.F90 @@ -162,7 +162,7 @@ INTEGER(KIND=C_INT) FUNCTION lvisit_cb(group, name, link_info, op_data) bind(C) INTEGER :: nlen, i, istart, iend - op_data%n_obj = op_data%n_obj + 1 + op_data%n_obj = op_data%n_obj + 1_C_INT nlen = 1 DO i = 1, MAX_CHAR_LEN diff --git a/fortran/test/tH5O_F03.F90 b/fortran/test/tH5O_F03.F90 index a4cf282ecca..f9cad325f3b 100644 --- a/fortran/test/tH5O_F03.F90 +++ b/fortran/test/tH5O_F03.F90 @@ -118,10 +118,10 @@ INTEGER FUNCTION compare_h5o_info_t( loc_id, oinfo_f, oinfo_c, field, full_f_fie IF((field .EQ. H5O_INFO_TIME_F).OR.(field .EQ. H5O_INFO_ALL_F))THEN - atime(1:8) = h5gmtime(oinfo_c%atime) - btime(1:8) = h5gmtime(oinfo_c%btime) - ctime(1:8) = h5gmtime(oinfo_c%ctime) - mtime(1:8) = h5gmtime(oinfo_c%mtime) + atime(1:8) = INT(h5gmtime(oinfo_c%atime),C_INT) + btime(1:8) = INT(h5gmtime(oinfo_c%btime),C_INT) + ctime(1:8) = INT(h5gmtime(oinfo_c%ctime),C_INT) + mtime(1:8) = INT(h5gmtime(oinfo_c%mtime),C_INT) DO i = 1, 8 IF( (atime(i) .NE. oinfo_f%atime(i)) )THEN diff --git a/fortran/test/tH5T_F03.F90 b/fortran/test/tH5T_F03.F90 index 65804d0d091..a59cd73f751 100644 --- a/fortran/test/tH5T_F03.F90 +++ b/fortran/test/tH5T_F03.F90 @@ -709,8 +709,8 @@ SUBROUTINE test_array_bkg(total_error) DO i = 1, LENGTH DO j = 1, ALEN cf(i)%a(j) = 100*(i+1) + j - cf(i)%b(j) = (100.*(i+1) + 0.01*j) - cf(i)%c(j) = 100.*(i+1) + 0.02*j + cf(i)%b(j) = (100._sp*REAL(i+1,sp) + 0.01_sp*REAL(j,sp)) + cf(i)%c(j) = 100._dp*REAL(i+1,dp) + 0.02_dp*REAL(j,dp) ENDDO ENDDO @@ -855,7 +855,7 @@ SUBROUTINE test_array_bkg(total_error) ! -------------------------------- DO i = 1, LENGTH DO j = 1, ALEN - fld(i)%b(j) = 1.313 + fld(i)%b(j) = 1.313_sp cf(i)%b(j) = fld(i)%b(j) ENDDO ENDDO @@ -2930,8 +2930,8 @@ SUBROUTINE test_nbit(total_error ) ! dataset datatype (no precision loss during datatype conversion) ! REAL(kind=wp), DIMENSION(1:2,1:5), TARGET :: orig_data = & - RESHAPE( (/188384.00, 19.103516, -1.0831790e9, -84.242188, & - 5.2045898, -49140.000, 2350.2500, -3.2110596e-1, 6.4998865e-5, -0.0000000/) , (/2,5/) ) + RESHAPE( (/188384.00_wp, 19.103516_wp, -1.0831790e9_wp, -84.242188_wp, & + 5.2045898_wp, -49140.000_wp, 2350.2500_wp, -3.2110596e-1_wp, 6.4998865e-5_wp, -0.0000000_wp/) , (/2,5/) ) REAL(kind=wp), DIMENSION(1:2,1:5), TARGET :: new_data INTEGER(size_t) :: PRECISION, offset INTEGER :: error diff --git a/fortran/testpar/async.F90 b/fortran/testpar/async.F90 index 5c7411f6ddb..aa2416fd24d 100644 --- a/fortran/testpar/async.F90 +++ b/fortran/testpar/async.F90 @@ -13,9 +13,15 @@ ! Tests async Fortran wrappers. It needs an async VOL. It will skip the tests if ! HDF5_VOL_CONNECTOR is not set or is set to a non-supporting async VOL. ! +#include + MODULE test_async_APIs +#ifdef H5_HAVE_MPI_F08 + USE MPI_F08 +#else USE MPI +#endif USE HDF5 USE TH5_MISC USE TH5_MISC_GEN @@ -40,6 +46,8 @@ MODULE test_async_APIs CHARACTER(LEN=10), TARGET :: app_func = "func_name"//C_NULL_CHAR INTEGER :: app_line = 42 + INTEGER :: mpi_ikind = MPI_INTEGER_KIND + CONTAINS INTEGER(KIND=C_INT) FUNCTION liter_cb(group, name, link_info, op_data) bind(C) @@ -60,7 +68,7 @@ INTEGER(KIND=C_INT) FUNCTION liter_cb(group, name, link_info, op_data) bind(C) CASE(0) liter_cb = 0 CASE(2) - liter_cb = op_data%command*10 + liter_cb = op_data%command*10_C_INT END SELECT op_data%command = op_data_command op_data%type = op_data_type @@ -381,9 +389,14 @@ SUBROUTINE H5D_async_tests(cleanup, total_error) INTEGER, TARGET :: fillvalue = 99 INTEGER :: error ! Error flags - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm, info - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag +#ifdef H5_HAVE_MPI_F08 + TYPE(MPI_COMM) :: comm + TYPE(MPI_INFO) :: info +#else + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, info +#endif + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank comm = MPI_COMM_WORLD info = MPI_INFO_NULL @@ -399,7 +412,7 @@ SUBROUTINE H5D_async_tests(cleanup, total_error) CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl_id, hdferror) CALL check("h5pcreate_f", hdferror, total_error) - CALL h5pset_fapl_mpio_f(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL, hdferror) + CALL h5pset_fapl_mpio_f(fapl_id, comm, info, hdferror) CALL check("h5pset_fapl_mpio_f", hdferror, total_error) CALL h5fcreate_async_f(filename, H5F_ACC_TRUNC_F, file_id, es_id, error, access_prp = fapl_id ) @@ -581,9 +594,14 @@ SUBROUTINE H5G_async_tests(cleanup, total_error) TYPE(H5G_info_t), DIMENSION(1:3) :: ginfo INTEGER :: error - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm, info - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag +#ifdef H5_HAVE_MPI_F08 + TYPE(MPI_COMM) :: comm + TYPE(MPI_INFO) :: info +#else + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, info +#endif + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank comm = MPI_COMM_WORLD info = MPI_INFO_NULL @@ -709,9 +727,14 @@ SUBROUTINE H5F_async_tests(cleanup, total_error) INTEGER(HID_T) :: ret_file_id INTEGER :: error ! Error flags - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm, info - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag +#ifdef H5_HAVE_MPI_F08 + TYPE(MPI_COMM) :: comm + TYPE(MPI_INFO) :: info +#else + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, info +#endif + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank comm = MPI_COMM_WORLD info = MPI_INFO_NULL @@ -812,12 +835,16 @@ SUBROUTINE H5L_async_tests(cleanup, total_error) TYPE(iter_info), TARGET :: info TYPE(C_FUNPTR) :: f1 TYPE(C_PTR) :: f2 - INTEGER(C_INT) :: ret_value + INTEGER :: ret_value INTEGER :: error ! Error flags - INTEGER :: mpierror ! MPI error flag - INTEGER :: comm - INTEGER :: mpi_size, mpi_rank + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI error flag +#ifdef H5_HAVE_MPI_F08 + TYPE(MPI_COMM) :: comm +#else + INTEGER(KIND=MPI_INTEGER_KIND) :: comm +#endif + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_rank INTEGER(SIZE_T) :: count @@ -1211,10 +1238,10 @@ SUBROUTINE H5O_async_tests(cleanup, total_error) CALL check("H5Oget_info_by_name_async_f", hdferror, total_error) ENDIF - atime(1:8) = h5gmtime(oinfo_f%atime) - btime(1:8) = h5gmtime(oinfo_f%btime) - ctime(1:8) = h5gmtime(oinfo_f%ctime) - mtime(1:8) = h5gmtime(oinfo_f%mtime) + atime(1:8) = INT(h5gmtime(oinfo_f%atime),C_INT) + btime(1:8) = INT(h5gmtime(oinfo_f%btime),C_INT) + ctime(1:8) = INT(h5gmtime(oinfo_f%ctime),C_INT) + mtime(1:8) = INT(h5gmtime(oinfo_f%mtime),C_INT) IF( atime(1) .LT. 2021 .OR. & btime(1).LT. 2021 .OR. & @@ -1244,10 +1271,15 @@ PROGRAM async_test IMPLICIT NONE INTEGER :: total_error = 0 ! sum of the number of errors - INTEGER :: mpierror ! MPI hdferror flag - INTEGER :: mpi_size ! number of processes in the group of communicator - INTEGER :: mpi_rank ! rank of the calling process in the communicator - INTEGER :: required, provided + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI hdferror flag + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size ! number of processes in the group of communicator + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank ! rank of the calling process in the communicator + INTEGER(KIND=MPI_INTEGER_KIND) :: required, provided +#ifdef H5_HAVE_MPI_F08 + TYPE(MPI_DATATYPE) :: mpi_int_type +#else + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_int_type +#endif INTEGER(HID_T) :: vol_id INTEGER :: hdferror @@ -1290,7 +1322,7 @@ PROGRAM async_test IF(mpi_rank==0) CALL write_test_status(sum, & 'Testing Initializing mpi_init_thread', total_error) CALL MPI_Barrier(MPI_COMM_WORLD, mpierror) - CALL mpi_abort(MPI_COMM_WORLD, 1, mpierror) + CALL mpi_abort(MPI_COMM_WORLD, 1_MPI_INTEGER_KIND, mpierror) ENDIF IF(mpi_rank==0) CALL write_test_header("ASYNC FORTRAN TESTING") @@ -1408,7 +1440,13 @@ PROGRAM async_test ! CALL h5close_f(hdferror) - CALL MPI_ALLREDUCE(total_error, sum, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, mpierror) + IF(h5_sizeof(total_error).EQ.8_size_t)THEN + mpi_int_type=MPI_INTEGER8 + ELSE + mpi_int_type=MPI_INTEGER4 + ENDIF + + CALL MPI_ALLREDUCE(total_error, sum, 1_MPI_INTEGER_KIND, mpi_int_type, MPI_SUM, MPI_COMM_WORLD, mpierror) IF(mpi_rank==0) CALL write_test_footer() @@ -1422,7 +1460,7 @@ PROGRAM async_test ENDIF ELSE WRITE(*,*) 'Errors detected in process ', mpi_rank - CALL mpi_abort(MPI_COMM_WORLD, 1, mpierror) + CALL mpi_abort(MPI_COMM_WORLD, 1_MPI_INTEGER_KIND, mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_ABORT *FAILED* Process = ", mpi_rank ENDIF diff --git a/fortran/testpar/hyper.F90 b/fortran/testpar/hyper.F90 index ec3a657afbb..61a3e260797 100644 --- a/fortran/testpar/hyper.F90 +++ b/fortran/testpar/hyper.F90 @@ -25,8 +25,8 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) INTEGER, INTENT(in) :: length ! array length LOGICAL, INTENT(in) :: do_collective ! use collective I/O LOGICAL, INTENT(in) :: do_chunk ! use chunking - INTEGER, INTENT(in) :: mpi_size ! number of processes in the group of communicator - INTEGER, INTENT(in) :: mpi_rank ! rank of the calling process in the communicator + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_size ! number of processes in the group of communicator + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_rank ! rank of the calling process in the communicator INTEGER, INTENT(inout) :: nerrors ! number of errors INTEGER :: hdferror ! HDF hdferror flag INTEGER(hsize_t), DIMENSION(1) :: dims ! dataset dimensions diff --git a/fortran/testpar/mdset.F90 b/fortran/testpar/mdset.F90 index 6757f4d7491..95e401137e6 100644 --- a/fortran/testpar/mdset.F90 +++ b/fortran/testpar/mdset.F90 @@ -25,8 +25,8 @@ SUBROUTINE multiple_dset_write(length, do_collective, do_chunk, mpi_size, mpi_ra INTEGER, INTENT(in) :: length ! array length LOGICAL, INTENT(in) :: do_collective ! use collective I/O LOGICAL, INTENT(in) :: do_chunk ! use chunking - INTEGER, INTENT(in) :: mpi_size ! number of processes in the group of communicator - INTEGER, INTENT(in) :: mpi_rank ! rank of the calling process in the communicator + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_size ! number of processes in the group of communicator + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_rank ! rank of the calling process in the communicator INTEGER, INTENT(inout) :: nerrors ! number of errors INTEGER :: hdferror ! HDF hdferror flag INTEGER(hsize_t), DIMENSION(1) :: dims ! dataset dimensions diff --git a/fortran/testpar/mpi_param.F90 b/fortran/testpar/mpi_param.F90 index ba4eaaae963..09a95d47177 100644 --- a/fortran/testpar/mpi_param.F90 +++ b/fortran/testpar/mpi_param.F90 @@ -18,24 +18,32 @@ SUBROUTINE mpi_param_03(nerrors) +#ifdef H5_HAVE_ISO_FORTRAN_ENV + USE, INTRINSIC :: iso_fortran_env, ONLY : atomic_logical_kind +#endif USE MPI USE HDF5 USE TH5_MISC USE TH5_MISC_GEN IMPLICIT NONE + INTEGER, INTENT(inout) :: nerrors ! number of errors INTEGER :: hdferror ! HDF hdferror flag INTEGER(hid_t) :: fapl_id ! file access identifier - INTEGER :: mpi_size, mpi_size_ret ! number of processes in the group of communicator - INTEGER :: mpierror ! MPI hdferror flag - INTEGER :: mpi_rank ! rank of the calling process in the communicator - - INTEGER :: info, info_ret - INTEGER :: comm, comm_ret - INTEGER :: nkeys - LOGICAL :: flag + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_size_ret ! number of processes in the group of communicator + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI hdferror flag + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank ! rank of the calling process in the communicator + + INTEGER(KIND=MPI_INTEGER_KIND) :: info, info_ret + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, comm_ret + INTEGER(KIND=MPI_INTEGER_KIND) :: nkeys +#ifdef H5_HAVE_ISO_FORTRAN_ENV + LOGICAL(KIND=atomic_logical_kind) :: flag +#else + LOGICAL(KIND=MPI_INTEGER_KIND) :: flag +#endif INTEGER :: iconfig CHARACTER(LEN=4) , PARAMETER :: in_key="host" CHARACTER(LEN=10), PARAMETER :: in_value="myhost.org" @@ -62,13 +70,13 @@ SUBROUTINE mpi_param_03(nerrors) ! Split the communicator IF(mpi_rank.EQ.0)THEN - CALL MPI_Comm_split(MPI_COMM_WORLD, 1, mpi_rank, comm, mpierror) + CALL MPI_Comm_split(MPI_COMM_WORLD, 1_MPI_INTEGER_KIND, mpi_rank, comm, mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_COMM_SPLIT *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 ENDIF ELSE - CALL MPI_Comm_split(MPI_COMM_WORLD, 0, mpi_rank, comm, mpierror) + CALL MPI_Comm_split(MPI_COMM_WORLD, 0_MPI_INTEGER_KIND, mpi_rank, comm, mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_COMM_SPLIT *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 @@ -111,9 +119,9 @@ SUBROUTINE mpi_param_03(nerrors) nerrors = nerrors + 1 ENDIF IF (mpi_rank.EQ.0)THEN - CALL VERIFY("h5pget_fapl_mpio_f", mpi_size_ret, 1, hdferror) + CALL VERIFY("h5pget_fapl_mpio_f", mpi_size_ret, 1_MPI_INTEGER_KIND, hdferror) ELSE - CALL VERIFY("h5pget_fapl_mpio_f", mpi_size_ret, mpi_size-1, hdferror) + CALL VERIFY("h5pget_fapl_mpio_f", mpi_size_ret, INT(mpi_size-1,MPI_INTEGER_KIND), hdferror) ENDIF ! Check info returned @@ -122,9 +130,9 @@ SUBROUTINE mpi_param_03(nerrors) WRITE(*,*) "MPI_INFO_GET_NKEYS *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 ENDIF - CALL VERIFY("h5pget_fapl_mpio_f", nkeys, 1, hdferror) + CALL VERIFY("h5pget_fapl_mpio_f", nkeys, 1_MPI_INTEGER_KIND, hdferror) - CALL MPI_Info_get_nthkey(info_ret, 0, key, mpierror) + CALL MPI_Info_get_nthkey(info_ret, 0_MPI_INTEGER_KIND, key, mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_INFO_GET_NTHKEY *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 @@ -136,7 +144,7 @@ SUBROUTINE mpi_param_03(nerrors) WRITE(*,*) "MPI_INFO_GET *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 ENDIF - CALL VERIFY("h5pget_fapl_mpio_f", flag, .TRUE., hdferror) + CALL VERIFY("h5pget_fapl_mpio_f", LOGICAL(flag), .TRUE., hdferror) CALL VERIFY("h5pget_fapl_mpio_f", TRIM(value), in_value, hdferror) ! Free the MPI resources @@ -171,6 +179,9 @@ SUBROUTINE mpi_param_08(nerrors) #ifdef H5_HAVE_MPI_F08 +#ifdef H5_HAVE_ISO_FORTRAN_ENV + USE, INTRINSIC :: iso_fortran_env, ONLY : atomic_logical_kind +#endif USE MPI_F08 USE HDF5 USE TH5_MISC @@ -181,14 +192,18 @@ SUBROUTINE mpi_param_08(nerrors) INTEGER :: hdferror ! HDF hdferror flag INTEGER(hid_t) :: fapl_id ! file access identifier - INTEGER :: mpi_size, mpi_size_ret ! number of processes in the group of communicator - INTEGER :: mpierror ! MPI hdferror flag - INTEGER :: mpi_rank ! rank of the calling process in the communicator + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_size_ret ! number of processes in the group of communicator + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI hdferror flag + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank ! rank of the calling process in the communicator TYPE(MPI_INFO) :: info, info_ret TYPE(MPI_COMM) :: comm, comm_ret - INTEGER :: nkeys - LOGICAL :: flag + INTEGER(KIND=MPI_INTEGER_KIND) :: nkeys +#ifdef H5_HAVE_ISO_FORTRAN_ENV + LOGICAL(KIND=atomic_logical_kind) :: flag +#else + LOGICAL(KIND=MPI_INTEGER_KIND) :: flag +#endif INTEGER :: iconfig CHARACTER(LEN=4) , PARAMETER :: in_key="host" CHARACTER(LEN=10), PARAMETER :: in_value="myhost.org" @@ -215,13 +230,13 @@ SUBROUTINE mpi_param_08(nerrors) ! Split the communicator IF(mpi_rank.EQ.0)THEN - CALL MPI_Comm_split(MPI_COMM_WORLD, 1, mpi_rank, comm, mpierror) + CALL MPI_Comm_split(MPI_COMM_WORLD, 1_MPI_INTEGER_KIND, mpi_rank, comm, mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_COMM_SPLIT *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 ENDIF ELSE - CALL MPI_Comm_split(MPI_COMM_WORLD, 0, mpi_rank, comm, mpierror) + CALL MPI_Comm_split(MPI_COMM_WORLD, 0_MPI_INTEGER_KIND, mpi_rank, comm, mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_COMM_SPLIT *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 @@ -264,9 +279,9 @@ SUBROUTINE mpi_param_08(nerrors) nerrors = nerrors + 1 ENDIF IF (mpi_rank.EQ.0)THEN - CALL VERIFY("h5pget_fapl_mpio_f", mpi_size_ret, 1, hdferror) + CALL VERIFY("h5pget_fapl_mpio_f", mpi_size_ret, 1_MPI_INTEGER_KIND, hdferror) ELSE - CALL VERIFY("h5pget_fapl_mpio_f", mpi_size_ret, mpi_size-1, hdferror) + CALL VERIFY("h5pget_fapl_mpio_f", mpi_size_ret, INT(mpi_size-1,MPI_INTEGER_KIND), hdferror) ENDIF ! Check info returned @@ -275,9 +290,9 @@ SUBROUTINE mpi_param_08(nerrors) WRITE(*,*) "MPI_INFO_GET_NKEYS *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 ENDIF - CALL VERIFY("h5pget_fapl_mpio_f", nkeys, 1, hdferror) + CALL VERIFY("h5pget_fapl_mpio_f", nkeys, 1_MPI_INTEGER_KIND, hdferror) - CALL MPI_Info_get_nthkey(info_ret, 0, key, mpierror) + CALL MPI_Info_get_nthkey(info_ret, 0_MPI_INTEGER_KIND, key, mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_INFO_GET_NTHKEY *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 @@ -289,7 +304,7 @@ SUBROUTINE mpi_param_08(nerrors) WRITE(*,*) "MPI_INFO_GET *FAILED* Process = ", mpi_rank nerrors = nerrors + 1 ENDIF - CALL VERIFY("h5pget_fapl_mpio_f", flag, .TRUE., hdferror) + CALL VERIFY("h5pget_fapl_mpio_f", LOGICAL(flag), .TRUE., hdferror) CALL VERIFY("h5pget_fapl_mpio_f", TRIM(value), in_value, hdferror) ! Free the MPI resources diff --git a/fortran/testpar/multidsetrw.F90 b/fortran/testpar/multidsetrw.F90 index e39900c9158..62eb5d1e8bb 100644 --- a/fortran/testpar/multidsetrw.F90 +++ b/fortran/testpar/multidsetrw.F90 @@ -25,8 +25,8 @@ SUBROUTINE pmultiple_dset_hyper_rw(do_collective, do_chunk, mpi_size, mpi_rank, LOGICAL, INTENT(in) :: do_collective ! use collective IO LOGICAL, INTENT(in) :: do_chunk ! use chunking - INTEGER, INTENT(in) :: mpi_size ! number of processes in the group of communicator - INTEGER, INTENT(in) :: mpi_rank ! rank of the calling process in the communicator + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_size ! number of processes in the group of communicator + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_rank ! rank of the calling process in the communicator INTEGER, INTENT(inout) :: nerrors ! number of errors CHARACTER(LEN=80):: dsetname ! Dataset name INTEGER(hsize_t), DIMENSION(1:2) :: cdims ! chunk dimensions @@ -156,6 +156,7 @@ SUBROUTINE pmultiple_dset_hyper_rw(do_collective, do_chunk, mpi_size, mpi_rank, CALL h5dwrite_multi_f(ndsets, dset_id, mem_type_id, mem_space_id, file_space_id, buf_md, error, plist_id) CALL check("h5dwrite_multi_f", error, nerrors) + return CALL h5pget_dxpl_mpio_f(plist_id, data_xfer_mode, error) CALL check("h5pget_dxpl_mpio_f", error, nerrors) diff --git a/fortran/testpar/ptest.F90 b/fortran/testpar/ptest.F90 index d2e9d105703..3d7280bbcf8 100644 --- a/fortran/testpar/ptest.F90 +++ b/fortran/testpar/ptest.F90 @@ -21,12 +21,12 @@ PROGRAM parallel_test IMPLICIT NONE - INTEGER :: mpierror ! MPI hdferror flag + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI hdferror flag INTEGER :: hdferror ! HDF hdferror flag 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(KIND=MPI_INTEGER_KIND) :: mpi_size ! number of processes in the group of communicator + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank ! rank of the calling process in the communicator INTEGER :: length = 12000 ! length of array INTEGER :: i,j, sum ! use collective MPI I/O @@ -35,6 +35,7 @@ PROGRAM parallel_test ! use chunking LOGICAL, DIMENSION(1:2) :: do_chunk = (/.FALSE.,.TRUE./) CHARACTER(LEN=10), DIMENSION(1:2) :: chr_chunk =(/"contiguous", "chunk "/) + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_int_type ! ! initialize MPI @@ -71,6 +72,7 @@ PROGRAM parallel_test ! ! 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 @@ -80,10 +82,10 @@ PROGRAM parallel_test total_error) ENDDO ENDDO - ! ! test write/read several datasets (independent MPI I/O) ! + 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, & @@ -105,7 +107,13 @@ PROGRAM parallel_test ! CALL h5close_f(hdferror) - CALL MPI_ALLREDUCE(total_error, sum, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, mpierror) + IF(h5_sizeof(total_error).EQ.8_size_t)THEN + mpi_int_type=MPI_INTEGER8 + ELSE + mpi_int_type=MPI_INTEGER4 + ENDIF + + CALL MPI_ALLREDUCE(total_error, sum, 1_MPI_INTEGER_KIND, mpi_int_type, MPI_SUM, MPI_COMM_WORLD, mpierror) IF(mpi_rank==0) CALL write_test_footer() @@ -119,7 +127,7 @@ PROGRAM parallel_test ENDIF ELSE WRITE(*,*) 'Errors detected in process ', mpi_rank - CALL mpi_abort(MPI_COMM_WORLD, 1, mpierror) + CALL mpi_abort(MPI_COMM_WORLD, 1_MPI_INTEGER_KIND, mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_ABORT *FAILED* Process = ", mpi_rank ENDIF diff --git a/fortran/testpar/subfiling.F90 b/fortran/testpar/subfiling.F90 index a677bea6121..9bee38bcc6f 100644 --- a/fortran/testpar/subfiling.F90 +++ b/fortran/testpar/subfiling.F90 @@ -18,6 +18,9 @@ PROGRAM subfiling_test USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_INT64_T +#ifdef H5_HAVE_ISO_FORTRAN_ENV + USE, INTRINSIC :: iso_fortran_env, ONLY : atomic_logical_kind +#endif USE HDF5 USE MPI USE TH5_MISC @@ -25,29 +28,33 @@ PROGRAM subfiling_test IMPLICIT NONE INTEGER :: total_error = 0 ! sum of the number of errors - INTEGER :: mpierror ! MPI hdferror flag - INTEGER :: mpi_rank ! rank of the calling process in the communicator + INTEGER(KIND=MPI_INTEGER_KIND) :: mpierror ! MPI hdferror flag + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_rank ! rank of the calling process in the communicator #ifdef H5_HAVE_SUBFILING_VFD CHARACTER(LEN=7), PARAMETER :: filename = "subf.h5" - INTEGER :: hdferror ! HDF hdferror flag - INTEGER :: mpi_size, mpi_size_ret ! number of processes in the group of communicator - INTEGER :: required, provided + INTEGER :: hdferror ! HDF hdferror flag + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_size, mpi_size_ret ! number of processes in the group of communicator + INTEGER(KIND=MPI_INTEGER_KIND) :: required, provided LOGICAL :: file_exists INTEGER(HID_T) :: fapl_id INTEGER(HID_T) :: file_id - INTEGER :: comm, comm_ret - INTEGER :: info, info_ret + INTEGER(KIND=MPI_INTEGER_KIND) :: comm, comm_ret + INTEGER(KIND=MPI_INTEGER_KIND) :: info, info_ret CHARACTER(LEN=3) :: info_val CHARACTER(LEN=180) :: subfname INTEGER :: i, sum INTEGER(C_INT64_T) inode TYPE(H5FD_subfiling_config_t) :: vfd_config TYPE(H5FD_ioc_config_t) :: vfd_config_ioc - LOGICAL :: flag +#ifdef H5_HAVE_ISO_FORTRAN_ENV + LOGICAL(KIND=atomic_logical_kind) :: flag +#else + LOGICAL(KIND=MPI_INTEGER_KIND) :: flag +#endif INTEGER :: nerrors = 0 @@ -56,6 +63,7 @@ PROGRAM subfiling_test CHARACTER(len=8) :: hex1, hex2 CHARACTER(len=1) :: arg + INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_int_type ! ! initialize MPI ! @@ -84,7 +92,7 @@ PROGRAM subfiling_test IF(mpi_rank==0) CALL write_test_status(sum, & 'Testing Initializing mpi_init_thread', total_error) CALL MPI_Barrier(MPI_COMM_WORLD, mpierror) - CALL mpi_abort(MPI_COMM_WORLD, 1, mpierror) + CALL mpi_abort(MPI_COMM_WORLD, 1_MPI_INTEGER_KIND, mpierror) ENDIF ! @@ -101,9 +109,9 @@ PROGRAM subfiling_test IF(mpi_size.GT.2)THEN IF (mpi_rank.LE.1)THEN - CALL MPI_Comm_split(MPI_COMM_WORLD, 1, mpi_rank, comm, mpierror) + CALL MPI_Comm_split(MPI_COMM_WORLD, 1_MPI_INTEGER_KIND, mpi_rank, comm, mpierror) ELSE - CALL MPI_Comm_split(MPI_COMM_WORLD, 0, mpi_rank, comm, mpierror) + CALL MPI_Comm_split(MPI_COMM_WORLD, 0_MPI_INTEGER_KIND, mpi_rank, comm, mpierror) ENDIF CALL MPI_Info_create(info, mpierror) @@ -128,8 +136,8 @@ PROGRAM subfiling_test nerrors = nerrors + 1 ENDIF - CALL mpi_info_get(info_ret,"foo", 3, info_val, flag, mpierror) - IF(flag .EQV. .TRUE.)THEN + CALL mpi_info_get(info_ret,"foo", 3_MPI_INTEGER_KIND, info_val, flag, mpierror) + IF(LOGICAL(flag) .EQV. .TRUE.)THEN IF(info_val.NE."bar")THEN IF(mpi_rank.EQ.0) & WRITE(*,*) "Failed H5Pset_mpi_params_f and H5Pget_mpi_params_f sequence" @@ -148,7 +156,13 @@ PROGRAM subfiling_test ENDIF - CALL MPI_REDUCE(nerrors, sum, 1, MPI_INTEGER, MPI_SUM, 0, MPI_COMM_WORLD, mpierror) + IF(h5_sizeof(total_error).EQ.8_size_t)THEN + mpi_int_type=MPI_INTEGER8 + ELSE + mpi_int_type=MPI_INTEGER4 + ENDIF + + CALL MPI_REDUCE(nerrors, sum, 1_MPI_INTEGER_KIND, mpi_int_type, MPI_SUM, 0_MPI_INTEGER_KIND, MPI_COMM_WORLD, mpierror) IF(mpi_rank==0) CALL write_test_status(sum, & 'Testing H5Pset/get_mpi_params_f', total_error) @@ -267,10 +281,10 @@ PROGRAM subfiling_test ! Testing modifying defaults for subfiling FD - vfd_config%magic = H5FD_SUBFILING_FAPL_MAGIC_F - vfd_config%version = H5FD_SUBFILING_CURR_FAPL_VERSION_F + vfd_config%magic = INT(H5FD_SUBFILING_FAPL_MAGIC_F,C_INT32_T) + vfd_config%version = INT(H5FD_SUBFILING_CURR_FAPL_VERSION_F,C_INT32_T) vfd_config%require_ioc = .TRUE. - vfd_config%shared_cfg%ioc_selection = SELECT_IOC_ONE_PER_NODE_F + vfd_config%shared_cfg%ioc_selection = INT(SELECT_IOC_ONE_PER_NODE_F,C_INT) vfd_config%shared_cfg%stripe_size = 16*1024*1024 vfd_config%shared_cfg%stripe_count = 3 @@ -299,8 +313,8 @@ PROGRAM subfiling_test IF(mpi_rank==0) CALL write_test_status(nerrors, & 'Testing H5Pset/get_fapl_subfiling_f with custom settings', total_error) - vfd_config_ioc%magic = H5FD_IOC_FAPL_MAGIC_F - vfd_config_ioc%version = H5FD_IOC_CURR_FAPL_VERSION_F + vfd_config_ioc%magic = INT(H5FD_IOC_FAPL_MAGIC_F,C_INT32_T) + vfd_config_ioc%version = INT(H5FD_IOC_CURR_FAPL_VERSION_F,C_INT32_T) vfd_config_ioc%thread_pool_size = 2 nerrors = 0 @@ -374,7 +388,13 @@ PROGRAM subfiling_test ! CALL h5close_f(hdferror) - CALL MPI_ALLREDUCE(total_error, sum, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, mpierror) + IF(h5_sizeof(total_error).EQ.8_size_t)THEN + mpi_int_type=MPI_INTEGER8 + ELSE + mpi_int_type=MPI_INTEGER4 + ENDIF + + CALL MPI_ALLREDUCE(total_error, sum, 1_MPI_INTEGER_KIND, mpi_int_type, MPI_SUM, MPI_COMM_WORLD, mpierror) ! ! close MPI @@ -386,7 +406,7 @@ PROGRAM subfiling_test ENDIF ELSE WRITE(*,*) 'Errors detected in process ', mpi_rank - CALL mpi_abort(MPI_COMM_WORLD, 1, mpierror) + CALL mpi_abort(MPI_COMM_WORLD, 1_MPI_INTEGER_KIND, mpierror) IF (mpierror .NE. MPI_SUCCESS) THEN WRITE(*,*) "MPI_ABORT *FAILED* Process = ", mpi_rank ENDIF diff --git a/m4/aclocal_fc.f90 b/m4/aclocal_fc.f90 index 939988f64aa..9e4bfde3c90 100644 --- a/m4/aclocal_fc.f90 +++ b/m4/aclocal_fc.f90 @@ -21,7 +21,8 @@ ! PROGRAM PROG_FC_ISO_FORTRAN_ENV - USE, INTRINSIC :: ISO_FORTRAN_ENV + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : atomic_logical_kind + LOGICAL(KIND=atomic_logical_kind) :: state END PROGRAM PROG_FC_ISO_FORTRAN_ENV PROGRAM PROG_FC_SIZEOF diff --git a/m4/aclocal_fc.m4 b/m4/aclocal_fc.m4 index f7427924ee2..6e5703e9132 100644 --- a/m4/aclocal_fc.m4 +++ b/m4/aclocal_fc.m4 @@ -64,11 +64,11 @@ dnl dnl See if the fortran compiler supports the intrinsic module "ISO_FORTRAN_ENV" AC_DEFUN([PAC_PROG_FC_ISO_FORTRAN_ENV],[ - HAVE_ISO_FORTRAN_ENV="no" - AC_MSG_CHECKING([if Fortran compiler supports intrinsic module ISO_FORTRAN_ENV]) + CHECK_ISO_FORTRAN_ENV="no" + AC_MSG_CHECKING([if Fortran compiler supports intrinsic module ISO_FORTRAN_ENV (F08)]) TEST_SRC="`sed -n '/PROGRAM PROG_FC_ISO_FORTRAN_ENV/,/END PROGRAM PROG_FC_ISO_FORTRAN_ENV/p' $srcdir/m4/aclocal_fc.f90`" AC_LINK_IFELSE([$TEST_SRC],[AC_MSG_RESULT([yes]) - HAVE_ISO_FORTRAN_ENV="yes"], + CHECK_ISO_FORTRAN_ENV="yes"], [AC_MSG_RESULT([no])]) ]) @@ -391,6 +391,8 @@ AC_DEFUN([PAC_FC_NATIVE_INTEGER],[ AC_REQUIRE([PAC_FC_AVAIL_KINDS]) AC_MSG_CHECKING([sizeof of native KINDS]) AC_LANG_PUSH([Fortran]) +saved_FCFLAGS=$FCFLAGS +FCFLAGS=$saved_user_FCFLAGS pack_int_sizeof="" rm -f pac_fconftest.out AC_LANG_CONFTEST([ @@ -424,6 +426,7 @@ rm -f pac_fconftest.out pack_int_sizeof="$2" ]) AC_MSG_RESULT([$pack_int_sizeof]) +FCFLAGS=$saved_FCFLAGS AC_LANG_POP([Fortran]) ]) From 1136ac526863c4fe6388a590a03ab71806179b5c Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Mon, 25 Mar 2024 05:46:12 -0700 Subject: [PATCH 05/17] Use cp -rp in test_plugin.sh (#4233) When building with debug symbols on MacOS, the cp -p commands in test_plugin.sh will attempt to copy the .dSYM directories with debugging info, which will fail since -r is missing. Using cp -rp is harmless and allows the test to run Fixes HDFFV-10542 --- test/test_plugin.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_plugin.sh.in b/test/test_plugin.sh.in index 1d04760fb3a..d96aba4e331 100644 --- a/test/test_plugin.sh.in +++ b/test/test_plugin.sh.in @@ -18,7 +18,7 @@ TOP_BUILDDIR=@top_builddir@ EXIT_SUCCESS=0 EXIT_FAILURE=1 -CP="cp -p" # Use -p to preserve mode,ownership, timestamps +CP="cp -rp" # Use -p to preserve mode,ownership, timestamps RM="rm -rf" nerrors=0 From ecdb656f0896e5eec67527e7c2f495ff0a93606b Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Mon, 25 Mar 2024 08:23:28 -0700 Subject: [PATCH 06/17] Clean up types in h5test.c (#4235) Reduces warnings on 32-bit and LLP64 systems --- test/h5test.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/h5test.c b/test/h5test.c index 6f27a93a368..5c2ed8013e0 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -216,11 +216,8 @@ h5_delete_test_file(const char *base_name, hid_t fapl) void h5_delete_all_test_files(const char *base_name[], hid_t fapl) { - int i; /* iterator */ - - for (i = 0; base_name[i]; i++) { + for (int i = 0; base_name[i]; i++) h5_delete_test_file(base_name[i], fapl); - } /* end for */ } /* end h5_delete_all_test_files() */ @@ -2201,13 +2198,13 @@ H5_get_srcdir(void) int h5_duplicate_file_by_bytes(const char *orig, const char *dest) { - FILE *orig_ptr = NULL; - FILE *dest_ptr = NULL; - hsize_t fsize = 0; - hsize_t read_size = 0; - hsize_t max_buf = 0; - void *dup_buf = NULL; - int ret_value = 0; + FILE *orig_ptr = NULL; + FILE *dest_ptr = NULL; + size_t fsize = 0; + size_t read_size = 0; + size_t max_buf = 0; + void *dup_buf = NULL; + int ret_value = 0; max_buf = 4096 * sizeof(char); @@ -2218,7 +2215,7 @@ h5_duplicate_file_by_bytes(const char *orig, const char *dest) } HDfseek(orig_ptr, 0, SEEK_END); - fsize = (hsize_t)HDftell(orig_ptr); + fsize = (size_t)HDftell(orig_ptr); HDrewind(orig_ptr); dest_ptr = fopen(dest, "wb"); From 987fd8bb4216610ff86bfc34f053cb5ba0a74bee Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Mon, 25 Mar 2024 10:23:49 -0500 Subject: [PATCH 07/17] Fix example links (#4237) --- doxygen/dox/LearnBasics3.dox | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doxygen/dox/LearnBasics3.dox b/doxygen/dox/LearnBasics3.dox index 2cf94b0246f..be227c2ba2c 100644 --- a/doxygen/dox/LearnBasics3.dox +++ b/doxygen/dox/LearnBasics3.dox @@ -294,12 +294,12 @@ Specifically look at the \ref ExAPI. There are examples for different languages, where examples of using #H5Literate and #H5Ovisit/#H5Lvisit are included. The h5ex_g_traverse example traverses a file using H5Literate: -\li C: h5ex_g_traverse.c -\li F90: h5ex_g_traverse_F03.f90 +\li C: h5ex_g_traverse.c +\li F90: h5ex_g_traverse_F03.f90 The h5ex_g_visit example traverses a file using H5Ovisit and H5Lvisit: -\li C: h5ex_g_visit.c -\li F90: h5ex_g_visit_F03.f90 +\li C: h5ex_g_visit.c +\li F90: h5ex_g_visit_F03.f90
Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics From 81c811b721fb1853721ff0c50971650521d17621 Mon Sep 17 00:00:00 2001 From: bmribler <39579120+bmribler@users.noreply.github.com> Date: Mon, 25 Mar 2024 11:54:31 -0400 Subject: [PATCH 08/17] Fix links md files (#4239) --- CONTRIBUTING.md | 2 +- HDF5Examples/README.md | 6 +++--- test/API/README.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de81b1c8e05..00c884b692c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -122,7 +122,7 @@ Please make sure that you check the items applicable to your pull request: * [ ] If changes were done to Autotools build, were they added to CMake and vice versa? * [ ] Is the pull request applicable to any other branches? If yes, which ones? Please document it in the GitHub issue. * [ ] Is the new code sufficiently documented for future maintenance? - * [ ] Does the new feature require a change to an existing API? See "API Compatibility Macros" document (https://portal.hdfgroup.org/display/HDF5/API+Compatibility+Macros) + * [ ] Does the new feature require a change to an existing API? See "API Compatibility Macros" document (https://docs.hdfgroup.org/hdf5/develop/api-compat-macros.html) * Documentation * [ ] Was the change described in the release_docs/RELEASE.txt file? * [ ] Was the new function documented in the corresponding public header file using [Doxygen](https://hdfgroup.github.io/hdf5/develop/_r_m_t.html)? diff --git a/HDF5Examples/README.md b/HDF5Examples/README.md index 9a658365245..2f0090ba02c 100644 --- a/HDF5Examples/README.md +++ b/HDF5Examples/README.md @@ -19,7 +19,7 @@ HELP AND SUPPORT ---------------- Information regarding Help Desk and Support services is available at - https://portal.hdfgroup.org/display/support/The+HDF+Help+Desk + https://hdfgroup.atlassian.net/servicedesk/customer/portals @@ -48,7 +48,7 @@ HDF5 SNAPSHOTS, PREVIOUS RELEASES AND SOURCE CODE -------------------------------------------- Full Documentation and Programming Resources for this HDF5 can be found at - https://portal.hdfgroup.org/display/HDF5 + https://portal.hdfgroup.org/documentation/index.html Periodically development code snapshots are provided at the following URL: @@ -56,7 +56,7 @@ Periodically development code snapshots are provided at the following URL: Source packages for current and previous releases are located at: - https://portal.hdfgroup.org/display/support/Downloads + https://portal.hdfgroup.org/downloads/ Development code is available at our Github location: diff --git a/test/API/README.md b/test/API/README.md index 2f5a0650412..aa5884995e1 100644 --- a/test/API/README.md +++ b/test/API/README.md @@ -1,7 +1,7 @@ # HDF5 API Tests This directory contains several test applications that exercise HDF5's -public API and serve as regression tests for HDF5 [VOL Connectors](https://portal.hdfgroup.org/display/HDF5/Virtual+Object+Layer). +public API and serve as regression tests for HDF5 [VOL Connectors](https://docs.hdfgroup.org/hdf5/develop/_h5_v_l__u_g.html). ## Build Process and options From 45ef8fe5330475e54ef1546ec72ecdd8fe31512a Mon Sep 17 00:00:00 2001 From: "H. Joe Lee" Date: Mon, 25 Mar 2024 11:19:34 -0500 Subject: [PATCH 09/17] Add markdown link checker action (#4219) --- .github/workflows/markdown-link-check.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/markdown-link-check.yml diff --git a/.github/workflows/markdown-link-check.yml b/.github/workflows/markdown-link-check.yml new file mode 100644 index 00000000000..00cb686c082 --- /dev/null +++ b/.github/workflows/markdown-link-check.yml @@ -0,0 +1,14 @@ +name: Check Markdown links + +on: + workflow_dispatch: + push: + pull_request: + branches: [ develop ] + +jobs: + markdown-link-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: gaurav-nelson/github-action-markdown-link-check@v1 From cb3169fc5a2784bd7595b9f92c269603abe930bf Mon Sep 17 00:00:00 2001 From: "H. Joe Lee" Date: Mon, 25 Mar 2024 11:51:01 -0500 Subject: [PATCH 10/17] Match minimum CMake version to 3.18 (#4215) --- HDF5Examples/Using_CMake.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HDF5Examples/Using_CMake.txt b/HDF5Examples/Using_CMake.txt index df761cb28db..78751599b33 100644 --- a/HDF5Examples/Using_CMake.txt +++ b/HDF5Examples/Using_CMake.txt @@ -30,7 +30,7 @@ I. Preconditions 1. We suggest you obtain the latest CMake for windows from the Kitware web site. The HDF5 product requires a minimum CMake version - of 3.12. + of 3.18. 2. You have installed the HDF5 library built with CMake, by executing the HDF Install Utility (the *.msi file in the binary package for @@ -45,7 +45,7 @@ I. Preconditions (Note there are no quote characters used on Windows and all platforms use forward slashes) - 4. Created separate source and build directories. + 4. Create separate source and build directories. (CMake commands are executed in the build directory) From fc46c83614aa5c1c6284c04df663cc629ba837c5 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:27:14 -0700 Subject: [PATCH 11/17] Take user block into account when returning chunk addresses (#4236) Both H5Dchunk_iter() and H5Dget_chunk_info(_by_coord)() did not take the size of the user block into account when reporting addresses. Since the #1 use of these functions is to root around in the file for the raw data, this is kind of a problem. Fixes GitHub issue #3003 --- release_docs/RELEASE.txt | 21 ++ src/H5Dchunk.c | 91 +++--- src/H5Dpublic.h | 15 +- test/chunk_info.c | 589 +++++++++++++++++++++++++++------------ 4 files changed, 493 insertions(+), 223 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 07b4d3bb4fd..d20574dc83b 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -784,6 +784,27 @@ Bug Fixes since HDF5-1.14.0 release overwriting data with a shorter (top level) variable length sequence, an error could occur. This has been fixed. + - Take user block into account in H5Dchunk_iter() and H5Dget_chunk_info() + + The address reported by the following functions did not correctly + take the user block into account: + + * H5Dchunk_iter() <-- addr passed to callback + * H5Dget_chunk_info() <-- addr parameter + * H5Dget_chunk_info_by_coord() <-- addr parameter + + This means that these functions reported logical HDF5 file addresses, + which would only be equal to the physical addresses when there is no + user block prepended to the HDF5 file. This is unfortunate, as the + primary use of these functions is to get physical addresses in order + to directly access the chunks. + + The listed functions now correctly take the user block into account, + so they will emit physical addresses that can be used to directly + access the chunks. + + Fixes #3003 + - Fixed asserts raised by large values of H5Pset_est_link_info() parameters If large values for est_num_entries and/or est_name_len were passed diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index e5b690e95c1..310f774e8da 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -250,9 +250,10 @@ typedef struct H5D_chunk_coll_fill_info_t { #endif /* H5_HAVE_PARALLEL */ typedef struct H5D_chunk_iter_ud_t { - H5D_chunk_iter_op_t op; /* User defined callback */ - void *op_data; /* User data for user defined callback */ - H5O_layout_chunk_t *chunk; /* Chunk layout */ + H5D_chunk_iter_op_t op; /* User defined callback */ + void *op_data; /* User data for user defined callback */ + H5O_layout_chunk_t *chunk; /* Chunk layout */ + haddr_t base_addr; /* Base address of the file, taking user block into account */ } H5D_chunk_iter_ud_t; /********************/ @@ -7850,7 +7851,7 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ /*------------------------------------------------------------------------- * Function: H5D__get_chunk_info_cb * - * Purpose: Get the chunk info of the queried chunk, given by its index. + * Purpose: Get the chunk info of the queried chunk, given by its index * * Return: Success: H5_ITER_CONT or H5_ITER_STOP * H5_ITER_STOP indicates the queried chunk is found @@ -7901,21 +7902,18 @@ H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) * Note: Currently, the domain of the index in this function is of all * the written chunks, regardless the dataspace. * - * Return: Success: SUCCEED - * Failure: FAIL - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_t chk_index, hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_chunk_info_iter_ud_t udata; /* User data for callback */ - const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ - H5D_rdcc_ent_t *ent; /* Cache entry index */ - hsize_t ii = 0; /* Dimension index */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ + H5D_rdcc_ent_t *ent; /* Cache entry index */ + hsize_t ii = 0; /* Dimension index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7947,6 +7945,9 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ /* If the chunk is written, get its info, otherwise, return without error */ if (H5_addr_defined(idx_info.storage->idx_addr)) { + + H5D_chunk_info_iter_ud_t udata; + /* Initialize before iteration */ udata.chunk_idx = chk_index; udata.curr_idx = 0; @@ -7967,14 +7968,14 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ if (filter_mask) *filter_mask = udata.filter_mask; if (addr) - *addr = udata.chunk_addr; + *addr = udata.chunk_addr + H5F_BASE_ADDR(dset->oloc.file); if (size) *size = udata.nbytes; if (offset) for (ii = 0; ii < udata.ndims; ii++) offset[ii] = udata.scaled[ii] * dset->shared->layout.u.chunk.dim[ii]; - } /* end if */ - } /* end if H5_addr_defined */ + } + } done: FUNC_LEAVE_NOAPI_TAG(ret_value) @@ -8039,12 +8040,11 @@ herr_t H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) { - const H5O_layout_t *layout = NULL; /* Dataset layout */ - const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ - H5D_rdcc_ent_t *ent; /* Cache entry index */ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_chunk_info_iter_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout = NULL; /* Dataset layout */ + const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ + H5D_rdcc_ent_t *ent; /* Cache entry index */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -8080,6 +8080,9 @@ H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned /* If the dataset is not written, return without errors */ if (H5_addr_defined(idx_info.storage->idx_addr)) { + + H5D_chunk_info_iter_ud_t udata; + /* Calculate the scaled of this chunk */ H5VM_chunk_scaled(dset->shared->ndims, offset, layout->u.chunk.dim, udata.scaled); udata.scaled[dset->shared->ndims] = 0; @@ -8102,11 +8105,11 @@ H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned if (filter_mask) *filter_mask = udata.filter_mask; if (addr) - *addr = udata.chunk_addr; + *addr = udata.chunk_addr + H5F_BASE_ADDR(dset->oloc.file); if (size) *size = udata.nbytes; - } /* end if */ - } /* end if H5_addr_defined */ + } + } done: FUNC_LEAVE_NOAPI_TAG(ret_value) @@ -8115,33 +8118,32 @@ H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned /*------------------------------------------------------------------------- * Function: H5D__chunk_iter_cb * - * Purpose: Call the user-defined function with the chunk data. The iterator continues if - * the user-defined function returns H5_ITER_CONT, and stops if H5_ITER_STOP is - * returned. + * Purpose: Call the user-defined function with the chunk data. The + * iterator continues if the user-defined function returns + * H5_ITER_CONT, and stops if H5_ITER_STOP is returned. * * Return: Success: H5_ITER_CONT or H5_ITER_STOP * Failure: Negative (H5_ITER_ERROR) - * *------------------------------------------------------------------------- */ static int H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata) { - const H5D_chunk_iter_ud_t *data = (H5D_chunk_iter_ud_t *)udata; - const H5O_layout_chunk_t *chunk = data->chunk; - int ret_value = H5_ITER_CONT; + const H5D_chunk_iter_ud_t *data = (H5D_chunk_iter_ud_t *)udata; + const H5O_layout_chunk_t *chunk = data->chunk; hsize_t offset[H5O_LAYOUT_NDIMS]; - unsigned ii; /* Match H5O_layout_chunk_t.ndims */ + int ret_value = H5_ITER_CONT; /* Similar to H5D__get_chunk_info */ - for (ii = 0; ii < chunk->ndims; ii++) - offset[ii] = chunk_rec->scaled[ii] * chunk->dim[ii]; + for (unsigned i = 0; i < chunk->ndims; i++) + offset[i] = chunk_rec->scaled[i] * chunk->dim[i]; FUNC_ENTER_PACKAGE_NOERR /* Check for callback failure and pass along return value */ - if ((ret_value = (data->op)(offset, (unsigned)chunk_rec->filter_mask, chunk_rec->chunk_addr, - (hsize_t)chunk_rec->nbytes, data->op_data)) < 0) + if ((ret_value = + (data->op)(offset, (unsigned)chunk_rec->filter_mask, data->base_addr + chunk_rec->chunk_addr, + (hsize_t)chunk_rec->nbytes, data->op_data)) < 0) HERROR(H5E_DATASET, H5E_CANTNEXT, "iteration operator failed"); FUNC_LEAVE_NOAPI(ret_value) @@ -8150,11 +8152,9 @@ H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata) /*------------------------------------------------------------------------- * Function: H5D__chunk_iter * - * Purpose: Iterate over all the chunks in the dataset with given callback. - * - * Return: Success: Non-negative - * Failure: Negative + * Purpose: Iterate over all the chunks in the dataset with given callback * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -8196,14 +8196,15 @@ H5D__chunk_iter(H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data) H5D_chunk_iter_ud_t ud; /* Set up info for iteration callback */ - ud.op = op; - ud.op_data = op_data; - ud.chunk = &dset->shared->layout.u.chunk; + ud.op = op; + ud.op_data = op_data; + ud.chunk = &dset->shared->layout.u.chunk; + ud.base_addr = H5F_BASE_ADDR(dset->oloc.file); /* Iterate over the allocated chunks calling the iterator callback */ if ((ret_value = (layout->storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0) HERROR(H5E_DATASET, H5E_CANTNEXT, "chunk iteration failed"); - } /* end if H5_addr_defined */ + } done: FUNC_LEAVE_NOAPI_TAG(ret_value) diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 35d0edfe211..eda38863d89 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -224,7 +224,7 @@ typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, size_t dst_buf_bytes_us * * \param[in] offset Logical position of the chunk's first element in units of dataset elements * \param[in] filter_mask Bitmask indicating the filters used when the chunk was written - * \param[in] addr Chunk address in the file + * \param[in] addr Chunk address in the file, taking the user block (if any) into account * \param[in] size Chunk size in bytes, 0 if the chunk does not exist * \param[in,out] op_data Pointer to any user-defined data associated with * the operation. @@ -669,7 +669,7 @@ H5_DLL herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks * \dset_id * \param[in] offset Logical position of the chunk's first element in units of dataset elements * \param[out] filter_mask Bitmask indicating the filters used when the chunk was written - * \param[out] addr Chunk address in the file + * \param[out] addr Chunk address in the file, taking the user block (if any) into account * \param[out] size Chunk size in bytes, 0 if the chunk does not exist * * \return \herr_t @@ -686,6 +686,9 @@ H5_DLL herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks * equal to the dataset's rank. Each element is the logical * position of the chunk's first element in a dimension. * + * \note Prior to HDF5 1.14.4, the reported address did not take the + * user block into account. + * * \since 1.10.5 * */ @@ -709,6 +712,9 @@ H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, u * user supplied callback with the details of the chunk and the supplied * context \p op_data. * + * \note Prior to HDF5 1.14.4, the address passed to the callback did not take + * the user block into account. + * * \par Example * For each chunk, print the allocated chunk size (0 for unallocated chunks). * \snippet H5D_examples.c H5Dchunk_iter_cb @@ -731,7 +737,7 @@ H5_DLL herr_t H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t cb * \param[in] chk_idx Index of the chunk * \param[out] offset Logical position of the chunk's first element in units of dataset elements * \param[out] filter_mask Bitmask indicating the filters used when the chunk was written - * \param[out] addr Chunk address in the file + * \param[out] addr Chunk address in the file, taking the user block (if any) into account * \param[out] size Chunk size in bytes, 0 if the chunk does not exist * * \return \herr_t @@ -745,6 +751,9 @@ H5_DLL herr_t H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t cb * address to #HADDR_UNDEF. The value pointed to by filter_mask will * not be modified. \c NULL can be passed in for any \p out parameters. * + * \note Prior to HDF5 1.14.4, the reported address did not take the + * user block into account. + * * \p chk_idx is the chunk index in the selection. The index value * may have a value of 0 up to the number of chunks stored in * the file that has a nonempty intersection with the file diff --git a/test/chunk_info.c b/test/chunk_info.c index 9533b2aacee..5604dfe1656 100644 --- a/test/chunk_info.c +++ b/test/chunk_info.c @@ -120,14 +120,15 @@ static const char *FILENAME[] = {"tchunk_info_earliest", void reinit_vars(unsigned *read_flt_msk, haddr_t *addr, hsize_t *size); /* Helper function containing common code that verifies indexing type - and number of chunks */ -static int verify_idx_nchunks(hid_t dset, hid_t dspace, H5D_chunk_index_t exp_idx_type, + * and number of chunks + */ +static herr_t verify_idx_nchunks(hid_t dset, hid_t dspace, H5D_chunk_index_t exp_idx_type, hsize_t exp_num_chunks); -static int verify_get_chunk_info(hid_t dset, hid_t dspace, hsize_t chk_index, hsize_t exp_chk_size, +static herr_t verify_get_chunk_info(hid_t dset, hid_t dspace, hsize_t chk_index, hsize_t exp_chk_size, const hsize_t *exp_offset, unsigned exp_flt_msk); -static int verify_get_chunk_info_by_coord(hid_t dset, hsize_t *offset, hsize_t exp_chk_size, +static herr_t verify_get_chunk_info_by_coord(hid_t dset, hsize_t *offset, hsize_t exp_chk_size, unsigned exp_flt_msk); -static int verify_empty_chunk_info(hid_t dset, hsize_t *offset); +static herr_t verify_empty_chunk_info(hid_t dset, hsize_t *offset); static const char *index_type_str(H5D_chunk_index_t idx_type); /*------------------------------------------------------------------------- @@ -135,10 +136,7 @@ static const char *index_type_str(H5D_chunk_index_t idx_type); * * Purpose: Wipes out variables for the next use, used in various tests. * - * Return: Won't fail - * - * Date: September 2018 - * + * Return: void *------------------------------------------------------------------------- */ void @@ -158,14 +156,10 @@ reinit_vars(unsigned *read_flt_msk, haddr_t *addr, hsize_t *size) * Purpose: Verifies that H5Dget_chunk_info returns correct * values for a chunk. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Date: August 2019 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ -static int +static herr_t verify_get_chunk_info(hid_t dset, hid_t dspace, hsize_t chk_index, hsize_t exp_chk_size, const hsize_t *exp_offset, unsigned exp_flt_msk) { @@ -200,14 +194,10 @@ verify_get_chunk_info(hid_t dset, hid_t dspace, hsize_t chk_index, hsize_t exp_c * Purpose: Verifies that H5Dget_chunk_info_by_coord returns correct * values for a chunk. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Date: August 2019 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ -static int +static herr_t verify_get_chunk_info_by_coord(hid_t dset, hsize_t *offset, hsize_t exp_chk_size, unsigned exp_flt_msk) { uint32_t read_flt_msk = 0; /* Read filter mask */ @@ -237,14 +227,10 @@ verify_get_chunk_info_by_coord(hid_t dset, hsize_t *offset, hsize_t exp_chk_size * Purpose: Verifies that H5Dget_chunk_info_by_coord returns correct * values for an empty chunk. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Date: August 2018 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ -static int +static herr_t verify_empty_chunk_info(hid_t dset, hsize_t *offset) { uint32_t read_flt_msk = 0; /* Read filter mask */ @@ -274,9 +260,6 @@ verify_empty_chunk_info(hid_t dset, hsize_t *offset) * * Return: Success: a valid indexing scheme string * Failure: a note indicating the indexing type is invalid - * - * Date: August 2019 - * *------------------------------------------------------------------------- */ static const char * @@ -297,7 +280,7 @@ index_type_str(H5D_chunk_index_t idx_type) return ("Version 1 B-tree index type (default)"); case H5D_CHUNK_IDX_NTYPES: default: - return ("invalid index type"); + return "invalid index type"; } } /* index_type_str */ @@ -307,14 +290,10 @@ index_type_str(H5D_chunk_index_t idx_type) * Purpose: Reads the chunks within the boundary {start,end} and verify * the values against the populated data. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Date: August 2019 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ -static int +static herr_t verify_selected_chunks(hid_t dset, hid_t plist, const hsize_t *start, const hsize_t *end) { int read_buf[CHUNK_NX][CHUNK_NY]; @@ -328,14 +307,16 @@ verify_selected_chunks(hid_t dset, hid_t plist, const hsize_t *start, const hsiz memset(&read_buf, 0, sizeof(read_buf)); /* Initialize the array of chunk data for all NUM_CHUNKS chunks, this is - the same as the written data and will be used to verify the read data */ + * the same as the written data and will be used to verify the read data + */ for (n = 0; n < NUM_CHUNKS; n++) for (ii = 0; ii < CHUNK_NX; ii++) for (jj = 0; jj < CHUNK_NY; jj++) expected_buf[n][ii][jj] = (int)(ii * jj) + 1; /* Read each chunk within the boundary of {start,end} and verify the - values against the expected data */ + * values against the expected data + */ chk_index = 0; for (ii = start[0]; ii < end[0]; ii++) for (jj = start[1]; jj < end[1]; jj++, chk_index++) { @@ -369,14 +350,10 @@ verify_selected_chunks(hid_t dset, hid_t plist, const hsize_t *start, const hsiz * a subset of chunks. This function opens the dataset then * closes it after writing. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Date: August 2019 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ -static int +static herr_t write_selected_chunks(hid_t dset, hid_t plist, const hsize_t *start, const hsize_t *end, unsigned flt_msk) { int direct_buf[NUM_CHUNKS][CHUNK_NX][CHUNK_NY]; /* Data in chunks */ @@ -392,7 +369,8 @@ write_selected_chunks(hid_t dset, hid_t plist, const hsize_t *start, const hsize direct_buf[n][ii][jj] = (int)(ii * jj) + 1; /* Write NUM_CHUNKS_WRITTEN chunks at the following logical coords: - (0,2) (0,3) (1,2) (1,3) */ + * (0,2) (0,3) (1,2) (1,3) + */ chk_index = 0; for (ii = start[0]; ii < end[0]; ii++) for (jj = start[1]; jj < end[1]; jj++, chk_index++) { @@ -414,14 +392,10 @@ write_selected_chunks(hid_t dset, hid_t plist, const hsize_t *start, const hsize * Purpose: Verifies that chunk indexing scheme and number of chunks of * the dataset match the expected values. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Date: August 2019 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ -static int +static herr_t verify_idx_nchunks(hid_t dset, hid_t dspace, H5D_chunk_index_t exp_idx_type, hsize_t exp_num_chunks) { H5D_chunk_index_t idx_type; /* Dataset chunk index type */ @@ -461,8 +435,7 @@ verify_idx_nchunks(hid_t dset, hid_t dspace, H5D_chunk_index_t exp_idx_type, hsi * * Purpose: Test getting various chunk information * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: # of errors * * Note: Note that the dataspace argument in these new functions is * currently not used. The functionality involved the dataspace @@ -472,12 +445,9 @@ verify_idx_nchunks(hid_t dset, hid_t dspace, H5D_chunk_index_t exp_idx_type, hsi * This function tests the new API functions added for EED-343: * H5Dget_num_chunks, H5Dget_chunk_info, and * H5Dget_chunk_info_by_coord for high bound up to 1.8. - * - * Date: September 2018 - * *------------------------------------------------------------------------- */ -static herr_t +static int test_get_chunk_info_highest_v18(hid_t fapl) { char filename[FILENAME_BUF_SIZE]; /* File name */ @@ -517,7 +487,8 @@ test_get_chunk_info_highest_v18(hid_t fapl) h5_fixname(FILENAME[H5F_LIBVER_V18], fapl, filename, sizeof filename); /* Set version bounds for creating the file. High bound to V18 to test - chunked dataset that use B-tree v1 structures to index chunks. */ + * chunked dataset that use B-tree v1 structures to index chunks. + */ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18) < 0) TEST_ERROR; @@ -589,7 +560,8 @@ test_get_chunk_info_highest_v18(hid_t fapl) #endif /* end H5_HAVE_FILTER_DEFLATE */ /* Write only NUM_CHUNKS_WRITTEN chunks at the following logical coords: - (0,2) (0,3) (1,2) (1,3) */ + * (0,2) (0,3) (1,2) (1,3) + */ n = 0; for (ii = START_CHK_X; ii < END_CHK_X; ii++) for (jj = START_CHK_Y; jj < END_CHK_Y; jj++, n++) { @@ -622,7 +594,8 @@ test_get_chunk_info_highest_v18(hid_t fapl) FAIL_PUTS_ERROR("unexpected number of chunks"); /* Get and verify info of the last written chunk again, passing in H5S_ALL - this time */ + * this time + */ offset[0] = 6; offset[1] = 12; if (verify_get_chunk_info(dset, H5S_ALL, NUM_CHUNKS_WRITTEN - 1, chunk_size, offset, flt_msk) == FAIL) @@ -696,7 +669,8 @@ test_get_chunk_info_highest_v18(hid_t fapl) FAIL_PUTS_ERROR(" Attempt to get info of a non-existing chunk."); /* Attempt to get info of a chunk given its coords from an empty dataset, - should succeed with the returned address as HADDR_UNDEF and size as 0 */ + * should succeed with the returned address as HADDR_UNDEF and size as 0 + */ offset[0] = EMPTY_CHK_X; offset[1] = EMPTY_CHK_Y; if (verify_empty_chunk_info(dset, offset) == FAIL) @@ -710,7 +684,8 @@ test_get_chunk_info_highest_v18(hid_t fapl) ************************************************************************/ /* Set space allocation to early so that chunk query functions will - retrieve chunk information even though the dataset is empty */ + * retrieve chunk information even though the dataset is empty + */ if (H5Pset_alloc_time(cparms, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR; @@ -733,7 +708,8 @@ test_get_chunk_info_highest_v18(hid_t fapl) TEST_ERROR; /* Attempt to get info of a chunk from an empty dataset, verify the - returned address and size in the case of H5D_ALLOC_TIME_EARLY */ + * returned address and size in the case of H5D_ALLOC_TIME_EARLY + */ chk_index = NONEXIST_CHK_INDEX; reinit_vars(&read_flt_msk, &addr, &size); ret = H5Dget_chunk_info(dset, dspace, chk_index, out_offset, &read_flt_msk, &addr, &size); @@ -758,7 +734,8 @@ test_get_chunk_info_highest_v18(hid_t fapl) TEST_ERROR; /* Attempt to get info of a chunk given its coords from an empty dataset, - verify the returned address and size */ + * verify the returned address and size + */ offset[0] = 0; offset[1] = 0; if (H5Dget_chunk_info_by_coord(dset, offset, &read_flt_msk, &addr, &size) < 0) @@ -781,7 +758,7 @@ test_get_chunk_info_highest_v18(hid_t fapl) TEST_ERROR; PASSED(); - return SUCCEED; + return 0; error: H5E_BEGIN_TRY @@ -793,8 +770,7 @@ test_get_chunk_info_highest_v18(hid_t fapl) } H5E_END_TRY - H5_FAILED(); - return FAIL; + return 1; } /* test_get_chunk_info_highest_v18() */ /*------------------------------------------------------------------------- @@ -803,18 +779,14 @@ test_get_chunk_info_highest_v18(hid_t fapl) * Purpose: Test getting various chunk information when Single Chunk * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: # of errors * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace * will be implemented in the next version. - * - * Date: November 2018 - * *------------------------------------------------------------------------- */ -static herr_t +static int test_chunk_info_single_chunk(const char *filename, hid_t fapl) { hid_t chunkfile = H5I_INVALID_HID; /* File ID */ @@ -863,8 +835,7 @@ test_chunk_info_single_chunk(const char *filename, hid_t fapl) if (H5Dclose(dset) < 0) TEST_ERROR; - /* ...open it again to test the chunk query functions on a single empty - chunk */ + /* ...open it again to test the chunk query functions on a single empty chunk */ if ((dset = H5Dopen2(chunkfile, SINGLE_CHUNK_DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -908,7 +879,8 @@ test_chunk_info_single_chunk(const char *filename, hid_t fapl) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord failed\n"); /* Attempt to get chunk info given an invalid chunk index and verify - * that failure occurs */ + * that failure occurs + */ chk_index = INVALID_CHK_INDEX; reinit_vars(&read_flt_msk, &addr, &size); H5E_BEGIN_TRY @@ -928,7 +900,7 @@ test_chunk_info_single_chunk(const char *filename, hid_t fapl) TEST_ERROR; PASSED(); - return SUCCEED; + return 0; error: H5E_BEGIN_TRY @@ -940,8 +912,7 @@ test_chunk_info_single_chunk(const char *filename, hid_t fapl) } H5E_END_TRY - H5_FAILED(); - return FAIL; + return 1; } /* test_chunk_info_single_chunk() */ /*------------------------------------------------------------------------- @@ -950,18 +921,14 @@ test_chunk_info_single_chunk(const char *filename, hid_t fapl) * Purpose: Test getting various chunk information when Implicit * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: # of errors * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace * will be implemented in the next version. - * - * Date: November 2018 - * *------------------------------------------------------------------------- */ -static herr_t +static int test_chunk_info_implicit(char *filename, hid_t fapl) { hid_t chunkfile = H5I_INVALID_HID; /* File ID */ @@ -1016,7 +983,8 @@ test_chunk_info_implicit(char *filename, hid_t fapl) FAIL_PUTS_ERROR("Verification and write failed\n"); /* Write NUM_CHUNKS_WRITTEN chunks at the following logical coords: - (0,2) (0,3) (1,2) (1,3) */ + * (0,2) (0,3) (1,2) (1,3) + */ if (write_selected_chunks(dset, H5P_DEFAULT, start, end, flt_msk) == FAIL) FAIL_PUTS_ERROR("Writing to selected chunks failed\n"); @@ -1030,8 +998,9 @@ test_chunk_info_implicit(char *filename, hid_t fapl) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info failed\n"); /* Get info of a chunk and verify its information. Note that - all chunks in this dataset are allocated because of the property - H5D_ALLOC_TIME_EARLY */ + * all chunks in this dataset are allocated because of the property + * H5D_ALLOC_TIME_EARLY + */ if (verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord failed\n"); } @@ -1047,7 +1016,7 @@ test_chunk_info_implicit(char *filename, hid_t fapl) TEST_ERROR; PASSED(); - return SUCCEED; + return 0; error: H5E_BEGIN_TRY @@ -1059,8 +1028,7 @@ test_chunk_info_implicit(char *filename, hid_t fapl) } H5E_END_TRY - H5_FAILED(); - return FAIL; + return 1; } /* test_chunk_info_implicit() */ /*------------------------------------------------------------------------- @@ -1069,18 +1037,14 @@ test_chunk_info_implicit(char *filename, hid_t fapl) * Purpose: Test getting various chunk information when Fixed Array * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: # of errors * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace * will be implemented in the next version. - * - * Date: November 2018 - * *------------------------------------------------------------------------- */ -static herr_t +static int test_chunk_info_fixed_array(const char *filename, hid_t fapl) { hid_t chunkfile = H5I_INVALID_HID; /* File ID */ @@ -1138,7 +1102,8 @@ test_chunk_info_fixed_array(const char *filename, hid_t fapl) FAIL_PUTS_ERROR("Verification and write failed\n"); /* Write NUM_CHUNKS_WRITTEN chunks at the following logical coords: - (0,2) (0,3) (1,2) (1,3) */ + * (0,2) (0,3) (1,2) (1,3) + */ if (write_selected_chunks(dset, H5P_DEFAULT, start, end, flt_msk) == FAIL) FAIL_PUTS_ERROR("Writing to selected chunks failed\n"); @@ -1180,17 +1145,18 @@ test_chunk_info_fixed_array(const char *filename, hid_t fapl) /* Read and verify values of selected chunks */ if (verify_selected_chunks(dset, H5P_DEFAULT, start, end) < 0) + FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord on selected chunks failed\n"); - /* Release resource */ - if (H5Dclose(dset) < 0) - TEST_ERROR; + /* Release resource */ + if (H5Dclose(dset) < 0) + TEST_ERROR; if (H5Sclose(dspace) < 0) TEST_ERROR; if (H5Fclose(chunkfile) < 0) TEST_ERROR; PASSED(); - return SUCCEED; + return 0; error: H5E_BEGIN_TRY @@ -1202,8 +1168,7 @@ test_chunk_info_fixed_array(const char *filename, hid_t fapl) } H5E_END_TRY - H5_FAILED(); - return FAIL; + return 1; } /* test_chunk_info_fixed_array() */ /*------------------------------------------------------------------------- @@ -1212,18 +1177,14 @@ test_chunk_info_fixed_array(const char *filename, hid_t fapl) * Purpose: Test getting various chunk information when Extensible Array * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: # of errors * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace * will be implemented in the next version. - * - * Date: November 2018 - * *------------------------------------------------------------------------- */ -static herr_t +static int test_chunk_info_extensible_array(const char *filename, hid_t fapl) { hid_t chunkfile = H5I_INVALID_HID; /* File ID */ @@ -1282,7 +1243,8 @@ test_chunk_info_extensible_array(const char *filename, hid_t fapl) FAIL_PUTS_ERROR("Verification and write failed\n"); /* Write NUM_CHUNKS_WRITTEN chunks at the following logical coords: - (0,2) (0,3) (1,2) (1,3) */ + * (0,2) (0,3) (1,2) (1,3) + */ if (write_selected_chunks(dset, H5P_DEFAULT, start, end, flt_msk) == FAIL) FAIL_PUTS_ERROR("Writing to selected chunks failed\n"); @@ -1339,7 +1301,7 @@ test_chunk_info_extensible_array(const char *filename, hid_t fapl) TEST_ERROR; PASSED(); - return SUCCEED; + return 0; error: H5E_BEGIN_TRY @@ -1351,8 +1313,7 @@ test_chunk_info_extensible_array(const char *filename, hid_t fapl) } H5E_END_TRY - H5_FAILED(); - return FAIL; + return 1; } /* test_chunk_info_extensible_array() */ /*------------------------------------------------------------------------- @@ -1361,18 +1322,14 @@ test_chunk_info_extensible_array(const char *filename, hid_t fapl) * Purpose: Test getting various chunk information when Version 2 B-trees * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: # of errors * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace * will be implemented in the next version. - * - * Date: November 2018 - * *------------------------------------------------------------------------- */ -static herr_t +static int test_chunk_info_version2_btrees(const char *filename, hid_t fapl) { hid_t chunkfile = H5I_INVALID_HID; /* File ID */ @@ -1431,7 +1388,8 @@ test_chunk_info_version2_btrees(const char *filename, hid_t fapl) FAIL_PUTS_ERROR("Verification and write failed\n"); /* Write NUM_CHUNKS_WRITTEN chunks at the following logical coords: - (0,2) (0,3) (1,2) (1,3) */ + * (0,2) (0,3) (1,2) (1,3) + */ if (write_selected_chunks(dset, H5P_DEFAULT, start, end, flt_msk) == FAIL) FAIL_PUTS_ERROR("Writing to selected chunks failed\n"); @@ -1488,7 +1446,7 @@ test_chunk_info_version2_btrees(const char *filename, hid_t fapl) TEST_ERROR; PASSED(); - return SUCCEED; + return 0; error: H5E_BEGIN_TRY @@ -1500,8 +1458,7 @@ test_chunk_info_version2_btrees(const char *filename, hid_t fapl) } H5E_END_TRY - H5_FAILED(); - return FAIL; + return 1; } /* test_chunk_info_version2_btrees() */ typedef struct chunk_iter_info_t { @@ -1557,18 +1514,14 @@ iter_cb_fail(const hsize_t H5_ATTR_UNUSED *offset, unsigned H5_ATTR_UNUSED filte * Purpose: Tests basic operations to ensure the chunk query functions * work properly. * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: # of errors * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace * will be implemented in the next version. - * - * Date: August 2019 - * *------------------------------------------------------------------------- */ -static herr_t +static int test_basic_query(hid_t fapl) { char filename[FILENAME_BUF_SIZE]; /* File name */ @@ -1757,7 +1710,7 @@ test_basic_query(hid_t fapl) HDremove(filename); PASSED(); - return SUCCEED; + return 0; error: H5E_BEGIN_TRY @@ -1769,8 +1722,7 @@ test_basic_query(hid_t fapl) } H5E_END_TRY - H5_FAILED(); - return FAIL; + return 1; } /* test_basic_query() */ /*------------------------------------------------------------------------- @@ -1778,18 +1730,14 @@ test_basic_query(hid_t fapl) * * Purpose: Test attempting to use chunk query functions incorrectly. * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: # of errors * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace * will be implemented in the next version. - * - * Date: August 2019 - * *------------------------------------------------------------------------- */ -static herr_t +static int test_failed_attempts(const char *filename, hid_t fapl) { hid_t chunkfile = H5I_INVALID_HID; /* File ID */ @@ -1881,7 +1829,7 @@ test_failed_attempts(const char *filename, hid_t fapl) TEST_ERROR; PASSED(); - return SUCCEED; + return 0; error: H5E_BEGIN_TRY @@ -1892,8 +1840,7 @@ test_failed_attempts(const char *filename, hid_t fapl) } H5E_END_TRY - H5_FAILED(); - return FAIL; + return 1; } /* test_failed_attempts() */ /*------------------------------------------------------------------------- @@ -1901,8 +1848,7 @@ test_failed_attempts(const char *filename, hid_t fapl) * * Purpose: Test getting various chunk information in version 1.10. * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: # of errors * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace @@ -1912,12 +1858,9 @@ test_failed_attempts(const char *filename, hid_t fapl) * This function tests the new API functions added for HDFFV-10677: * H5Dget_num_chunks, H5Dget_chunk_info, and * H5Dget_chunk_info_by_coord for low bound beyond 1.8. - * - * Date: October 2018 - * *------------------------------------------------------------------------- */ -static herr_t +static int test_get_chunk_info_v110(hid_t fapl) { char filename[FILENAME_BUF_SIZE]; /* File name */ @@ -1973,26 +1916,21 @@ test_get_chunk_info_v110(hid_t fapl) } /* for low libver bound */ - return SUCCEED; + return 0; error: - H5_FAILED(); - return FAIL; + return 1; } /* test_get_chunk_info_v110() */ /*------------------------------------------------------------------------- * Function: test_flt_msk_with_skip_compress * - * Purpose: Test getting chunk info when compression filter is skipped. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Date: August 2019 (based on direct_chunk.c/test_skip_compress_write1) + * Purpose: Test getting chunk info when compression filter is skipped * + * Return: # of errors *------------------------------------------------------------------------- */ -static herr_t +static int test_flt_msk_with_skip_compress(hid_t fapl) { char filename[FILENAME_BUF_SIZE]; /* File name */ @@ -2166,7 +2104,7 @@ test_flt_msk_with_skip_compress(hid_t fapl) HDremove(filename); PASSED(); - return SUCCEED; + return 0; error: H5E_BEGIN_TRY @@ -2180,17 +2118,316 @@ test_flt_msk_with_skip_compress(hid_t fapl) } H5E_END_TRY - H5_FAILED(); - return FAIL; + return 1; } /* test_flt_msk_with_skip_compress() */ +#define UBLOCK_FILE_NAME "file_with_userblock.h5" +#define NO_UBLOCK_FILE_NAME "file_without_userblock.h5" +#define UBLOCK_DSET_NAME "ublock_dset" +#define UBLOCK_SIZE 2048 + +/* Helper function to create userblock files and datasets */ +static herr_t +create_userblock_file(const char *filename, hid_t fcpl_id, hid_t fapl_id) +{ + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + + /* The chunk size is set to 1 so we get a lot of chunks without + * writing a lot of data. + */ + int rank = 1; + hsize_t dims = {256}; + hsize_t chunk_dims = {1}; + + int *data = NULL; + + /* Create a new file */ + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) + TEST_ERROR; + + /* Create file data space for the dataset */ + if ((sid = H5Screate_simple(rank, &dims, &dims)) < 0) + TEST_ERROR; + + /* Create dataset create property list with chunking */ + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl_id, rank, &chunk_dims) < 0) + TEST_ERROR; + + /* Create a new dataset */ + if ((did = H5Dcreate2(fid, UBLOCK_DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Create some arbitrary data */ + if (NULL == (data = (int *)malloc(256 * sizeof(int)))) + TEST_ERROR; + for (int i = 0; i < 256; i++) + data[i] = i; + + /* Write the data to the dataset */ + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + TEST_ERROR; + + /* Close everything */ + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Sclose(sid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + + free(data); + + return SUCCEED; +error: + H5E_BEGIN_TRY + { + H5Pclose(dcpl_id); + H5Dclose(did); + H5Sclose(sid); + H5Fclose(fid); + } + H5E_END_TRY + + free(data); + + return FAIL; +} + +/* op_data for the userblock iterator */ +struct ub_op_data { + haddr_t *addresses; + hsize_t i; + hsize_t max; +}; + +/* Callback function for iterating over dataset chunks is files both with + * and without a userblock + */ +static int +ublock_iter_cb(const hsize_t H5_ATTR_UNUSED *offset, unsigned H5_ATTR_UNUSED filter_mask, haddr_t addr, + hsize_t H5_ATTR_UNUSED size, void *op_data) +{ + struct ub_op_data *od = (struct ub_op_data *)op_data; + + /* Error if we try to iterate over too many chunks */ + if (od->i == od->max) + return H5_ITER_ERROR; + + /* Store the address for later comparison */ + od->addresses[od->i] = addr; + od->i += 1; + + return H5_ITER_CONT; +} + +/*------------------------------------------------------------------------- + * Function: test_chunk_address_with_userblock + * + * Purpose: Test that chunk addresses are correct when a file has + * a userblock + * + * Return: # of errors + *------------------------------------------------------------------------- + */ +static int +test_chunk_address_with_userblock(hid_t fapl_id) +{ + hid_t fid = H5I_INVALID_HID; + hid_t fid_ub = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t did_ub = H5I_INVALID_HID; + hid_t fcpl_id = H5I_INVALID_HID; + + hsize_t num_chunks = HSIZE_UNDEF; + hsize_t num_chunks_ub = 0; + + haddr_t *addresses = NULL; + haddr_t *addresses_ub = NULL; + + struct ub_op_data od; + struct ub_op_data od_ub; + + int fd = -1; + int fd_ub = -1; + + TESTING("if chunk addresses are correct when a file has a userblock"); + + /* Create files with and without a userblock */ + if (create_userblock_file(NO_UBLOCK_FILE_NAME, H5P_DEFAULT, fapl_id) < 0) + TEST_ERROR; + + if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) == H5I_INVALID_HID) + TEST_ERROR; + if (H5Pset_userblock(fcpl_id, UBLOCK_SIZE) < 0) + TEST_ERROR; + + if (create_userblock_file(UBLOCK_FILE_NAME, fcpl_id, fapl_id) < 0) + TEST_ERROR; + + /* Open both files and datasets */ + if ((fid = H5Fopen(NO_UBLOCK_FILE_NAME, H5F_ACC_RDONLY, fapl_id)) == H5I_INVALID_HID) + TEST_ERROR; + if ((did = H5Dopen2(fid, UBLOCK_DSET_NAME, H5P_DEFAULT)) == H5I_INVALID_HID) + TEST_ERROR; + if ((fid_ub = H5Fopen(UBLOCK_FILE_NAME, H5F_ACC_RDONLY, fapl_id)) == H5I_INVALID_HID) + TEST_ERROR; + if ((did_ub = H5Dopen2(fid_ub, UBLOCK_DSET_NAME, H5P_DEFAULT)) == H5I_INVALID_HID) + TEST_ERROR; + + /* Get the number of chunks */ + if (H5Dget_num_chunks(did, H5S_ALL, &num_chunks) < 0) + TEST_ERROR; + if (H5Dget_num_chunks(did_ub, H5S_ALL, &num_chunks_ub) < 0) + TEST_ERROR; + + if (num_chunks != num_chunks_ub) + TEST_ERROR; + + /* Check the chunk information to make sure that the userblock file takes + * the block's size into account. + */ + for (hsize_t i = 0; i < num_chunks; i++) { + haddr_t addr = HADDR_UNDEF; + haddr_t addr_ub = 0; + + /* H5Dget_chunk_info() */ + if (H5Dget_chunk_info(did, H5S_ALL, i, NULL, NULL, &addr, NULL) < 0) + TEST_ERROR; + if (H5Dget_chunk_info(did_ub, H5S_ALL, i, NULL, NULL, &addr_ub, NULL) < 0) + TEST_ERROR; + + if (addr + UBLOCK_SIZE != addr_ub) + TEST_ERROR; + + addr = HADDR_UNDEF; + addr_ub = 0; + + /* H5Dget_chunk_info_by_coord() */ + if (H5Dget_chunk_info_by_coord(did, &i, NULL, &addr, NULL) < 0) + TEST_ERROR; + if (H5Dget_chunk_info_by_coord(did_ub, &i, NULL, &addr_ub, NULL) < 0) + TEST_ERROR; + + if (addr + UBLOCK_SIZE != addr_ub) + TEST_ERROR; + } + + /* Allocate arrays to hold the chunk addresses */ + if (NULL == (addresses = (haddr_t *)calloc(num_chunks, sizeof(haddr_t)))) + TEST_ERROR; + if (NULL == (addresses_ub = (haddr_t *)calloc(num_chunks, sizeof(haddr_t)))) + TEST_ERROR; + + od.addresses = addresses; + od.i = 0; + od.max = num_chunks; + + od_ub.addresses = addresses_ub; + od_ub.i = 0; + od_ub.max = num_chunks; + + /* Iterate over the chunks, storing the chunk addresses */ + if (H5Dchunk_iter(did, H5P_DEFAULT, ublock_iter_cb, &od) < 0) + TEST_ERROR; + if (H5Dchunk_iter(did_ub, H5P_DEFAULT, ublock_iter_cb, &od_ub) < 0) + TEST_ERROR; + + /* Compare the chunk addresses to ensure the userblock file takes the + * chunk's size into account. + */ + if (od.i != od_ub.i) + TEST_ERROR; + for (hsize_t i = 0; i < num_chunks; i++) + if (od.addresses[i] + UBLOCK_SIZE != od_ub.addresses[i]) + TEST_ERROR; + + /* Compare the raw chunk data */ + if ((fd = HDopen(NO_UBLOCK_FILE_NAME, O_RDONLY)) < 0) + TEST_ERROR; + if ((fd_ub = HDopen(UBLOCK_FILE_NAME, O_RDONLY)) < 0) + TEST_ERROR; + + for (hsize_t i = 0; i < num_chunks; i++) { + int data = -1; + int data_ub = -1; + + if (HDlseek(fd, (off_t)(od.addresses[i]), SEEK_SET) < 0) + TEST_ERROR; + if (HDlseek(fd_ub, (off_t)(od_ub.addresses[i]), SEEK_SET) < 0) + TEST_ERROR; + + if (HDread(fd, &data, sizeof(int)) != sizeof(int)) + TEST_ERROR; + if (HDread(fd_ub, &data_ub, sizeof(int)) != sizeof(int)) + TEST_ERROR; + + if (data != data_ub) + TEST_ERROR; + } + + HDclose(fd); + fd = -1; + HDclose(fd_ub); + fd_ub = -1; + + /* Close everything */ + if (H5Pclose(fcpl_id) < 0) + TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Dclose(did_ub) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if (H5Fclose(fid_ub) < 0) + TEST_ERROR; + + free(addresses); + free(addresses_ub); + + if (H5Fdelete(UBLOCK_FILE_NAME, fapl_id) < 0) + TEST_ERROR; + if (H5Fdelete(NO_UBLOCK_FILE_NAME, fapl_id) < 0) + TEST_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fcpl_id); + H5Dclose(did); + H5Dclose(did_ub); + H5Fclose(fid); + H5Fclose(fid_ub); + } + H5E_END_TRY + + if (fd >= 0) + HDclose(fd); + if (fd_ub >= 0) + HDclose(fd_ub); + + free(addresses); + free(addresses_ub); + + return 1; +} /* test_chunk_address_with_userblock() */ + /*------------------------------------------------------------------------- * Function: main * * Purpose: Tests functions related to chunk information * * Return: EXIT_SUCCESS/EXIT_FAILURE - * *------------------------------------------------------------------------- */ int @@ -2203,19 +2440,22 @@ main(void) /* Create a copy of file access property list */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - TEST_ERROR; + goto error; /* Test basic operations on the chunk query functions */ - nerrors += test_basic_query(fapl) < 0 ? 1 : 0; + nerrors += test_basic_query(fapl); /* Tests getting chunk information of version 1.8 and prior */ - nerrors += test_get_chunk_info_highest_v18(fapl) < 0 ? 1 : 0; + nerrors += test_get_chunk_info_highest_v18(fapl); /* Tests getting chunk information of version 1.10 */ - nerrors += test_get_chunk_info_v110(fapl) < 0 ? 1 : 0; + nerrors += test_get_chunk_info_v110(fapl); /* Tests getting filter mask when compression filter is skipped */ - nerrors += test_flt_msk_with_skip_compress(fapl) < 0 ? 1 : 0; + nerrors += test_flt_msk_with_skip_compress(fapl); + + /* Test that chunk addresses are correct when files have a userblock */ + nerrors += test_chunk_address_with_userblock(fapl); if (nerrors) goto error; @@ -2227,14 +2467,13 @@ main(void) return EXIT_SUCCESS; error: + H5E_BEGIN_TRY + { + H5Pclose(fapl); + } + H5E_END_TRY + nerrors = MAX(1, nerrors); printf("***** %d QUERY CHUNK INFO TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return EXIT_FAILURE; } - -/**************************************************************************** - Additional tests to be added: -- do the query when extending the dataset (shrink or expand) -- verify that invalid input parameters are handled properly - -****************************************************************************/ From 9a08e3f47661a58a09891a3b7ebf941ac727e657 Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Mon, 25 Mar 2024 21:56:34 -0500 Subject: [PATCH 12/17] Fix a minor warning in h5test.c (#4242) --- test/h5test.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/h5test.c b/test/h5test.c index 5c2ed8013e0..ba68918c2a1 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -844,13 +844,13 @@ h5_get_vfd_fapl(hid_t fapl) } else if (!strcmp(tok, "multi")) { /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char *sv[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - const int multi_memname_maxlen = 1024; + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + char *sv[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_mem_t mt; + const size_t multi_memname_maxlen = 1024; memset(memb_map, 0, sizeof(memb_map)); memset(memb_fapl, 0, sizeof(memb_fapl)); From db8193def5abd81baa88507d2852570c5266fe73 Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Tue, 26 Mar 2024 07:40:16 -0500 Subject: [PATCH 13/17] Turn on -Werror for Java in GitHub -Werror workflows (#4243) --- .github/workflows/main-auto-spc.yml | 8 ++++++-- config/gnu-warnings/8 | 1 - config/gnu-warnings/error-8 | 11 +++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main-auto-spc.yml b/.github/workflows/main-auto-spc.yml index 3a7f72d4fbe..b0fc236ee33 100644 --- a/.github/workflows/main-auto-spc.yml +++ b/.github/workflows/main-auto-spc.yml @@ -417,8 +417,10 @@ jobs: sh ./autogen.sh mkdir "${{ runner.workspace }}/build" cd "${{ runner.workspace }}/build" - CFLAGS=-Werror $GITHUB_WORKSPACE/configure \ + CFLAGS=-Werror JAVACFLAGS=-Werror JNIFLAGS=-Werror \ + $GITHUB_WORKSPACE/configure \ --enable-build-mode=debug \ + --enable-warnings-as-errors \ --enable-deprecated-symbols \ --with-default-api-version=v114 \ --enable-shared \ @@ -478,8 +480,10 @@ jobs: sh ./autogen.sh mkdir "${{ runner.workspace }}/build" cd "${{ runner.workspace }}/build" - CFLAGS=-Werror $GITHUB_WORKSPACE/configure \ + CFLAGS=-Werror JAVACFLAGS=-Werror JNIFLAGS=-Werror \ + $GITHUB_WORKSPACE/configure \ --enable-build-mode=production \ + --enable-warnings-as-errors \ --enable-deprecated-symbols \ --with-default-api-version=v114 \ --enable-shared \ diff --git a/config/gnu-warnings/8 b/config/gnu-warnings/8 index 5e7519dd795..323110950b1 100644 --- a/config/gnu-warnings/8 +++ b/config/gnu-warnings/8 @@ -1,3 +1,2 @@ -Wattribute-alias --Wcast-align=strict -Wshift-overflow=2 diff --git a/config/gnu-warnings/error-8 b/config/gnu-warnings/error-8 index 36c14143228..25839a847b4 100644 --- a/config/gnu-warnings/error-8 +++ b/config/gnu-warnings/error-8 @@ -7,3 +7,14 @@ # that GCC 8 only performs that analysis at -O3, though. # -Werror=maybe-uninitialized +# Ask GCC to warn about cast-align problems, even on platforms where +# it normally wouldn't (because those platforms don't require alignment). +# While this flag doesn't follow the -Werror format like above, it's +# placed here to make sure that it comes after the -Werror=cast-align +# line from error-general in the list of flags. Otherwise, if the +# '--enable-warnings-as-errors' flag isn't passed at configure time, +# the logic in config/gnu-flags that demotes these errors to their +# normal warning form will cause -Wcast-align to come after +# -Wcast-align=strict in the list of flags, causing it to take +# precedence and mask cast-align warnings from GCC on certain platforms. +-Wcast-align=strict From fb127766102109bb79b54b9689f7500f3696278d Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Tue, 26 Mar 2024 07:41:01 -0500 Subject: [PATCH 14/17] Update Windows CI to not install ninja (#4230) --- .github/workflows/main-cmake.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/main-cmake.yml b/.github/workflows/main-cmake.yml index 2b02765da9e..a7613dc3a76 100644 --- a/.github/workflows/main-cmake.yml +++ b/.github/workflows/main-cmake.yml @@ -135,10 +135,6 @@ jobs: # CMake gets libaec from fetchcontent - - name: Install Dependencies (Windows) - run: choco install ninja - if: matrix.os == 'windows-latest' - - name: Install Dependencies (macOS) run: brew install ninja if: matrix.os == 'macos-13' From eacb0157dc46c52843bef0970cfa6e31862f830a Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:20:11 -0500 Subject: [PATCH 15/17] Rework Fortran macros to use the proper code. (#4240) --- CMakeLists.txt | 12 ---- config/cmake/HDF5UseFortran.cmake | 16 +----- config/cmake/HDFUseFortran.cmake | 96 +++++++------------------------ 3 files changed, 22 insertions(+), 102 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81a6e96b6fe..879e7307bf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1072,8 +1072,6 @@ set (H5_FC_FUNC_ "H5_FC_FUNC_(name,NAME) name ## _") if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/fortran") option (HDF5_BUILD_FORTRAN "Build FORTRAN support" OFF) if (HDF5_BUILD_FORTRAN) - include (${HDF_RESOURCES_DIR}/HDFUseFortran.cmake) - message (VERBOSE "Fortran compiler ID is ${CMAKE_Fortran_COMPILER_ID}") include (${HDF_RESOURCES_DIR}/HDFFortranCompilerFlags.cmake) include (${HDF_RESOURCES_DIR}/HDF5UseFortran.cmake) @@ -1147,16 +1145,6 @@ if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++") endif () endif () -#----------------------------------------------------------------------------- -# Check if Fortran's default real is double precision. If it is and HL is -# being built then configure should fail due to bug HDFFV-889. -#----------------------------------------------------------------------------- -if (HDF5_BUILD_FORTRAN AND HDF5_BUILD_HL_LIB) - if (NOT H5_FORTRAN_DEFAULT_REAL_NOT_DOUBLE) - message (FATAL_ERROR " **** Fortran high-level routines are not supported when the default REAL is DOUBLE PRECISION, use HDF5_BUILD_HL_LIB:BOOL=OFF **** ") - endif () -endif () - #----------------------------------------------------------------------------- # Option to build HDF5 Java Library #----------------------------------------------------------------------------- diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index f22d8d2c390..b7d310315a9 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -14,27 +14,15 @@ # This file provides functions for HDF5 specific Fortran support. # #------------------------------------------------------------------------------- -enable_language (Fortran) +include (${HDF_RESOURCES_DIR}/HDFUseFortran.cmake) -set (HDF_PREFIX "H5") +include (CheckFortranFunctionExists) # Force lowercase Fortran module file names if (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ef") endif () -include (CheckFortranFunctionExists) - -include (CheckFortranSourceRuns) -include (CheckFortranSourceCompiles) - -# Read source line beginning at the line matching Input:"START" and ending at the line matching Input:"END" -macro (READ_SOURCE SOURCE_START SOURCE_END RETURN_VAR) - file (READ "${HDF5_SOURCE_DIR}/m4/aclocal_fc.f90" SOURCE_MASTER) - string (REGEX MATCH "${SOURCE_START}[\\\t\\\n\\\r[].+]*${SOURCE_END}" SOURCE_CODE ${SOURCE_MASTER}) - set (RETURN_VAR "${SOURCE_CODE}") -endmacro () - set (RUN_OUTPUT_PATH_DEFAULT ${CMAKE_BINARY_DIR}) # The provided CMake Fortran macros don't provide a general compile/run function # so this one is used. diff --git a/config/cmake/HDFUseFortran.cmake b/config/cmake/HDFUseFortran.cmake index dd35c07531d..44d3e7cfd2b 100644 --- a/config/cmake/HDFUseFortran.cmake +++ b/config/cmake/HDFUseFortran.cmake @@ -43,72 +43,26 @@ file (STRINGS ${CMAKE_BINARY_DIR}/FCMangle.h CONTENTS REGEX "H5_FC_GLOBAL_\\(.*, string (REGEX MATCH "H5_FC_GLOBAL_\\(.*,.*\\) +(.*)" RESULT ${CONTENTS}) set (H5_FC_FUNC_ "H5_FC_FUNC_(name,NAME) ${CMAKE_MATCH_1}") -#test code source -set (SIZEOF_CODE - " - PROGRAM main - i = sizeof(x) - END PROGRAM - " -) -set (C_SIZEOF_CODE - " - PROGRAM main - USE ISO_C_BINDING - INTEGER(C_INT) :: a - INTEGER(C_SIZE_T) :: result - result = c_sizeof(a) - END PROGRAM - " -) -set (STORAGE_SIZE_CODE - " - PROGRAM main - INTEGER :: a - INTEGER :: result - result = storage_size(a) - END PROGRAM - " -) -set (CHAR_ALLOC - " - PROGRAM main - CHARACTER(:), ALLOCATABLE :: str - END PROGRAM - " -) -set (ISO_FORTRAN_ENV_CODE - " - PROGRAM main - USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : atomic_logical_kind - LOGICAL(KIND=atomic_logical_kind) :: state - END PROGRAM - " -) -set (REALISNOTDOUBLE_CODE - " - MODULE type_mod - INTERFACE h5t - MODULE PROCEDURE h5t_real - MODULE PROCEDURE h5t_dble - END INTERFACE - CONTAINS - SUBROUTINE h5t_real(r) - REAL :: r - END SUBROUTINE h5t_real - SUBROUTINE h5t_dble(d) - DOUBLE PRECISION :: d - END SUBROUTINE h5t_dble - END MODULE type_mod - PROGRAM main - USE type_mod - REAL :: r - DOUBLE PRECISION :: d - CALL h5t(r) - CALL h5t(d) - END PROGRAM main - " -) +# Read source line beginning at the line matching Input:"START" and ending at the line matching Input:"END" +macro (READ_SOURCE SOURCE_START SOURCE_END RETURN_VAR) + file (READ "${HDF5_SOURCE_DIR}/m4/aclocal_fc.f90" SOURCE_MASTER) + string (REGEX MATCH "${SOURCE_START}[\\\t\\\n\\\r[].+]*${SOURCE_END}" SOURCE_CODE ${SOURCE_MASTER}) + set (RETURN_VAR "${SOURCE_CODE}") +endmacro () + +if (HDF5_REQUIRED_LIBRARIES) + set (CMAKE_REQUIRED_LIBRARIES "${HDF5_REQUIRED_LIBRARIES}") +endif () + +READ_SOURCE("PROGRAM PROG_FC_SIZEOF" "END PROGRAM PROG_FC_SIZEOF" SOURCE_CODE) +check_fortran_source_compiles (${SOURCE_CODE} ${HDF_PREFIX}_FORTRAN_HAVE_SIZEOF SRC_EXT f90) + +READ_SOURCE("PROGRAM PROG_FC_C_SIZEOF" "END PROGRAM PROG_FC_C_SIZEOF" SOURCE_CODE) +check_fortran_source_compiles (${SOURCE_CODE} ${HDF_PREFIX}_FORTRAN_HAVE_C_SIZEOF SRC_EXT f90) + +READ_SOURCE("PROGRAM PROG_FC_STORAGE_SIZE" "END PROGRAM PROG_FC_STORAGE_SIZE" SOURCE_CODE) +check_fortran_source_compiles (${SOURCE_CODE} ${HDF_PREFIX}_FORTRAN_HAVE_STORAGE_SIZE SRC_EXT f90) + set (ISO_C_BINDING_CODE " PROGRAM main @@ -122,17 +76,7 @@ set (ISO_C_BINDING_CODE END PROGRAM " ) - -if (HDF5_REQUIRED_LIBRARIES) - set (CMAKE_REQUIRED_LIBRARIES "${HDF5_REQUIRED_LIBRARIES}") -endif () -check_fortran_source_compiles (${SIZEOF_CODE} ${HDF_PREFIX}_FORTRAN_HAVE_SIZEOF SRC_EXT f90) -check_fortran_source_compiles (${C_SIZEOF_CODE} ${HDF_PREFIX}_FORTRAN_HAVE_C_SIZEOF SRC_EXT f90) -check_fortran_source_compiles (${STORAGE_SIZE_CODE} ${HDF_PREFIX}_FORTRAN_HAVE_STORAGE_SIZE SRC_EXT f90) -check_fortran_source_compiles (${ISO_FORTRAN_ENV_CODE} ${HDF_PREFIX}_HAVE_ISO_FORTRAN_ENV SRC_EXT f90) -check_fortran_source_compiles (${REALISNOTDOUBLE_CODE} ${HDF_PREFIX}_FORTRAN_DEFAULT_REAL_NOT_DOUBLE SRC_EXT f90) check_fortran_source_compiles (${ISO_C_BINDING_CODE} ${HDF_PREFIX}_FORTRAN_HAVE_ISO_C_BINDING SRC_EXT f90) -check_fortran_source_compiles (${CHAR_ALLOC} ${HDF_PREFIX}_FORTRAN_HAVE_CHAR_ALLOC SRC_EXT f90) #----------------------------------------------------------------------------- # Add debug information (intel Fortran : JB) From 42f9d2426ffbfd63a1bb18cd16dc1fc886a0e1b6 Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:04:36 -0500 Subject: [PATCH 16/17] Correct reference copy for 16 API (#4244) --- HDF5Examples/C/H5T/CMakeLists.txt | 48 +++++++++---- doxygen/dox/ExamplesAPI.dox | 112 +++++++++++++++--------------- 2 files changed, 89 insertions(+), 71 deletions(-) diff --git a/HDF5Examples/C/H5T/CMakeLists.txt b/HDF5Examples/C/H5T/CMakeLists.txt index e0d76e83fe8..c21a8d03fa1 100644 --- a/HDF5Examples/C/H5T/CMakeLists.txt +++ b/HDF5Examples/C/H5T/CMakeLists.txt @@ -115,7 +115,7 @@ if (HDF5_BUILD_TOOLS) if (NOT ${example_name} STREQUAL "h5ex_t_convert") if (${example_name} STREQUAL "h5ex_t_vlen" OR ${example_name} STREQUAL "h5ex_t_vlenatt") if (HDF5_VERSION_STRING VERSION_GREATER_EQUAL "1.14.3") - if (${H5_LIBVER_DIR} EQUAL 16 AND ${example_name} STREQUAL "h5ex_t_vlenatt") + if ((${EXAMPLE_VARNAME}_USE_16_API OR ${H5_LIBVER_DIR} EQUAL 16) AND ${example_name} STREQUAL "h5ex_t_vlenatt") add_custom_command ( TARGET ${EXAMPLE_VARNAME}_${example_name} POST_BUILD @@ -130,7 +130,7 @@ if (HDF5_BUILD_TOOLS) ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/tfiles/114/${example_name}.ddl ${PROJECT_BINARY_DIR}/${example_name}.ddl ) endif () - elseif (${H5_LIBVER_DIR} EQUAL 16) + elseif (${EXAMPLE_VARNAME}_USE_16_API OR ${H5_LIBVER_DIR} EQUAL 16) add_custom_command ( TARGET ${EXAMPLE_VARNAME}_${example_name} POST_BUILD @@ -180,7 +180,7 @@ if (HDF5_BUILD_TOOLS) ) endif () elseif (HDF5_VERSION_MAJOR VERSION_GREATER_EQUAL "1.12") - if (${H5_LIBVER_DIR} EQUAL 16) + if (${EXAMPLE_VARNAME}_USE_16_API OR ${H5_LIBVER_DIR} EQUAL 16) add_custom_command ( TARGET ${EXAMPLE_VARNAME}_${example_name} POST_BUILD @@ -196,12 +196,21 @@ if (HDF5_BUILD_TOOLS) ) endif () else () - add_custom_command ( - TARGET ${EXAMPLE_VARNAME}_${example_name} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/tfiles/18/${example_name}.ddl ${PROJECT_BINARY_DIR}/${example_name}.ddl - ) + if (${EXAMPLE_VARNAME}_USE_16_API OR ${H5_LIBVER_DIR} EQUAL 16) + add_custom_command ( + TARGET ${EXAMPLE_VARNAME}_${example_name} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/tfiles/16/${example_name}.ddl ${PROJECT_BINARY_DIR}/${example_name}.ddl + ) + else () + add_custom_command ( + TARGET ${EXAMPLE_VARNAME}_${example_name} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/tfiles/18/${example_name}.ddl ${PROJECT_BINARY_DIR}/${example_name}.ddl + ) + endif () endif () else () if (HDF5_VERSION_MAJOR VERSION_EQUAL "1.8") @@ -260,12 +269,21 @@ if (HDF5_BUILD_TOOLS) ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/tfiles/16/${example_name}.ddl ${PROJECT_BINARY_DIR}/${example_name}.ddl ) else () - add_custom_command ( - TARGET ${EXAMPLE_VARNAME}_${example_name} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/tfiles/18/${example_name}.ddl ${PROJECT_BINARY_DIR}/${example_name}.ddl - ) + if (${EXAMPLE_VARNAME}_USE_16_API) + add_custom_command ( + TARGET ${EXAMPLE_VARNAME}_${example_name} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/tfiles/16/${example_name}.ddl ${PROJECT_BINARY_DIR}/${example_name}.ddl + ) + else () + add_custom_command ( + TARGET ${EXAMPLE_VARNAME}_${example_name} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/tfiles/18/${example_name}.ddl ${PROJECT_BINARY_DIR}/${example_name}.ddl + ) + endif () endif () endif () endforeach () diff --git a/doxygen/dox/ExamplesAPI.dox b/doxygen/dox/ExamplesAPI.dox index 5178b0875a9..b0344e48cb1 100644 --- a/doxygen/dox/ExamplesAPI.dox +++ b/doxygen/dox/ExamplesAPI.dox @@ -394,8 +394,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_arrayatt.h5 -h5ex_t_arrayatt.tst -h5ex_t_arrayatt.ddl +h5ex_t_arrayatt.tst +h5ex_t_arrayatt.ddl Read / Write Array (Dataset) @@ -407,8 +407,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_array.h5 -h5ex_t_array.tst -h5ex_t_array.ddl +h5ex_t_array.tst +h5ex_t_array.ddl Read / Write Bitfield (Attribute) @@ -420,8 +420,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_bitatt.h5 -h5ex_t_bitatt.tst -h5ex_t_bitatt.ddl +h5ex_t_bitatt.tst +h5ex_t_bitatt.ddl Read / Write Bitfield (Dataset) @@ -433,8 +433,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_bit.h5 -h5ex_t_bit.tst -h5ex_t_bit.ddl +h5ex_t_bit.tst +h5ex_t_bit.ddl Read / Write Compound (Attribute) @@ -446,8 +446,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_cmpdatt.h5 -h5ex_t_cmpdatt.tst -h5ex_t_cmpdatt.ddl +h5ex_t_cmpdatt.tst +h5ex_t_cmpdatt.ddl Read / Write Compound (Dataset) @@ -459,8 +459,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_cmpd.h5 -h5ex_t_cmpd.tst -h5ex_t_cmpd.ddl +h5ex_t_cmpd.tst +h5ex_t_cmpd.ddl Commit Named Datatype and Read Back @@ -472,8 +472,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_commit.h5 -h5ex_t_commit.tst -h5ex_t_commit.ddl +h5ex_t_commit.tst +h5ex_t_commit.ddl Convert Between Datatypes in Memory @@ -482,8 +482,8 @@ FORTRAN FORTRAN Java JavaObj MATLAB PyHigh PyLow h5ex_t_convert.h5 -h5ex_t_convert.tst -h5ex_t_convert.ddl +h5ex_t_convert.tst +h5ex_t_convert.ddl Read / Write Complex Compound (Attribute) @@ -492,8 +492,8 @@ FORTRAN FORTRAN Java JavaObj MATLAB PyHigh PyLow h5ex_t_cpxcmpdatt.h5 -h5ex_t_cpxcmpdatt.tst -h5ex_t_cpxcmpdatt.ddl +h5ex_t_cpxcmpdatt.tst +h5ex_t_cpxcmpdatt.ddl Read / Write Complex Compound (Dataset) @@ -502,8 +502,8 @@ FORTRAN FORTRAN Java JavaObj MATLAB PyHigh PyLow h5ex_t_cpxcmpd.h5 -h5ex_t_cpxcmpd.tst -h5ex_t_cpxcmpd.ddl +h5ex_t_cpxcmpd.tst +h5ex_t_cpxcmpd.ddl Read / Write Enumerated (Attribute) @@ -513,8 +513,8 @@ FORTRAN Java JavaObj MATLAB PyHigh PyLow h5ex_t_enumatt.h5 -h5ex_t_enumatt.tst -h5ex_t_enumatt.ddl +h5ex_t_enumatt.tst +h5ex_t_enumatt.ddl Read / Write Enumerated (Dataset) @@ -524,8 +524,8 @@ FORTRAN Java JavaObj MATLAB PyHigh PyLow h5ex_t_enum.h5 -h5ex_t_enum.tst -h5ex_t_enum.ddl +h5ex_t_enum.tst +h5ex_t_enum.ddl Read / Write Floating Point (Attribute) @@ -537,8 +537,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_floatatt.h5 -h5ex_t_floatatt.tst -h5ex_t_floatatt.ddl +h5ex_t_floatatt.tst +h5ex_t_floatatt.ddl Read / Write Floating Point (Dataset) @@ -550,8 +550,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_float.h5 -h5ex_t_float.tst -h5ex_t_float.ddl +h5ex_t_float.tst +h5ex_t_float.ddl Read / Write Integer Datatype (Attribute) @@ -563,8 +563,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_intatt.h5 -h5ex_t_intatt.tst -h5ex_t_intatt.ddl +h5ex_t_intatt.tst +h5ex_t_intatt.ddl Read / Write Integer Datatype (Dataset) @@ -576,8 +576,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_int.h5 -h5ex_t_int.tst -h5ex_t_int.ddl +h5ex_t_int.tst +h5ex_t_int.ddl Read / Write Object References (Attribute) @@ -589,8 +589,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_objrefatt.h5 -h5ex_t_objrefatt.tst -h5ex_t_objrefatt.ddl +h5ex_t_objrefatt.tst +h5ex_t_objrefatt.ddl Read / Write Object References (Dataset) @@ -602,8 +602,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_objref.h5 -h5ex_t_objref.tst -h5ex_t_objref.ddl +h5ex_t_objref.tst +h5ex_t_objref.ddl Read / Write Opaque (Attribute) @@ -615,8 +615,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_opaqueatt.h5 -h5ex_t_opaqueatt.tst -h5ex_t_opaqueatt.ddl +h5ex_t_opaqueatt.tst +h5ex_t_opaqueatt.ddl Read / Write Opaque (Dataset) @@ -628,8 +628,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_opaque.h5 -h5ex_t_opaque.tst -h5ex_t_opaque.ddl +h5ex_t_opaque.tst +h5ex_t_opaque.ddl Read / Write Region References (Attribute) @@ -641,8 +641,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_regrefatt.h5 -h5ex_t_regrefatt.tst -h5ex_t_regrefatt.ddl +h5ex_t_regrefatt.tst +h5ex_t_regrefatt.ddl Read / Write Region References (Dataset) @@ -654,8 +654,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_regref.h5 -h5ex_t_regref.tst -h5ex_t_regref.ddl +h5ex_t_regref.tst +h5ex_t_regref.ddl Read / Write String (Attribute) @@ -667,8 +667,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_stringatt.h5 -h5ex_t_stringatt.tst -h5ex_t_stringatt.ddl +h5ex_t_stringatt.tst +h5ex_t_stringatt.ddl Read / Write String (Dataset) @@ -680,8 +680,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_string.h5 -h5ex_t_string.tst -h5ex_t_string.ddl +h5ex_t_string.tst +h5ex_t_string.ddl Read / Write Variable Length (Attribute) @@ -691,8 +691,8 @@ FORTRAN Java JavaObj MATLAB PyHigh PyLow h5ex_t_vlenatt.h5 -h5ex_t_vlenatt.tst -h5ex_t_vlenatt.ddl +h5ex_t_vlenatt.tst +h5ex_t_vlenatt.ddl Read / Write Variable Length (Dataset) @@ -702,8 +702,8 @@ FORTRAN Java JavaObj MATLAB PyHigh PyLow h5ex_t_vlen.h5 -h5ex_t_vlen.tst -h5ex_t_vlen.ddl +h5ex_t_vlen.tst +h5ex_t_vlen.ddl Read / Write Variable Length String (Attribute) @@ -713,8 +713,8 @@ FORTRAN Java JavaObj MATLAB PyHigh PyLow h5ex_t_vlstringatt.h5 -h5ex_t_vlstringatt.tst -h5ex_t_vlstringatt.ddl +h5ex_t_vlstringatt.tst +h5ex_t_vlstringatt.ddl Read / Write Variable Length String (Dataset) @@ -726,8 +726,8 @@ FORTRAN MATLAB PyHigh PyLow h5ex_t_vlstring.h5 -h5ex_t_vlstring.tst -h5ex_t_vlstring.ddl +h5ex_t_vlstring.tst +h5ex_t_vlstring.ddl From 724eaaf618b8f38d4a1243d77033f98186ae0827 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Tue, 26 Mar 2024 11:05:51 -0500 Subject: [PATCH 17/17] Determine MPI LOGICAL during build, used in tests. (#4246) --- config/cmake/HDF5UseFortran.cmake | 59 +++++++++++++++++++- configure.ac | 19 ++++++- fortran/src/CMakeLists.txt | 5 ++ fortran/src/H5config_f.inc.cmake | 8 +++ fortran/src/H5config_f.inc.in | 3 + fortran/testpar/mpi_param.F90 | 15 ++--- fortran/testpar/ptest.F90 | 46 ++++++++++++++++ fortran/testpar/subfiling.F90 | 7 +-- m4/aclocal_fc.f90 | 67 ++++++++++++++++++++++- m4/aclocal_fc.m4 | 91 +++++++++++++++++++++++++++++++ 10 files changed, 298 insertions(+), 22 deletions(-) diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index b7d310315a9..318f9a69848 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -140,8 +140,12 @@ endif () #----------------------------------------------------------------------------- # Determine the available KINDs for REALs and INTEGERs #----------------------------------------------------------------------------- +if (${HAVE_ISO_FORTRAN_ENV}) + READ_SOURCE ("PROGRAM FC08_AVAIL_KINDS" "END PROGRAM FC08_AVAIL_KINDS" SOURCE_CODE) +else () + READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) +endif () -READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) FORTRAN_RUN ("REAL and INTEGER KINDs" "${SOURCE_CODE}" XX @@ -155,6 +159,9 @@ FORTRAN_RUN ("REAL and INTEGER KINDs" # dnl -- LINE 3 -- max decimal precision for reals # dnl -- LINE 4 -- number of valid integer kinds # dnl -- LINE 5 -- number of valid real kinds +# dnl -- LINE 6 -- number of valid logical kinds +# dnl -- LINE 7 -- valid logical kinds (comma separated list) + # # Convert the string to a list of strings by replacing the carriage return with a semicolon string (REGEX REPLACE "[\r\n]+" ";" PROG_OUTPUT "${PROG_OUTPUT}") @@ -190,6 +197,55 @@ message (STATUS "....REAL KINDS FOUND ${PAC_FC_ALL_REAL_KINDS}") message (STATUS "....INTEGER KINDS FOUND ${PAC_FC_ALL_INTEGER_KINDS}") message (STATUS "....MAX DECIMAL PRECISION ${${HDF_PREFIX}_PAC_FC_MAX_REAL_PRECISION}") +if (${HAVE_ISO_FORTRAN_ENV}) + + list (GET PROG_OUTPUT 5 NUM_LKIND) + set (PAC_FORTRAN_NUM_LOGICAL_KINDS "${NUM_LKIND}") + + list (GET PROG_OUTPUT 6 pac_validLogicalKinds) + # If the list is empty then something went wrong. + if (NOT pac_validLogicalKinds) + message (FATAL_ERROR "Failed to find available LOGICAL KINDs for Fortran") + endif () + + set (PAC_FC_ALL_LOGICAL_KINDS "\{${pac_validLogicalKinds}\}") + message (STATUS "....LOGICAL KINDS FOUND ${PAC_FC_ALL_LOGICAL_KINDS}") + +# ******************** +# LOGICAL KIND FOR MPI +# ******************** + if (HDF5_ENABLE_PARALLEL AND BUILD_TESTING) + string (REGEX REPLACE "," ";" VAR "${pac_validLogicalKinds}") + + set(CMAKE_REQUIRED_QUIET TRUE) + foreach (KIND ${VAR}) + unset(MPI_LOGICAL_KIND CACHE) + set (PROG_SRC + " + PROGRAM main + USE MPI + IMPLICIT NONE + LOGICAL(KIND=${KIND}) :: flag + INTEGER(KIND=MPI_INTEGER_KIND) :: info_ret, mpierror + CHARACTER(LEN=3) :: info_val + CALL mpi_info_get(info_ret,\"foo\", 3_MPI_INTEGER_KIND, info_val, flag, mpierror) + END + " + ) + check_fortran_source_compiles (${PROG_SRC} MPI_LOGICAL_KIND SRC_EXT f90) + + if (MPI_LOGICAL_KIND) + set (${HDF_PREFIX}_MPI_LOGICAL_KIND ${KIND}) + message (STATUS "....FORTRAN LOGICAL KIND for MPI is ${KIND}") + endif () + endforeach () + if (${HDF_PREFIX}_MPI_LOGICAL_KIND STREQUAL "") + message (FATAL_ERROR "Failed to determine LOGICAL KIND for MPI") + endif () + set(CMAKE_REQUIRED_QUIET FALSE) + endif() +endif() + #----------------------------------------------------------------------------- # Determine the available KINDs for REALs and INTEGERs #----------------------------------------------------------------------------- @@ -338,7 +394,6 @@ if (NOT PAC_FORTRAN_NATIVE_DOUBLE_KIND) message (FATAL_ERROR "Failed to find KIND of NATIVE DOUBLE for Fortran") endif () - set (${HDF_PREFIX}_FORTRAN_SIZEOF_LONG_DOUBLE ${${HDF_PREFIX}_SIZEOF_LONG_DOUBLE}) # remove the invalid kind from the list diff --git a/configure.ac b/configure.ac index f94dcf848bd..6b546dc1f5e 100644 --- a/configure.ac +++ b/configure.ac @@ -830,8 +830,13 @@ if test "X$HDF_FORTRAN" = "Xyes"; then PAC_FC_NATIVE_INTEGER ## Find all available KINDs - PAC_FC_AVAIL_KINDS - ## Find all sizeofs for available KINDs + if test "X$HAVE_ISO_FORTRAN_ENV" = "X1";then + PAC_FC_AVAIL_KINDS_F08 + else + PAC_FC_AVAIL_KINDS + fi + + ## Find all SIZEOFs for available KINDs PAC_FC_SIZEOF_INT_KINDS PAC_FC_SIZEOF_REAL_KINDS @@ -3055,6 +3060,16 @@ if test -n "$PARALLEL"; then [AC_MSG_RESULT([no])] ) AC_LANG_POP(Fortran) + + if test "X$HDF5_TESTS" = "Xyes"; then + AC_SUBST([MPI_LOGICAL_KIND]) + PAC_FIND_MPI_LOGICAL_KIND + if test "X$" = "Xyes"; then + HAVE_ISO_FORTRAN_ENV="1" + AC_DEFINE([HAVE_ISO_FORTRAN_ENV], [1], [Define if Fortran supports ISO_FORTRAN_ENV (F08)]) + fi + fi + fi ## ---------------------------------------------------------------------- diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 80ee2889bc7..1b23c94a976 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -79,6 +79,11 @@ if (H5_FORTRAN_HAVE_CHAR_ALLOC) set (CMAKE_H5_FORTRAN_HAVE_CHAR_ALLOC 1) endif () +set (CMAKE_H5_MPI_LOGICAL_KIND 0) +if (H5_MPI_LOGICAL_KIND) + set (CMAKE_H5_MPI_LOGICAL_KIND 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) diff --git a/fortran/src/H5config_f.inc.cmake b/fortran/src/H5config_f.inc.cmake index 31c149883cf..bc9f036e020 100644 --- a/fortran/src/H5config_f.inc.cmake +++ b/fortran/src/H5config_f.inc.cmake @@ -79,6 +79,14 @@ ! Define if Fortran C_BOOL is different from default LOGICAL #define H5_FORTRAN_C_BOOL_IS_UNIQUE @H5_FORTRAN_C_BOOL_IS_UNIQUE@ +! Define MPI Fortran KIND of LOGICAL +#cmakedefine01 CMAKE_H5_MPI_LOGICAL_KIND +#if CMAKE_H5_MPI_LOGICAL_KIND == 0 +#undef H5_MPI_LOGICAL_KIND +#else +#define H5_MPI_LOGICAL_KIND @H5_MPI_LOGICAL_KIND@ +#endif + ! Define if Fortran supports ISO_FORTRAN_ENV (F08) #cmakedefine01 CMAKE_H5_HAVE_ISO_FORTRAN_ENV #if CMAKE_H5_HAVE_ISO_FORTRAN_ENV == 0 diff --git a/fortran/src/H5config_f.inc.in b/fortran/src/H5config_f.inc.in index 6e465ca014b..7f2d3cad8a9 100644 --- a/fortran/src/H5config_f.inc.in +++ b/fortran/src/H5config_f.inc.in @@ -50,6 +50,9 @@ ! Define if Fortran supports ISO_FORTRAN_ENV (F08) #undef HAVE_ISO_FORTRAN_ENV +! Define MPI Fortran KIND of LOGICAL +#undef MPI_LOGICAL_KIND + ! Define the size of C's double #undef SIZEOF_DOUBLE diff --git a/fortran/testpar/mpi_param.F90 b/fortran/testpar/mpi_param.F90 index 09a95d47177..1d7f8ff70f8 100644 --- a/fortran/testpar/mpi_param.F90 +++ b/fortran/testpar/mpi_param.F90 @@ -18,9 +18,6 @@ SUBROUTINE mpi_param_03(nerrors) -#ifdef H5_HAVE_ISO_FORTRAN_ENV - USE, INTRINSIC :: iso_fortran_env, ONLY : atomic_logical_kind -#endif USE MPI USE HDF5 USE TH5_MISC @@ -39,8 +36,8 @@ SUBROUTINE mpi_param_03(nerrors) INTEGER(KIND=MPI_INTEGER_KIND) :: info, info_ret INTEGER(KIND=MPI_INTEGER_KIND) :: comm, comm_ret INTEGER(KIND=MPI_INTEGER_KIND) :: nkeys -#ifdef H5_HAVE_ISO_FORTRAN_ENV - LOGICAL(KIND=atomic_logical_kind) :: flag +#ifdef H5_MPI_LOGICAL_KIND + LOGICAL(KIND=H5_MPI_LOGICAL_KIND) :: flag #else LOGICAL(KIND=MPI_INTEGER_KIND) :: flag #endif @@ -178,10 +175,6 @@ END SUBROUTINE mpi_param_03 SUBROUTINE mpi_param_08(nerrors) #ifdef H5_HAVE_MPI_F08 - -#ifdef H5_HAVE_ISO_FORTRAN_ENV - USE, INTRINSIC :: iso_fortran_env, ONLY : atomic_logical_kind -#endif USE MPI_F08 USE HDF5 USE TH5_MISC @@ -199,8 +192,8 @@ SUBROUTINE mpi_param_08(nerrors) TYPE(MPI_INFO) :: info, info_ret TYPE(MPI_COMM) :: comm, comm_ret INTEGER(KIND=MPI_INTEGER_KIND) :: nkeys -#ifdef H5_HAVE_ISO_FORTRAN_ENV - LOGICAL(KIND=atomic_logical_kind) :: flag +#ifdef H5_MPI_LOGICAL_KIND + LOGICAL(KIND=H5_MPI_LOGICAL_KIND) :: flag #else LOGICAL(KIND=MPI_INTEGER_KIND) :: flag #endif diff --git a/fortran/testpar/ptest.F90 b/fortran/testpar/ptest.F90 index 3d7280bbcf8..6e34ffdaaac 100644 --- a/fortran/testpar/ptest.F90 +++ b/fortran/testpar/ptest.F90 @@ -37,6 +37,52 @@ PROGRAM parallel_test CHARACTER(LEN=10), DIMENSION(1:2) :: chr_chunk =(/"contiguous", "chunk "/) INTEGER(KIND=MPI_INTEGER_KIND) :: mpi_int_type + INTERFACE + + SUBROUTINE mpi_param_03(ret_total_error) + IMPLICIT NONE + INTEGER, INTENT(inout) :: ret_total_error + END SUBROUTINE mpi_param_03 + + SUBROUTINE mpi_param_08(ret_total_error) + IMPLICIT NONE + INTEGER, INTENT(inout) :: ret_total_error + END SUBROUTINE mpi_param_08 + + SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) + USE MPI + IMPLICIT NONE + INTEGER, INTENT(in) :: length + LOGICAL, INTENT(in) :: do_collective + LOGICAL, INTENT(in) :: do_chunk + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_size + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_rank + INTEGER, INTENT(inout) :: nerrors + END SUBROUTINE hyper + + SUBROUTINE pmultiple_dset_hyper_rw(do_collective, do_chunk, mpi_size, mpi_rank, nerrors) + USE MPI + IMPLICIT NONE + LOGICAL, INTENT(in) :: do_collective + LOGICAL, INTENT(in) :: do_chunk + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_size + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_rank + INTEGER, INTENT(inout) :: nerrors + END SUBROUTINE pmultiple_dset_hyper_rw + + SUBROUTINE multiple_dset_write(length, do_collective, do_chunk, mpi_size, mpi_rank, nerrors) + USE MPI + IMPLICIT NONE + INTEGER, INTENT(in) :: length + LOGICAL, INTENT(in) :: do_collective + LOGICAL, INTENT(in) :: do_chunk + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_size + INTEGER(KIND=MPI_INTEGER_KIND), INTENT(in) :: mpi_rank + INTEGER, INTENT(inout) :: nerrors + END SUBROUTINE multiple_dset_write + + END INTERFACE + ! ! initialize MPI ! diff --git a/fortran/testpar/subfiling.F90 b/fortran/testpar/subfiling.F90 index 9bee38bcc6f..a9c67e9b94c 100644 --- a/fortran/testpar/subfiling.F90 +++ b/fortran/testpar/subfiling.F90 @@ -18,9 +18,6 @@ PROGRAM subfiling_test USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_INT64_T -#ifdef H5_HAVE_ISO_FORTRAN_ENV - USE, INTRINSIC :: iso_fortran_env, ONLY : atomic_logical_kind -#endif USE HDF5 USE MPI USE TH5_MISC @@ -50,8 +47,8 @@ PROGRAM subfiling_test INTEGER(C_INT64_T) inode TYPE(H5FD_subfiling_config_t) :: vfd_config TYPE(H5FD_ioc_config_t) :: vfd_config_ioc -#ifdef H5_HAVE_ISO_FORTRAN_ENV - LOGICAL(KIND=atomic_logical_kind) :: flag +#ifdef H5_MPI_LOGICAL_KIND + LOGICAL(KIND=H5_MPI_LOGICAL_KIND) :: flag #else LOGICAL(KIND=MPI_INTEGER_KIND) :: flag #endif diff --git a/m4/aclocal_fc.f90 b/m4/aclocal_fc.f90 index 9e4bfde3c90..918fc6769dd 100644 --- a/m4/aclocal_fc.f90 +++ b/m4/aclocal_fc.f90 @@ -21,8 +21,7 @@ ! PROGRAM PROG_FC_ISO_FORTRAN_ENV - USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : atomic_logical_kind - LOGICAL(KIND=atomic_logical_kind) :: state + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : logical_kinds END PROGRAM PROG_FC_ISO_FORTRAN_ENV PROGRAM PROG_FC_SIZEOF @@ -183,6 +182,70 @@ PROGRAM FC_AVAIL_KINDS END PROGRAM FC_AVAIL_KINDS !---- END ----- Determine the available KINDs for REALs and INTEGERs +!---- START ----- Determine the available KINDs for REALs, INTEGERs and LOGICALs -- ISO_FORTRAN_ENV (F08) +PROGRAM FC08_AVAIL_KINDS + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : stdout=>OUTPUT_UNIT, integer_kinds, real_kinds, logical_kinds + IMPLICIT NONE + INTEGER :: ik, jk, k, max_decimal_prec + INTEGER :: num_rkinds, num_ikinds, num_lkinds + + ! Find integer KINDs + + num_ikinds = SIZE(integer_kinds) + + DO k = 1, num_ikinds + WRITE(stdout,'(I0)', ADVANCE='NO') integer_kinds(k) + IF(k.NE.num_ikinds)THEN + WRITE(stdout,'(A)',ADVANCE='NO') ',' + ELSE + WRITE(stdout,'()') + ENDIF + ENDDO + + ! Find real KINDs + + num_rkinds = SIZE(real_kinds) + + max_decimal_prec = 1 + + prec: DO ik = 2, 36 + exp: DO jk = 1, 700 + k = SELECTED_REAL_KIND(ik,jk) + IF(k.LT.0) EXIT exp + max_decimal_prec = ik + ENDDO exp + ENDDO prec + + DO k = 1, num_rkinds + WRITE(stdout,'(I0)', ADVANCE='NO') real_kinds(k) + IF(k.NE.num_rkinds)THEN + WRITE(stdout,'(A)',ADVANCE='NO') ',' + ELSE + WRITE(stdout,'()') + ENDIF + ENDDO + + WRITE(stdout,'(I0)') max_decimal_prec + WRITE(stdout,'(I0)') num_ikinds + WRITE(stdout,'(I0)') num_rkinds + + ! Find logical KINDs + + num_lkinds = SIZE(logical_kinds) + WRITE(stdout,'(I0)') num_lkinds + + DO k = 1, num_lkinds + WRITE(stdout,'(I0)', ADVANCE='NO') logical_kinds(k) + IF(k.NE.num_lkinds)THEN + WRITE(stdout,'(A)',ADVANCE='NO') ',' + ELSE + WRITE(stdout,'()') + ENDIF + ENDDO + +END PROGRAM FC08_AVAIL_KINDS +!---- END ----- Determine the available KINDs for REALs, INTEGERs and LOGICALs -- ISO_FORTRAN_ENV (F08) + PROGRAM FC_MPI_CHECK USE mpi INTEGER :: comm, amode, info, fh, ierror diff --git a/m4/aclocal_fc.m4 b/m4/aclocal_fc.m4 index 6e5703e9132..ebc64c6f7bc 100644 --- a/m4/aclocal_fc.m4 +++ b/m4/aclocal_fc.m4 @@ -323,6 +323,97 @@ AC_RUN_IFELSE([$TEST_SRC], AC_LANG_POP([Fortran]) ]) + +dnl -------------------------------------------------------------- +dnl Determine the available KINDs for REALs, INTEGERs and LOGICALS +dnl -------------------------------------------------------------- +dnl +dnl This is a runtime test. +dnl +AC_DEFUN([PAC_FC_AVAIL_KINDS_F08],[ +AC_LANG_PUSH([Fortran]) +TEST_SRC="`sed -n '/PROGRAM FC08_AVAIL_KINDS/,/END PROGRAM FC08_AVAIL_KINDS/p' $srcdir/m4/aclocal_fc.f90`" +AC_RUN_IFELSE([$TEST_SRC], + [ + dnl The output from the above program will be: + dnl -- LINE 1 -- valid integer kinds (comma separated list) + dnl -- LINE 2 -- valid real kinds (comma separated list) + dnl -- LINE 3 -- max decimal precision for reals + dnl -- LINE 4 -- number of valid integer kinds + dnl -- LINE 5 -- number of valid real kinds + dnl -- LINE 6 -- number of valid logical kinds + dnl -- LINE 7 -- valid logical kinds (comma separated list) + + pac_validIntKinds=$(./conftest$EXEEXT 2>&1 | sed -n '1p') + pac_validRealKinds=$(./conftest$EXEEXT 2>&1 | sed -n '2p') + PAC_FC_MAX_REAL_PRECISION=$(./conftest$EXEEXT 2>&1 | sed -n '3p') + AC_DEFINE_UNQUOTED([PAC_FC_MAX_REAL_PRECISION], $PAC_FC_MAX_REAL_PRECISION, [Define Fortran Maximum Real Decimal Precision]) + + PAC_FC_ALL_INTEGER_KINDS="{`echo $pac_validIntKinds`}" + PAC_FC_ALL_REAL_KINDS="{`echo $pac_validRealKinds`}" + + PAC_FORTRAN_NUM_INTEGER_KINDS=$(./conftest$EXEEXT 2>&1 | sed -n '4p') + H5CONFIG_F_NUM_IKIND="INTEGER, PARAMETER :: num_ikinds = `echo $PAC_FORTRAN_NUM_INTEGER_KINDS`" + H5CONFIG_F_IKIND="INTEGER, DIMENSION(1:num_ikinds) :: ikind = (/`echo $pac_validIntKinds`/)" + H5CONFIG_F_NUM_RKIND="INTEGER, PARAMETER :: num_rkinds = $(./conftest$EXEEXT 2>&1 | sed -n '5p')" + H5CONFIG_F_RKIND="INTEGER, DIMENSION(1:num_rkinds) :: rkind = (/`echo $pac_validRealKinds`/)" + + AC_DEFINE_UNQUOTED([H5CONFIG_F_NUM_RKIND], $H5CONFIG_F_NUM_RKIND, [Define number of valid Fortran REAL KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_NUM_IKIND], $H5CONFIG_F_NUM_IKIND, [Define number of valid Fortran INTEGER KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_RKIND], $H5CONFIG_F_RKIND, [Define valid Fortran REAL KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_IKIND], $H5CONFIG_F_IKIND, [Define valid Fortran INTEGER KINDs]) + + PAC_FORTRAN_NUM_LOGICAL_KINDS=$(./conftest$EXEEXT 2>&1 | sed -n '6p') + pac_validLogicalKinds=$(./conftest$EXEEXT 2>&1 | sed -n '7p') + PAC_FC_ALL_LOGICAL_KINDS="{`echo $pac_validLogicalKinds`}" + + AC_MSG_CHECKING([for Number of Fortran INTEGER KINDs]) + AC_MSG_RESULT([$PAC_FORTRAN_NUM_INTEGER_KINDS]) + AC_MSG_CHECKING([for Fortran INTEGER KINDs]) + AC_MSG_RESULT([$PAC_FC_ALL_INTEGER_KINDS]) + AC_MSG_CHECKING([for Fortran REAL KINDs]) + AC_MSG_RESULT([$PAC_FC_ALL_REAL_KINDS]) + AC_MSG_CHECKING([for Fortran REALs maximum decimal precision]) + AC_MSG_RESULT([$PAC_FC_MAX_REAL_PRECISION]) + AC_MSG_CHECKING([for Number of Fortran LOGICAL KINDs]) + AC_MSG_RESULT([$PAC_FORTRAN_NUM_LOGICAL_KINDS]) + AC_MSG_CHECKING([for Fortran LOGICAL KINDs]) + AC_MSG_RESULT([$PAC_FC_ALL_LOGICAL_KINDS]) +],[ + AC_MSG_RESULT([Error]) + AC_MSG_ERROR([Failed to run Fortran program to determine available KINDs]) +],[]) +AC_LANG_POP([Fortran]) +]) + +AC_DEFUN([PAC_FIND_MPI_LOGICAL_KIND],[ +AC_REQUIRE([PAC_FC_AVAIL_KINDS]) +AC_MSG_CHECKING([default Fortran KIND of LOGICAL in MPI]) +AC_LANG_PUSH([Fortran]) + +for kind in `echo $pac_validLogicalKinds | sed -e 's/,/ /g'`; do + AC_COMPILE_IFELSE([ + PROGRAM main + USE MPI + IMPLICIT NONE + LOGICAL(KIND=$kind) :: flag + INTEGER(KIND=MPI_INTEGER_KIND) :: info_ret, mpierror + CHARACTER(LEN=3) :: info_val + CALL mpi_info_get(info_ret,"foo", 3_MPI_INTEGER_KIND, info_val, flag, mpierror) + END], + [AC_SUBST([PAC_MPI_LOGICAL_KIND]) PAC_MPI_LOGICAL_KIND=$kind], + [] + ) +done +if test "X$PAC_MPI_LOGICAL_KIND" = "X"; then + AC_MSG_ERROR([Failed to find Fortran KIND of LOGICAL in MPI]) +else + AC_DEFINE_UNQUOTED([MPI_LOGICAL_KIND], [$PAC_MPI_LOGICAL_KIND], [Define MPI Fortran KIND of LOGICAL]) + AC_MSG_RESULT([$PAC_MPI_LOGICAL_KIND]) +fi +AC_LANG_POP([Fortran]) +]) + AC_DEFUN([PAC_FC_SIZEOF_INT_KINDS],[ AC_REQUIRE([PAC_FC_AVAIL_KINDS]) AC_MSG_CHECKING([sizeof of available INTEGER KINDs])