From db06c797cde2aa83d870fc97c0b0ddd5d038da05 Mon Sep 17 00:00:00 2001 From: Nan Jia Date: Tue, 14 Feb 2012 15:19:59 +0000 Subject: [PATCH] store number of outputs for each instance of the constitution in constitutive_[j2/titanmod/...]_Nouput and use this value to loop over all valid outputs when determining the size of the outputs array --- code/constitutive_dislotwin.f90 | 12 +++++++----- code/constitutive_j2.f90 | 11 ++++++----- code/constitutive_nonlocal.f90 | 11 ++++++----- code/constitutive_phenopowerlaw.f90 | 13 +++++++------ code/constitutive_titanmod.f90 | 16 +++++++++------- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/code/constitutive_dislotwin.f90 b/code/constitutive_dislotwin.f90 index 7264c015f..a0d459950 100644 --- a/code/constitutive_dislotwin.f90 +++ b/code/constitutive_dislotwin.f90 @@ -49,6 +49,7 @@ integer(pInt), dimension(:), allocatable :: constitutive_dislotwin constitutive_dislotwin_sizePostResults ! cumulative size of post results integer(pInt), dimension(:,:), allocatable, target :: constitutive_dislotwin_sizePostResult ! size of each post result output character(len=64), dimension(:,:), allocatable, target :: constitutive_dislotwin_output ! name of each post result output +integer(pInt), dimension(:), allocatable :: constitutive_dislotwin_Noutput ! number of outputs per instance of this constitution character(len=32), dimension(:), allocatable :: constitutive_dislotwin_structureName ! name of the lattice structure integer(pInt), dimension(:), allocatable :: constitutive_dislotwin_structure, & ! number representing the kind of lattice structure constitutive_dislotwin_totalNslip, & ! total number of active slip systems for each instance @@ -145,7 +146,7 @@ integer(pInt), intent(in) :: file !* Local variables integer(pInt), parameter :: maxNchunks = 21 integer(pInt), dimension(1+2*maxNchunks) :: positions -integer(pInt) section,maxNinstance,f,i,j,k,l,m,n,o,p,q,r,s,s1,s2,t1,t2,ns,nt,output,mySize,myStructure,maxTotalNslip,maxTotalNtwin +integer(pInt) section,maxNinstance,f,i,j,k,l,m,n,o,p,q,r,s,s1,s2,t1,t2,ns,nt,mySize,myStructure,maxTotalNslip,maxTotalNtwin character(len=64) tag character(len=1024) line @@ -165,11 +166,13 @@ allocate(constitutive_dislotwin_sizeState(maxNinstance)) allocate(constitutive_dislotwin_sizePostResults(maxNinstance)) allocate(constitutive_dislotwin_sizePostResult(maxval(phase_Noutput),maxNinstance)) allocate(constitutive_dislotwin_output(maxval(phase_Noutput),maxNinstance)) +allocate(constitutive_dislotwin_Noutput(maxNinstance)) constitutive_dislotwin_sizeDotState = 0_pInt constitutive_dislotwin_sizeState = 0_pInt constitutive_dislotwin_sizePostResults = 0_pInt constitutive_dislotwin_sizePostResult = 0_pInt constitutive_dislotwin_output = '' +constitutive_dislotwin_Noutput = 0_pInt allocate(constitutive_dislotwin_structureName(maxNinstance)) allocate(constitutive_dislotwin_structure(maxNinstance)) @@ -289,7 +292,6 @@ do ! read thru sections of if (IO_getTag(line,'<','>') /= '') exit ! stop at next part if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt ! advance section counter - output = 0_pInt ! reset output counter cycle endif if (section > 0_pInt .and. phase_constitution(section) == constitutive_dislotwin_label) then ! one of my sections @@ -300,8 +302,8 @@ do ! read thru sections of case ('constitution') cycle case ('(output)') - output = output + 1_pInt - constitutive_dislotwin_output(output,i) = IO_lc(IO_stringValue(line,positions,2_pInt)) + constitutive_dislotwin_Noutput(i) = constitutive_dislotwin_Noutput(i) + 1_pInt + constitutive_dislotwin_output(constitutive_dislotwin_Noutput(i),i) = IO_lc(IO_stringValue(line,positions,2_pInt)) case ('lattice_structure') constitutive_dislotwin_structureName(i) = IO_lc(IO_stringValue(line,positions,2_pInt)) case ('covera_ratio') @@ -509,7 +511,7 @@ do i = 1_pInt,maxNinstance size(constitutive_dislotwin_listDependentSlipStates)*ns+size(constitutive_dislotwin_listDependentTwinStates)*nt !* Determine size of postResults array - do o = 1_pInt,maxval(phase_Noutput) + do o = 1_pInt,constitutive_dislotwin_Noutput(i) select case(constitutive_dislotwin_output(o,i)) case('edge_density', & 'dipole_density', & diff --git a/code/constitutive_j2.f90 b/code/constitutive_j2.f90 index bff742166..a6dd53d83 100644 --- a/code/constitutive_j2.f90 +++ b/code/constitutive_j2.f90 @@ -53,6 +53,7 @@ MODULE constitutive_j2 constitutive_j2_sizePostResults integer(pInt), dimension(:,:), allocatable,target :: constitutive_j2_sizePostResult ! size of each post result output character(len=64), dimension(:,:), allocatable,target :: constitutive_j2_output ! name of each post result output + integer(pInt), dimension(:), allocatable :: constitutive_j2_Noutput real(pReal), dimension(:), allocatable :: constitutive_j2_C11 real(pReal), dimension(:), allocatable :: constitutive_j2_C12 real(pReal), dimension(:,:,:), allocatable :: constitutive_j2_Cslip_66 @@ -91,7 +92,7 @@ subroutine constitutive_j2_init(file) integer(pInt), intent(in) :: file integer(pInt), parameter :: maxNchunks = 7 integer(pInt), dimension(1+2*maxNchunks) :: positions - integer(pInt) section, maxNinstance, i,j,k, output, mySize + integer(pInt) section, maxNinstance, i,j,k, mySize character(len=64) tag character(len=1024) line @@ -117,6 +118,7 @@ subroutine constitutive_j2_init(file) allocate(constitutive_j2_sizePostResults(maxNinstance)); constitutive_j2_sizePostResults = 0_pInt allocate(constitutive_j2_sizePostResult(maxval(phase_Noutput), maxNinstance)); constitutive_j2_sizePostResult = 0_pInt allocate(constitutive_j2_output(maxval(phase_Noutput), maxNinstance)) ; constitutive_j2_output = '' + allocate(constitutive_j2_Noutput(maxNinstance)) ; constitutive_j2_Noutput = 0_pInt allocate(constitutive_j2_C11(maxNinstance)) ; constitutive_j2_C11 = 0.0_pReal allocate(constitutive_j2_C12(maxNinstance)) ; constitutive_j2_C12 = 0.0_pReal allocate(constitutive_j2_Cslip_66(6,6,maxNinstance)) ; constitutive_j2_Cslip_66 = 0.0_pReal @@ -143,7 +145,6 @@ subroutine constitutive_j2_init(file) if (IO_getTag(line,'<','>') /= '') exit ! stop at next part if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt ! advance section counter - output = 0_pInt ! reset output counter cycle endif if (section > 0_pInt .and. phase_constitution(section) == constitutive_j2_label) then ! one of my sections @@ -154,8 +155,8 @@ subroutine constitutive_j2_init(file) case ('constitution') cycle case ('(output)') - output = output + 1 - constitutive_j2_output(output,i) = IO_lc(IO_stringValue(line,positions,2)) + constitutive_j2_Noutput(i) = constitutive_j2_Noutput(i) + 1_pInt + constitutive_j2_output(constitutive_j2_Noutput(i),i) = IO_lc(IO_stringValue(line,positions,2)) case ('c11') constitutive_j2_C11(i) = IO_floatValue(line,positions,2) case ('c12') @@ -193,7 +194,7 @@ subroutine constitutive_j2_init(file) enddo do i = 1,maxNinstance - do j = 1,maxval(phase_Noutput) + do j = 1,constitutive_j2_Noutput(i) select case(constitutive_j2_output(j,i)) case('flowstress') mySize = 1_pInt diff --git a/code/constitutive_nonlocal.f90 b/code/constitutive_nonlocal.f90 index d5b55388f..770777b89 100644 --- a/code/constitutive_nonlocal.f90 +++ b/code/constitutive_nonlocal.f90 @@ -62,6 +62,7 @@ integer(pInt), dimension(:), allocatable :: constitutive_nonlocal_ constitutive_nonlocal_sizePostResults ! cumulative size of post results integer(pInt), dimension(:,:), allocatable, target :: constitutive_nonlocal_sizePostResult ! size of each post result output character(len=64), dimension(:,:), allocatable, target :: constitutive_nonlocal_output ! name of each post result output +integer(pInt), dimension(:), allocatable :: constitutive_nonlocal_Noutput ! number of outputs per instance of this constitution character(len=32), dimension(:), allocatable :: constitutive_nonlocal_structureName ! name of the lattice structure integer(pInt), dimension(:), allocatable :: constitutive_nonlocal_structure, & ! number representing the kind of lattice structure @@ -199,7 +200,6 @@ integer(pInt) section, & s1, & ! index of my slip system s2, & ! index of my slip system it, & ! index of my interaction type - output, & mySize character(len=64) tag character(len=1024) line @@ -230,12 +230,14 @@ allocate(constitutive_nonlocal_sizeState(maxNinstance)) allocate(constitutive_nonlocal_sizePostResults(maxNinstance)) allocate(constitutive_nonlocal_sizePostResult(maxval(phase_Noutput), maxNinstance)) allocate(constitutive_nonlocal_output(maxval(phase_Noutput), maxNinstance)) +allocate(constitutive_nonlocal_Noutput(maxNinstance)) constitutive_nonlocal_sizeDotState = 0_pInt constitutive_nonlocal_sizeDependentState = 0_pInt constitutive_nonlocal_sizeState = 0_pInt constitutive_nonlocal_sizePostResults = 0_pInt constitutive_nonlocal_sizePostResult = 0_pInt constitutive_nonlocal_output = '' +constitutive_nonlocal_Noutput = 0_pInt allocate(constitutive_nonlocal_structureName(maxNinstance)) allocate(constitutive_nonlocal_structure(maxNinstance)) @@ -341,7 +343,6 @@ do if (IO_getTag(line,'<','>') /= '') exit ! stop at next part if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt ! advance section counter - output = 0_pInt ! reset output counter cycle endif if (section > 0_pInt .and. phase_constitution(section) == constitutive_nonlocal_label) then ! one of my sections @@ -352,8 +353,8 @@ do case('constitution','/nonlocal/') cycle case ('(output)') - output = output + 1_pInt - constitutive_nonlocal_output(output,i) = IO_lc(IO_stringValue(line,positions,2_pInt)) + constitutive_nonlocal_Noutput(i) = constitutive_nonlocal_Noutput(i) + 1_pInt + constitutive_nonlocal_output(constitutive_nonlocal_Noutput(i),i) = IO_lc(IO_stringValue(line,positions,2_pInt)) case ('lattice_structure') constitutive_nonlocal_structureName(i) = IO_lc(IO_stringValue(line,positions,2_pInt)) case ('c/a_ratio','covera_ratio') @@ -573,7 +574,7 @@ do i = 1,maxNinstance !*** determine size of postResults array - do o = 1,maxval(phase_Noutput) + do o = 1,constitutive_nonlocal_Noutput(i) select case(constitutive_nonlocal_output(o,i)) case( 'rho', & 'delta', & diff --git a/code/constitutive_phenopowerlaw.f90 b/code/constitutive_phenopowerlaw.f90 index f6803f3a3..8b8c7af86 100644 --- a/code/constitutive_phenopowerlaw.f90 +++ b/code/constitutive_phenopowerlaw.f90 @@ -83,7 +83,8 @@ MODULE constitutive_phenopowerlaw constitutive_phenopowerlaw_sizePostResults ! cumulative size of post results integer(pInt), dimension(:,:), allocatable,target :: constitutive_phenopowerlaw_sizePostResult ! size of each post result output character(len=64), dimension(:,:), allocatable,target :: constitutive_phenopowerlaw_output ! name of each post result output - + integer(pInt), dimension(:), allocatable :: constitutive_phenopowerlaw_Noutput ! number of outputs per instance of this constitution + character(len=32), dimension(:), allocatable :: constitutive_phenopowerlaw_structureName integer(pInt), dimension(:), allocatable :: constitutive_phenopowerlaw_structure integer(pInt), dimension(:,:), allocatable :: constitutive_phenopowerlaw_Nslip ! active number of slip systems per family @@ -165,7 +166,7 @@ subroutine constitutive_phenopowerlaw_init(file) integer(pInt), intent(in) :: file integer(pInt), parameter :: maxNchunks = lattice_maxNinteraction + 1_pInt integer(pInt), dimension(1+2*maxNchunks) :: positions - integer(pInt) section, maxNinstance, i,j,k, f,o, output, & + integer(pInt) section, maxNinstance, i,j,k, f,o, & mySize, myStructure, index_myFamily, index_otherFamily character(len=64) tag character(len=1024) line @@ -193,6 +194,7 @@ subroutine constitutive_phenopowerlaw_init(file) maxNinstance)) ; constitutive_phenopowerlaw_sizePostResult = 0_pInt allocate(constitutive_phenopowerlaw_output(maxval(phase_Noutput), & maxNinstance)) ; constitutive_phenopowerlaw_output = '' + allocate(constitutive_phenopowerlaw_Noutput(maxNinstance)) ; constitutive_phenopowerlaw_Noutput = 0_pInt allocate(constitutive_phenopowerlaw_structureName(maxNinstance)) ; constitutive_phenopowerlaw_structureName = '' allocate(constitutive_phenopowerlaw_structure(maxNinstance)) ; constitutive_phenopowerlaw_structure = 0_pInt @@ -264,7 +266,6 @@ subroutine constitutive_phenopowerlaw_init(file) if (IO_getTag(line,'<','>') /= '') exit ! stop at next part if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt ! advance section counter - output = 0_pInt ! reset output counter cycle ! skip to next line endif if (section > 0_pInt .and. phase_constitution(section) == constitutive_phenopowerlaw_label) then ! one of my sections @@ -275,8 +276,8 @@ subroutine constitutive_phenopowerlaw_init(file) case ('constitution') cycle case ('(output)') - output = output + 1_pInt - constitutive_phenopowerlaw_output(output,i) = IO_lc(IO_stringValue(line,positions,2_pInt)) + constitutive_phenopowerlaw_Noutput(i) = constitutive_phenopowerlaw_Noutput(i) + 1_pInt + constitutive_phenopowerlaw_output(constitutive_phenopowerlaw_Noutput(i),i) = IO_lc(IO_stringValue(line,positions,2_pInt)) case ('lattice_structure') constitutive_phenopowerlaw_structureName(i) = IO_lc(IO_stringValue(line,positions,2_pInt)) case ('covera_ratio') @@ -406,7 +407,7 @@ subroutine constitutive_phenopowerlaw_init(file) do i = 1_pInt,maxNinstance - do j = 1_pInt,maxval(phase_Noutput) + do j = 1_pInt,constitutive_phenopowerlaw_Noutput(i) select case(constitutive_phenopowerlaw_output(j,i)) case('resistance_slip', & 'shearrate_slip', & diff --git a/code/constitutive_titanmod.f90 b/code/constitutive_titanmod.f90 index 4f9ef2fdc..2e9e49c46 100644 --- a/code/constitutive_titanmod.f90 +++ b/code/constitutive_titanmod.f90 @@ -81,7 +81,8 @@ integer(pInt), dimension(:), allocatable :: constitutive_titanmod_ constitutive_titanmod_sizeState, & ! total number of microstructural state variables constitutive_titanmod_sizePostResults ! cumulative size of post results integer(pInt), dimension(:,:), allocatable, target :: constitutive_titanmod_sizePostResult ! size of each post result output -character(len=64), dimension(:,:), allocatable, target :: constitutive_titanmod_output ! name of each post result output +character(len=64), dimension(:,:), allocatable, target :: constitutive_titanmod_output ! name of each post result output +integer(pInt), dimension(:), allocatable :: constitutive_titanmod_Noutput ! number of outputs per instance of this constitution character(len=32), dimension(:), allocatable :: constitutive_titanmod_structureName ! name of the lattice structure integer(pInt), dimension(:), allocatable :: constitutive_titanmod_structure, & ! number representing the kind of lattice structure constitutive_titanmod_totalNslip, & ! total number of active slip systems for each instance @@ -214,7 +215,7 @@ integer(pInt), intent(in) :: file !* Local variables integer(pInt), parameter :: maxNchunks = 21 integer(pInt), dimension(1+2*maxNchunks) :: positions -integer(pInt) section,maxNinstance,f,i,j,k,l,m,n,o,p,q,r,s,s1,s2,t,t1,t2,ns,nt,output,mySize,myStructure,maxTotalNslip, & +integer(pInt) section,maxNinstance,f,i,j,k,l,m,n,o,p,q,r,s,s1,s2,t,t1,t2,ns,nt,mySize,myStructure,maxTotalNslip, & maxTotalNtwin character(len=64) tag character(len=1024) line @@ -233,11 +234,13 @@ allocate(constitutive_titanmod_sizeState(maxNinstance)) allocate(constitutive_titanmod_sizePostResults(maxNinstance)) allocate(constitutive_titanmod_sizePostResult(maxval(phase_Noutput),maxNinstance)) allocate(constitutive_titanmod_output(maxval(phase_Noutput),maxNinstance)) +allocate(constitutive_titanmod_Noutput(maxNinstance)) constitutive_titanmod_sizeDotState = 0_pInt constitutive_titanmod_sizeState = 0_pInt constitutive_titanmod_sizePostResults = 0_pInt constitutive_titanmod_sizePostResult = 0_pInt constitutive_titanmod_output = '' +constitutive_titanmod_Noutput = 0_pInt allocate(constitutive_titanmod_structureName(maxNinstance)) allocate(constitutive_titanmod_structure(maxNinstance)) @@ -391,7 +394,6 @@ enddo if (IO_getTag(line,'<','>') /= '') exit ! stop at next part if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt ! advance section counter - output = 0_pInt ! reset output counter cycle ! skip to next line endif if (section > 0_pInt .and. phase_constitution(section) == constitutive_titanmod_label) then ! one of my sections @@ -402,9 +404,9 @@ enddo case ('constitution') cycle case ('(output)') - output = output + 1_pInt - constitutive_titanmod_output(output,i) = IO_lc(IO_stringValue(line,positions,2_pInt)) - write(6,*) tag,constitutive_titanmod_output(output,i) + constitutive_titanmod_Noutput(i) = constitutive_titanmod_Noutput(i) + 1_pInt + constitutive_titanmod_output(constitutive_titanmod_Noutput(i),i) = IO_lc(IO_stringValue(line,positions,2_pInt)) + write(6,*) tag,constitutive_titanmod_output(constitutive_titanmod_Noutput(i),i) case ('lattice_structure') constitutive_titanmod_structureName(i) = IO_lc(IO_stringValue(line,positions,2_pInt)) write(6,*) tag,constitutive_titanmod_structureName(i) @@ -763,7 +765,7 @@ do i = 1_pInt,maxNinstance write(6,*) 'Determined size of state and dot state' !* Determine size of postResults array - do o = 1,maxval(phase_Noutput) + do o = 1,constitutive_titanmod_Noutput(i) select case(constitutive_titanmod_output(o,i)) case('rhoedge', & 'rhoscrew', &