From f8ae0ec92554a17906ebd5d88c05796dbdcdf7c1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 10 Jun 2018 11:07:17 +0200 Subject: [PATCH] list does tokenizing automatically --- src/config_material.f90 | 9 ++++++++- src/list.f90 | 25 ++++++++++++++++--------- src/material.f90 | 15 ++++++++------- src/math.f90 | 1 - 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/config_material.f90 b/src/config_material.f90 index cca6acfa4..6bb8d81d8 100644 --- a/src/config_material.f90 +++ b/src/config_material.f90 @@ -1,3 +1,10 @@ +!-------------------------------------------------------------------------------------------------- +!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH +!> @brief Reads in the material configuration from file +!> @details Reads the material configuration file, where solverJobName.materialConfig takes +!! precedence over material.config. Stores the raw strings and the positions of delimiters for the +!! parts 'homogenization', 'crystallite', 'phase', 'texture', and 'microstucture' +!-------------------------------------------------------------------------------------------------- module config_material use chained_list use prec, only: & @@ -189,7 +196,7 @@ subroutine parseFile(partLabel,part,fileUnit,nextLine) tag = IO_lc(IO_stringValue(trim(line),chunkPos,1_pInt)) ! extract key inSection: if (h > 0_pInt) then chunkPos = IO_stringPos(line) - call homogenizationConfig(h)%add(IO_lc(trim(line)),chunkPos) + call part(h)%add(IO_lc(trim(line))) else inSection echo = (trim(tag) == '/echo/') endif inSection diff --git a/src/list.f90 b/src/list.f90 index e9e27b6d4..86c24eb86 100644 --- a/src/list.f90 +++ b/src/list.f90 @@ -42,18 +42,24 @@ contains !> @brief add element !> @details adds raw string and start/end position of chunks in this string !-------------------------------------------------------------------------------------------------- -subroutine add(this,string,stringPos) +subroutine add(this,string) + use IO, only: & + IO_isBlank, & + IO_lc, & + IO_stringPos + implicit none - class(tPartitionedStringList) :: this - type(tPartitionedStringList), pointer :: & - new, & - tmp - character(len=*), intent(in) :: string - integer(pInt), dimension(:), intent(in) :: stringPos + class(tPartitionedStringList) :: this + character(len=*), intent(in) :: string + + integer(pInt), allocatable,dimension(:) :: p + type(tPartitionedStringList), pointer :: new, tmp + + if (IO_isBlank(string)) return allocate(new) - new%string%val=string - new%string%pos=stringPos + new%string%val=trim(string) + new%string%pos=IO_stringPos(trim(string)) if (.not. associated(this%next)) then this%next => new @@ -61,6 +67,7 @@ subroutine add(this,string,stringPos) tmp => this%next this%next => new this%next%next => tmp + !new%prev => this%prev%next end if end subroutine add diff --git a/src/material.f90 b/src/material.f90 index 72599f9cc..dc70304fa 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -622,12 +622,13 @@ character(len=65536) function material_parseHomogenization(fileUnit) chunkPos = IO_stringPos(line) tag = IO_lc(IO_stringValue(trim(line),chunkPos,1_pInt)) ! extract key inSection: if (h > 0_pInt) then - chunkPos = IO_stringPos(line) - call homogenizationConfig(h)%add(IO_lc(trim(line)),chunkPos) + call homogenizationConfig(h)%add(line) else inSection echo = (trim(tag) == '/echo/') endif inSection enddo + + if (echo) call homogenizationConfig(1)%show() material_Nhomogenization = size(homogenizationConfig) if (material_Nhomogenization < 1_pInt) call IO_error(160_pInt,ext_msg=material_partHomogenization) @@ -814,7 +815,7 @@ character(len=65536) function material_parseMicrostructure(fileUnit) tag = IO_lc(IO_stringValue(trim(line),chunkPos,1_pInt)) ! extract key inSection: if (m > 0_pInt) then chunkPos = IO_stringPos(line) - call microstructureConfig(m)%add(IO_lc(trim(line)),chunkPos) + call microstructureConfig(m)%add(IO_lc(line)) else inSection echo = (trim(tag) == '/echo/') endif inSection @@ -919,8 +920,8 @@ character(len=65536) function material_parseCrystallite(fileUnit) chunkPos = IO_stringPos(line) tag = IO_lc(IO_stringValue(trim(line),chunkPos,1_pInt)) ! extract key inSection: if (c > 0_pInt) then - chunkPos = IO_stringPos(line) - call crystalliteConfig(c)%add(IO_lc(trim(line)),chunkPos) + chunkPos = IO_stringPos(trim(line)) + call crystalliteConfig(c)%add(IO_lc(line)) else inSection echo = (trim(tag) == '/echo/') endif inSection @@ -997,7 +998,7 @@ character(len=65536) function material_parsePhase(fileUnit) tag = IO_lc(IO_stringValue(trim(line),chunkPos,1_pInt)) ! extract key inSection: if (p > 0_pInt) then chunkPos = IO_stringPos(line) - call phaseConfig(p)%add(IO_lc(trim(line)),chunkPos) + call phaseConfig(p)%add(IO_lc(trim(line))) else inSection echo = (trim(tag) == '/echo/') endif inSection @@ -1183,7 +1184,7 @@ character(len=65536) function material_parseTexture(fileUnit) tag = IO_lc(IO_stringValue(trim(line2),chunkPos,1_pInt)) ! extract key inSection: if (t > 0_pInt) then chunkPos = IO_stringPos(line2) - call textureConfig(t)%add(IO_lc(trim(line2)),chunkPos) + call textureConfig(t)%add(IO_lc(trim(line2))) else inSection echo = (trim(tag) == '/echo/') endif inSection diff --git a/src/math.f90 b/src/math.f90 index 8f228582b..c874e422d 100644 --- a/src/math.f90 +++ b/src/math.f90 @@ -223,7 +223,6 @@ end subroutine math_init !> @brief check correctness of (some) math functions !-------------------------------------------------------------------------------------------------- subroutine math_check - use prec, only: tol_math_check use IO, only: IO_error