cleaning and separating functions

This commit is contained in:
Martin Diehl 2018-12-04 23:09:25 +01:00
parent 8f26fc9358
commit ecb00af147
3 changed files with 82 additions and 88 deletions

View File

@ -108,8 +108,7 @@ subroutine CPFEM_init
debug_levelBasic, & debug_levelBasic, &
debug_levelExtensive debug_levelExtensive
use FEsolving, only: & use FEsolving, only: &
restartRead, & restartRead
modelName
use material, only: & use material, only: &
material_phase, & material_phase, &
homogState, & homogState, &
@ -128,16 +127,17 @@ subroutine CPFEM_init
use hdf5 use hdf5
use HDF5_utilities, only: & use HDF5_utilities, only: &
HDF5_openFile, & HDF5_openFile, &
HDF5_openGroup2, & HDF5_closeFile, &
HDF5_openGroup, &
HDF5_closeGroup, &
HDF5_read HDF5_read
use DAMASK_interface, only: & use DAMASK_interface, only: &
getSolverJobName getSolverJobName
implicit none implicit none
integer(pInt) :: k,l,m,ph,homog integer(pInt) :: ph,homog
character(len=1024) :: rankStr, PlasticItem, HomogItem character(len=1024) :: rankStr, PlasticItem, HomogItem
integer(HID_T) :: fileReadID, groupPlasticID, groupHomogID integer(HID_T) :: fileHandle, groupPlasticID, groupHomogID
integer :: hdferr
mainProcess: if (worldrank == 0) then mainProcess: if (worldrank == 0) then
write(6,'(/,a)') ' <<<+- CPFEM init -+>>>' write(6,'(/,a)') ' <<<+- CPFEM init -+>>>'
@ -155,28 +155,33 @@ subroutine CPFEM_init
write(rankStr,'(a1,i0)')'_',worldrank write(rankStr,'(a1,i0)')'_',worldrank
fileReadID = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5') fileHandle = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5')
call HDF5_read(material_phase, fileReadID,'recordedPhase') call HDF5_read(material_phase, fileHandle,'recordedPhase')
call HDF5_read(crystallite_F0, fileReadID,'convergedF') call HDF5_read(crystallite_F0, fileHandle,'convergedF')
call HDF5_read(crystallite_Fp0, fileReadID,'convergedFp') call HDF5_read(crystallite_Fp0, fileHandle,'convergedFp')
call HDF5_read(crystallite_Fi0, fileReadID,'convergedFi') call HDF5_read(crystallite_Fi0, fileHandle,'convergedFi')
call HDF5_read(crystallite_Lp0, fileReadID,'convergedLp') call HDF5_read(crystallite_Lp0, fileHandle,'convergedLp')
call HDF5_read(crystallite_Li0, fileReadID,'convergedLi') call HDF5_read(crystallite_Li0, fileHandle,'convergedLi')
call HDF5_read(crystallite_dPdF0, fileReadID,'convergeddPdF') call HDF5_read(crystallite_dPdF0, fileHandle,'convergeddPdF')
call HDF5_read(crystallite_Tstar0_v,fileReadID,'convergedTstar') call HDF5_read(crystallite_Tstar0_v,fileHandle,'convergedTstar')
groupPlasticID = HDF5_openGroup2(fileReadID,'PlasticPhases') groupPlasticID = HDF5_openGroup(fileHandle,'PlasticPhases')
do ph = 1_pInt,size(phase_plasticity) do ph = 1_pInt,size(phase_plasticity)
write(PlasticItem,*) ph,'_' write(PlasticItem,*) ph,'_'
call HDF5_read(plasticState(ph)%state0,groupPlasticID,trim(PlasticItem)//'convergedStateConst') call HDF5_read(plasticState(ph)%state0,groupPlasticID,trim(PlasticItem)//'convergedStateConst')
enddo enddo
call HDF5_closeGroup(groupPlasticID)
groupHomogID = HDF5_openGroup2(fileReadID,'HomogStates') groupHomogID = HDF5_openGroup(fileHandle,'HomogStates')
do homog = 1_pInt, material_Nhomogenization do homog = 1_pInt, material_Nhomogenization
write(HomogItem,*) homog,'_' write(HomogItem,*) homog,'_'
call HDF5_read(homogState(homog)%state0, groupHomogID,trim(HomogItem)//'convergedStateHomog') call HDF5_read(homogState(homog)%state0, groupHomogID,trim(HomogItem)//'convergedStateHomog')
enddo enddo
call HDF5_closeGroup(groupHomogID)
call HDF5_closeFile(fileHandle)
restartRead = .false. restartRead = .false.
endif endif
@ -234,8 +239,8 @@ subroutine CPFEM_age()
use HDF5_utilities, only: & use HDF5_utilities, only: &
HDF5_openFile, & HDF5_openFile, &
HDF5_closeFile, & HDF5_closeFile, &
HDF5_addGroup, &
HDF5_closeGroup, & HDF5_closeGroup, &
HDF5_addGroup2, &
HDF5_write HDF5_write
use hdf5 use hdf5
use DAMASK_interface, only: & use DAMASK_interface, only: &
@ -243,11 +248,9 @@ subroutine CPFEM_age()
implicit none implicit none
integer(pInt) :: i, k, l, m, ph, homog, mySource integer(pInt) :: i, ph, homog, mySource
character(len=32) :: rankStr, PlasticItem, HomogItem character(len=32) :: rankStr, PlasticItem, HomogItem
integer(HID_T) :: fileHandle, groupPlastic, groupHomog integer(HID_T) :: fileHandle, groupPlastic, groupHomog
integer :: hdferr
integer(HSIZE_T) :: hdfsize
if (iand(debug_level(debug_CPFEM), debug_levelBasic) /= 0_pInt) & if (iand(debug_level(debug_CPFEM), debug_levelBasic) /= 0_pInt) &
write(6,'(a)') '<< CPFEM >> aging states' write(6,'(a)') '<< CPFEM >> aging states'
@ -291,14 +294,14 @@ if (restartWrite) then
call HDF5_write(crystallite_dPdF0, fileHandle,'convergeddPdF') call HDF5_write(crystallite_dPdF0, fileHandle,'convergeddPdF')
call HDF5_write(crystallite_Tstar0_v,fileHandle,'convergedTstar') call HDF5_write(crystallite_Tstar0_v,fileHandle,'convergedTstar')
groupPlastic = HDF5_addGroup2(fileHandle,'PlasticPhases') groupPlastic = HDF5_addGroup(fileHandle,'PlasticPhases')
do ph = 1_pInt,size(phase_plasticity) do ph = 1_pInt,size(phase_plasticity)
write(PlasticItem,*) ph,'_' write(PlasticItem,*) ph,'_'
call HDF5_write(plasticState(ph)%state0,groupPlastic,trim(PlasticItem)//'convergedStateConst') call HDF5_write(plasticState(ph)%state0,groupPlastic,trim(PlasticItem)//'convergedStateConst')
enddo enddo
call HDF5_closeGroup(groupPlastic) call HDF5_closeGroup(groupPlastic)
groupHomog = HDF5_addGroup2(fileHandle,'HomogStates') groupHomog = HDF5_addGroup(fileHandle,'HomogStates')
do homog = 1_pInt, material_Nhomogenization do homog = 1_pInt, material_Nhomogenization
write(HomogItem,*) homog,'_' write(HomogItem,*) homog,'_'
call HDF5_write(homogState(homog)%state0,groupHomog,trim(HomogItem)//'convergedStateHomog') call HDF5_write(homogState(homog)%state0,groupHomog,trim(HomogItem)//'convergedStateHomog')

View File

@ -68,8 +68,8 @@ module HDF5_utilities
HDF5_addStringAttribute, & HDF5_addStringAttribute, &
HDF5_addIntegerAttribute, & HDF5_addIntegerAttribute, &
HDF5_closeGroup ,& HDF5_closeGroup ,&
HDF5_openGroup2, & HDF5_openGroup, &
HDF5_addGroup2, & HDF5_addGroup, &
HDF5_read, & HDF5_read, &
HDF5_write HDF5_write
contains contains
@ -154,9 +154,10 @@ end function HDF5_openFile
subroutine HDF5_closeFile(fileHandle) subroutine HDF5_closeFile(fileHandle)
implicit none implicit none
integer(HDF5_ERR_TYPE) :: hdferr
integer(HID_T), intent(in) :: fileHandle integer(HID_T), intent(in) :: fileHandle
integer(HDF5_ERR_TYPE) :: hdferr
call h5fclose_f(fileHandle,hdferr) call h5fclose_f(fileHandle,hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_closeFile: h5fclose_f') if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_closeFile: h5fclose_f')
@ -164,63 +165,66 @@ end subroutine HDF5_closeFile
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief adds a new group to the fileHandle (additional to addGroup2) !> @brief adds a new group to the fileHandle
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
integer(HID_T) function HDF5_addGroup2(fileHandle,groupName,parallel) integer(HID_T) function HDF5_addGroup(fileHandle,groupName)
implicit none implicit none
character(len=*), intent(in) :: groupName
integer(HID_T), intent(in) :: fileHandle integer(HID_T), intent(in) :: fileHandle
character(len=*), intent(in) :: groupName
integer(HDF5_ERR_TYPE) :: hdferr integer(HDF5_ERR_TYPE) :: hdferr
integer(HID_T) :: aplist_id
logical,intent(in), optional :: parallel
integer(HID_T) :: plist_id,gapl_id, gcpl_id, aplist_id
!------------------------------------------------------------------------------------------------- !-------------------------------------------------------------------------------------------------
! 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) call IO_error(1_pInt,ext_msg = 'HDF5_openGroup2: h5pcreate_f ('//trim(groupName)//')') if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_addGroup: h5pcreate_f ('//trim(groupName)//')')
!-------------------------------------------------------------------------------------------------
! setting I/O mode to collective
call h5pset_all_coll_metadata_ops_f(aplist_id, .true., hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_openGroup2: h5pset_all_coll_metadata_ops_f ('//trim(groupName)//')')
!-------------------------------------------------------------------------------------------------
! Create group
call h5gcreate_f(fileHandle, trim(groupName), HDF5_addGroup2, hdferr, OBJECT_NAMELEN_DEFAULT_F,gapl_id = aplist_id)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_addGroup2: h5gcreate_f ('//trim(groupName)//')')
end function HDF5_addGroup2 !-------------------------------------------------------------------------------------------------
! setting I/O mode to collective
call h5pset_all_coll_metadata_ops_f(aplist_id, .true., hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_addGroup: h5pset_all_coll_metadata_ops_f ('//trim(groupName)//')')
!-------------------------------------------------------------------------------------------------
! Create group
call h5gcreate_f(fileHandle, trim(groupName), HDF5_addGroup, hdferr, OBJECT_NAMELEN_DEFAULT_F,gapl_id = aplist_id)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_addGroup: h5gcreate_f ('//trim(groupName)//')')
end function HDF5_addGroup
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief open an existing group of a file !> @brief open an existing group of a file
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
integer(HID_T) function HDF5_openGroup2(FileReadID,groupName) integer(HID_T) function HDF5_openGroup(fileHandle,groupName)
implicit none implicit none
integer(HID_T), intent(in) :: fileHandle
character(len=*), intent(in) :: groupName character(len=*), intent(in) :: groupName
integer(HDF5_ERR_TYPE) :: hdferr
integer(HID_T), intent(in) :: FileReadID
integer(HDF5_ERR_TYPE) :: hdferr
integer(HID_T) :: aplist_id integer(HID_T) :: aplist_id
logical :: is_collective logical :: is_collective
!------------------------------------------------------------------------------------------------- !-------------------------------------------------------------------------------------------------
! 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) call IO_error(1_pInt,ext_msg = 'HDF5_openGroup2: h5pcreate_f ('//trim(groupName)//')') if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_openGroup: h5pcreate_f ('//trim(groupName)//')')
!-------------------------------------------------------------------------------------------------
! setting I/O mode to collective
call h5pget_all_coll_metadata_ops_f(aplist_id, is_collective, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_openGroup2: h5pset_all_coll_metadata_ops_f ('//trim(groupName)//')')
!-------------------------------------------------------------------------------------------------
! opening the group
call h5gopen_f(FileReadID, trim(groupName), HDF5_openGroup2, hdferr, gapl_id = aplist_id)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_openGroup2: h5gopen_f ('//trim(groupName)//')')
end function HDF5_openGroup2 !-------------------------------------------------------------------------------------------------
! setting I/O mode to collective
call h5pget_all_coll_metadata_ops_f(aplist_id, is_collective, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_openGroup: h5pset_all_coll_metadata_ops_f ('//trim(groupName)//')')
!-------------------------------------------------------------------------------------------------
! opening the group
call h5gopen_f(fileHandle, trim(groupName), HDF5_openGroup, hdferr, gapl_id = aplist_id)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_openGroup: h5gopen_f ('//trim(groupName)//')')
end function HDF5_openGroup
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
@ -2880,7 +2884,3 @@ end subroutine HDF5_write_pInt7
end module HDF5_Utilities end module HDF5_Utilities
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

View File

@ -31,9 +31,8 @@ module results
HDF5_backwardMappingHomog, & HDF5_backwardMappingHomog, &
HDF5_backwardMappingCrystallite, & HDF5_backwardMappingCrystallite, &
HDF5_mappingCells, & HDF5_mappingCells, &
HDF5_addGroup ,& results_addGroup, &
HDF5_closeGroup ,& results_openGroup, &
HDF5_openGroup, &
HDF5_writeVectorDataset, & HDF5_writeVectorDataset, &
HDF5_writeScalarDataset, & HDF5_writeScalarDataset, &
HDF5_writeTensorDataset, & HDF5_writeTensorDataset, &
@ -72,8 +71,6 @@ end subroutine results_openJobFile
!> @brief closes the results file !> @brief closes the results file
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine results_closeJobFile() subroutine results_closeJobFile()
use DAMASK_interface, only: &
getSolverJobName
implicit none implicit none
call HDF5_closeFile(resultsFile) call HDF5_closeFile(resultsFile)
@ -94,33 +91,27 @@ end subroutine results_addIncrement
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief open a group from the results file !> @brief open a group from the results file
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
integer(HID_T) function HDF5_openGroup(groupName) integer(HID_T) function results_openGroup(groupName)
use hdf5
implicit none implicit none
character(len=*), intent(in) :: groupName character(len=*), intent(in) :: groupName
integer :: hdferr
call h5gopen_f(resultsFile, trim(groupName), HDF5_openGroup, hdferr) results_openGroup = HDF5_openGroup(resultsFile,groupName)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_openGroup: h5gopen_f ('//trim(groupName)//')')
end function HDF5_openGroup end function results_openGroup
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief adds a new group to the results file !> @brief adds a new group to the results file
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
integer(HID_T) function HDF5_addGroup(groupName) integer(HID_T) function results_addGroup(groupName)
use hdf5
implicit none implicit none
character(len=*), intent(in) :: groupName character(len=*), intent(in) :: groupName
integer :: hdferr
call h5gcreate_f(resultsFile, trim(groupName), HDF5_addGroup, hdferr) results_addGroup = HDF5_addGroup(resultsFile,groupName)
if (hdferr < 0) call IO_error(1_pInt,ext_msg = 'HDF5_addGroup: h5gcreate_f ('//trim(groupName)//')')
end function HDF5_addGroup end function results_addGroup
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief set link to object in results file !> @brief set link to object in results file
@ -189,7 +180,7 @@ subroutine HDF5_mappingPhase(mapping,mapping2,Nconstituents,material_phase,phase
a = n a = n
allocate(namesNA(0:size(phase_name)),source=[a,phase_name]) allocate(namesNA(0:size(phase_name)),source=[a,phase_name])
NmatPoints = size(mapping,1)/Nconstituents NmatPoints = size(mapping,1)/Nconstituents
mapping_ID = HDF5_openGroup("current/mapGeometry") mapping_ID = results_openGroup("current/mapGeometry")
allocate(arrOffset(Nconstituents,NmatPoints)) allocate(arrOffset(Nconstituents,NmatPoints))
do i=1_pInt, NmatPoints do i=1_pInt, NmatPoints
@ -336,7 +327,7 @@ subroutine HDF5_backwardMappingPhase(material_phase,phasememberat,phase_name,dat
do i=1_pInt, size(phase_name) do i=1_pInt, size(phase_name)
write(phaseID, '(i0)') i write(phaseID, '(i0)') i
mapping_ID = HDF5_openGroup('/current/constitutive/'//trim(phaseID)//'_'//phase_name(i)) mapping_ID = results_openGroup('/current/constitutive/'//trim(phaseID)//'_'//phase_name(i))
NmatPoints = count(material_phase == i) NmatPoints = count(material_phase == i)
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
@ -436,7 +427,7 @@ subroutine HDF5_mappingHomog(material_homog,homogmemberat,homogenization_name,da
integer(pInt), dimension(:), allocatable :: arrOffset integer(pInt), dimension(:), allocatable :: arrOffset
NmatPoints = count(material_homog /=0_pInt) NmatPoints = count(material_homog /=0_pInt)
mapping_ID = HDF5_openGroup("current/mapGeometry") mapping_ID = results_openGroup("current/mapGeometry")
allocate(arrOffset(NmatPoints)) allocate(arrOffset(NmatPoints))
do i=1_pInt, NmatPoints do i=1_pInt, NmatPoints
@ -573,7 +564,7 @@ subroutine HDF5_backwardMappingHomog(material_homog,homogmemberat,homogenization
do i=1_pInt, size(homogenization_name) do i=1_pInt, size(homogenization_name)
write(homogID, '(i0)') i write(homogID, '(i0)') i
mapping_ID = HDF5_openGroup('/current/homogenization/'//trim(homogID)//'_'//homogenization_name(i)) mapping_ID = results_openGroup('/current/homogenization/'//trim(homogID)//'_'//homogenization_name(i))
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! create dataspace ! create dataspace
@ -679,7 +670,7 @@ subroutine HDF5_mappingCrystallite(crystalliteAt,crystmemberAt,crystallite_name,
Nconstituents = size(crystmemberAt,1) Nconstituents = size(crystmemberAt,1)
NmatPoints = count(crystalliteAt /=0_pInt) NmatPoints = count(crystalliteAt /=0_pInt)
mapping_ID = HDF5_openGroup("current/mapGeometry") mapping_ID = results_openGroup("current/mapGeometry")
allocate(position_id(Nconstituents)) allocate(position_id(Nconstituents))
@ -842,7 +833,7 @@ subroutine HDF5_backwardMappingCrystallite(crystalliteAt,crystmemberAt,crystalli
do i=1_pInt, size(crystallite_name) do i=1_pInt, size(crystallite_name)
if (crystallite_name(i) == 'none') cycle if (crystallite_name(i) == 'none') cycle
write(crystallID, '(i0)') i write(crystallID, '(i0)') i
mapping_ID = HDF5_openGroup('/current/crystallite/'//trim(crystallID)//'_'//crystallite_name(i)) mapping_ID = results_openGroup('/current/crystallite/'//trim(crystallID)//'_'//crystallite_name(i))
NmatPoints = count(crystalliteAt == i) NmatPoints = count(crystalliteAt == i)
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
@ -933,7 +924,7 @@ subroutine HDF5_mappingCells(mapping)
integer(HID_T) :: mapping_id, dset_id, space_id integer(HID_T) :: mapping_id, dset_id, space_id
Nnodes=size(mapping) Nnodes=size(mapping)
mapping_ID = HDF5_openGroup("mapping") mapping_ID = results_openGroup("mapping")
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! create dataspace ! create dataspace