From 137b235bc1d95e5fc13ea9acd487296cc097c055 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 7 Dec 2019 11:06:39 +0100 Subject: [PATCH 1/6] i0 format specifier easier then hand-written IO_intOut using variable pStringLen allows string assignment without length issues --- src/config.f90 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/config.f90 b/src/config.f90 index 00b473767..cffa9f644 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -27,7 +27,7 @@ module config config_numerics, & config_debug - character(len=64), dimension(:), allocatable, public, protected :: & + character(len=pStringLen), dimension(:), allocatable, public, protected :: & config_name_phase, & !< name of each phase config_name_homogenization, & !< name of each homogenization config_name_crystallite, & !< name of each crystallite setting @@ -54,7 +54,7 @@ subroutine config_init character(len=pStringLen), dimension(:), allocatable :: fileContent logical :: fileExists - write(6,'(/,a)') ' <<<+- config init -+>>>' + write(6,'(/,a)') ' <<<+- config init -+>>>'; flush(6) verbose = iand(debug_level(debug_material),debug_levelBasic) /= 0 @@ -214,7 +214,7 @@ end function read_materialConfig subroutine parse_materialConfig(sectionNames,part,line, & fileContent) - character(len=64), allocatable, dimension(:), intent(out) :: sectionNames + character(len=pStringLen), allocatable, dimension(:), intent(out) :: sectionNames type(tPartitionedStringList), allocatable, dimension(:), intent(inout) :: part character(len=pStringLen), intent(inout) :: line character(len=pStringLen), dimension(:), intent(in) :: fileContent @@ -222,7 +222,7 @@ subroutine parse_materialConfig(sectionNames,part,line, & integer, allocatable, dimension(:) :: partPosition !< position of [] tags + last line in section integer :: i, j logical :: echo - character(len=pStringLen) :: section_ID + character(len=pStringLen) :: sectionName echo = .false. @@ -246,8 +246,8 @@ subroutine parse_materialConfig(sectionNames,part,line, & partPosition = [partPosition, i] ! needed when actually storing content do i = 1, size(partPosition) -1 - write(section_ID,'('//IO_intOut(size(partPosition))//')') i - sectionNames(i) = trim(section_ID)//'_'//trim(adjustl(IO_getTag(fileContent(partPosition(i)),'[',']'))) + write(sectionName,'(i0,a,a)') i,'_',trim(IO_getTag(fileContent(partPosition(i)),'[',']')) + sectionNames(i) = sectionName do j = partPosition(i) + 1, partPosition(i+1) -1 call part(i)%add(trim(adjustl(fileContent(j)))) enddo From 7ecb0245ec030bcca7e48e1f3075330ae0a614f4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 7 Dec 2019 11:10:48 +0100 Subject: [PATCH 2/6] simplified (use novel i0 format specifier) --- src/IO.f90 | 1 + src/grid/DAMASK_grid.f90 | 11 ++--------- src/mesh/DAMASK_FEM.f90 | 11 ++--------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index a585fc7c4..8973860c2 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -544,6 +544,7 @@ end function IO_lc !-------------------------------------------------------------------------------------------------- !> @brief returns format string for integer values without leading zeros +!> @details deprecated, use '(i0)' format specifier !-------------------------------------------------------------------------------------------------- pure function IO_intOut(intToPrint) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index e83cf3283..b6b415b5e 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -443,19 +443,12 @@ program DAMASK_spectral !-------------------------------------------------------------------------------------------------- ! report begin of new step write(6,'(/,a)') ' ###########################################################################' - write(6,'(1x,a,es12.5'//& - ',a,'//IO_intOut(inc) //',a,'//IO_intOut(loadCases(currentLoadCase)%incs)//& - ',a,'//IO_intOut(stepFraction) //',a,'//IO_intOut(subStepFactor**cutBackLevel)//& - ',a,'//IO_intOut(currentLoadCase)//',a,'//IO_intOut(size(loadCases))//')') & + write(6,'(1x,a,es12.5,6(a,i0))') & 'Time', time, & 's: Increment ', inc,'/',loadCases(currentLoadCase)%incs,& '-', stepFraction,'/',subStepFactor**cutBackLevel,& ' of load case ', currentLoadCase,'/',size(loadCases) - write(incInfo,& - '(a,'//IO_intOut(totalIncsCounter)//& - ',a,'//IO_intOut(sum(loadCases%incs))//& - ',a,'//IO_intOut(stepFraction)//& - ',a,'//IO_intOut(subStepFactor**cutBackLevel)//')') & + write(incInfo,'(4(a,i0))') & 'Increment ',totalIncsCounter,'/',sum(loadCases%incs),& '-', stepFraction,'/',subStepFactor**cutBackLevel flush(6) diff --git a/src/mesh/DAMASK_FEM.f90 b/src/mesh/DAMASK_FEM.f90 index 3d4c332a0..5ebcbe217 100644 --- a/src/mesh/DAMASK_FEM.f90 +++ b/src/mesh/DAMASK_FEM.f90 @@ -296,19 +296,12 @@ program DAMASK_FEM !-------------------------------------------------------------------------------------------------- ! report begin of new step write(6,'(/,a)') ' ###########################################################################' - write(6,'(1x,a,es12.5'//& - ',a,'//IO_intOut(inc)//',a,'//IO_intOut(loadCases(currentLoadCase)%incs)//& - ',a,'//IO_intOut(stepFraction)//',a,'//IO_intOut(subStepFactor**cutBackLevel)//& - ',a,'//IO_intOut(currentLoadCase)//',a,'//IO_intOut(size(loadCases))//')') & + write(6,'(1x,a,es12.5,6(a,i0))')& 'Time', time, & 's: Increment ', inc, '/', loadCases(currentLoadCase)%incs,& '-', stepFraction, '/', subStepFactor**cutBackLevel,& ' of load case ', currentLoadCase,'/',size(loadCases) - write(incInfo,& - '(a,'//IO_intOut(totalIncsCounter)//& - ',a,'//IO_intOut(sum(loadCases%incs))//& - ',a,'//IO_intOut(stepFraction)//& - ',a,'//IO_intOut(subStepFactor**cutBackLevel)//')') & + write(incInfo,'(4(a,i0))') & 'Increment ',totalIncsCounter,'/',sum(loadCases%incs),& '-',stepFraction, '/', subStepFactor**cutBackLevel flush(6) From 23944de6de8d0ae0882c17c74fc80f64d847ecbc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 7 Dec 2019 15:20:04 +0100 Subject: [PATCH 3/6] less variables for better readability --- src/CPFEM2.f90 | 98 ++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index 7123602f8..4575b9caa 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -42,7 +42,7 @@ contains !-------------------------------------------------------------------------------------------------- -!> @brief call (thread safe) all module initializations +!> @brief call all module initializations !-------------------------------------------------------------------------------------------------- subroutine CPFEM_initAll @@ -70,29 +70,24 @@ subroutine CPFEM_initAll end subroutine CPFEM_initAll + !-------------------------------------------------------------------------------------------------- !> @brief allocate the arrays defined in module CPFEM and initialize them !-------------------------------------------------------------------------------------------------- subroutine CPFEM_init - integer :: ph,homog - character(len=1024) :: rankStr, PlasticItem, HomogItem - integer(HID_T) :: fileHandle, groupPlasticID, groupHomogID + integer :: i + integer(HID_T) :: fileHandle, groupHandle + character(len=pStringLen) :: fileName, datasetName - write(6,'(/,a)') ' <<<+- CPFEM init -+>>>' - flush(6) + write(6,'(/,a)') ' <<<+- CPFEM init -+>>>'; flush(6) - ! *** restore the last converged values of each essential variable if (interface_restartInc > 0) then - if (iand(debug_level(debug_CPFEM), debug_levelExtensive) /= 0) then - write(6,'(a)') '<< CPFEM >> restored state variables of last converged step from hdf5 file' - flush(6) - endif - - write(rankStr,'(a1,i0)')'_',worldrank + write(6,'(/,a,i0,a)') ' reading restart information of increment ', interface_restartInc, ' from file' - fileHandle = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5') - + write(fileName,'(a,i0,a)') trim(getSolverJobName())//'_',worldrank,'.hdf5' + fileHandle = HDF5_openFile(fileName) + call HDF5_read(fileHandle,crystallite_F0, 'F') call HDF5_read(fileHandle,crystallite_Fp0,'Fp') call HDF5_read(fileHandle,crystallite_Fi0,'Fi') @@ -100,19 +95,19 @@ subroutine CPFEM_init call HDF5_read(fileHandle,crystallite_Li0,'Li') call HDF5_read(fileHandle,crystallite_S0, 'S') - groupPlasticID = HDF5_openGroup(fileHandle,'constituent') - do ph = 1,size(phase_plasticity) - write(PlasticItem,*) ph,'_' - call HDF5_read(groupPlasticID,plasticState(ph)%state0,trim(PlasticItem)//'omega_plastic') + groupHandle = HDF5_openGroup(fileHandle,'constituent') + do i = 1,size(phase_plasticity) + write(datasetName,'(i0,a)') i,'_omega_plastic' + call HDF5_read(groupHandle,plasticState(i)%state,datasetName) enddo - call HDF5_closeGroup(groupPlasticID) - - groupHomogID = HDF5_openGroup(fileHandle,'materialpoint') - do homog = 1, material_Nhomogenization - write(HomogItem,*) homog,'_' - call HDF5_read(groupHomogID,homogState(homog)%state0, trim(HomogItem)//'omega_homogenization') + call HDF5_closeGroup(groupHandle) + + groupHandle = HDF5_openGroup(fileHandle,'materialpoint') + do i = 1, material_Nhomogenization + write(datasetName,'(i0,a)') i,'_omega_homogenization' + call HDF5_read(groupHandle,homogState(i)%state,datasetName) enddo - call HDF5_closeGroup(groupHomogID) + call HDF5_closeGroup(groupHandle) call HDF5_closeFile(fileHandle) endif @@ -126,7 +121,7 @@ end subroutine CPFEM_init !-------------------------------------------------------------------------------------------------- subroutine CPFEM_forward - integer :: i, homog, mySource + integer :: i, j if (iand(debug_level(debug_CPFEM), debug_levelBasic) /= 0) & write(6,'(a)') '<< CPFEM >> aging states' @@ -142,32 +137,31 @@ subroutine CPFEM_forward plasticState(i)%state0 = plasticState(i)%state enddo do i = 1, size(sourceState) - do mySource = 1,phase_Nsources(i) - sourceState(i)%p(mySource)%state0 = sourceState(i)%p(mySource)%state + do j = 1,phase_Nsources(i) + sourceState(i)%p(j)%state0 = sourceState(i)%p(j)%state enddo; enddo - do homog = 1, material_Nhomogenization - homogState (homog)%state0 = homogState (homog)%state - thermalState (homog)%state0 = thermalState (homog)%state - damageState (homog)%state0 = damageState (homog)%state + do i = 1, material_Nhomogenization + homogState (i)%state0 = homogState (i)%state + thermalState(i)%state0 = thermalState(i)%state + damageState (i)%state0 = damageState (i)%state enddo end subroutine CPFEM_forward !-------------------------------------------------------------------------------------------------- -!> @brief Write current constitutive variables for restart to file. +!> @brief Write current restart information (Field and constitutive data) to file. !-------------------------------------------------------------------------------------------------- subroutine CPFEM_restartWrite - integer :: ph, homog - character(len=32) :: rankStr, PlasticItem, HomogItem - integer(HID_T) :: fileHandle, groupPlastic, groupHomog + integer :: i + integer(HID_T) :: fileHandle, groupHandle + character(len=pStringLen) :: fileName, datasetName - - write(6,'(a)') ' writing constitutive data required for restart to file';flush(6) + write(6,'(a)') ' writing field and constitutive data required for restart to file';flush(6) - write(rankStr,'(a1,i0)')'_',worldrank - fileHandle = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5','a') + write(fileName,'(a,i0,a)') trim(getSolverJobName())//'_',worldrank,'.hdf5' + fileHandle = HDF5_openFile(fileName,'a') call HDF5_write(fileHandle,crystallite_partionedF,'F') call HDF5_write(fileHandle,crystallite_Fp, 'Fp') @@ -176,19 +170,19 @@ subroutine CPFEM_restartWrite call HDF5_write(fileHandle,crystallite_Li, 'Li') call HDF5_write(fileHandle,crystallite_S, 'S') - groupPlastic = HDF5_addGroup(fileHandle,'constituent') - do ph = 1,size(phase_plasticity) - write(PlasticItem,*) ph,'_' - call HDF5_write(groupPlastic,plasticState(ph)%state,trim(PlasticItem)//'omega_plastic') + groupHandle = HDF5_addGroup(fileHandle,'constituent') + do i = 1,size(phase_plasticity) + write(datasetName,'(i0,a)') i,'_omega_plastic' + call HDF5_write(groupHandle,plasticState(i)%state,datasetName) enddo - call HDF5_closeGroup(groupPlastic) + call HDF5_closeGroup(groupHandle) - groupHomog = HDF5_addGroup(fileHandle,'materialpoint') - do homog = 1, material_Nhomogenization - write(HomogItem,*) homog,'_' - call HDF5_write(groupHomog,homogState(homog)%state,trim(HomogItem)//'omega_homogenization') + groupHandle = HDF5_addGroup(fileHandle,'materialpoint') + do i = 1, material_Nhomogenization + write(datasetName,'(i0,a)') i,'_omega_homogenization' + call HDF5_write(groupHandle,homogState(i)%state,datasetName) enddo - call HDF5_closeGroup(groupHomog) + call HDF5_closeGroup(groupHandle) call HDF5_closeFile(fileHandle) @@ -209,7 +203,7 @@ subroutine CPFEM_results(inc,time) call crystallite_results call homogenization_results call discretization_results - call results_removeLink('current') ! ToDo: put this into closeJobFile + call results_removeLink('current') ! ToDo: put this into closeJobFile? call results_closeJobFile end subroutine CPFEM_results From 4eacc1d16d08f942b28c823a39aed1a15ef27617 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 7 Dec 2019 15:24:45 +0100 Subject: [PATCH 4/6] polishing --- src/grid/DAMASK_grid.f90 | 8 ++--- src/grid/grid_mech_FEM.f90 | 34 +++++++++----------- src/grid/grid_mech_spectral_basic.f90 | 32 +++++++++--------- src/grid/grid_mech_spectral_polarisation.f90 | 34 +++++++++----------- src/grid/spectral_utilities.f90 | 2 +- src/mesh/DAMASK_FEM.f90 | 8 ++--- 6 files changed, 54 insertions(+), 64 deletions(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index b6b415b5e..45e62bab7 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -105,7 +105,7 @@ program DAMASK_spectral !-------------------------------------------------------------------------------------------------- ! init DAMASK (all modules) call CPFEM_initAll - write(6,'(/,a)') ' <<<+- DAMASK_spectral init -+>>>' + write(6,'(/,a)') ' <<<+- DAMASK_spectral init -+>>>'; flush(6) write(6,'(/,a)') ' Shanthraj et al., Handbook of Mechanics of Materials, 2019' write(6,'(a)') ' https://doi.org/10.1007/978-981-10-6855-3_80' @@ -533,11 +533,9 @@ program DAMASK_spectral cutBackLevel = max(0, cutBackLevel - 1) ! try half number of subincs next inc if (all(solres(:)%converged)) then - write(6,'(/,a,'//IO_intOut(totalIncsCounter)//',a)') & ! report converged inc - ' increment ', totalIncsCounter, ' converged' + write(6,'(/,a,i0,a)') ' increment ', totalIncsCounter, ' converged' else - write(6,'(/,a,'//IO_intOut(totalIncsCounter)//',a)') & ! report non-converged inc - ' increment ', totalIncsCounter, ' NOT converged' + write(6,'(/,a,i0,a)') ' increment ', totalIncsCounter, ' NOT converged' endif; flush(6) if (mod(inc,loadCases(currentLoadCase)%outputFrequency) == 0) then ! at output frequency diff --git a/src/grid/grid_mech_FEM.f90 b/src/grid/grid_mech_FEM.f90 index 0c3844fcf..1c3447ebd 100644 --- a/src/grid/grid_mech_FEM.f90 +++ b/src/grid/grid_mech_FEM.f90 @@ -96,15 +96,15 @@ subroutine grid_mech_FEM_init 1.0_pReal,-1.0_pReal,-1.0_pReal,-1.0_pReal, & 1.0_pReal, 1.0_pReal, 1.0_pReal, 1.0_pReal], [4,8]) PetscErrorCode :: ierr - integer :: rank - integer(HID_T) :: fileHandle, groupHandle - character(len=1024) :: rankStr + integer :: rank + integer(HID_T) :: fileHandle, groupHandle + character(len=pStringLen) :: fileName real(pReal), dimension(3,3,3,3) :: devNull PetscScalar, pointer, dimension(:,:,:,:) :: & u_current,u_lastInc - write(6,'(/,a)') ' <<<+- grid_mech_FEM init -+>>>' - + write(6,'(/,a)') ' <<<+- grid_mech_FEM init -+>>>'; flush(6) + !-------------------------------------------------------------------------------------------------- ! set default and user defined options for PETSc call PETScOptionsInsertString(PETSC_NULL_OPTIONS,'-mech_snes_type newtonls -mech_ksp_type fgmres & @@ -184,11 +184,10 @@ subroutine grid_mech_FEM_init !-------------------------------------------------------------------------------------------------- ! init fields restartRead: if (interface_restartInc > 0) then - write(6,'(/,a,'//IO_intOut(interface_restartInc)//',a)') & - 'reading values of increment ', interface_restartInc, ' from file' + write(6,'(/,a,i0,a)') ' reading restart data of increment ', interface_restartInc, ' from file' - write(rankStr,'(a1,i0)')'_',worldrank - fileHandle = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5') + write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' + fileHandle = HDF5_openFile(fileName) groupHandle = HDF5_openGroup(fileHandle,'solver') call HDF5_read(groupHandle,F_aim, 'F_aim') @@ -215,8 +214,7 @@ subroutine grid_mech_FEM_init CHKERRQ(ierr) restartRead2: if (interface_restartInc > 0) then - write(6,'(/,a,'//IO_intOut(interface_restartInc)//',a)') & - 'reading more values of increment ', interface_restartInc, ' from file' + write(6,'(/,a,i0,a)') ' reading more restart data of increment ', interface_restartInc, ' from file' call HDF5_read(groupHandle,C_volAvg, 'C_volAvg') call HDF5_read(groupHandle,C_volAvgLastInc,'C_volAvgLastInc') @@ -355,7 +353,7 @@ end subroutine grid_mech_FEM_forward !-------------------------------------------------------------------------------------------------- !> @brief Age !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_FEM_updateCoords() +subroutine grid_mech_FEM_updateCoords call utilities_updateCoords(F) @@ -365,20 +363,20 @@ end subroutine grid_mech_FEM_updateCoords !-------------------------------------------------------------------------------------------------- !> @brief Write current solver and constitutive data for restart to file !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_FEM_restartWrite() +subroutine grid_mech_FEM_restartWrite PetscErrorCode :: ierr + integer(HID_T) :: fileHandle, groupHandle PetscScalar, dimension(:,:,:,:), pointer :: u_current,u_lastInc - integer(HID_T) :: fileHandle, groupHandle - character(len=32) :: rankStr + character(len=pStringLen) :: fileName call DMDAVecGetArrayF90(mech_grid,solution_current,u_current,ierr); CHKERRQ(ierr) call DMDAVecGetArrayF90(mech_grid,solution_lastInc,u_lastInc,ierr); CHKERRQ(ierr) - write(6,'(a)') ' writing solver data required for restart to file';flush(6) + write(6,'(a)') ' writing solver data required for restart to file'; flush(6) - write(rankStr,'(a1,i0)')'_',worldrank - fileHandle = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5','w') + write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' + fileHandle = HDF5_openFile(fileName,'w') groupHandle = HDF5_addGroup(fileHandle,'solver') call HDF5_write(groupHandle,F_aim, 'F_aim') diff --git a/src/grid/grid_mech_spectral_basic.f90 b/src/grid/grid_mech_spectral_basic.f90 index 3dc978dc6..1f61de1a9 100644 --- a/src/grid/grid_mech_spectral_basic.f90 +++ b/src/grid/grid_mech_spectral_basic.f90 @@ -94,11 +94,11 @@ subroutine grid_mech_spectral_basic_init PetscScalar, pointer, dimension(:,:,:,:) :: & F ! pointer to solution data PetscInt, dimension(worldsize) :: localK - integer(HID_T) :: fileHandle, groupHandle - integer :: fileUnit - character(len=1024) :: rankStr + integer(HID_T) :: fileHandle, groupHandle + integer :: fileUnit + character(len=pStringLen) :: fileName - write(6,'(/,a)') ' <<<+- grid_mech_spectral_basic init -+>>>' + write(6,'(/,a)') ' <<<+- grid_mech_spectral_basic init -+>>>'; flush(6) write(6,'(/,a)') ' Eisenlohr et al., International Journal of Plasticity 46:37–53, 2013' write(6,'(a)') ' https://doi.org/10.1016/j.ijplas.2012.09.012' @@ -151,11 +151,10 @@ subroutine grid_mech_spectral_basic_init call DMDAVecGetArrayF90(da,solution_vec,F,ierr); CHKERRQ(ierr) ! places pointer on PETSc data restartRead: if (interface_restartInc > 0) then - write(6,'(/,a,'//IO_intOut(interface_restartInc)//',a)') & - ' reading values of increment ', interface_restartInc, ' from file' + write(6,'(/,a,i0,a)') ' reading restart data of increment ', interface_restartInc, ' from file' - write(rankStr,'(a1,i0)')'_',worldrank - fileHandle = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5') + write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' + fileHandle = HDF5_openFile(fileName) groupHandle = HDF5_openGroup(fileHandle,'solver') call HDF5_read(groupHandle,F_aim, 'F_aim') @@ -178,8 +177,7 @@ subroutine grid_mech_spectral_basic_init call DMDAVecRestoreArrayF90(da,solution_vec,F,ierr); CHKERRQ(ierr) ! deassociate pointer restartRead2: if (interface_restartInc > 0) then - write(6,'(/,a,'//IO_intOut(interface_restartInc)//',a)') & - 'reading more values of increment ', interface_restartInc, ' from file' + write(6,'(/,a,i0,a)') ' reading more restart data of increment ', interface_restartInc, ' from file' call HDF5_read(groupHandle,C_volAvg, 'C_volAvg') call HDF5_read(groupHandle,C_volAvgLastInc,'C_volAvgLastInc') @@ -320,7 +318,7 @@ end subroutine grid_mech_spectral_basic_forward !-------------------------------------------------------------------------------------------------- !> @brief Age !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_basic_updateCoords() +subroutine grid_mech_spectral_basic_updateCoords PetscErrorCode :: ierr PetscScalar, dimension(:,:,:,:), pointer :: F @@ -335,19 +333,19 @@ end subroutine grid_mech_spectral_basic_updateCoords !-------------------------------------------------------------------------------------------------- !> @brief Write current solver and constitutive data for restart to file !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_basic_restartWrite() +subroutine grid_mech_spectral_basic_restartWrite PetscErrorCode :: ierr + integer(HID_T) :: fileHandle, groupHandle PetscScalar, dimension(:,:,:,:), pointer :: F - integer(HID_T) :: fileHandle, groupHandle - character(len=32) :: rankStr + character(len=pStringLen) :: fileName call DMDAVecGetArrayF90(da,solution_vec,F,ierr); CHKERRQ(ierr) - write(6,'(a)') ' writing solver data required for restart to file';flush(6) + write(6,'(a)') ' writing solver data required for restart to file'; flush(6) - write(rankStr,'(a1,i0)')'_',worldrank - fileHandle = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5','w') + write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' + fileHandle = HDF5_openFile(fileName,'w') groupHandle = HDF5_addGroup(fileHandle,'solver') call HDF5_write(groupHandle,F_aim, 'F_aim') diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index c1b5d79c9..20ca8d69d 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -102,11 +102,11 @@ subroutine grid_mech_spectral_polarisation_init F, & ! specific (sub)pointer F_tau ! specific (sub)pointer PetscInt, dimension(worldsize) :: localK - integer(HID_T) :: fileHandle, groupHandle - integer :: fileUnit - character(len=1024) :: rankStr + integer(HID_T) :: fileHandle, groupHandle + integer :: fileUnit + character(len=pStringLen) :: fileName - write(6,'(/,a)') ' <<<+- grid_mech_spectral_polarisation init -+>>>' + write(6,'(/,a)') ' <<<+- grid_mech_spectral_polarisation init -+>>>'; flush(6) write(6,'(/,a)') ' Shanthraj et al., International Journal of Plasticity 66:31–45, 2015' write(6,'(a)') ' https://doi.org/10.1016/j.ijplas.2014.02.006' @@ -160,11 +160,10 @@ subroutine grid_mech_spectral_polarisation_init F_tau => FandF_tau(9:17,:,:,:) restartRead: if (interface_restartInc > 0) then - write(6,'(/,a,'//IO_intOut(interface_restartInc)//',a)') & - ' reading values of increment ', interface_restartInc, ' from file' - - write(rankStr,'(a1,i0)')'_',worldrank - fileHandle = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5') + write(6,'(/,a,i0,a)') ' reading restart data of increment ', interface_restartInc, ' from file' + + write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' + fileHandle = HDF5_openFile(fileName) groupHandle = HDF5_openGroup(fileHandle,'solver') call HDF5_read(groupHandle,F_aim, 'F_aim') @@ -191,8 +190,7 @@ subroutine grid_mech_spectral_polarisation_init call DMDAVecRestoreArrayF90(da,solution_vec,FandF_tau,ierr); CHKERRQ(ierr) ! deassociate pointer restartRead2: if (interface_restartInc > 0) then - write(6,'(/,a,'//IO_intOut(interface_restartInc)//',a)') & - ' reading more values of increment ', interface_restartInc, ' from file' + write(6,'(/,a,i0,a)') ' reading more restart data of increment ', interface_restartInc, ' from file' call HDF5_read(groupHandle,C_volAvg, 'C_volAvg') call HDF5_read(groupHandle,C_volAvgLastInc,'C_volAvgLastInc') @@ -363,7 +361,7 @@ end subroutine grid_mech_spectral_polarisation_forward !-------------------------------------------------------------------------------------------------- !> @brief Age !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_polarisation_updateCoords() +subroutine grid_mech_spectral_polarisation_updateCoords PetscErrorCode :: ierr PetscScalar, dimension(:,:,:,:), pointer :: FandF_tau @@ -378,21 +376,21 @@ end subroutine grid_mech_spectral_polarisation_updateCoords !-------------------------------------------------------------------------------------------------- !> @brief Write current solver and constitutive data for restart to file !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_polarisation_restartWrite() +subroutine grid_mech_spectral_polarisation_restartWrite PetscErrorCode :: ierr + integer(HID_T) :: fileHandle, groupHandle PetscScalar, dimension(:,:,:,:), pointer :: FandF_tau, F, F_tau - integer(HID_T) :: fileHandle, groupHandle - character(len=32) :: rankStr + character(len=pStringLen) :: fileName call DMDAVecGetArrayF90(da,solution_vec,FandF_tau,ierr); CHKERRQ(ierr) F => FandF_tau(0: 8,:,:,:) F_tau => FandF_tau(9:17,:,:,:) - write(6,'(a)') ' writing solver data required for restart to file';flush(6) + write(6,'(a)') ' writing solver data required for restart to file'; flush(6) - write(rankStr,'(a1,i0)')'_',worldrank - fileHandle = HDF5_openFile(trim(getSolverJobName())//trim(rankStr)//'.hdf5','w') + write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' + fileHandle = HDF5_openFile(fileName,'w') groupHandle = HDF5_addGroup(fileHandle,'solver') call HDF5_write(groupHandle,F_aim, 'F_aim') diff --git a/src/grid/spectral_utilities.f90 b/src/grid/spectral_utilities.f90 index 8b0e430f3..6aba32c76 100644 --- a/src/grid/spectral_utilities.f90 +++ b/src/grid/spectral_utilities.f90 @@ -1119,7 +1119,7 @@ subroutine utilities_saveReferenceStiffness fileUnit if (worldrank == 0) then - write(6,'(a)') ' writing reference stiffness data required for restart to file';flush(6) + write(6,'(a)') ' writing reference stiffness data required for restart to file'; flush(6) fileUnit = IO_open_jobFile_binary('C_ref','w') write(fileUnit) C_ref close(fileUnit) diff --git a/src/mesh/DAMASK_FEM.f90 b/src/mesh/DAMASK_FEM.f90 index 5ebcbe217..cd0bcacb1 100644 --- a/src/mesh/DAMASK_FEM.f90 +++ b/src/mesh/DAMASK_FEM.f90 @@ -73,7 +73,7 @@ program DAMASK_FEM !-------------------------------------------------------------------------------------------------- ! init DAMASK (all modules) call CPFEM_initAll - write(6,'(/,a)') ' <<<+- DAMASK_FEM init -+>>>' + write(6,'(/,a)') ' <<<+- DAMASK_FEM init -+>>>'; flush(6) ! reading basic information from load case file and allocate data structure containing load cases call DMGetDimension(geomMesh,dimPlex,ierr); CHKERRA(ierr) !< dimension of mesh (2D or 3D) @@ -366,11 +366,9 @@ program DAMASK_FEM cutBackLevel = max(0, cutBackLevel - 1) ! try half number of subincs next inc if (all(solres(:)%converged)) then - write(6,'(/,a,'//IO_intOut(totalIncsCounter)//',a)') & ! report converged inc - ' increment ', totalIncsCounter, ' converged' + write(6,'(/,a,i0,a)') ' increment ', totalIncsCounter, ' converged' else - write(6,'(/,a,'//IO_intOut(totalIncsCounter)//',a)') & ! report non-converged inc - ' increment ', totalIncsCounter, ' NOT converged' + write(6,'(/,a,i0,a)') ' increment ', totalIncsCounter, ' NOT converged' endif; flush(6) if (mod(inc,loadCases(currentLoadCase)%outputFrequency) == 0) then ! at output frequency From fbe2228ade08ed3dce995f8ed9f35fb71cadefb2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 7 Dec 2019 20:22:55 +0100 Subject: [PATCH 5/6] avoid string length mismatch --- src/results.f90 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/results.f90 b/src/results.f90 index 93355b6c4..03277ab38 100644 --- a/src/results.f90 +++ b/src/results.f90 @@ -453,9 +453,9 @@ end subroutine results_writeScalarDataset_rotation !-------------------------------------------------------------------------------------------------- subroutine results_mapping_constituent(phaseAt,memberAt,label) - integer, dimension(:,:), intent(in) :: phaseAt !< phase section at (constituent,element) - integer, dimension(:,:,:), intent(in) :: memberAt !< phase member at (constituent,IP,element) - character(len=64), dimension(:), intent(in) :: label !< label of each phase section + integer, dimension(:,:), intent(in) :: phaseAt !< phase section at (constituent,element) + integer, dimension(:,:,:), intent(in) :: memberAt !< phase member at (constituent,IP,element) + character(len=pStringLen), dimension(:), intent(in) :: label !< label of each phase section integer, dimension(size(memberAt,1),size(memberAt,2),size(memberAt,3)) :: & phaseAt_perIP, & @@ -588,9 +588,9 @@ end subroutine results_mapping_constituent !-------------------------------------------------------------------------------------------------- subroutine results_mapping_materialpoint(homogenizationAt,memberAt,label) - integer, dimension(:), intent(in) :: homogenizationAt !< homogenization section at (element) - integer, dimension(:,:), intent(in) :: memberAt !< homogenization member at (IP,element) - character(len=64), dimension(:), intent(in) :: label !< label of each homogenization section + integer, dimension(:), intent(in) :: homogenizationAt !< homogenization section at (element) + integer, dimension(:,:), intent(in) :: memberAt !< homogenization member at (IP,element) + character(len=pStringLen), dimension(:), intent(in) :: label !< label of each homogenization section integer, dimension(size(memberAt,1),size(memberAt,2)) :: & homogenizationAt_perIP, & From c2e91ae5e1381ebaf1bfec5f65b5220eb7fb85b5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 8 Dec 2019 20:52:05 +0100 Subject: [PATCH 6/6] copy and paste error, wrong array was set --- src/CPFEM2.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index 4575b9caa..9edb61d33 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -98,14 +98,14 @@ subroutine CPFEM_init groupHandle = HDF5_openGroup(fileHandle,'constituent') do i = 1,size(phase_plasticity) write(datasetName,'(i0,a)') i,'_omega_plastic' - call HDF5_read(groupHandle,plasticState(i)%state,datasetName) + call HDF5_read(groupHandle,plasticState(i)%state0,datasetName) enddo call HDF5_closeGroup(groupHandle) groupHandle = HDF5_openGroup(fileHandle,'materialpoint') do i = 1, material_Nhomogenization write(datasetName,'(i0,a)') i,'_omega_homogenization' - call HDF5_read(groupHandle,homogState(i)%state,datasetName) + call HDF5_read(groupHandle,homogState(i)%state0,datasetName) enddo call HDF5_closeGroup(groupHandle)