diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 old mode 100644 new mode 100755 index 43dab1b44..d52caa77a --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -91,7 +91,7 @@ subroutine CPFEM_init compiler_options #endif use prec, only: & - pInt + pInt, pReal use IO, only: & IO_read_realFile,& IO_read_intFile, & @@ -126,6 +126,7 @@ subroutine CPFEM_init implicit none integer(pInt) :: k,l,m,ph,homog character(len=1024) :: rankStr + mainProcess: if (worldrank == 0) then write(6,'(/,a)') ' <<<+- CPFEM init -+>>>' @@ -249,9 +250,6 @@ subroutine CPFEM_age() HDF5_closeGroup, & HDF5_addGroup2, & HDF5_writeScalarDataset3, & - HDF5_writeScalarDataset4, & - HDF5_writeScalarDataset5, & - HDF5_writeScalarDataset7, & HDF5_addScalarDataset2 use hdf5 use DAMASK_interface, only: & @@ -261,9 +259,12 @@ subroutine CPFEM_age() integer(pInt) :: i, k, l, m, ph, homog, mySource character(len=32) :: rankStr - integer(HID_T) :: fileHandle + integer(HID_T) :: fileHandle, groupHandle integer :: hdferr integer(HSIZE_T) :: hdfsize + + real(pReal), dimension(4,1,1,3,2) :: testData = reshape(real([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, & + 16,17,18,19,20,21,22,23,24],pReal),[4,1,1,3,2]) if (iand(debug_level(debug_CPFEM), debug_levelBasic) /= 0_pInt) & write(6,'(a)') '<< CPFEM >> aging states' @@ -297,22 +298,21 @@ if (restartWrite) then write(rankStr,'(a1,i0)')'_',worldrank - fileHandle = HDF5_createFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5_restart') + fileHandle = HDF5_createFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5') - !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,testdata,'test',shape(testdata)) call HDF5_writeScalarDataset3(fileHandle,real(material_phase,pReal),'recordedPhase',shape(material_phase)) + call HDF5_writeScalarDataset3(fileHandle,crystallite_F0,'convergedF',shape(crystallite_F0)) + call HDF5_writeScalarDataset3(fileHandle,crystallite_Fp0,'convergedFp',shape(crystallite_Fp0)) + call HDF5_writeScalarDataset3(fileHandle,crystallite_Fi0,'convergedFi',shape(crystallite_Fi0)) + call HDF5_writeScalarDataset3(fileHandle,crystallite_Lp0,'convergedLp',shape(crystallite_Lp0)) + call HDF5_writeScalarDataset3(fileHandle,crystallite_Li0,'convergedLi',shape(crystallite_Li0)) + call HDF5_writeScalarDataset3(fileHandle,crystallite_dPdF0,'convergeddPdF',shape(crystallite_dPdF0)) + call HDF5_writeScalarDataset3(fileHandle,crystallite_Tstar0_v,'convergedTstar',shape(crystallite_Tstar0_v)) - call HDF5_addScalarDataset2(fileHandle,shape(crystallite_F0),'convergedF') - call HDF5_writeScalarDataset5(fileHandle,real(crystallite_F0,pReal),'convergedF',shape(crystallite_F0)) + groupHandle = HDF5_addGroup2(fileHandle,'PlasticPhases') + !call HDF5_writeScalarDatasetLoop(fileHandle,plasticState(ph)%state0,'convergedStateConst',shape()) - 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 467d69331..8868cb4d7 --- a/src/HDF5_utilities.f90 +++ b/src/HDF5_utilities.f90 @@ -30,9 +30,7 @@ module HDF5_Utilities HDF5_removeLink, & HDF5_createFile, & HDF5_closeFile, & - HDF5_addGroup2, HDF5_addScalarDataset2, HDF5_writeScalarDataset3, HDF5_writeScalarDataset4, HDF5_writeScalarDataset5, & - HDF5_writeScalarDataset7 - + HDF5_addGroup2, HDF5_addScalarDataset2, HDF5_writeScalarDataset3 contains subroutine HDF5_Utilities_init @@ -185,16 +183,16 @@ end function HDF5_addGroup !-------------------------------------------------------------------------------------------------- !> @brief adds a new group to the results file, or if loc is present at the given location !-------------------------------------------------------------------------------------------------- -integer(HID_T) function HDF5_addGroup2(fileHandle,path) +integer(HID_T) function HDF5_addGroup2(fileHandle,groupName) use hdf5 implicit none - character(len=*), intent(in) :: path + character(len=*), intent(in) :: groupName integer(HID_T), intent(in) :: fileHandle integer :: hdferr - call h5gcreate_f(fileHandle, trim(path), HDF5_addGroup2, hdferr) - if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_addGroup2: h5gcreate_f ('//trim(path)//')') + call h5gcreate_f(fileHandle, trim(groupName), HDF5_addGroup2, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_addGroup2: h5gcreate_f ('//trim(groupName)//')') end function HDF5_addGroup2 @@ -1345,210 +1343,80 @@ end subroutine HDF5_writeScalarDataset !-------------------------------------------------------------------------------------------------- !> @brief creates a new scalar dataset in the given group location !-------------------------------------------------------------------------------------------------- -subroutine HDF5_writeScalarDataset3(group,dataset,label,dataspace_size) +subroutine HDF5_writeScalarDataset3(group,dataset,label,myShape) use hdf5 implicit none integer(HID_T), intent(in) :: group + integer(pInt), intent(in), dimension(:) :: myShape character(len=*), intent(in) :: label - integer(pInt), intent(in),dimension(:) :: dataspace_size - real(pReal), intent(in), dimension(:,:,:) :: dataset + 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') + integer(HID_T) :: dset_id, space_id - ! 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 dataspace + call h5screate_simple_f(size(myShape), int(myShape,HSIZE_T), space_id, hdferr, & + int(myShape,HSIZE_T)) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset3: h5screate_simple_f') + +!-------------------------------------------------------------------------------------------------- +! create Dataset + call h5dcreate_f(group, trim(label), H5T_NATIVE_DOUBLE, space_id, dset_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset3: h5dcreate_f') + + CALL h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(myShape,HSIZE_T), hdferr) + - ! 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) +!-------------------------------------------------------------------------------------------------- +!close types, dataspaces call h5dclose_f(dset_id, hdferr) - call h5pclose_f(plist_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset3: h5dclose_f') + call h5sclose_f(space_id, hdferr) + if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset3: h5sclose_f') 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 +! subroutine HDF5_writeScalarDatasetLoop(group,dataset,label,myShape) + ! 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 + ! implicit none + ! integer(HID_T), intent(in) :: group + ! integer(pInt), intent(in), dimension(:) :: myShape + ! character(len=*), intent(in) :: label + ! 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') + ! integer :: hdferr + ! integer(HID_T) :: dset_id, space_id - ! 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 + ! !-------------------------------------------------------------------------------------------------- +! ! create dataspace + ! call h5screate_simple_f(size(myShape), int(myShape,HSIZE_T), space_id, hdferr, & + ! int(myShape,HSIZE_T)) + ! if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset3: h5screate_simple_f') -!-------------------------------------------------------------------------------------------------- -!> @brief creates a new scalar dataset in the given group location -!-------------------------------------------------------------------------------------------------- -subroutine HDF5_writeScalarDataset5(group,dataset,label,dataspace_size) - use hdf5 +! !-------------------------------------------------------------------------------------------------- +! ! create Dataset + ! call h5dcreate_f(group, trim(label), H5T_NATIVE_DOUBLE, space_id, dset_id, hdferr) + ! if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset3: h5dcreate_f') - 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 + ! CALL h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE,dataset,int(myShape,HSIZE_T), hdferr) - integer :: hdferr - integer(HID_T) :: dset_id, space_id, memspace, plist_id - integer(HSIZE_T), dimension(1) :: counter - integer(HSSIZE_T), dimension(1) :: fileOffset +! !-------------------------------------------------------------------------------------------------- +! !close types, dataspaces + ! call h5dclose_f(dset_id, hdferr) + ! if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset3: h5dclose_f') + ! call h5sclose_f(space_id, hdferr) + ! if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_writeScalarDataset3: h5sclose_f') - 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 +! end subroutine HDF5_writeScalarDatasetLoop !-------------------------------------------------------------------------------------------------- !> @brief creates a new scalar dataset in the given group location