From 820d590b6b8a5096226f65029111f2475089119a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 27 Jul 2021 07:25:44 +0200 Subject: [PATCH] write string to result requires to open file without MPI support --- src/HDF5_utilities.f90 | 9 +++++++-- src/results.f90 | 27 +++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/HDF5_utilities.f90 b/src/HDF5_utilities.f90 index 7de6be431..bd88feee2 100644 --- a/src/HDF5_utilities.f90 +++ b/src/HDF5_utilities.f90 @@ -129,10 +129,11 @@ end subroutine HDF5_utilities_init !-------------------------------------------------------------------------------------------------- !> @brief open and initializes HDF5 output file !-------------------------------------------------------------------------------------------------- -integer(HID_T) function HDF5_openFile(fileName,mode) +integer(HID_T) function HDF5_openFile(fileName,mode,parallel) character(len=*), intent(in) :: fileName character, intent(in), optional :: mode + logical, intent(in), optional :: parallel character :: m integer(HID_T) :: plist_id @@ -149,7 +150,11 @@ integer(HID_T) function HDF5_openFile(fileName,mode) if(hdferr < 0) error stop 'HDF5 error' #ifdef PETSC - call h5pset_fapl_mpio_f(plist_id, PETSC_COMM_WORLD, MPI_INFO_NULL, hdferr) + if (present(parallel)) then + if (parallel) call h5pset_fapl_mpio_f(plist_id, PETSC_COMM_WORLD, MPI_INFO_NULL, hdferr) + else + call h5pset_fapl_mpio_f(plist_id, PETSC_COMM_WORLD, MPI_INFO_NULL, hdferr) + endif if(hdferr < 0) error stop 'HDF5 error' #endif diff --git a/src/results.f90 b/src/results.f90 index 94625a4b9..ef6298151 100644 --- a/src/results.f90 +++ b/src/results.f90 @@ -52,6 +52,7 @@ module results results_openGroup, & results_closeGroup, & results_writeDataset, & + results_writeDataset_str, & results_setLink, & results_addAttribute, & results_removeLink, & @@ -90,9 +91,12 @@ end subroutine results_init !-------------------------------------------------------------------------------------------------- !> @brief opens the results file to append data !-------------------------------------------------------------------------------------------------- -subroutine results_openJobFile +subroutine results_openJobFile(parallel) - resultsFile = HDF5_openFile(getSolverJobName()//'.hdf5','a') + logical, intent(in), optional :: parallel + + + resultsFile = HDF5_openFile(getSolverJobName()//'.hdf5','a',parallel) end subroutine results_openJobFile @@ -297,6 +301,25 @@ subroutine results_removeLink(link) end subroutine results_removeLink +!-------------------------------------------------------------------------------------------------- +!> @brief Store string dataset. +!> @details Not collective, must be called by one process at at time. +!-------------------------------------------------------------------------------------------------- +subroutine results_writeDataset_str(dataset,group,label,description) + + character(len=*), intent(in) :: label,group,description,dataset + + integer(HID_T) :: groupHandle + + + groupHandle = results_openGroup(group) + call HDF5_write_str(dataset,groupHandle,label) + call executionStamp(group//'/'//label,description) + call HDF5_closeGroup(groupHandle) + +end subroutine results_writeDataset_str + + !-------------------------------------------------------------------------------------------------- !> @brief Store real scalar dataset with associated metadata. !--------------------------------------------------------------------------------------------------