using sourced allocation

This commit is contained in:
Martin Diehl 2013-12-12 23:03:37 +00:00
parent 37046cd2ea
commit acad3d4a33
1 changed files with 62 additions and 68 deletions

View File

@ -307,11 +307,11 @@ subroutine material_parseHomogenization(fileUnit,myPart)
if (Nsections < 1_pInt) call IO_error(160_pInt,ext_msg=myPart)
allocate(homogenization_name(Nsections)); homogenization_name = ''
allocate(homogenization_type(Nsections)); homogenization_type = -1
allocate(homogenization_typeInstance(Nsections)); homogenization_typeInstance = 0_pInt
allocate(homogenization_Ngrains(Nsections)); homogenization_Ngrains = 0_pInt
allocate(homogenization_Noutput(Nsections)); homogenization_Noutput = 0_pInt
allocate(homogenization_active(Nsections)); homogenization_active = .false.
allocate(homogenization_type(Nsections), source=HOMOGENIZATION_undefined_ID)
allocate(homogenization_typeInstance(Nsections), source=0_pInt)
allocate(homogenization_Ngrains(Nsections), source=0_pInt)
allocate(homogenization_Noutput(Nsections), source=0_pInt)
allocate(homogenization_active(Nsections), source=.false.)
forall (s = 1_pInt:Nsections) homogenization_active(s) = any(mesh_element(3,:) == s) ! current homogenization used in model? Homogenization view, maximum operations depend on maximum number of homog schemes
homogenization_Noutput = IO_countTagInPart(fileUnit,myPart,'(output)',Nsections)
@ -324,7 +324,6 @@ subroutine material_parseHomogenization(fileUnit,myPart)
enddo
if (echo) write(6,'(/,1x,a)') trim(line) ! echo part header
do while (trim(line) /= IO_EOF) ! read through sections of material part
line = IO_read(fileUnit)
if (IO_isBlank(line)) cycle ! skip empty lines
@ -391,10 +390,10 @@ subroutine material_parseMicrostructure(fileUnit,myPart)
if (Nsections < 1_pInt) call IO_error(160_pInt,ext_msg=myPart)
allocate(microstructure_name(Nsections)); microstructure_name = ''
allocate(microstructure_crystallite(Nsections)); microstructure_crystallite = 0_pInt
allocate(microstructure_Nconstituents(Nsections))
allocate(microstructure_active(Nsections))
allocate(microstructure_elemhomo(Nsections))
allocate(microstructure_crystallite(Nsections), source=0_pInt)
allocate(microstructure_Nconstituents(Nsections), source=0_pInt)
allocate(microstructure_active(Nsections), source=.false.)
allocate(microstructure_elemhomo(Nsections), source=.false.)
forall (e = 1_pInt:mesh_NcpElems) microstructure_active(mesh_element(4,e)) = .true. ! current microstructure used in model? Elementwise view, maximum N operations for N elements
@ -402,12 +401,9 @@ subroutine material_parseMicrostructure(fileUnit,myPart)
microstructure_maxNconstituents = maxval(microstructure_Nconstituents)
microstructure_elemhomo = IO_spotTagInPart(fileUnit,myPart,'/elementhomogeneous/',Nsections)
allocate(microstructure_phase (microstructure_maxNconstituents,Nsections))
microstructure_phase = 0_pInt
allocate(microstructure_texture (microstructure_maxNconstituents,Nsections))
microstructure_texture = 0_pInt
allocate(microstructure_fraction(microstructure_maxNconstituents,Nsections))
microstructure_fraction = 0.0_pReal
allocate(microstructure_phase (microstructure_maxNconstituents,Nsections),source=0_pInt)
allocate(microstructure_texture (microstructure_maxNconstituents,Nsections),source=0_pInt)
allocate(microstructure_fraction(microstructure_maxNconstituents,Nsections),source=0.0_pReal)
rewind(fileUnit)
line = '' ! to have it initialized
@ -487,8 +483,8 @@ subroutine material_parseCrystallite(fileUnit,myPart)
material_Ncrystallite = Nsections
if (Nsections < 1_pInt) call IO_error(160_pInt,ext_msg=myPart)
allocate(crystallite_name(Nsections)); crystallite_name = ''
allocate(crystallite_Noutput(Nsections)); crystallite_Noutput = 0_pInt
allocate(crystallite_name(Nsections)); crystallite_name=''
allocate(crystallite_Noutput(Nsections), source=0_pInt)
crystallite_Noutput = IO_countTagInPart(fileUnit,myPart,'(output)',Nsections)
@ -554,12 +550,12 @@ subroutine material_parsePhase(fileUnit,myPart)
if (Nsections < 1_pInt) call IO_error(160_pInt,ext_msg=myPart)
allocate(phase_name(Nsections)); phase_name = ''
allocate(phase_elasticity(Nsections)); phase_elasticity = -1
allocate(phase_elasticityInstance(Nsections)); phase_elasticityInstance = 0_pInt
allocate(phase_plasticity(Nsections)); phase_plasticity = -1
allocate(phase_plasticityInstance(Nsections)); phase_plasticityInstance = 0_pInt
allocate(phase_Noutput(Nsections)); phase_Noutput = 0_pInt
allocate(phase_localPlasticity(Nsections)); phase_localPlasticity = .false.
allocate(phase_elasticity(Nsections), source=ELASTICITY_undefined_ID)
allocate(phase_elasticityInstance(Nsections), source=0_pInt)
allocate(phase_plasticity(Nsections) , source=PLASTICITY_undefined_ID)
allocate(phase_plasticityInstance(Nsections), source=0_pInt)
allocate(phase_Noutput(Nsections), source=0_pInt)
allocate(phase_localPlasticity(Nsections), source=.false.)
phase_Noutput = IO_countTagInPart(fileUnit,myPart,'(output)',Nsections)
phase_localPlasticity = .not. IO_spotTagInPart(fileUnit,myPart,'/nonlocal/',Nsections)
@ -663,23 +659,21 @@ subroutine material_parseTexture(fileUnit,myPart)
material_Ntexture = Nsections
if (Nsections < 1_pInt) call IO_error(160_pInt,ext_msg=myPart)
allocate(texture_name(Nsections)); texture_name = ''
allocate(texture_ODFfile(Nsections)); texture_ODFfile = ''
allocate(texture_symmetry(Nsections)); texture_symmetry = 1_pInt
allocate(texture_Ngauss(Nsections)); texture_Ngauss = 0_pInt
allocate(texture_Nfiber(Nsections)); texture_Nfiber = 0_pInt
allocate(texture_name(Nsections)); texture_name=''
allocate(texture_ODFfile(Nsections)); texture_ODFfile=''
allocate(texture_symmetry(Nsections), source=0_pInt)
allocate(texture_Ngauss(Nsections), source=0_pInt)
allocate(texture_Nfiber(Nsections), source=0_pInt)
texture_Ngauss = IO_countTagInPart(fileUnit,myPart,'(gauss)', Nsections) + &
IO_countTagInPart(fileUnit,myPart,'(random)',Nsections)
texture_Nfiber = IO_countTagInPart(fileUnit,myPart,'(fiber)', Nsections)
texture_maxNgauss = maxval(texture_Ngauss)
texture_maxNfiber = maxval(texture_Nfiber)
allocate(texture_Gauss (5,texture_maxNgauss,Nsections)); texture_Gauss = 0.0_pReal
allocate(texture_Fiber (6,texture_maxNfiber,Nsections)); texture_Fiber = 0.0_pReal
allocate(texture_transformation(3,3,Nsections));
do j = 1_pInt, Nsections
texture_transformation(1:3,1:3,j) = math_I3
enddo
allocate(texture_Gauss (5,texture_maxNgauss,Nsections), source=0.0_pReal)
allocate(texture_Fiber (6,texture_maxNfiber,Nsections), source=0.0_pReal)
allocate(texture_transformation(3,3,Nsections), source=0.0_pReal)
texture_transformation = spread(math_I3,3,Nsections)
rewind(fileUnit)
line = '' ! to have in initialized
@ -857,13 +851,13 @@ subroutine material_populateGrains
myDebug = debug_level(debug_material)
allocate(material_volume(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; material_volume = 0.0_pReal
allocate(material_phase(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; material_phase = 0_pInt
allocate(material_texture(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; material_texture = 0_pInt
allocate(material_EulerAngles(3,homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; material_EulerAngles = 0.0_pReal
allocate(material_volume(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems), source=0.0_pReal)
allocate(material_phase(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems), source=0_pInt)
allocate(material_texture(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems), source=0_pInt)
allocate(material_EulerAngles(3,homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems),source=0.0_pReal)
allocate(Ngrains(material_Nhomogenization,material_Nmicrostructure)); Ngrains = 0_pInt
allocate(Nelems(material_Nhomogenization,material_Nmicrostructure)); Nelems = 0_pInt
allocate(Ngrains(material_Nhomogenization,material_Nmicrostructure), source=0_pInt)
allocate(Nelems(material_Nhomogenization,material_Nmicrostructure), source=0_pInt)
!--------------------------------------------------------------------------------------------------
! precounting of elements for each homog/micro pair
@ -903,10 +897,10 @@ subroutine material_populateGrains
elemsOfHomogMicro(homog,micro)%p(Nelems(homog,micro)) = e ! remember elements active in this homog/micro pair
enddo elementLooping
allocate(volumeOfGrain(maxval(Ngrains))) ! reserve memory for maximum case
allocate(phaseOfGrain(maxval(Ngrains))) ! reserve memory for maximum case
allocate(textureOfGrain(maxval(Ngrains))) ! reserve memory for maximum case
allocate(orientationOfGrain(3,maxval(Ngrains))) ! reserve memory for maximum case
allocate(volumeOfGrain(maxval(Ngrains)), source=0.0_pReal) ! reserve memory for maximum case
allocate(phaseOfGrain(maxval(Ngrains)), source=0_pInt) ! reserve memory for maximum case
allocate(textureOfGrain(maxval(Ngrains)), source=0_pInt) ! reserve memory for maximum case
allocate(orientationOfGrain(3,maxval(Ngrains)),source=0.0_pReal) ! reserve memory for maximum case
if (iand(myDebug,debug_levelBasic) /= 0_pInt) then
!$OMP CRITICAL (write2out)