From a1ab526456be14804f20159f0e638f110fde9bb6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 24 Oct 2020 14:56:03 +0200 Subject: [PATCH] avoid global variables --- src/crystallite.f90 | 6 ++--- src/damage_none.f90 | 2 +- src/grid/DAMASK_grid.f90 | 2 +- src/material.f90 | 50 +++++++++++++++++--------------------- src/thermal_adiabatic.f90 | 2 +- src/thermal_conduction.f90 | 2 +- src/thermal_isothermal.f90 | 2 +- 7 files changed, 30 insertions(+), 36 deletions(-) diff --git a/src/crystallite.f90 b/src/crystallite.f90 index 1d850abaf..b71bb37f0 100644 --- a/src/crystallite.f90 +++ b/src/crystallite.f90 @@ -1571,7 +1571,7 @@ subroutine crystallite_restartWrite call HDF5_closeGroup(groupHandle) groupHandle = HDF5_addGroup(fileHandle,'materialpoint') - do i = 1, material_Nhomogenization + do i = 1, size(material_name_homogenization) write(datasetName,'(i0,a)') i,'_omega_homogenization' call HDF5_write(groupHandle,homogState(i)%state,datasetName) enddo @@ -1612,7 +1612,7 @@ subroutine crystallite_restartRead call HDF5_closeGroup(groupHandle) groupHandle = HDF5_openGroup(fileHandle,'materialpoint') - do i = 1, material_Nhomogenization + do i = 1,size(material_name_homogenization) write(datasetName,'(i0,a)') i,'_omega_homogenization' call HDF5_read(groupHandle,homogState(i)%state0,datasetName) enddo @@ -1645,7 +1645,7 @@ subroutine crystallite_forward do j = 1,phase_Nsources(i) sourceState(i)%p(j)%state0 = sourceState(i)%p(j)%state enddo; enddo - do i = 1, material_Nhomogenization + do i = 1,size(material_name_homogenization) homogState (i)%state0 = homogState (i)%state thermalState(i)%state0 = thermalState(i)%state damageState (i)%state0 = damageState (i)%state diff --git a/src/damage_none.f90 b/src/damage_none.f90 index 4e01998bc..52100707e 100644 --- a/src/damage_none.f90 +++ b/src/damage_none.f90 @@ -20,7 +20,7 @@ subroutine damage_none_init print'(/,a)', ' <<<+- damage_none init -+>>>'; flush(6) - do h = 1, material_Nhomogenization + do h = 1, size(material_name_homogenization) if (damage_type(h) /= DAMAGE_NONE_ID) cycle NofMyHomog = count(material_homogenizationAt == h) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 4b8302def..1cb3acf16 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -210,7 +210,7 @@ program DAMASK_grid if(.not. step_discretization%contains('t')) call IO_error(error_ID=837,ext_msg = 't missing') if(.not. step_discretization%contains('N')) call IO_error(error_ID=837,ext_msg = 'N missing') loadCases(l)%time = step_discretization%get_asFloat('t') - loadCases(l)%incs = step_discretization%get_asFloat('N') + loadCases(l)%incs = step_discretization%get_asInt ('N') loadCases(l)%logscale = step_discretization%get_asBool ('log_timestep', defaultVal= .false.) loadCases(l)%outputfrequency = step_discretization%get_asInt ('f_out', defaultVal=1) loadCases(l)%restartfrequency = step_discretization%get_asInt ('f_restart', defaultVal=huge(0)) diff --git a/src/material.f90 b/src/material.f90 index f16c10362..d65adf7c7 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -63,9 +63,6 @@ module material integer(kind(HOMOGENIZATION_undefined_ID)), dimension(:), allocatable, public, protected :: & homogenization_type !< type of each homogenization - integer, public, protected :: & - material_Nhomogenization !< number of homogenizations - integer, public, protected :: & homogenization_maxNconstituent !< max number of grains in any USED homogenization @@ -83,7 +80,7 @@ module material material_homogenizationAt !< homogenization ID of each element integer, dimension(:,:), allocatable, public, target :: & ! (ip,elem) ToDo: ugly target for mapping hack material_homogenizationMemberAt !< position of the element within its homogenization instance - integer, dimension(:,:), allocatable, public, protected :: & ! (constituent,elem) + integer, dimension(:,:), allocatable, public, protected :: & ! (constituent,elem) material_phaseAt !< phase ID of each element integer, dimension(:,:,:), allocatable, public, protected :: & ! (constituent,IP,elem) material_phaseMemberAt !< position of the element within its phase instance @@ -185,17 +182,17 @@ subroutine material_init(restart) if(homogenization_maxNconstituent > size(material_phaseAt,1)) call IO_error(148) - allocate(homogState (material_Nhomogenization)) - allocate(thermalState (material_Nhomogenization)) - allocate(damageState (material_Nhomogenization)) + allocate(homogState (size(material_name_homogenization))) + allocate(thermalState (size(material_name_homogenization))) + allocate(damageState (size(material_name_homogenization))) - allocate(thermalMapping (material_Nhomogenization)) - allocate(damageMapping (material_Nhomogenization)) + allocate(thermalMapping (size(material_name_homogenization))) + allocate(damageMapping (size(material_name_homogenization))) - allocate(temperature (material_Nhomogenization)) - allocate(damage (material_Nhomogenization)) + allocate(temperature (size(material_name_homogenization))) + allocate(damage (size(material_name_homogenization))) - allocate(temperatureRate (material_Nhomogenization)) + allocate(temperatureRate (size(material_name_homogenization))) if (.not. restart) then @@ -210,7 +207,7 @@ subroutine material_init(restart) allocate(mappingHomogenizationConst( discretization_nIP,discretization_nElem),source=1) ! hack needed to initialize field values used during constitutive initialization - do myHomog = 1,material_Nhomogenization + do myHomog = 1, size(material_name_homogenization) thermalMapping (myHomog)%p => mappingHomogenizationConst damageMapping (myHomog)%p => mappingHomogenizationConst allocate(temperature (myHomog)%p(1), source=thermal_initialT(myHomog)) @@ -234,12 +231,11 @@ subroutine material_parseNconstituent integer :: h material_homogenization => config_material%get('homogenization') - material_Nhomogenization = material_homogenization%length - allocate(homogenization_Nconstituent(material_Nhomogenization)) + allocate(homogenization_Nconstituent(size(material_name_homogenization))) - do h=1, material_Nhomogenization + do h=1, size(material_name_homogenization) homog => material_homogenization%get(h) homogenization_Nconstituent(h) = homog%get_asInt('N_constituents') enddo @@ -266,19 +262,18 @@ subroutine material_parseHomogenization material_homogenization => config_material%get('homogenization') - allocate(homogenization_type(material_Nhomogenization), source=HOMOGENIZATION_undefined_ID) - allocate(thermal_type(material_Nhomogenization), source=THERMAL_isothermal_ID) - allocate(damage_type (material_Nhomogenization), source=DAMAGE_none_ID) - allocate(homogenization_typeInstance(material_Nhomogenization), source=0) - allocate(thermal_typeInstance(material_Nhomogenization), source=0) - allocate(damage_typeInstance(material_Nhomogenization), source=0) - allocate(thermal_initialT(material_Nhomogenization), source=300.0_pReal) - allocate(damage_initialPhi(material_Nhomogenization), source=1.0_pReal) + allocate(homogenization_type(size(material_name_homogenization)), source=HOMOGENIZATION_undefined_ID) + allocate(thermal_type(size(material_name_homogenization)), source=THERMAL_isothermal_ID) + allocate(damage_type (size(material_name_homogenization)), source=DAMAGE_none_ID) + allocate(homogenization_typeInstance(size(material_name_homogenization)), source=0) + allocate(thermal_typeInstance(size(material_name_homogenization)), source=0) + allocate(damage_typeInstance(size(material_name_homogenization)), source=0) + allocate(thermal_initialT(size(material_name_homogenization)), source=300.0_pReal) + allocate(damage_initialPhi(size(material_name_homogenization)), source=1.0_pReal) - do h=1, material_Nhomogenization + do h=1, size(material_name_homogenization) homog => material_homogenization%get(h) homogMech => homog%get('mech') - homogenization_Nconstituent(h) = homog%get_asInt('N_constituents') select case (homogMech%get_asString('type')) case('none') homogenization_type(h) = HOMOGENIZATION_NONE_ID @@ -324,7 +319,7 @@ subroutine material_parseHomogenization endif enddo - do h=1, material_Nhomogenization + do h=1, size(material_name_homogenization) homogenization_typeInstance(h) = count(homogenization_type(1:h) == homogenization_type(h)) thermal_typeInstance(h) = count(thermal_type (1:h) == thermal_type (h)) damage_typeInstance(h) = count(damage_type (1:h) == damage_type (h)) @@ -387,7 +382,6 @@ subroutine material_parseMaterial allocate(material_orientation0(maxNconstituents,discretization_nIP,discretization_nElem)) - do e = 1, discretization_nElem material => materials%get(discretization_materialAt(e)) constituents => material%get('constituents') diff --git a/src/thermal_adiabatic.f90 b/src/thermal_adiabatic.f90 index 00b73862a..07dbdebff 100644 --- a/src/thermal_adiabatic.f90 +++ b/src/thermal_adiabatic.f90 @@ -54,7 +54,7 @@ subroutine thermal_adiabatic_init allocate(param(maxNinstance)) material_homogenization => config_material%get('homogenization') - do h = 1, material_Nhomogenization + do h = 1, size(material_name_homogenization) if (thermal_type(h) /= THERMAL_adiabatic_ID) cycle homog => material_homogenization%get(h) homogThermal => homog%get('thermal') diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index f1f444c28..616965df0 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -53,7 +53,7 @@ subroutine thermal_conduction_init allocate(param(Ninstance)) material_homogenization => config_material%get('homogenization') - do h = 1, material_Nhomogenization + do h = 1, size(material_name_homogenization) if (thermal_type(h) /= THERMAL_conduction_ID) cycle homog => material_homogenization%get(h) homogThermal => homog%get('thermal') diff --git a/src/thermal_isothermal.f90 b/src/thermal_isothermal.f90 index 2dda358ac..703a9aaac 100644 --- a/src/thermal_isothermal.f90 +++ b/src/thermal_isothermal.f90 @@ -20,7 +20,7 @@ subroutine thermal_isothermal_init print'(/,a)', ' <<<+- thermal_isothermal init -+>>>'; flush(6) - do h = 1, material_Nhomogenization + do h = 1, size(material_name_homogenization) if (thermal_type(h) /= THERMAL_isothermal_ID) cycle NofMyHomog = count(material_homogenizationAt == h)