Shorthand subroutines for standard HDF/MPI error checking to avoid code duplication
This commit is contained in:
parent
01df331632
commit
dd4390fb75
|
@ -96,6 +96,7 @@ module HDF5_utilities
|
||||||
|
|
||||||
public :: &
|
public :: &
|
||||||
HDF5_utilities_init, &
|
HDF5_utilities_init, &
|
||||||
|
HDF5_chkerr, &
|
||||||
HDF5_read, &
|
HDF5_read, &
|
||||||
HDF5_write, &
|
HDF5_write, &
|
||||||
HDF5_write_str, &
|
HDF5_write_str, &
|
||||||
|
@ -125,45 +126,58 @@ subroutine HDF5_utilities_init
|
||||||
|
|
||||||
|
|
||||||
call H5Open_f(hdferr)
|
call H5Open_f(hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Tget_size_f(H5T_NATIVE_INTEGER,typeSize, hdferr)
|
call H5Tget_size_f(H5T_NATIVE_INTEGER,typeSize, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (int(bit_size(0),SIZE_T)/=typeSize*8) &
|
if (int(bit_size(0),SIZE_T)/=typeSize*8) &
|
||||||
error stop 'Default integer size does not match H5T_NATIVE_INTEGER'
|
error stop 'Default integer size does not match H5T_NATIVE_INTEGER'
|
||||||
|
|
||||||
call H5Tget_size_f(H5T_NATIVE_DOUBLE,typeSize, hdferr)
|
call H5Tget_size_f(H5T_NATIVE_DOUBLE,typeSize, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (int(storage_size(0.0_pReal),SIZE_T)/=typeSize*8) &
|
if (int(storage_size(0.0_pReal),SIZE_T)/=typeSize*8) &
|
||||||
error stop 'pReal does not match H5T_NATIVE_DOUBLE'
|
error stop 'pReal does not match H5T_NATIVE_DOUBLE'
|
||||||
|
|
||||||
call H5get_libversion_f(HDF5_major,HDF5_minor,HDF5_release,hdferr)
|
call H5get_libversion_f(HDF5_major,HDF5_minor,HDF5_release,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
compression_possible = (HDF5_major == 1 .and. HDF5_minor >= 12) ! https://forum.hdfgroup.org/t/6186
|
compression_possible = (HDF5_major == 1 .and. HDF5_minor >= 12) ! https://forum.hdfgroup.org/t/6186
|
||||||
|
|
||||||
call H5Zfilter_avail_f(H5Z_FILTER_DEFLATE_F,avail,hdferr)
|
call H5Zfilter_avail_f(H5Z_FILTER_DEFLATE_F,avail,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
compression_possible = compression_possible .and. avail
|
compression_possible = compression_possible .and. avail
|
||||||
|
|
||||||
if (avail) then
|
if (avail) then
|
||||||
call H5Zget_filter_info_f(H5Z_FILTER_DEFLATE_F,configFlags,hdferr)
|
call H5Zget_filter_info_f(H5Z_FILTER_DEFLATE_F,configFlags,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
compression_possible = compression_possible .and. iand(H5Z_FILTER_ENCODE_ENABLED_F,configFlags) > 0
|
compression_possible = compression_possible .and. iand(H5Z_FILTER_ENCODE_ENABLED_F,configFlags) > 0
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call H5Zfilter_avail_f(H5Z_FILTER_SHUFFLE_F,avail,hdferr)
|
call H5Zfilter_avail_f(H5Z_FILTER_SHUFFLE_F,avail,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
compression_possible = compression_possible .and. avail
|
compression_possible = compression_possible .and. avail
|
||||||
|
|
||||||
if (avail) then
|
if (avail) then
|
||||||
call H5Zget_filter_info_f(H5Z_FILTER_SHUFFLE_F,configFlags,hdferr)
|
call H5Zget_filter_info_f(H5Z_FILTER_SHUFFLE_F,configFlags,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
compression_possible = compression_possible .and. iand(H5Z_FILTER_ENCODE_ENABLED_F,configFlags) > 0
|
compression_possible = compression_possible .and. iand(H5Z_FILTER_ENCODE_ENABLED_F,configFlags) > 0
|
||||||
end if
|
end if
|
||||||
|
|
||||||
end subroutine HDF5_utilities_init
|
end subroutine HDF5_utilities_init
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief Check for HDF5 error.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
subroutine HDF5_chkerr(e)
|
||||||
|
|
||||||
|
integer, intent(in) :: e
|
||||||
|
|
||||||
|
|
||||||
|
if (e<0) error stop 'HDF5 error'
|
||||||
|
|
||||||
|
end subroutine HDF5_chkerr
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief Open and initialize HDF5 file.
|
!> @brief Open and initialize HDF5 file.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
@ -181,7 +195,7 @@ integer(HID_T) function HDF5_openFile(fileName,mode,parallel)
|
||||||
m = misc_optional(mode,'r')
|
m = misc_optional(mode,'r')
|
||||||
|
|
||||||
call H5Pcreate_f(H5P_FILE_ACCESS_F, plist_id, hdferr)
|
call H5Pcreate_f(H5P_FILE_ACCESS_F, plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
#ifdef PETSC
|
#ifdef PETSC
|
||||||
if (misc_optional(parallel,.true.)) &
|
if (misc_optional(parallel,.true.)) &
|
||||||
|
@ -190,24 +204,24 @@ integer(HID_T) function HDF5_openFile(fileName,mode,parallel)
|
||||||
#else
|
#else
|
||||||
call H5Pset_fapl_mpio_f(plist_id, PETSC_COMM_WORLD, MPI_INFO_NULL, hdferr)
|
call H5Pset_fapl_mpio_f(plist_id, PETSC_COMM_WORLD, MPI_INFO_NULL, hdferr)
|
||||||
#endif
|
#endif
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m == 'w') then
|
if (m == 'w') then
|
||||||
call H5Fcreate_f(fileName,H5F_ACC_TRUNC_F,HDF5_openFile,hdferr,access_prp = plist_id)
|
call H5Fcreate_f(fileName,H5F_ACC_TRUNC_F,HDF5_openFile,hdferr,access_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
elseif (m == 'a') then
|
elseif (m == 'a') then
|
||||||
call H5Fopen_f(fileName,H5F_ACC_RDWR_F,HDF5_openFile,hdferr,access_prp = plist_id)
|
call H5Fopen_f(fileName,H5F_ACC_RDWR_F,HDF5_openFile,hdferr,access_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
elseif (m == 'r') then
|
elseif (m == 'r') then
|
||||||
call H5Fopen_f(fileName,H5F_ACC_RDONLY_F,HDF5_openFile,hdferr,access_prp = plist_id)
|
call H5Fopen_f(fileName,H5F_ACC_RDONLY_F,HDF5_openFile,hdferr,access_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
else
|
else
|
||||||
error stop 'unknown access mode'
|
error stop 'unknown access mode'
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call H5Pclose_f(plist_id, hdferr)
|
call H5Pclose_f(plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end function HDF5_openFile
|
end function HDF5_openFile
|
||||||
|
|
||||||
|
@ -222,7 +236,7 @@ subroutine HDF5_closeFile(fileHandle)
|
||||||
integer :: hdferr
|
integer :: hdferr
|
||||||
|
|
||||||
call H5Fclose_f(fileHandle,hdferr)
|
call H5Fclose_f(fileHandle,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_closeFile
|
end subroutine HDF5_closeFile
|
||||||
|
|
||||||
|
@ -241,19 +255,19 @@ integer(HID_T) function HDF5_addGroup(fileHandle,groupName)
|
||||||
!-------------------------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------------------------
|
||||||
! creating a property list for data access properties
|
! creating a property list for data access properties
|
||||||
call H5Pcreate_f(H5P_GROUP_ACCESS_F, aplist_id, hdferr)
|
call H5Pcreate_f(H5P_GROUP_ACCESS_F, aplist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!-------------------------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------------------------
|
||||||
! setting I/O mode to collective
|
! setting I/O mode to collective
|
||||||
#ifdef PETSC
|
#ifdef PETSC
|
||||||
call H5Pset_all_coll_metadata_ops_f(aplist_id, .true., hdferr)
|
call H5Pset_all_coll_metadata_ops_f(aplist_id, .true., hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
!-------------------------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------------------------
|
||||||
! Create group
|
! Create group
|
||||||
call H5Gcreate_f(fileHandle, trim(groupName), HDF5_addGroup, hdferr, OBJECT_NAMELEN_DEFAULT_F,gapl_id = aplist_id)
|
call H5Gcreate_f(fileHandle, trim(groupName), HDF5_addGroup, hdferr, OBJECT_NAMELEN_DEFAULT_F,gapl_id = aplist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Pclose_f(aplist_id,hdferr)
|
call H5Pclose_f(aplist_id,hdferr)
|
||||||
|
|
||||||
|
@ -277,19 +291,19 @@ integer(HID_T) function HDF5_openGroup(fileHandle,groupName)
|
||||||
!-------------------------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------------------------
|
||||||
! creating a property list for data access properties
|
! creating a property list for data access properties
|
||||||
call H5Pcreate_f(H5P_GROUP_ACCESS_F, aplist_id, hdferr)
|
call H5Pcreate_f(H5P_GROUP_ACCESS_F, aplist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!-------------------------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------------------------
|
||||||
! setting I/O mode to collective
|
! setting I/O mode to collective
|
||||||
#ifdef PETSC
|
#ifdef PETSC
|
||||||
call H5Pget_all_coll_metadata_ops_f(aplist_id, is_collective, hdferr)
|
call H5Pget_all_coll_metadata_ops_f(aplist_id, is_collective, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
!-------------------------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------------------------
|
||||||
! opening the group
|
! opening the group
|
||||||
call H5Gopen_f(fileHandle, trim(groupName), HDF5_openGroup, hdferr, gapl_id = aplist_id)
|
call H5Gopen_f(fileHandle, trim(groupName), HDF5_openGroup, hdferr, gapl_id = aplist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Pclose_f(aplist_id,hdferr)
|
call H5Pclose_f(aplist_id,hdferr)
|
||||||
|
|
||||||
|
@ -306,7 +320,7 @@ subroutine HDF5_closeGroup(group_id)
|
||||||
integer :: hdferr
|
integer :: hdferr
|
||||||
|
|
||||||
call H5Gclose_f(group_id, hdferr)
|
call H5Gclose_f(group_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_closeGroup
|
end subroutine HDF5_closeGroup
|
||||||
|
|
||||||
|
@ -326,11 +340,11 @@ logical function HDF5_objectExists(loc_id,path)
|
||||||
p = trim(misc_optional(path,'.'))
|
p = trim(misc_optional(path,'.'))
|
||||||
|
|
||||||
call H5Lexists_f(loc_id, p, HDF5_objectExists, hdferr)
|
call H5Lexists_f(loc_id, p, HDF5_objectExists, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
if (HDF5_objectExists) then
|
if (HDF5_objectExists) then
|
||||||
call H5Oexists_by_name_f(loc_id, p, HDF5_objectExists, hdferr)
|
call H5Oexists_by_name_f(loc_id, p, HDF5_objectExists, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
end function HDF5_objectExists
|
end function HDF5_objectExists
|
||||||
|
@ -359,24 +373,24 @@ subroutine HDF5_addAttribute_str(loc_id,attrLabel,attrValue,path)
|
||||||
ptr(1) = c_loc(attrValue_(1))
|
ptr(1) = c_loc(attrValue_(1))
|
||||||
|
|
||||||
call H5Screate_f(H5S_SCALAR_F,space_id,hdferr)
|
call H5Screate_f(H5S_SCALAR_F,space_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (attrExists) then
|
if (attrExists) then
|
||||||
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_STRING,space_id,attr_id,hdferr)
|
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_STRING,space_id,attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Awrite_f(attr_id, H5T_STRING, c_loc(ptr), hdferr) ! ptr instead of c_loc(ptr) works on gfortran, not on ifort
|
call H5Awrite_f(attr_id, H5T_STRING, c_loc(ptr), hdferr) ! ptr instead of c_loc(ptr) works on gfortran, not on ifort
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aclose_f(attr_id,hdferr)
|
call H5Aclose_f(attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(space_id,hdferr)
|
call H5Sclose_f(space_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_addAttribute_str
|
end subroutine HDF5_addAttribute_str
|
||||||
|
|
||||||
|
@ -400,24 +414,24 @@ subroutine HDF5_addAttribute_int(loc_id,attrLabel,attrValue,path)
|
||||||
p = trim(misc_optional(path,'.'))
|
p = trim(misc_optional(path,'.'))
|
||||||
|
|
||||||
call H5Screate_f(H5S_SCALAR_F,space_id,hdferr)
|
call H5Screate_f(H5S_SCALAR_F,space_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (attrExists) then
|
if (attrExists) then
|
||||||
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_NATIVE_INTEGER,space_id,attr_id,hdferr)
|
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_NATIVE_INTEGER,space_id,attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Awrite_f(attr_id, H5T_NATIVE_INTEGER, attrValue, int([1],HSIZE_T), hdferr)
|
call H5Awrite_f(attr_id, H5T_NATIVE_INTEGER, attrValue, int([1],HSIZE_T), hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aclose_f(attr_id,hdferr)
|
call H5Aclose_f(attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(space_id,hdferr)
|
call H5Sclose_f(space_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_addAttribute_int
|
end subroutine HDF5_addAttribute_int
|
||||||
|
|
||||||
|
@ -441,24 +455,24 @@ subroutine HDF5_addAttribute_real(loc_id,attrLabel,attrValue,path)
|
||||||
p = trim(misc_optional(path,'.'))
|
p = trim(misc_optional(path,'.'))
|
||||||
|
|
||||||
call H5Screate_f(H5S_SCALAR_F,space_id,hdferr)
|
call H5Screate_f(H5S_SCALAR_F,space_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (attrExists) then
|
if (attrExists) then
|
||||||
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_NATIVE_DOUBLE,space_id,attr_id,hdferr)
|
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_NATIVE_DOUBLE,space_id,attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Awrite_f(attr_id, H5T_NATIVE_DOUBLE, attrValue, int([1],HSIZE_T), hdferr)
|
call H5Awrite_f(attr_id, H5T_NATIVE_DOUBLE, attrValue, int([1],HSIZE_T), hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aclose_f(attr_id,hdferr)
|
call H5Aclose_f(attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(space_id,hdferr)
|
call H5Sclose_f(space_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_addAttribute_real
|
end subroutine HDF5_addAttribute_real
|
||||||
|
|
||||||
|
@ -489,24 +503,24 @@ subroutine HDF5_addAttribute_str_array(loc_id,attrLabel,attrValue,path)
|
||||||
end do
|
end do
|
||||||
|
|
||||||
call H5Screate_simple_f(1,shape(attrValue_,kind=HSIZE_T),space_id,hdferr,shape(attrValue_,kind=HSIZE_T))
|
call H5Screate_simple_f(1,shape(attrValue_,kind=HSIZE_T),space_id,hdferr,shape(attrValue_,kind=HSIZE_T))
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (attrExists) then
|
if (attrExists) then
|
||||||
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_STRING,space_id,attr_id,hdferr)
|
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_STRING,space_id,attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Awrite_f(attr_id, H5T_STRING, c_loc(ptr), hdferr) ! ptr instead of c_loc(ptr) works on gfortran, not on ifort
|
call H5Awrite_f(attr_id, H5T_STRING, c_loc(ptr), hdferr) ! ptr instead of c_loc(ptr) works on gfortran, not on ifort
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aclose_f(attr_id,hdferr)
|
call H5Aclose_f(attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(space_id,hdferr)
|
call H5Sclose_f(space_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_addAttribute_str_array
|
end subroutine HDF5_addAttribute_str_array
|
||||||
|
|
||||||
|
@ -533,24 +547,24 @@ subroutine HDF5_addAttribute_int_array(loc_id,attrLabel,attrValue,path)
|
||||||
array_size = size(attrValue,kind=HSIZE_T)
|
array_size = size(attrValue,kind=HSIZE_T)
|
||||||
|
|
||||||
call H5Screate_simple_f(1, array_size, space_id, hdferr, array_size)
|
call H5Screate_simple_f(1, array_size, space_id, hdferr, array_size)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (attrExists) then
|
if (attrExists) then
|
||||||
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_NATIVE_INTEGER,space_id,attr_id,hdferr)
|
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_NATIVE_INTEGER,space_id,attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Awrite_f(attr_id, H5T_NATIVE_INTEGER, attrValue, array_size, hdferr)
|
call H5Awrite_f(attr_id, H5T_NATIVE_INTEGER, attrValue, array_size, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aclose_f(attr_id,hdferr)
|
call H5Aclose_f(attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(space_id,hdferr)
|
call H5Sclose_f(space_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_addAttribute_int_array
|
end subroutine HDF5_addAttribute_int_array
|
||||||
|
|
||||||
|
@ -577,24 +591,24 @@ subroutine HDF5_addAttribute_real_array(loc_id,attrLabel,attrValue,path)
|
||||||
array_size = size(attrValue,kind=HSIZE_T)
|
array_size = size(attrValue,kind=HSIZE_T)
|
||||||
|
|
||||||
call H5Screate_simple_f(1, array_size, space_id, hdferr, array_size)
|
call H5Screate_simple_f(1, array_size, space_id, hdferr, array_size)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
call H5Aexists_by_name_f(loc_id,p,attrLabel,attrExists,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (attrExists) then
|
if (attrExists) then
|
||||||
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
call H5Adelete_by_name_f(loc_id,p,attrLabel,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_NATIVE_DOUBLE,space_id,attr_id,hdferr)
|
call H5Acreate_by_name_f(loc_id,p,trim(attrLabel),H5T_NATIVE_DOUBLE,space_id,attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Awrite_f(attr_id, H5T_NATIVE_DOUBLE, attrValue, array_size, hdferr)
|
call H5Awrite_f(attr_id, H5T_NATIVE_DOUBLE, attrValue, array_size, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Aclose_f(attr_id,hdferr)
|
call H5Aclose_f(attr_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(space_id,hdferr)
|
call H5Sclose_f(space_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_addAttribute_real_array
|
end subroutine HDF5_addAttribute_real_array
|
||||||
|
|
||||||
|
@ -610,13 +624,13 @@ subroutine HDF5_setLink(loc_id,target_name,link_name)
|
||||||
logical :: linkExists
|
logical :: linkExists
|
||||||
|
|
||||||
call H5Lexists_f(loc_id, link_name,linkExists, hdferr)
|
call H5Lexists_f(loc_id, link_name,linkExists, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (linkExists) then
|
if (linkExists) then
|
||||||
call H5Ldelete_f(loc_id,link_name, hdferr)
|
call H5Ldelete_f(loc_id,link_name, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
call H5Lcreate_soft_f(target_name, loc_id, link_name, hdferr)
|
call H5Lcreate_soft_f(target_name, loc_id, link_name, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_setLink
|
end subroutine HDF5_setLink
|
||||||
|
|
||||||
|
@ -649,7 +663,7 @@ subroutine HDF5_read_real1(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -683,7 +697,7 @@ subroutine HDF5_read_real2(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -717,7 +731,7 @@ subroutine HDF5_read_real3(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -752,7 +766,7 @@ subroutine HDF5_read_real4(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -787,7 +801,7 @@ subroutine HDF5_read_real5(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -822,7 +836,7 @@ if (any(totalShape == 0)) return
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -857,7 +871,7 @@ subroutine HDF5_read_real7(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -892,7 +906,7 @@ if (any(totalShape == 0)) return
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -927,7 +941,7 @@ subroutine HDF5_read_int2(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -961,7 +975,7 @@ subroutine HDF5_read_int3(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -995,7 +1009,7 @@ subroutine HDF5_read_int4(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -1029,7 +1043,7 @@ subroutine HDF5_read_int5(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -1064,7 +1078,7 @@ subroutine HDF5_read_int6(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -1099,7 +1113,7 @@ subroutine HDF5_read_int7(dataset,loc_id,datasetName,parallel)
|
||||||
|
|
||||||
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
call H5Dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,&
|
||||||
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
file_space_id = filespace_id, xfer_prp = plist_id, mem_space_id = memspace_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
call finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id)
|
||||||
|
|
||||||
|
@ -1137,7 +1151,7 @@ subroutine HDF5_write_real1(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1174,7 +1188,7 @@ subroutine HDF5_write_real2(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1211,7 +1225,7 @@ subroutine HDF5_write_real3(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1248,7 +1262,7 @@ subroutine HDF5_write_real4(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1286,7 +1300,7 @@ subroutine HDF5_write_real5(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1323,7 +1337,7 @@ subroutine HDF5_write_real6(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1360,7 +1374,7 @@ subroutine HDF5_write_real7(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1420,7 +1434,7 @@ subroutine HDF5_write_real(dataset,loc_id,datasetName,parallel)
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
end select
|
end select
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1447,46 +1461,46 @@ subroutine HDF5_write_str(dataset,loc_id,datasetName)
|
||||||
dataset_ = trim(dataset)
|
dataset_ = trim(dataset)
|
||||||
|
|
||||||
call H5Tcopy_f(H5T_C_S1, filetype_id, hdferr)
|
call H5Tcopy_f(H5T_C_S1, filetype_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tset_size_f(filetype_id, len(dataset_,SIZE_T)+1_SIZE_T, hdferr) ! +1 for NULL
|
call H5Tset_size_f(filetype_id, len(dataset_,SIZE_T)+1_SIZE_T, hdferr) ! +1 for NULL
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Tcopy_f(H5T_FORTRAN_S1, memtype_id, hdferr)
|
call H5Tcopy_f(H5T_FORTRAN_S1, memtype_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tset_size_f(memtype_id, len(dataset_,SIZE_T), hdferr)
|
call H5Tset_size_f(memtype_id, len(dataset_,SIZE_T), hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Pcreate_f(H5P_DATASET_CREATE_F, dcpl, hdferr)
|
call H5Pcreate_f(H5P_DATASET_CREATE_F, dcpl, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Pset_chunk_f(dcpl, 1, [1_HSIZE_T], hdferr)
|
call H5Pset_chunk_f(dcpl, 1, [1_HSIZE_T], hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Pset_Fletcher32_f(dcpl,hdferr)
|
call H5Pset_Fletcher32_f(dcpl,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (compression_possible .and. len(dataset,pI64) > 1024_pI64*256_pI64) then
|
if (compression_possible .and. len(dataset,pI64) > 1024_pI64*256_pI64) then
|
||||||
call H5Pset_shuffle_f(dcpl, hdferr)
|
call H5Pset_shuffle_f(dcpl, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Pset_deflate_f(dcpl, 6, hdferr)
|
call H5Pset_deflate_f(dcpl, 6, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call H5Screate_simple_f(1, [1_HSIZE_T], space_id, hdferr)
|
call H5Screate_simple_f(1, [1_HSIZE_T], space_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
CALL H5Dcreate_f(loc_id, datasetName, filetype_id, space_id, dataset_id, hdferr, dcpl)
|
CALL H5Dcreate_f(loc_id, datasetName, filetype_id, space_id, dataset_id, hdferr, dcpl)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Dwrite_f(dataset_id, memtype_id, c_loc(dataset_(1:1)), hdferr)
|
call H5Dwrite_f(dataset_id, memtype_id, c_loc(dataset_(1:1)), hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Pclose_f(dcpl, hdferr)
|
call H5Pclose_f(dcpl, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Dclose_f(dataset_id, hdferr)
|
call H5Dclose_f(dataset_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(space_id, hdferr)
|
call H5Sclose_f(space_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tclose_f(memtype_id, hdferr)
|
call H5Tclose_f(memtype_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tclose_f(filetype_id, hdferr)
|
call H5Tclose_f(filetype_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine HDF5_write_str
|
end subroutine HDF5_write_str
|
||||||
|
|
||||||
|
@ -1522,7 +1536,7 @@ subroutine HDF5_write_int1(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1559,7 +1573,7 @@ subroutine HDF5_write_int2(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1596,7 +1610,7 @@ subroutine HDF5_write_int3(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1633,7 +1647,7 @@ subroutine HDF5_write_int4(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1670,7 +1684,7 @@ subroutine HDF5_write_int5(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1707,7 +1721,7 @@ subroutine HDF5_write_int6(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1744,7 +1758,7 @@ subroutine HDF5_write_int7(dataset,loc_id,datasetName,parallel)
|
||||||
if (product(totalShape) /= 0) then
|
if (product(totalShape) /= 0) then
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1804,7 +1818,7 @@ subroutine HDF5_write_int(dataset,loc_id,datasetName,parallel)
|
||||||
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
call H5Dwrite_f(dset_id, H5T_NATIVE_INTEGER,dataset,int(totalShape,HSIZE_T), hdferr,&
|
||||||
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
end select
|
end select
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
call finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
|
@ -1837,7 +1851,7 @@ subroutine initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_
|
||||||
!-------------------------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------------------------
|
||||||
! creating a property list for transfer properties (is collective for MPI)
|
! creating a property list for transfer properties (is collective for MPI)
|
||||||
call H5Pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr)
|
call H5Pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
readSize = 0_MPI_INTEGER_KIND
|
readSize = 0_MPI_INTEGER_KIND
|
||||||
|
@ -1845,7 +1859,7 @@ subroutine initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_
|
||||||
#ifdef PETSC
|
#ifdef PETSC
|
||||||
if (parallel) then
|
if (parallel) then
|
||||||
call H5Pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr)
|
call H5Pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call MPI_Allreduce(MPI_IN_PLACE,readSize,worldsize,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,err_MPI) ! get total output size over each process
|
call MPI_Allreduce(MPI_IN_PLACE,readSize,worldsize,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,err_MPI) ! get total output size over each process
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||||
end if
|
end if
|
||||||
|
@ -1856,35 +1870,35 @@ subroutine initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_
|
||||||
|
|
||||||
if (any(globalShape == 0)) then
|
if (any(globalShape == 0)) then
|
||||||
call H5Pclose_f(plist_id, hdferr)
|
call H5Pclose_f(plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! create dataspace in memory (local shape)
|
! create dataspace in memory (local shape)
|
||||||
call H5Screate_simple_f(size(localShape), localShape, memspace_id, hdferr, localShape)
|
call H5Screate_simple_f(size(localShape), localShape, memspace_id, hdferr, localShape)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! creating a property list for IO and set it to collective
|
! creating a property list for IO and set it to collective
|
||||||
call H5Pcreate_f(H5P_DATASET_ACCESS_F, aplist_id, hdferr)
|
call H5Pcreate_f(H5P_DATASET_ACCESS_F, aplist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
#ifdef PETSC
|
#ifdef PETSC
|
||||||
call H5Pset_all_coll_metadata_ops_f(aplist_id, .true., hdferr)
|
call H5Pset_all_coll_metadata_ops_f(aplist_id, .true., hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! open the dataset in the file and get the space ID
|
! open the dataset in the file and get the space ID
|
||||||
call H5Dopen_f(loc_id,datasetName,dset_id,hdferr, dapl_id = aplist_id)
|
call H5Dopen_f(loc_id,datasetName,dset_id,hdferr, dapl_id = aplist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Dget_space_f(dset_id, filespace_id, hdferr)
|
call H5Dget_space_f(dset_id, filespace_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! select a hyperslab (the portion of the current process) in the file
|
! select a hyperslab (the portion of the current process) in the file
|
||||||
call H5Sselect_hyperslab_f(filespace_id, H5S_SELECT_SET_F, myStart, localShape, hdferr)
|
call H5Sselect_hyperslab_f(filespace_id, H5S_SELECT_SET_F, myStart, localShape, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine initialize_read
|
end subroutine initialize_read
|
||||||
|
|
||||||
|
@ -1898,15 +1912,15 @@ subroutine finalize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id
|
||||||
integer :: hdferr
|
integer :: hdferr
|
||||||
|
|
||||||
call H5Pclose_f(plist_id, hdferr)
|
call H5Pclose_f(plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Pclose_f(aplist_id, hdferr)
|
call H5Pclose_f(aplist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Dclose_f(dset_id, hdferr)
|
call H5Dclose_f(dset_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(filespace_id, hdferr)
|
call H5Sclose_f(filespace_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(memspace_id, hdferr)
|
call H5Sclose_f(memspace_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine finalize_read
|
end subroutine finalize_read
|
||||||
|
|
||||||
|
@ -1939,11 +1953,11 @@ subroutine initialize_write(dset_id, filespace_id, memspace_id, plist_id, &
|
||||||
!-------------------------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------------------------
|
||||||
! creating a property list for transfer properties (is collective when writing in parallel)
|
! creating a property list for transfer properties (is collective when writing in parallel)
|
||||||
call H5Pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr)
|
call H5Pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
#ifdef PETSC
|
#ifdef PETSC
|
||||||
if (parallel) then
|
if (parallel) then
|
||||||
call H5Pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr)
|
call H5Pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1964,43 +1978,43 @@ subroutine initialize_write(dset_id, filespace_id, memspace_id, plist_id, &
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! chunk dataset, enable compression for larger datasets
|
! chunk dataset, enable compression for larger datasets
|
||||||
call H5Pcreate_f(H5P_DATASET_CREATE_F, dcpl, hdferr)
|
call H5Pcreate_f(H5P_DATASET_CREATE_F, dcpl, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
if (product(totalShape) > 0) then
|
if (product(totalShape) > 0) then
|
||||||
call H5Pset_Fletcher32_f(dcpl,hdferr)
|
call H5Pset_Fletcher32_f(dcpl,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
if (product(totalShape) >= chunkSize*2_HSIZE_T) then
|
if (product(totalShape) >= chunkSize*2_HSIZE_T) then
|
||||||
call H5Pset_chunk_f(dcpl, size(totalShape), getChunks(totalShape,chunkSize), hdferr)
|
call H5Pset_chunk_f(dcpl, size(totalShape), getChunks(totalShape,chunkSize), hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
if (compression_possible) then
|
if (compression_possible) then
|
||||||
call H5Pset_shuffle_f(dcpl, hdferr)
|
call H5Pset_shuffle_f(dcpl, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Pset_deflate_f(dcpl, 6, hdferr)
|
call H5Pset_deflate_f(dcpl, 6, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
else
|
else
|
||||||
call H5Pset_chunk_f(dcpl, size(totalShape), totalShape, hdferr)
|
call H5Pset_chunk_f(dcpl, size(totalShape), totalShape, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! create dataspace in memory (local shape) and in file (global shape)
|
! create dataspace in memory (local shape) and in file (global shape)
|
||||||
call H5Screate_simple_f(size(myShape), myShape, memspace_id, hdferr, myShape)
|
call H5Screate_simple_f(size(myShape), myShape, memspace_id, hdferr, myShape)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Screate_simple_f(size(totalShape), totalShape, filespace_id, hdferr, totalShape)
|
call H5Screate_simple_f(size(totalShape), totalShape, filespace_id, hdferr, totalShape)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! create dataset in the file and select a hyperslab from it (the portion of the current process)
|
! create dataset in the file and select a hyperslab from it (the portion of the current process)
|
||||||
call H5Dcreate_f(loc_id, trim(datasetName), datatype, filespace_id, dset_id, hdferr, dcpl)
|
call H5Dcreate_f(loc_id, trim(datasetName), datatype, filespace_id, dset_id, hdferr, dcpl)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sselect_hyperslab_f(filespace_id, H5S_SELECT_SET_F, myStart, myShape, hdferr)
|
call H5Sselect_hyperslab_f(filespace_id, H5S_SELECT_SET_F, myStart, myShape, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Pclose_f(dcpl , hdferr)
|
call H5Pclose_f(dcpl , hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
contains
|
contains
|
||||||
!------------------------------------------------------------------------------------------------
|
!------------------------------------------------------------------------------------------------
|
||||||
|
@ -2029,13 +2043,13 @@ subroutine finalize_write(plist_id, dset_id, filespace_id, memspace_id)
|
||||||
integer :: hdferr
|
integer :: hdferr
|
||||||
|
|
||||||
call H5Pclose_f(plist_id, hdferr)
|
call H5Pclose_f(plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Dclose_f(dset_id, hdferr)
|
call H5Dclose_f(dset_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(filespace_id, hdferr)
|
call H5Sclose_f(filespace_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(memspace_id, hdferr)
|
call H5Sclose_f(memspace_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
end subroutine finalize_write
|
end subroutine finalize_write
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ end subroutine parallelization_bcast_str
|
||||||
#else
|
#else
|
||||||
public :: &
|
public :: &
|
||||||
parallelization_init, &
|
parallelization_init, &
|
||||||
|
parallelization_chkerr, &
|
||||||
parallelization_bcast_str
|
parallelization_bcast_str
|
||||||
|
|
||||||
contains
|
contains
|
||||||
|
@ -154,6 +155,19 @@ subroutine parallelization_init()
|
||||||
end subroutine parallelization_init
|
end subroutine parallelization_init
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief Check for MPI error.
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
subroutine parallelization_chkerr(e)
|
||||||
|
|
||||||
|
integer(MPI_INTEGER_KIND), intent(in) :: e
|
||||||
|
|
||||||
|
|
||||||
|
if (e/=0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||||
|
|
||||||
|
end subroutine parallelization_chkerr
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief Broadcast a string from process 0.
|
!> @brief Broadcast a string from process 0.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
|
118
src/result.f90
118
src/result.f90
|
@ -497,7 +497,7 @@ subroutine result_mapping_phase(ID,entry,label)
|
||||||
writeSize(worldrank) = size(entry(1,:)) ! total number of entries of this process
|
writeSize(worldrank) = size(entry(1,:)) ! total number of entries of this process
|
||||||
|
|
||||||
call H5Pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr)
|
call H5Pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
#ifndef PETSC
|
#ifndef PETSC
|
||||||
entryGlobal = int(entry -1,pI64) ! 0-based
|
entryGlobal = int(entry -1,pI64) ! 0-based
|
||||||
|
@ -505,10 +505,10 @@ subroutine result_mapping_phase(ID,entry,label)
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! MPI settings and communication
|
! MPI settings and communication
|
||||||
call H5Pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr)
|
call H5Pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call MPI_Allreduce(MPI_IN_PLACE,writeSize,worldsize,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,err_MPI) ! get output at each process
|
call MPI_Allreduce(MPI_IN_PLACE,writeSize,worldsize,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,err_MPI) ! get output at each process
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
call parallelization_chkerr(err_MPI)
|
||||||
|
|
||||||
entryOffset = 0_pI64
|
entryOffset = 0_pI64
|
||||||
do co = 1, size(ID,1)
|
do co = 1, size(ID,1)
|
||||||
|
@ -517,7 +517,7 @@ subroutine result_mapping_phase(ID,entry,label)
|
||||||
end do
|
end do
|
||||||
end do
|
end do
|
||||||
call MPI_Allreduce(MPI_IN_PLACE,entryOffset,size(entryOffset),MPI_INTEGER8,MPI_SUM,MPI_COMM_WORLD,err_MPI)! get offset at each process
|
call MPI_Allreduce(MPI_IN_PLACE,entryOffset,size(entryOffset),MPI_INTEGER8,MPI_SUM,MPI_COMM_WORLD,err_MPI)! get offset at each process
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
call parallelization_chkerr(err_MPI)
|
||||||
entryOffset(:,worldrank) = sum(entryOffset(:,0:worldrank-1),2)
|
entryOffset(:,worldrank) = sum(entryOffset(:,0:worldrank-1),2)
|
||||||
do co = 1, size(ID,1)
|
do co = 1, size(ID,1)
|
||||||
do ce = 1, size(ID,2)
|
do ce = 1, size(ID,2)
|
||||||
|
@ -533,80 +533,80 @@ subroutine result_mapping_phase(ID,entry,label)
|
||||||
!---------------------------------------------------------------------------------------------------
|
!---------------------------------------------------------------------------------------------------
|
||||||
! compound type: label(ID) + entry
|
! compound type: label(ID) + entry
|
||||||
call H5Tcopy_f(H5T_NATIVE_CHARACTER, dt_id, hdferr)
|
call H5Tcopy_f(H5T_NATIVE_CHARACTER, dt_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tset_size_f(dt_id, int(len(label(1)),SIZE_T), hdferr)
|
call H5Tset_size_f(dt_id, int(len(label(1)),SIZE_T), hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tget_size_f(dt_id, type_size_string, hdferr)
|
call H5Tget_size_f(dt_id, type_size_string, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
pI64_t = h5kind_to_type(kind(entryGlobal),H5_INTEGER_KIND)
|
pI64_t = h5kind_to_type(kind(entryGlobal),H5_INTEGER_KIND)
|
||||||
call H5Tget_size_f(pI64_t, type_size_int, hdferr)
|
call H5Tget_size_f(pI64_t, type_size_int, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Tcreate_f(H5T_COMPOUND_F, type_size_string + type_size_int, dtype_id, hdferr)
|
call H5Tcreate_f(H5T_COMPOUND_F, type_size_string + type_size_int, dtype_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tinsert_f(dtype_id, 'label', 0_SIZE_T, dt_id,hdferr)
|
call H5Tinsert_f(dtype_id, 'label', 0_SIZE_T, dt_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tinsert_f(dtype_id, 'entry', type_size_string, pI64_t, hdferr)
|
call H5Tinsert_f(dtype_id, 'entry', type_size_string, pI64_t, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! create memory types for each component of the compound type
|
! create memory types for each component of the compound type
|
||||||
call H5Tcreate_f(H5T_COMPOUND_F, type_size_string, label_id, hdferr)
|
call H5Tcreate_f(H5T_COMPOUND_F, type_size_string, label_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tinsert_f(label_id, 'label', 0_SIZE_T, dt_id, hdferr)
|
call H5Tinsert_f(label_id, 'label', 0_SIZE_T, dt_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Tcreate_f(H5T_COMPOUND_F, type_size_int, entry_id, hdferr)
|
call H5Tcreate_f(H5T_COMPOUND_F, type_size_int, entry_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tinsert_f(entry_id, 'entry', 0_SIZE_T, pI64_t, hdferr)
|
call H5Tinsert_f(entry_id, 'entry', 0_SIZE_T, pI64_t, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Tclose_f(dt_id, hdferr)
|
call H5Tclose_f(dt_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! create dataspace in memory (local shape = hyperslab) and in file (global shape)
|
! create dataspace in memory (local shape = hyperslab) and in file (global shape)
|
||||||
call H5Screate_simple_f(2,myShape,memspace_id,hdferr,myShape)
|
call H5Screate_simple_f(2,myShape,memspace_id,hdferr,myShape)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Screate_simple_f(2,totalShape,filespace_id,hdferr,totalShape)
|
call H5Screate_simple_f(2,totalShape,filespace_id,hdferr,totalShape)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Sselect_hyperslab_f(filespace_id, H5S_SELECT_SET_F, myOffset, myShape, hdferr)
|
call H5Sselect_hyperslab_f(filespace_id, H5S_SELECT_SET_F, myOffset, myShape, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! write the components of the compound type individually
|
! write the components of the compound type individually
|
||||||
call H5Pset_preserve_f(plist_id, .true., hdferr)
|
call H5Pset_preserve_f(plist_id, .true., hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
loc_id = result_openGroup('/cell_to')
|
loc_id = result_openGroup('/cell_to')
|
||||||
call H5Dcreate_f(loc_id, 'phase', dtype_id, filespace_id, dset_id, hdferr)
|
call H5Dcreate_f(loc_id, 'phase', dtype_id, filespace_id, dset_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Dwrite_f(dset_id, label_id, reshape(label(pack(ID,.true.)),myShape), &
|
call H5Dwrite_f(dset_id, label_id, reshape(label(pack(ID,.true.)),myShape), &
|
||||||
myShape, hdferr, file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
myShape, hdferr, file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Dwrite_f(dset_id, entry_id, reshape(pack(entryGlobal,.true.),myShape), &
|
call H5Dwrite_f(dset_id, entry_id, reshape(pack(entryGlobal,.true.),myShape), &
|
||||||
myShape, hdferr, file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
myShape, hdferr, file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! close all
|
! close all
|
||||||
call HDF5_closeGroup(loc_id)
|
call HDF5_closeGroup(loc_id)
|
||||||
call H5Pclose_f(plist_id, hdferr)
|
call H5Pclose_f(plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(filespace_id, hdferr)
|
call H5Sclose_f(filespace_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(memspace_id, hdferr)
|
call H5Sclose_f(memspace_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Dclose_f(dset_id, hdferr)
|
call H5Dclose_f(dset_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tclose_f(dtype_id, hdferr)
|
call H5Tclose_f(dtype_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tclose_f(label_id, hdferr)
|
call H5Tclose_f(label_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tclose_f(entry_id, hdferr)
|
call H5Tclose_f(entry_id, hdferr)
|
||||||
|
|
||||||
call executionStamp('cell_to/phase','cell ID and constituent ID to phase results')
|
call executionStamp('cell_to/phase','cell ID and constituent ID to phase results')
|
||||||
|
@ -653,7 +653,7 @@ subroutine result_mapping_homogenization(ID,entry,label)
|
||||||
writeSize(worldrank) = size(entry) ! total number of entries of this process
|
writeSize(worldrank) = size(entry) ! total number of entries of this process
|
||||||
|
|
||||||
call H5Pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr)
|
call H5Pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
#ifndef PETSC
|
#ifndef PETSC
|
||||||
entryGlobal = int(entry -1,pI64) ! 0-based
|
entryGlobal = int(entry -1,pI64) ! 0-based
|
||||||
|
@ -661,17 +661,17 @@ subroutine result_mapping_homogenization(ID,entry,label)
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! MPI settings and communication
|
! MPI settings and communication
|
||||||
call H5Pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr)
|
call H5Pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call MPI_Allreduce(MPI_IN_PLACE,writeSize,worldsize,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,err_MPI) ! get output at each process
|
call MPI_Allreduce(MPI_IN_PLACE,writeSize,worldsize,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,err_MPI) ! get output at each process
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
call parallelization_chkerr(err_MPI)
|
||||||
|
|
||||||
entryOffset = 0_pI64
|
entryOffset = 0_pI64
|
||||||
do ce = 1, size(ID,1)
|
do ce = 1, size(ID,1)
|
||||||
entryOffset(ID(ce),worldrank) = entryOffset(ID(ce),worldrank) +1_pI64
|
entryOffset(ID(ce),worldrank) = entryOffset(ID(ce),worldrank) +1_pI64
|
||||||
end do
|
end do
|
||||||
call MPI_Allreduce(MPI_IN_PLACE,entryOffset,size(entryOffset),MPI_INTEGER8,MPI_SUM,MPI_COMM_WORLD,err_MPI)! get offset at each process
|
call MPI_Allreduce(MPI_IN_PLACE,entryOffset,size(entryOffset),MPI_INTEGER8,MPI_SUM,MPI_COMM_WORLD,err_MPI)! get offset at each process
|
||||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
call parallelization_chkerr(err_MPI)
|
||||||
entryOffset(:,worldrank) = sum(entryOffset(:,0:worldrank-1),2)
|
entryOffset(:,worldrank) = sum(entryOffset(:,0:worldrank-1),2)
|
||||||
do ce = 1, size(ID,1)
|
do ce = 1, size(ID,1)
|
||||||
entryGlobal(ce) = int(entry(ce),pI64) -1_pI64 + entryOffset(ID(ce),worldrank)
|
entryGlobal(ce) = int(entry(ce),pI64) -1_pI64 + entryOffset(ID(ce),worldrank)
|
||||||
|
@ -685,82 +685,82 @@ subroutine result_mapping_homogenization(ID,entry,label)
|
||||||
!---------------------------------------------------------------------------------------------------
|
!---------------------------------------------------------------------------------------------------
|
||||||
! compound type: label(ID) + entry
|
! compound type: label(ID) + entry
|
||||||
call H5Tcopy_f(H5T_NATIVE_CHARACTER, dt_id, hdferr)
|
call H5Tcopy_f(H5T_NATIVE_CHARACTER, dt_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tset_size_f(dt_id, int(len(label(1)),SIZE_T), hdferr)
|
call H5Tset_size_f(dt_id, int(len(label(1)),SIZE_T), hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tget_size_f(dt_id, type_size_string, hdferr)
|
call H5Tget_size_f(dt_id, type_size_string, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
pI64_t = h5kind_to_type(kind(entryGlobal),H5_INTEGER_KIND)
|
pI64_t = h5kind_to_type(kind(entryGlobal),H5_INTEGER_KIND)
|
||||||
call H5Tget_size_f(pI64_t, type_size_int, hdferr)
|
call H5Tget_size_f(pI64_t, type_size_int, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Tcreate_f(H5T_COMPOUND_F, type_size_string + type_size_int, dtype_id, hdferr)
|
call H5Tcreate_f(H5T_COMPOUND_F, type_size_string + type_size_int, dtype_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tinsert_f(dtype_id, 'label', 0_SIZE_T, dt_id,hdferr)
|
call H5Tinsert_f(dtype_id, 'label', 0_SIZE_T, dt_id,hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tinsert_f(dtype_id, 'entry', type_size_string, pI64_t, hdferr)
|
call H5Tinsert_f(dtype_id, 'entry', type_size_string, pI64_t, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! create memory types for each component of the compound type
|
! create memory types for each component of the compound type
|
||||||
call H5Tcreate_f(H5T_COMPOUND_F, type_size_string, label_id, hdferr)
|
call H5Tcreate_f(H5T_COMPOUND_F, type_size_string, label_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tinsert_f(label_id, 'label', 0_SIZE_T, dt_id, hdferr)
|
call H5Tinsert_f(label_id, 'label', 0_SIZE_T, dt_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Tcreate_f(H5T_COMPOUND_F, type_size_int, entry_id, hdferr)
|
call H5Tcreate_f(H5T_COMPOUND_F, type_size_int, entry_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tinsert_f(entry_id, 'entry', 0_SIZE_T, pI64_t, hdferr)
|
call H5Tinsert_f(entry_id, 'entry', 0_SIZE_T, pI64_t, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Tclose_f(dt_id, hdferr)
|
call H5Tclose_f(dt_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! create dataspace in memory (local shape = hyperslab) and in file (global shape)
|
! create dataspace in memory (local shape = hyperslab) and in file (global shape)
|
||||||
call H5Screate_simple_f(1,myShape,memspace_id,hdferr,myShape)
|
call H5Screate_simple_f(1,myShape,memspace_id,hdferr,myShape)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Screate_simple_f(1,totalShape,filespace_id,hdferr,totalShape)
|
call H5Screate_simple_f(1,totalShape,filespace_id,hdferr,totalShape)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Sselect_hyperslab_f(filespace_id, H5S_SELECT_SET_F, myOffset, myShape, hdferr)
|
call H5Sselect_hyperslab_f(filespace_id, H5S_SELECT_SET_F, myOffset, myShape, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! write the components of the compound type individually
|
! write the components of the compound type individually
|
||||||
call H5Pset_preserve_f(plist_id, .true., hdferr)
|
call H5Pset_preserve_f(plist_id, .true., hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
loc_id = result_openGroup('/cell_to')
|
loc_id = result_openGroup('/cell_to')
|
||||||
call H5Dcreate_f(loc_id, 'homogenization', dtype_id, filespace_id, dset_id, hdferr)
|
call H5Dcreate_f(loc_id, 'homogenization', dtype_id, filespace_id, dset_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call H5Dwrite_f(dset_id, label_id, reshape(label(pack(ID,.true.)),myShape), &
|
call H5Dwrite_f(dset_id, label_id, reshape(label(pack(ID,.true.)),myShape), &
|
||||||
myShape, hdferr, file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
myShape, hdferr, file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Dwrite_f(dset_id, entry_id, reshape(pack(entryGlobal,.true.),myShape), &
|
call H5Dwrite_f(dset_id, entry_id, reshape(pack(entryGlobal,.true.),myShape), &
|
||||||
myShape, hdferr, file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
myShape, hdferr, file_space_id = filespace_id, mem_space_id = memspace_id, xfer_prp = plist_id)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! close all
|
! close all
|
||||||
call HDF5_closeGroup(loc_id)
|
call HDF5_closeGroup(loc_id)
|
||||||
call H5Pclose_f(plist_id, hdferr)
|
call H5Pclose_f(plist_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(filespace_id, hdferr)
|
call H5Sclose_f(filespace_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Sclose_f(memspace_id, hdferr)
|
call H5Sclose_f(memspace_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Dclose_f(dset_id, hdferr)
|
call H5Dclose_f(dset_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tclose_f(dtype_id, hdferr)
|
call H5Tclose_f(dtype_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tclose_f(label_id, hdferr)
|
call H5Tclose_f(label_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
call H5Tclose_f(entry_id, hdferr)
|
call H5Tclose_f(entry_id, hdferr)
|
||||||
if (hdferr < 0) error stop 'HDF5 error'
|
call HDF5_chkerr(hdferr)
|
||||||
|
|
||||||
call executionStamp('cell_to/homogenization','cell ID to homogenization results')
|
call executionStamp('cell_to/homogenization','cell ID to homogenization results')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue