diff --git a/PRIVATE b/PRIVATE index aeae4513b..50eb21714 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit aeae4513b1ffb43b949399c12bae27fc6abb6f29 +Subproject commit 50eb21714e2f501b111bb62096ebb6a5bfc6708a diff --git a/examples/SpectralMethod/Polycrystal/tensionX.load b/examples/SpectralMethod/Polycrystal/tensionX.load index b0af80ea8..8c5c45d2b 100644 --- a/examples/SpectralMethod/Polycrystal/tensionX.load +++ b/examples/SpectralMethod/Polycrystal/tensionX.load @@ -1,2 +1 @@ -fdot 1.0e-3 0 0 0 * 0 0 0 * stress * * * * 0 * * * 0 time 10 incs 40 freq 4 -fdot 1.0e-3 0 0 0 * 0 0 0 * stress * * * * 0 * * * 0 time 60 incs 60 +fdot 1.0e-3 0 0 0 * 0 0 0 * stress * * * * 0 * * * 0 time 0.001 incs 2 restart 1 diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 old mode 100644 new mode 100755 index ed356d5b6..6e11e9d6b --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -247,8 +247,13 @@ subroutine CPFEM_age() HDF5_createFile, & HDF5_closeFile, & HDF5_closeGroup, & - HDF5_addGroup2 - use HDF5 + HDF5_addGroup2, & + HDF5_writeScalarDataset3, & + HDF5_writeScalarDataset4, & + HDF5_writeScalarDataset5, & + HDF5_writeScalarDataset7, & + HDF5_addScalarDataset2 + use hdf5 use DAMASK_interface, only: & getSolverJobName @@ -257,6 +262,8 @@ subroutine CPFEM_age() integer(pInt) :: i, k, l, m, ph, homog, mySource character(len=32) :: rankStr integer(HID_T) :: fileHandle + integer :: hdferr + integer(HSIZE_T) :: hdfsize if (iand(debug_level(debug_CPFEM), debug_levelBasic) /= 0_pInt) & write(6,'(a)') '<< CPFEM >> aging states' @@ -291,8 +298,19 @@ if (restartWrite) then write(rankStr,'(a1,i0)')'_',worldrank fileHandle = HDF5_createFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5_restart') - - call HDF5_closeGroup(HDF5_addGroup2(fileHandle,'HelloWorld')) + + !call HDF5_closeGroup(HDF5_addGroup2(fileHandle,'recordedPhase')) + !hdfsize = size(material_phase) + !call h5dwrite_f(HDF5_addGroup2(fileHandle,'recordedPhase'), H5T_NATIVE_INTEGER, material_phase, hdfsize, hdferr) + + call HDF5_addScalarDataset2(fileHandle,shape(material_phase),'recordedPhase') + call HDF5_writeScalarDataset3(fileHandle,real(material_phase,pReal),'recordedPhase',shape(material_phase)) + call HDF5_addScalarDataset2(fileHandle,shape(crystallite_F0),'convergedF') + call HDF5_writeScalarDataset5(fileHandle,real(crystallite_F0,pReal),'convergedF',shape(crystallite_F0)) + call HDF5_addScalarDataset2(fileHandle,shape(crystallite_Fp0),'convergedFp') + call HDF5_writeScalarDataset5(fileHandle,real(crystallite_Fp0,pReal),'convergedFp',shape(crystallite_Fp0)) + + !call HDF5_closeGroup(HDF5_addGroup2(fileHandle,'recordedPhase')) call HDF5_closeFile(fileHandle) call IO_write_jobRealFile(777,'recordedPhase'//trim(rankStr),size(material_phase)) diff --git a/src/HDF5_utilities.f90 b/src/HDF5_utilities.f90 old mode 100644 new mode 100755 index 7cd02e46e..467d69331 --- a/src/HDF5_utilities.f90 +++ b/src/HDF5_utilities.f90 @@ -30,7 +30,9 @@ module HDF5_Utilities HDF5_removeLink, & HDF5_createFile, & HDF5_closeFile, & - HDF5_addGroup2 + HDF5_addGroup2, HDF5_addScalarDataset2, HDF5_writeScalarDataset3, HDF5_writeScalarDataset4, HDF5_writeScalarDataset5, & + HDF5_writeScalarDataset7 + contains subroutine HDF5_Utilities_init @@ -1047,6 +1049,7 @@ subroutine HDF5_backwardMappingCrystallite(crystalliteAt,crystmemberAt,crystalli end subroutine HDF5_backwardMappingCrystallite + !-------------------------------------------------------------------------------------------------- !> @brief adds the unique cell to node mapping !-------------------------------------------------------------------------------------------------- @@ -1090,7 +1093,6 @@ end subroutine HDF5_mappingCells - !-------------------------------------------------------------------------------------------------- !> @brief creates a new scalar dataset in the given group location !-------------------------------------------------------------------------------------------------- @@ -1340,6 +1342,213 @@ subroutine HDF5_writeScalarDataset(group,dataset,label,SIunit,dataspace_size,mpi end subroutine HDF5_writeScalarDataset +!-------------------------------------------------------------------------------------------------- +!> @brief creates a new scalar dataset in the given group location +!-------------------------------------------------------------------------------------------------- +subroutine HDF5_writeScalarDataset3(group,dataset,label,dataspace_size) + use hdf5 + + implicit none + integer(HID_T), intent(in) :: group + character(len=*), intent(in) :: label + integer(pInt), intent(in),dimension(:) :: dataspace_size + real(pReal), intent(in), dimension(:,:,:) :: dataset + + integer :: hdferr + integer(HID_T) :: dset_id, space_id, memspace, plist_id + + integer(HSIZE_T), dimension(1) :: counter + integer(HSSIZE_T), dimension(1) :: fileOffset + + call h5dopen_f(group, label, dset_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dopen_f') + + ! Define and select hyperslabs + counter = size(dataset) ! how big i am + fileOffset = 0 ! where i start to write my data + + call h5screate_simple_f(1, counter, memspace, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5screate_simple_f') + call h5dget_space_f(dset_id, space_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dget_space_f') + !call h5sselect_hyperslab_f(space_id, H5S_SELECT_SET_F, fileOffset, counter, hdferr) + !if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5sselect_hyperslab_f') + + ! Create property list for collective dataset write +#ifdef PETSc + call h5pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5pcreate_f') + call h5pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5pset_dxpl_mpio_f') +#endif + + ! Write the dataset collectively + call h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, dataset, int(dataspace_size,HSIZE_T), hdferr, & + file_space_id = space_id, mem_space_id = memspace)!, xfer_prp = plist_id) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dwrite_f') + + call h5sclose_f(space_id, hdferr) + call h5sclose_f(memspace, hdferr) + call h5dclose_f(dset_id, hdferr) + call h5pclose_f(plist_id, hdferr) + +end subroutine HDF5_writeScalarDataset3 + +!-------------------------------------------------------------------------------------------------- +!> @brief creates a new scalar dataset in the given group location +!-------------------------------------------------------------------------------------------------- +subroutine HDF5_writeScalarDataset4(group,dataset,label,dataspace_size) + use hdf5 + + implicit none + integer(HID_T), intent(in) :: group + character(len=*), intent(in) :: label + integer(pInt), intent(in),dimension(:) :: dataspace_size + real(pReal), intent(in), dimension(:,:,:,:) :: dataset + + integer :: hdferr + integer(HID_T) :: dset_id, space_id, memspace, plist_id + + integer(HSIZE_T), dimension(1) :: counter + integer(HSSIZE_T), dimension(1) :: fileOffset + + call h5dopen_f(group, label, dset_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dopen_f') + + ! Define and select hyperslabs + counter = size(dataset) ! how big i am + fileOffset = 0 ! where i start to write my data + + call h5screate_simple_f(1, counter, memspace, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5screate_simple_f') + call h5dget_space_f(dset_id, space_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dget_space_f') + !call h5sselect_hyperslab_f(space_id, H5S_SELECT_SET_F, fileOffset, counter, hdferr) + !if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5sselect_hyperslab_f') + + ! Create property list for collective dataset write +#ifdef PETSc + call h5pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5pcreate_f') + call h5pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5pset_dxpl_mpio_f') +#endif + + ! Write the dataset collectively + call h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, dataset, int(dataspace_size,HSIZE_T), hdferr, & + file_space_id = space_id, mem_space_id = memspace)!, xfer_prp = plist_id) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dwrite_f') + + call h5sclose_f(space_id, hdferr) + call h5sclose_f(memspace, hdferr) + call h5dclose_f(dset_id, hdferr) + call h5pclose_f(plist_id, hdferr) + +end subroutine HDF5_writeScalarDataset4 + +!-------------------------------------------------------------------------------------------------- +!> @brief creates a new scalar dataset in the given group location +!-------------------------------------------------------------------------------------------------- +subroutine HDF5_writeScalarDataset5(group,dataset,label,dataspace_size) + use hdf5 + + implicit none + integer(HID_T), intent(in) :: group + character(len=*), intent(in) :: label + integer(pInt), intent(in),dimension(:) :: dataspace_size + real(pReal), intent(in), dimension(:,:,:,:,:) :: dataset + + integer :: hdferr + integer(HID_T) :: dset_id, space_id, memspace, plist_id + + integer(HSIZE_T), dimension(1) :: counter + integer(HSSIZE_T), dimension(1) :: fileOffset + + call h5dopen_f(group, label, dset_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dopen_f') + + ! Define and select hyperslabs + counter = size(dataset) ! how big i am + fileOffset = 0 ! where i start to write my data + + call h5screate_simple_f(1, counter, memspace, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5screate_simple_f') + call h5dget_space_f(dset_id, space_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dget_space_f') + !call h5sselect_hyperslab_f(space_id, H5S_SELECT_SET_F, fileOffset, counter, hdferr) + !if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5sselect_hyperslab_f') + + ! Create property list for collective dataset write +#ifdef PETSc + call h5pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5pcreate_f') + call h5pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5pset_dxpl_mpio_f') +#endif + + ! Write the dataset collectively + call h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, dataset, int(dataspace_size,HSIZE_T), hdferr, & + file_space_id = space_id, mem_space_id = memspace)!, xfer_prp = plist_id) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dwrite_f') + + call h5sclose_f(space_id, hdferr) + call h5sclose_f(memspace, hdferr) + call h5dclose_f(dset_id, hdferr) + call h5pclose_f(plist_id, hdferr) + +end subroutine HDF5_writeScalarDataset5 + +!-------------------------------------------------------------------------------------------------- +!> @brief creates a new scalar dataset in the given group location +!-------------------------------------------------------------------------------------------------- +subroutine HDF5_writeScalarDataset7(group,dataset,label,dataspace_size) + use hdf5 + + implicit none + integer(HID_T), intent(in) :: group + character(len=*), intent(in) :: label + integer(pInt), intent(in),dimension(:) :: dataspace_size + real(pReal), intent(in), dimension(:,:,:,:,:,:,:) :: dataset + + integer :: hdferr + integer(HID_T) :: dset_id, space_id, memspace, plist_id + + integer(HSIZE_T), dimension(1) :: counter + integer(HSSIZE_T), dimension(1) :: fileOffset + + call h5dopen_f(group, label, dset_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dopen_f') + + ! Define and select hyperslabs + counter = size(dataset) ! how big i am + fileOffset = 0 ! where i start to write my data + + call h5screate_simple_f(1, counter, memspace, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5screate_simple_f') + call h5dget_space_f(dset_id, space_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dget_space_f') + !call h5sselect_hyperslab_f(space_id, H5S_SELECT_SET_F, fileOffset, counter, hdferr) + !if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5sselect_hyperslab_f') + + ! Create property list for collective dataset write +#ifdef PETSc + call h5pcreate_f(H5P_DATASET_XFER_F, plist_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5pcreate_f') + call h5pset_dxpl_mpio_f(plist_id, H5FD_MPIO_COLLECTIVE_F, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5pset_dxpl_mpio_f') +#endif + + ! Write the dataset collectively + call h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, dataset, int(dataspace_size,HSIZE_T), hdferr, & + file_space_id = space_id, mem_space_id = memspace)!, xfer_prp = plist_id) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset: h5dwrite_f') + + call h5sclose_f(space_id, hdferr) + call h5sclose_f(memspace, hdferr) + call h5dclose_f(dset_id, hdferr) + call h5pclose_f(plist_id, hdferr) + +end subroutine HDF5_writeScalarDataset7 !-------------------------------------------------------------------------------------------------- !> @brief creates a new scalar dataset in the given group location @@ -1375,6 +1584,39 @@ subroutine HDF5_addScalarDataset(group,nnodes,label,SIunit) end subroutine HDF5_addScalarDataset +!-------------------------------------------------------------------------------------------------- +!> @brief creates a new scalar dataset in the given group location +!-------------------------------------------------------------------------------------------------- +subroutine HDF5_addScalarDataset2(fileHandle,dataShape,label) + use hdf5 + + implicit none + integer(HID_T), intent(in) :: fileHandle + integer(pInt), dimension(:), intent(in) :: dataShape + character(len=*), intent(in) :: label + + integer :: hdferr + integer(HID_T) :: space_id, dset_id + +!-------------------------------------------------------------------------------------------------- +! create dataspace + call h5screate_simple_f(size(dataShape), int(dataShape,HSIZE_T), space_id, hdferr, & + int(dataShape,HSIZE_T)) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addScalarDataset: h5screate_simple_f') + +!-------------------------------------------------------------------------------------------------- +! create Dataset + call h5dcreate_f(fileHandle, trim(label),H5T_NATIVE_DOUBLE, space_id, dset_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addScalarDataset: h5dcreate_f') + +!-------------------------------------------------------------------------------------------------- +!close types, dataspaces + call h5dclose_f(dset_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addScalarDataset: h5dclose_f') + call h5sclose_f(space_id, hdferr) + +end subroutine HDF5_addScalarDataset2 + !--------------------------------------------------------------------------------------------------