fixed bug in initialization when reading in material.config.

Fortran does not short-circuit, e.g. (if a>0 .and. b(a) ==c) might cause an out-of-bounds error when a=-1 it'll try to access b(-1)!
This commit is contained in:
Martin Diehl 2013-06-11 20:16:40 +00:00
parent 6f7740a243
commit 296a5040b9
6 changed files with 715 additions and 711 deletions

View File

@ -156,7 +156,7 @@ integer(pInt), intent(in) :: file
integer(pInt), parameter :: maxNchunks = 21_pInt
integer(pInt), dimension(1+2*maxNchunks) :: positions
integer(pInt), dimension(6) :: configNchunks
integer(pInt) :: section, maxNinstance,mySize=0_pInt,myStructure,maxTotalNslip,maxTotalNtwin,&
integer(pInt) :: section = 0_pInt, maxNinstance,mySize=0_pInt,myStructure,maxTotalNslip,maxTotalNtwin,&
f,i,j,k,l,m,n,o,p,q,r,s,ns,nt, &
Nchunks_SlipSlip, Nchunks_SlipTwin, Nchunks_TwinSlip, Nchunks_TwinTwin, &
Nchunks_SlipFamilies, Nchunks_TwinFamilies, &
@ -289,8 +289,6 @@ allocate(constitutive_dislotwin_sbSv(6,6,homogenization_maxNgrains,mesh_maxNips,
!* Readout data from material.config file
rewind(file)
line = ''
section = 0_pInt
do while (IO_lc(IO_getTag(line,'<','>')) /= 'phase') ! wind forward to <phase>
read(file,'(a1024)',END=100) line
@ -304,7 +302,8 @@ do ! read thru sections of
section = section + 1_pInt ! advance section counter
cycle
endif
if (section > 0_pInt .and. phase_plasticity(section) == constitutive_dislotwin_label) then ! one of my sections
if (section > 0_pInt ) then ! do not short-circuit here (.and. with next if statemen). It's not safe in Fortran
if (phase_plasticity(section) == constitutive_dislotwin_LABEL) then ! one of my sections
i = phase_plasticityInstance(section) ! which instance of my plasticity is present phase
positions = IO_stringPos(line,maxNchunks)
tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key
@ -447,6 +446,7 @@ do ! read thru sections of
call IO_error(210_pInt,ext_msg=tag//' ('//constitutive_dislotwin_label//')')
end select
endif
endif
enddo
100 do i = 1_pInt,maxNinstance

View File

@ -204,7 +204,8 @@ subroutine constitutive_j2_init(myFile)
section = section + 1_pInt ! advance section counter
cycle
endif
if (section > 0_pInt .and. phase_plasticity(section) == constitutive_j2_label) then ! one of my sections
if (section > 0_pInt ) then ! do not short-circuit here (.and. with next if statemen). It's not safe in Fortran
if (phase_plasticity(section) == constitutive_j2_LABEL) then ! one of my sections
i = phase_plasticityInstance(section) ! which instance of my plasticity is present phase
positions = IO_stringPos(line,maxNchunks)
tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key
@ -264,6 +265,7 @@ subroutine constitutive_j2_init(myFile)
call IO_error(210_pInt,ext_msg=tag//' ('//constitutive_j2_label//')')
end select
endif
endif
enddo
100 do i = 1_pInt,maxNinstance ! sanity checks

View File

@ -130,7 +130,8 @@ subroutine constitutive_none_init(myFile)
section = section + 1_pInt ! advance section counter
cycle
endif
if (section > 0_pInt .and. phase_plasticity(section) == constitutive_none_label) then ! one of my sections
if (section > 0_pInt ) then ! do not short-circuit here (.and. with next if statemen). It's not safe in Fortran
if ( phase_plasticity(section) == constitutive_none_LABEL) then ! one of my sections
i = phase_plasticityInstance(section) ! which instance of my plasticity is present phase
positions = IO_stringPos(line,MAXNCHUNKS)
tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key
@ -161,6 +162,7 @@ subroutine constitutive_none_init(myFile)
call IO_error(210_pInt,ext_msg=tag//' ('//constitutive_none_label//')')
end select
endif
endif
enddo
100 do i = 1_pInt,maxNinstance

View File

@ -258,7 +258,7 @@ integer(pInt), parameter :: maxNchunks = 21_pInt
integer(pInt), &
dimension(1_pInt+2_pInt*maxNchunks) :: positions
integer(pInt), dimension(6) :: configNchunks
integer(pInt) :: section, &
integer(pInt) :: section = 0_pInt, &
maxNinstance, &
maxTotalNslip, &
myStructure, &
@ -420,9 +420,6 @@ nonSchmidCoeff = 0.0_pReal
!*** readout data from material.config file
rewind(myFile)
line = ''
section = 0_pInt
do while (IO_lc(IO_getTag(line,'<','>')) /= 'phase') ! wind forward to <phase>
read(myFile,'(a1024)',END=100) line
enddo
@ -435,7 +432,8 @@ do
section = section + 1_pInt ! advance section counter
cycle
endif
if (section > 0_pInt .and. phase_plasticity(section) == CONSTITUTIVE_NONLOCAL_LABEL) then ! one of my sections
if (section > 0_pInt ) then ! do not short-circuit here (.and. with next if statemen). It's not safe in Fortran
if (phase_plasticity(section) == CONSTITUTIVE_NONLOCAL_LABEL) then ! one of my sections
i = phase_plasticityInstance(section) ! which instance of my plasticity is present phase
positions = IO_stringPos(line,maxNchunks)
tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key
@ -590,6 +588,7 @@ do
call IO_error(210_pInt,ext_msg=tag//' ('//CONSTITUTIVE_NONLOCAL_LABEL//')')
end select
endif
endif
enddo

View File

@ -132,7 +132,7 @@ subroutine constitutive_phenopowerlaw_init(myFile)
integer(pInt), parameter :: MAXNCHUNKS = lattice_maxNinteraction + 1_pInt
integer(pInt), dimension(1+2*MAXNCHUNKS) :: positions
integer(pInt), dimension(6) :: configNchunks
integer(pInt) :: section, maxNinstance, i,j,k, f,o, &
integer(pInt) :: section = 0_pInt, maxNinstance, i,j,k, f,o, &
Nchunks_SlipSlip, Nchunks_SlipTwin, Nchunks_TwinSlip, Nchunks_TwinTwin, &
Nchunks_SlipFamilies, Nchunks_TwinFamilies, &
mySize=0_pInt, myStructure, index_myFamily, index_otherFamily
@ -239,7 +239,6 @@ subroutine constitutive_phenopowerlaw_init(myFile)
constitutive_phenopowerlaw_nonSchmidCoeff = 0.0_pReal
rewind(myFile)
section = 0_pInt
do while (IO_lc(IO_getTag(line,'<','>')) /= 'phase') ! wind forward to <phase>
read(myFile,'(a1024)',END=100) line
@ -253,7 +252,8 @@ subroutine constitutive_phenopowerlaw_init(myFile)
section = section + 1_pInt ! advance section counter
cycle ! skip to next line
endif
if (section > 0_pInt .and. phase_plasticity(section) == constitutive_phenopowerlaw_label) then ! one of my sections
if (section > 0_pInt ) then ! do not short-circuit here (.and. with next if statemen). It's not safe in Fortran
if (phase_plasticity(section) == constitutive_phenopowerlaw_LABEL) then ! one of my sections
i = phase_plasticityInstance(section) ! which instance of my plasticity is present phase
positions = IO_stringPos(line,MAXNCHUNKS)
tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key
@ -372,6 +372,7 @@ subroutine constitutive_phenopowerlaw_init(myFile)
call IO_error(210_pInt,ext_msg=tag//' ('//constitutive_phenopowerlaw_label//')')
end select
endif
endif
enddo
100 do i = 1_pInt,maxNinstance

View File

@ -247,7 +247,7 @@ integer(pInt), intent(in) :: file
integer(pInt), parameter :: maxNchunks = 21_pInt
integer(pInt), dimension(1_pInt+2_pInt*maxNchunks) :: positions
integer(pInt), dimension(6) :: configNchunks
integer(pInt) :: section,f,i,j,k,l,m,n,o,p,q,r,s,s1,s2,t,t1,t2,ns,nt,&
integer(pInt) :: section = 0_pInt,f,i,j,k,l,m,n,o,p,q,r,s,s1,s2,t,t1,t2,ns,nt,&
Nchunks_SlipSlip, Nchunks_SlipTwin, Nchunks_TwinSlip, Nchunks_TwinTwin, &
Nchunks_SlipFamilies, Nchunks_TwinFamilies, &
mySize,myStructure,maxTotalNslip,maxTotalNtwin
@ -414,8 +414,6 @@ allocate(constitutive_titanmod_interactionTwinTwin(lattice_maxNinteraction,maxNi
!* Read data from material.config file
rewind(file)
line = ''
section = 0_pInt
do while (IO_lc(IO_getTag(line,'<','>')) /= 'phase') ! wind forward to <phase>
read(file,'(a1024)',END=100) line
@ -429,7 +427,8 @@ enddo
section = section + 1_pInt ! advance section counter
cycle ! skip to next line
endif
if (section > 0_pInt .and. phase_plasticity(section) == constitutive_titanmod_label) then ! one of my sections
if (section > 0_pInt ) then ! do not short-circuit here (.and. with next if statemen). It's not safe in Fortran
if (phase_plasticity(section) == constitutive_titanmod_LABEL) then ! one of my sections
i = phase_plasticityInstance(section) ! which instance of my plasticity is present phase
positions = IO_stringPos(line,maxNchunks)
tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key
@ -626,6 +625,7 @@ enddo
call IO_error(210_pInt,ext_msg=tag//' ('//constitutive_titanmod_label//')')
end select
endif
endif
enddo
100 do i = 1_pInt,maxNinstance