diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2022-10-07 16:01:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-07 16:01:42 (GMT) |
commit | 306db409d44cccbeaff1cd5acb1a99173ac8b185 (patch) | |
tree | 6f5dca24e9a78ca6710961fcd7da5459048bd2e7 | |
parent | e80079fd21ffe6978ac69e7632e069cc44874675 (diff) | |
download | hdf5-306db409d44cccbeaff1cd5acb1a99173ac8b185.zip hdf5-306db409d44cccbeaff1cd5acb1a99173ac8b185.tar.gz hdf5-306db409d44cccbeaff1cd5acb1a99173ac8b185.tar.bz2 |
Avoid calling H5FD_subfiling_init from h5open_f. (#2149)
* Only call H5FD_SUBFILING if subfiling conditions are met
* clang format
-rw-r--r-- | fortran/src/H5_f.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c index 385241d..dc7768f 100644 --- a/fortran/src/H5_f.c +++ b/fortran/src/H5_f.c @@ -561,7 +561,29 @@ h5init_flags_c(int_f *h5d_flags, size_t_f *h5d_size_flags, int_f *h5e_flags, hid h5fd_hid_flags[4] = (hid_t_f)H5FD_MULTI; h5fd_hid_flags[5] = (hid_t_f)H5FD_SEC2; h5fd_hid_flags[6] = (hid_t_f)H5FD_STDIO; - h5fd_hid_flags[7] = (hid_t_f)H5FD_SUBFILING; + + /* Calling H5FD_subfiling_init here requires the + subfiling requirements to be met. Only set the + subfiling if it meets the below conditions */ + + h5fd_hid_flags[7] = (hid_t_f)H5I_INVALID_HID; + +#ifdef H5_HAVE_PARALLEL + int mpi_initialized = 0; + int provided = 0; + int mpi_code; + + if (MPI_SUCCESS == (mpi_code = MPI_Initialized(&mpi_initialized))) { + if (mpi_initialized) { + /* If MPI is initialized, validate that it was initialized with MPI_THREAD_MULTIPLE */ + if (MPI_SUCCESS == (mpi_code = MPI_Query_thread(&provided))) { + if (provided == MPI_THREAD_MULTIPLE) { + h5fd_hid_flags[7] = (hid_t_f)H5FD_SUBFILING; + } + } + } + } +#endif #ifdef H5_HAVE_SUBFILING_VFD h5fd_hid_flags[8] = (hid_t_f)H5FD_SUBFILING_DEFAULT_STRIPE_SIZE; #else |