From b4103b205d09b6cd52acc791d6b6aea82b55ee42 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 26 Jun 2012 10:24:54 +0000 Subject: [PATCH] parts of the material.config can now be set to echo their content back into the log-file (i.e. STDOUT / unit 6) use keyword "/echo/" before first section in the respective parts that you want to see echoed back into the log file. --- code/IO.f90 | 49 +++++++++++++++++++++++++++++++++++++++++++++-- code/material.f90 | 31 +++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/code/IO.f90 b/code/IO.f90 index 308bb0258..0811a4735 100644 --- a/code/IO.f90 +++ b/code/IO.f90 @@ -40,6 +40,7 @@ module IO IO_countSections, & IO_countTagInPart, & IO_spotTagInPart, & + IO_globalTagInPart, & IO_stringPos, & IO_stringValue, & IO_fixedStringValue ,& @@ -645,7 +646,7 @@ function IO_spotTagInPart(myFile,part,myTag,Nsections) character(len=*), intent(in) :: part, & myTag - integer(pInt), parameter :: maxNchunks = 1_pInt + integer(pInt), parameter :: maxNchunks = 1_pInt integer(pInt), dimension(1+2*maxNchunks) :: positions integer(pInt) :: section @@ -669,7 +670,7 @@ function IO_spotTagInPart(myFile,part,myTag,Nsections) section = section + 1_pInt if (section > 0_pInt) then positions = IO_stringPos(line,maxNchunks) - tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key + tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key if (tag == myTag) & ! match IO_spotTagInPart(section) = .true. endif @@ -678,6 +679,50 @@ function IO_spotTagInPart(myFile,part,myTag,Nsections) 100 end function IO_spotTagInPart +!********************************************************************* +! return logical whether myTag is present within before any [sections] +!********************************************************************* +logical function IO_globalTagInPart(myFile,part,myTag) + + implicit none + + integer(pInt), intent(in) :: myFile + character(len=*), intent(in) :: part, & + myTag + + integer(pInt), parameter :: maxNchunks = 1_pInt + + integer(pInt), dimension(1+2*maxNchunks) :: positions + integer(pInt) :: section + character(len=1024) :: line, & + tag + + IO_globalTagInPart = .false. ! assume to nowhere spot tag + section = 0_pInt + line ='' + + rewind(myFile) + do while (IO_getTag(line,'<','>') /= part) ! search for part + read(myFile,'(a1024)',END=100) line + enddo + + do + read(myFile,'(a1024)',END=100) line + if (IO_isBlank(line)) cycle ! skip empty lines + if (IO_getTag(line,'<','>') /= '') exit ! stop at next part + if (IO_getTag(line,'[',']') /= '') & ! found [section] identifier + section = section + 1_pInt + if (section == 0_pInt) then + positions = IO_stringPos(line,maxNchunks) + tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key + if (tag == myTag) & ! match + IO_globalTagInPart = .true. + endif + enddo + +100 end function IO_globalTagInPart + + !******************************************************************** ! locate at most N space-separated parts in line ! return array containing number of parts in line and diff --git a/code/material.f90 b/code/material.f90 index 3a98d01ec..477de1aad 100644 --- a/code/material.f90 +++ b/code/material.f90 @@ -249,7 +249,10 @@ subroutine material_parseHomogenization(myFile,myPart) integer(pInt), dimension(1+2*maxNchunks) :: positions integer(pInt) Nsections, section, s character(len=64) :: tag - character(len=1024) ::line + character(len=1024) :: line + logical :: echo + + echo = IO_globalTagInPart(myFile,myPart,'/echo/') Nsections = IO_countSections(myFile,myPart) material_Nhomogenization = Nsections @@ -272,11 +275,13 @@ subroutine material_parseHomogenization(myFile,myPart) do while (IO_lc(IO_getTag(line,'<','>')) /= myPart) ! wind forward to myPart read(myFile,'(a1024)',END=100) line enddo + if (echo) write(6,*) trim(line) ! echo part header do read(myFile,'(a1024)',END=100) line if (IO_isBlank(line)) cycle ! skip empty lines if (IO_getTag(line,'<','>') /= '') exit ! stop at next part + if (echo) write(6,*) trim(line) ! echo back read lines if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt homogenization_name(section) = IO_getTag(line,'[',']') @@ -286,7 +291,7 @@ subroutine material_parseHomogenization(myFile,myPart) tag = IO_lc(IO_stringValue(line,positions,1_pInt)) ! extract key select case(tag) case ('type') - homogenization_type(section) = IO_lc(IO_stringValue(line,positions,2_pInt)) ! adding: IO_lc function <<>> + homogenization_type(section) = IO_lc(IO_stringValue(line,positions,2_pInt)) ! adding: IO_lc function do s = 1_pInt,section if (homogenization_type(s) == homogenization_type(section)) & homogenization_typeInstance(section) = homogenization_typeInstance(section) + 1_pInt ! count instances @@ -319,6 +324,9 @@ subroutine material_parseMicrostructure(myFile,myPart) integer(pInt) :: Nsections, section, constituent, e, i character(len=64) :: tag character(len=1024) :: line + logical :: echo + + echo = IO_globalTagInPart(myFile,myPart,'/echo/') Nsections = IO_countSections(myFile,myPart) material_Nmicrostructure = Nsections @@ -347,11 +355,13 @@ subroutine material_parseMicrostructure(myFile,myPart) do while (IO_lc(IO_getTag(line,'<','>')) /= myPart) ! wind forward to myPart read(myFile,'(a1024)',END=100) line enddo + if (echo) write(6,*) trim(line) ! echo part header do read(myFile,'(a1024)',END=100) line if (IO_isBlank(line)) cycle ! skip empty lines if (IO_getTag(line,'<','>') /= '') exit ! stop at next part + if (echo) write(6,*) trim(line) ! echo back read lines if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt constituent = 0_pInt @@ -390,6 +400,7 @@ subroutine material_parseCrystallite(myFile,myPart) use IO, only: IO_countSections, & IO_error, & IO_countTagInPart, & + IO_globalTagInPart, & IO_getTag, & IO_lc, & IO_isBlank @@ -401,6 +412,9 @@ subroutine material_parseCrystallite(myFile,myPart) integer(pInt) :: Nsections, & section character(len=1024) :: line + logical :: echo + + echo = IO_globalTagInPart(myFile,myPart,'/echo/') Nsections = IO_countSections(myFile,myPart) material_Ncrystallite = Nsections @@ -418,11 +432,13 @@ subroutine material_parseCrystallite(myFile,myPart) do while (IO_lc(IO_getTag(line,'<','>')) /= myPart) ! wind forward to myPart read(myFile,'(a1024)',END=100) line enddo + if (echo) write(6,*) trim(line) ! echo part header do read(myFile,'(a1024)',END=100) line if (IO_isBlank(line)) cycle ! skip empty lines if (IO_getTag(line,'<','>') /= '') exit ! stop at next part + if (echo) write(6,*) trim(line) ! echo back read lines if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt crystallite_name(section) = IO_getTag(line,'[',']') @@ -448,6 +464,9 @@ subroutine material_parsePhase(myFile,myPart) integer(pInt) Nsections, section, s character(len=64) :: tag character(len=1024) :: line + logical :: echo + + echo = IO_globalTagInPart(myFile,myPart,'/echo/') Nsections = IO_countSections(myFile,myPart) material_Nphase = Nsections @@ -471,11 +490,13 @@ subroutine material_parsePhase(myFile,myPart) do while (IO_lc(IO_getTag(line,'<','>')) /= myPart) ! wind forward to myPart read(myFile,'(a1024)',END=100) line enddo + if (echo) write(6,*) trim(line) ! echo part header do read(myFile,'(a1024)',END=100) line if (IO_isBlank(line)) cycle ! skip empty lines if (IO_getTag(line,'<','>') /= '') exit ! stop at next part + if (echo) write(6,*) trim(line) ! echo back read lines if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt phase_name(section) = IO_getTag(line,'[',']') @@ -520,7 +541,9 @@ subroutine material_parseTexture(myFile,myPart) integer(pInt) :: Nsections, section, gauss, fiber, i character(len=64) :: tag character(len=1024) :: line - + logical :: echo + + echo = IO_globalTagInPart(myFile,myPart,'/echo/') Nsections = IO_countSections(myFile,myPart) material_Ntexture = Nsections @@ -547,11 +570,13 @@ subroutine material_parseTexture(myFile,myPart) do while (IO_lc(IO_getTag(line,'<','>')) /= myPart) ! wind forward to myPart read(myFile,'(a1024)',END=100) line enddo + if (echo) write(6,*) trim(line) ! echo part header do read(myFile,'(a1024)',END=100) line if (IO_isBlank(line)) cycle ! skip empty lines if (IO_getTag(line,'<','>') /= '') exit ! stop at next part + if (echo) write(6,*) trim(line) ! echo back read lines if (IO_getTag(line,'[',']') /= '') then ! next section section = section + 1_pInt gauss = 0_pInt