2018-06-10 14:37:17 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @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'
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-14 10:09:49 +05:30
|
|
|
module config
|
2018-06-09 00:31:58 +05:30
|
|
|
use prec, only: &
|
|
|
|
pReal, &
|
|
|
|
pInt
|
2018-06-10 22:08:31 +05:30
|
|
|
|
2018-06-09 00:31:58 +05:30
|
|
|
implicit none
|
2018-06-10 22:08:31 +05:30
|
|
|
private
|
2018-06-20 03:23:14 +05:30
|
|
|
type, private :: tPartitionedString
|
|
|
|
character(len=:), allocatable :: val
|
|
|
|
integer(pInt), dimension(:), allocatable :: pos
|
|
|
|
end type tPartitionedString
|
|
|
|
|
|
|
|
type, public :: tPartitionedStringList
|
|
|
|
type(tPartitionedString) :: string
|
|
|
|
type(tPartitionedStringList), pointer :: next => null()
|
2018-06-22 03:18:34 +05:30
|
|
|
|
2018-06-20 03:23:14 +05:30
|
|
|
contains
|
|
|
|
procedure :: add => add
|
|
|
|
procedure :: show => show
|
|
|
|
|
2018-06-22 02:04:32 +05:30
|
|
|
procedure :: keyExists => keyExists
|
|
|
|
procedure :: countKeys => countKeys
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
procedure :: getFloat => getFloat
|
|
|
|
procedure :: getInt => getInt
|
2018-06-22 03:18:34 +05:30
|
|
|
procedure :: getString => getString
|
|
|
|
|
|
|
|
procedure :: getFloats => getFloats
|
2018-06-20 03:23:14 +05:30
|
|
|
procedure :: getInts => getInts
|
2018-06-22 03:18:34 +05:30
|
|
|
procedure :: getStrings => getStrings
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
end type tPartitionedStringList
|
|
|
|
|
|
|
|
type(tPartitionedStringList), public :: emptyList
|
|
|
|
|
2018-06-10 21:31:52 +05:30
|
|
|
type(tPartitionedStringList), public, protected, allocatable, dimension(:) :: &
|
2018-06-09 00:31:58 +05:30
|
|
|
phaseConfig, &
|
|
|
|
microstructureConfig, &
|
|
|
|
homogenizationConfig, &
|
|
|
|
textureConfig, &
|
|
|
|
crystalliteConfig
|
2018-06-10 22:08:31 +05:30
|
|
|
|
2018-06-09 00:31:58 +05:30
|
|
|
character(len=64), dimension(:), allocatable, public, protected :: &
|
|
|
|
phase_name, & !< name of each phase
|
|
|
|
homogenization_name, & !< name of each homogenization
|
|
|
|
crystallite_name, & !< name of each crystallite setting
|
|
|
|
microstructure_name, & !< name of each microstructure
|
|
|
|
texture_name !< name of each texture
|
2018-06-10 22:08:31 +05:30
|
|
|
|
|
|
|
! ToDo: make private, no one needs to know that
|
2018-06-10 21:31:52 +05:30
|
|
|
character(len=*), parameter, public :: &
|
2018-06-09 00:31:58 +05:30
|
|
|
MATERIAL_partHomogenization = 'homogenization', & !< keyword for homogenization part
|
|
|
|
MATERIAL_partCrystallite = 'crystallite', & !< keyword for crystallite part
|
2018-06-10 22:08:31 +05:30
|
|
|
MATERIAL_partPhase = 'phase', & !< keyword for phase part
|
2018-06-09 00:31:58 +05:30
|
|
|
MATERIAL_partMicrostructure = 'microstructure', & !< keyword for microstructure part
|
|
|
|
MATERIAL_partTexture = 'texture' !< keyword for texture part
|
|
|
|
|
2018-06-10 22:08:31 +05:30
|
|
|
! ToDo: Remove, use size(phaseConfig) etc
|
2018-06-09 00:31:58 +05:30
|
|
|
integer(pInt), public, protected :: &
|
|
|
|
material_Ntexture, & !< number of textures
|
|
|
|
material_Nphase, & !< number of phases
|
|
|
|
material_Nhomogenization, & !< number of homogenizations
|
|
|
|
material_Nmicrostructure, & !< number of microstructures
|
|
|
|
material_Ncrystallite !< number of crystallite settings
|
|
|
|
|
2018-06-10 22:08:31 +05:30
|
|
|
! ToDo: make private, no one needs to know that
|
2018-06-10 21:31:52 +05:30
|
|
|
character(len=*), parameter, public :: &
|
|
|
|
MATERIAL_configFile = 'material.config', & !< generic name for material configuration file
|
|
|
|
MATERIAL_localFileExt = 'materialConfig' !< extension of solver job name depending material configuration file
|
2018-06-09 00:31:58 +05:30
|
|
|
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
public :: config_init
|
2018-06-10 22:08:31 +05:30
|
|
|
|
2018-06-09 00:31:58 +05:30
|
|
|
contains
|
|
|
|
|
2018-06-14 10:09:49 +05:30
|
|
|
subroutine config_init()
|
2018-06-09 00:31:58 +05:30
|
|
|
#if defined(__GFORTRAN__) || __INTEL_COMPILER >= 1800
|
|
|
|
use, intrinsic :: iso_fortran_env, only: &
|
|
|
|
compiler_version, &
|
|
|
|
compiler_options
|
|
|
|
#endif
|
|
|
|
use IO, only: &
|
|
|
|
IO_error, &
|
|
|
|
IO_open_file, &
|
|
|
|
IO_read, &
|
|
|
|
IO_lc, &
|
|
|
|
IO_open_jobFile_stat, &
|
|
|
|
IO_getTag, &
|
|
|
|
IO_timeStamp, &
|
|
|
|
IO_EOF
|
|
|
|
use debug, only: &
|
|
|
|
debug_level, &
|
|
|
|
debug_material, &
|
2018-06-10 21:31:52 +05:30
|
|
|
debug_levelBasic
|
2018-06-09 00:31:58 +05:30
|
|
|
|
|
|
|
implicit none
|
|
|
|
integer(pInt), parameter :: FILEUNIT = 200_pInt
|
2018-06-10 22:08:31 +05:30
|
|
|
integer(pInt) :: myDebug
|
2018-06-09 00:31:58 +05:30
|
|
|
|
|
|
|
character(len=65536) :: &
|
2018-06-10 22:08:31 +05:30
|
|
|
line, &
|
|
|
|
part
|
2018-06-09 00:31:58 +05:30
|
|
|
|
|
|
|
|
|
|
|
myDebug = debug_level(debug_material)
|
|
|
|
|
|
|
|
write(6,'(/,a)') ' <<<+- material init -+>>>'
|
|
|
|
write(6,'(a15,a)') ' Current time: ',IO_timeStamp()
|
|
|
|
#include "compilation_info.f90"
|
|
|
|
|
|
|
|
if (.not. IO_open_jobFile_stat(FILEUNIT,material_localFileExt)) & ! no local material configuration present...
|
|
|
|
call IO_open_file(FILEUNIT,material_configFile) ! ...open material.config file
|
|
|
|
|
|
|
|
rewind(fileUnit)
|
|
|
|
line = '' ! to have it initialized
|
|
|
|
do while (trim(line) /= IO_EOF)
|
|
|
|
part = IO_lc(IO_getTag(line,'<','>'))
|
|
|
|
|
|
|
|
select case (trim(part))
|
|
|
|
|
|
|
|
case (trim(material_partPhase))
|
2018-06-14 10:05:28 +05:30
|
|
|
call parseFile(line,phase_name,phaseConfig,FILEUNIT)
|
2018-06-09 00:31:58 +05:30
|
|
|
if (iand(myDebug,debug_levelBasic) /= 0_pInt) write(6,'(a)') ' Phase parsed'; flush(6)
|
|
|
|
|
|
|
|
case (trim(material_partMicrostructure))
|
2018-06-14 10:05:28 +05:30
|
|
|
call parseFile(line,microstructure_name,microstructureConfig,FILEUNIT)
|
2018-06-09 00:31:58 +05:30
|
|
|
if (iand(myDebug,debug_levelBasic) /= 0_pInt) write(6,'(a)') ' Microstructure parsed'; flush(6)
|
|
|
|
|
|
|
|
case (trim(material_partCrystallite))
|
2018-06-14 10:05:28 +05:30
|
|
|
call parseFile(line,crystallite_name,crystalliteConfig,FILEUNIT)
|
2018-06-09 00:31:58 +05:30
|
|
|
if (iand(myDebug,debug_levelBasic) /= 0_pInt) write(6,'(a)') ' Crystallite parsed'; flush(6)
|
|
|
|
|
|
|
|
case (trim(material_partHomogenization))
|
2018-06-14 10:05:28 +05:30
|
|
|
call parseFile(line,homogenization_name,homogenizationConfig,FILEUNIT)
|
2018-06-09 00:31:58 +05:30
|
|
|
if (iand(myDebug,debug_levelBasic) /= 0_pInt) write(6,'(a)') ' Homogenization parsed'; flush(6)
|
|
|
|
|
|
|
|
case (trim(material_partTexture))
|
2018-06-14 10:05:28 +05:30
|
|
|
call parseFile(line,texture_name,textureConfig,FILEUNIT)
|
2018-06-09 00:31:58 +05:30
|
|
|
if (iand(myDebug,debug_levelBasic) /= 0_pInt) write(6,'(a)') ' Texture parsed'; flush(6)
|
|
|
|
|
|
|
|
case default
|
|
|
|
line = IO_read(fileUnit)
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
enddo
|
2018-06-09 17:18:37 +05:30
|
|
|
|
|
|
|
material_Nhomogenization = size(homogenizationConfig)
|
|
|
|
if (material_Nhomogenization < 1_pInt) call IO_error(160_pInt,ext_msg=material_partHomogenization)
|
|
|
|
material_Nmicrostructure = size(microstructureConfig)
|
|
|
|
if (material_Nmicrostructure < 1_pInt) call IO_error(160_pInt,ext_msg=material_partMicrostructure)
|
|
|
|
material_Ncrystallite = size(crystalliteConfig)
|
|
|
|
if (material_Ncrystallite < 1_pInt) call IO_error(160_pInt,ext_msg=material_partCrystallite)
|
|
|
|
material_Nphase = size(phaseConfig)
|
|
|
|
if (material_Nphase < 1_pInt) call IO_error(160_pInt,ext_msg=material_partPhase)
|
|
|
|
material_Ntexture = size(textureConfig)
|
|
|
|
if (material_Ntexture < 1_pInt) call IO_error(160_pInt,ext_msg=material_partTexture)
|
|
|
|
|
|
|
|
|
2018-06-14 10:09:49 +05:30
|
|
|
end subroutine config_init
|
2018-06-09 00:31:58 +05:30
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief parses the homogenization part in the material configuration file
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-14 10:05:28 +05:30
|
|
|
subroutine parseFile(line,&
|
|
|
|
sectionNames,part,fileUnit)
|
2018-06-09 00:31:58 +05:30
|
|
|
use IO, only: &
|
|
|
|
IO_read, &
|
|
|
|
IO_error, &
|
|
|
|
IO_lc, &
|
|
|
|
IO_getTag, &
|
|
|
|
IO_isBlank, &
|
|
|
|
IO_stringValue, &
|
|
|
|
IO_stringPos, &
|
|
|
|
IO_EOF
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
integer(pInt), intent(in) :: fileUnit
|
2018-06-10 21:31:52 +05:30
|
|
|
character(len=*), dimension(:), allocatable, intent(inout) :: sectionNames
|
|
|
|
type(tPartitionedStringList), allocatable, dimension(:), intent(inout) :: part
|
|
|
|
character(len=65536),intent(out) :: line
|
2018-06-09 00:31:58 +05:30
|
|
|
|
|
|
|
integer(pInt), allocatable, dimension(:) :: chunkPos
|
2018-06-10 22:08:31 +05:30
|
|
|
integer(pInt) :: s
|
2018-06-10 21:31:52 +05:30
|
|
|
character(len=65536) :: devNull
|
|
|
|
character(len=64) :: tag
|
2018-06-09 00:31:58 +05:30
|
|
|
logical :: echo
|
2018-06-11 04:12:42 +05:30
|
|
|
|
|
|
|
echo = .false.
|
2018-06-09 17:18:37 +05:30
|
|
|
allocate(part(0))
|
2018-06-09 00:31:58 +05:30
|
|
|
|
2018-06-10 21:31:52 +05:30
|
|
|
s = 0_pInt
|
2018-06-09 00:31:58 +05:30
|
|
|
do while (trim(line) /= IO_EOF) ! read through sections of material part
|
|
|
|
line = IO_read(fileUnit)
|
|
|
|
if (IO_isBlank(line)) cycle ! skip empty lines
|
|
|
|
foundNextPart: if (IO_getTag(line,'<','>') /= '') then
|
|
|
|
devNull = IO_read(fileUnit, .true.) ! reset IO_read
|
|
|
|
exit
|
|
|
|
endif foundNextPart
|
|
|
|
nextSection: if (IO_getTag(line,'[',']') /= '') then
|
2018-06-10 21:31:52 +05:30
|
|
|
s = s + 1_pInt
|
2018-06-09 17:18:37 +05:30
|
|
|
part = [part, emptyList]
|
2018-06-10 21:31:52 +05:30
|
|
|
tag = IO_getTag(line,'[',']')
|
|
|
|
GfortranBug86033: if (.not. allocated(sectionNames)) then
|
|
|
|
allocate(sectionNames(1),source=tag)
|
2018-06-09 00:31:58 +05:30
|
|
|
else GfortranBug86033
|
2018-06-10 21:31:52 +05:30
|
|
|
sectionNames = [sectionNames,tag]
|
2018-06-09 00:31:58 +05:30
|
|
|
endif GfortranBug86033
|
|
|
|
endif nextSection
|
|
|
|
chunkPos = IO_stringPos(line)
|
|
|
|
tag = IO_lc(IO_stringValue(trim(line),chunkPos,1_pInt)) ! extract key
|
2018-06-10 21:31:52 +05:30
|
|
|
inSection: if (s > 0_pInt) then
|
|
|
|
call part(s)%add(IO_lc(trim(line)))
|
2018-06-09 00:31:58 +05:30
|
|
|
else inSection
|
|
|
|
echo = (trim(tag) == '/echo/')
|
|
|
|
endif inSection
|
|
|
|
enddo
|
|
|
|
|
2018-06-10 22:08:31 +05:30
|
|
|
if (echo) then
|
|
|
|
do s = 1, size(sectionNames)
|
|
|
|
call part(s)%show()
|
|
|
|
end do
|
|
|
|
end if
|
2018-06-09 17:18:37 +05:30
|
|
|
end subroutine parseFile
|
2018-06-09 00:31:58 +05:30
|
|
|
|
2018-06-20 03:23:14 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief add element
|
|
|
|
!> @details Adds a string together with the start/end position of chunks in this string. The new
|
|
|
|
!! element is added at the end of the list. Empty strings are not added. All strings are converted
|
|
|
|
!! to lower case
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
subroutine add(this,string)
|
|
|
|
use IO, only: &
|
|
|
|
IO_isBlank, &
|
|
|
|
IO_lc, &
|
|
|
|
IO_stringPos
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
class(tPartitionedStringList), target, intent(in) :: this
|
|
|
|
character(len=*), intent(in) :: string
|
|
|
|
type(tPartitionedStringList), pointer :: new, item
|
|
|
|
|
|
|
|
if (IO_isBlank(string)) return
|
|
|
|
|
|
|
|
allocate(new)
|
|
|
|
new%string%val = IO_lc (trim(string))
|
|
|
|
new%string%pos = IO_stringPos(trim(string))
|
|
|
|
|
|
|
|
item => this
|
|
|
|
do while (associated(item%next))
|
|
|
|
item => item%next
|
|
|
|
enddo
|
|
|
|
item%next => new
|
|
|
|
|
|
|
|
end subroutine add
|
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief prints all elements
|
|
|
|
!> @details Strings are printed in order of insertion (FIFO)
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
subroutine show(this)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
class(tPartitionedStringList) :: this
|
|
|
|
type(tPartitionedStringList), pointer :: item
|
|
|
|
|
|
|
|
item => this%next
|
|
|
|
do while (associated(item))
|
|
|
|
write(6,'(a)') trim(item%string%val)
|
|
|
|
item => item%next
|
|
|
|
end do
|
|
|
|
|
|
|
|
end subroutine show
|
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief deallocates all elements of a given list
|
|
|
|
!> @details Strings are printed in order of insertion (FIFO)
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! subroutine free_all()
|
|
|
|
! implicit none
|
|
|
|
!
|
|
|
|
! type(node), pointer :: item
|
|
|
|
!
|
|
|
|
! do
|
|
|
|
! item => first
|
|
|
|
!
|
|
|
|
! if (associated(item) .eqv. .FALSE.) exit
|
|
|
|
!
|
|
|
|
! first => first%next
|
|
|
|
! deallocate(item)
|
|
|
|
! end do
|
|
|
|
! end subroutine free_all
|
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief reports wether a given key (string value at first position) exists in the list
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 02:04:32 +05:30
|
|
|
logical function keyExists(this,key)
|
2018-06-20 03:23:14 +05:30
|
|
|
use IO, only: &
|
|
|
|
IO_stringValue
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
class(tPartitionedStringList), intent(in) :: this
|
|
|
|
character(len=*), intent(in) :: key
|
|
|
|
type(tPartitionedStringList), pointer :: item
|
|
|
|
|
2018-06-22 02:04:32 +05:30
|
|
|
keyExists = .false.
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
item => this%next
|
2018-06-22 02:04:32 +05:30
|
|
|
do while (associated(item) .and. .not. keyExists)
|
|
|
|
keyExists = trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)
|
2018-06-20 03:23:14 +05:30
|
|
|
item => item%next
|
|
|
|
end do
|
|
|
|
|
2018-06-22 02:04:32 +05:30
|
|
|
end function keyExists
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief count number of key appearances
|
|
|
|
!> @details traverses list and counts each occurrence of specified key
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 02:04:32 +05:30
|
|
|
integer(pInt) function countKeys(this,key)
|
2018-06-20 03:23:14 +05:30
|
|
|
use IO, only: &
|
|
|
|
IO_stringValue
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
class(tPartitionedStringList), intent(in) :: this
|
|
|
|
character(len=*), intent(in) :: key
|
|
|
|
type(tPartitionedStringList), pointer :: item
|
|
|
|
|
2018-06-22 02:04:32 +05:30
|
|
|
countKeys = 0_pInt
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
item => this%next
|
|
|
|
do while (associated(item))
|
|
|
|
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) &
|
2018-06-22 02:04:32 +05:30
|
|
|
countKeys = countKeys + 1_pInt
|
2018-06-20 03:23:14 +05:30
|
|
|
item => item%next
|
|
|
|
end do
|
|
|
|
|
2018-06-22 02:04:32 +05:30
|
|
|
end function countKeys
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 03:18:34 +05:30
|
|
|
!> @brief gets float value of for a given key from a linked list
|
|
|
|
!> @details gets the last value if the key occurs more than once. If key is not found exits with
|
|
|
|
!! error unless default is given
|
2018-06-20 03:23:14 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
real(pReal) function getFloat(this,key,defaultVal)
|
|
|
|
use IO, only : &
|
|
|
|
IO_error, &
|
|
|
|
IO_stringValue, &
|
|
|
|
IO_FloatValue
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
class(tPartitionedStringList), intent(in) :: this
|
|
|
|
character(len=*), intent(in) :: key
|
|
|
|
real(pReal), intent(in), optional :: defaultVal
|
|
|
|
type(tPartitionedStringList), pointer :: item
|
|
|
|
logical :: found
|
|
|
|
|
|
|
|
if (present(defaultVal)) getFloat = defaultVal
|
|
|
|
found = present(defaultVal)
|
|
|
|
|
|
|
|
item => this%next
|
|
|
|
do while (associated(item))
|
|
|
|
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
|
|
|
found = .true.
|
|
|
|
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
|
|
|
getFloat = IO_FloatValue(item%string%val,item%string%pos,2)
|
|
|
|
endif
|
|
|
|
item => item%next
|
|
|
|
end do
|
|
|
|
|
|
|
|
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
|
|
|
|
|
|
|
end function getFloat
|
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 03:18:34 +05:30
|
|
|
!> @brief gets integer value of for a given key from a linked list
|
|
|
|
!> @details gets the last value if the key occurs more than once. If key is not found exits with
|
|
|
|
!! error unless default is given
|
2018-06-20 03:23:14 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
integer(pInt) function getInt(this,key,defaultVal)
|
|
|
|
use IO, only: &
|
|
|
|
IO_error, &
|
|
|
|
IO_stringValue, &
|
|
|
|
IO_IntValue
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
class(tPartitionedStringList), intent(in) :: this
|
|
|
|
character(len=*), intent(in) :: key
|
|
|
|
integer(pInt), intent(in), optional :: defaultVal
|
|
|
|
type(tPartitionedStringList), pointer :: item
|
|
|
|
logical :: found
|
|
|
|
|
|
|
|
if (present(defaultVal)) getInt = defaultVal
|
|
|
|
found = present(defaultVal)
|
|
|
|
|
|
|
|
item => this%next
|
|
|
|
do while (associated(item))
|
|
|
|
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
|
|
|
found = .true.
|
|
|
|
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
|
|
|
getInt = IO_IntValue(item%string%val,item%string%pos,2)
|
|
|
|
endif
|
|
|
|
item => item%next
|
|
|
|
end do
|
|
|
|
|
|
|
|
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
|
|
|
|
|
|
|
end function getInt
|
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 03:18:34 +05:30
|
|
|
!> @brief gets string value of for a given key from a linked list
|
|
|
|
!> @details gets the last value if the key occurs more than once. If key is not found exits with
|
|
|
|
!! error unless default is given. If raw is true, the the complete string is returned, otherwise
|
|
|
|
!! the individual chunks are returned
|
2018-06-20 03:23:14 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
character(len=65536) function getString(this,key,defaultVal,raw)
|
|
|
|
use IO, only: &
|
|
|
|
IO_error, &
|
|
|
|
IO_stringValue
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
class(tPartitionedStringList), intent(in) :: this
|
|
|
|
character(len=*), intent(in) :: key
|
|
|
|
character(len=65536), intent(in), optional :: defaultVal
|
|
|
|
logical, intent(in), optional :: raw
|
|
|
|
type(tPartitionedStringList), pointer :: item
|
|
|
|
logical :: found, &
|
|
|
|
split
|
|
|
|
|
|
|
|
if (present(defaultVal)) getString = defaultVal
|
|
|
|
split = merge(.not. raw,.true.,present(raw))
|
|
|
|
found = present(defaultVal)
|
|
|
|
|
|
|
|
item => this%next
|
|
|
|
do while (associated(item))
|
|
|
|
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
|
|
|
found = .true.
|
|
|
|
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
|
|
|
|
|
|
|
if (split) then
|
|
|
|
getString = IO_StringValue(item%string%val,item%string%pos,2)
|
|
|
|
else
|
|
|
|
getString = trim(item%string%val(item%string%pos(4):)) ! raw string starting a second chunk
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
item => item%next
|
|
|
|
end do
|
|
|
|
|
|
|
|
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
|
|
|
|
|
|
|
end function getString
|
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 03:18:34 +05:30
|
|
|
!> @brief gets array of float values of for a given key from a linked list
|
|
|
|
!> @details for cumulative keys, "()", values from all occurrences are return. Otherwise only all
|
|
|
|
!! values from the last occurrence. If key is not found exits with error unless default is given.
|
2018-06-20 03:23:14 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 03:18:34 +05:30
|
|
|
function getFloats(this,key,defaultVal)
|
|
|
|
use IO, only: &
|
|
|
|
IO_error, &
|
|
|
|
IO_stringValue, &
|
|
|
|
IO_FloatValue
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
implicit none
|
2018-06-22 03:18:34 +05:30
|
|
|
real(pReal), dimension(:), allocatable :: getFloats
|
|
|
|
class(tPartitionedStringList), intent(in) :: this
|
|
|
|
character(len=*), intent(in) :: key
|
|
|
|
real(pReal), dimension(:), intent(in), optional :: defaultVal
|
|
|
|
type(tPartitionedStringList), pointer :: item
|
|
|
|
integer(pInt) :: i
|
2018-06-20 03:23:14 +05:30
|
|
|
logical :: found, &
|
2018-06-22 03:18:34 +05:30
|
|
|
cumulative
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
cumulative = (key(1:1) == '(' .and. key(len_trim(key):len_trim(key)) == ')')
|
|
|
|
found = .false.
|
|
|
|
|
2018-06-22 03:18:34 +05:30
|
|
|
allocate(getFloats(0))
|
|
|
|
|
2018-06-20 03:23:14 +05:30
|
|
|
item => this%next
|
|
|
|
do while (associated(item))
|
|
|
|
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
|
|
|
found = .true.
|
2018-06-22 03:18:34 +05:30
|
|
|
if (.not. cumulative) then
|
|
|
|
deallocate(getFloats) ! use here rhs allocation with empty list
|
|
|
|
allocate(getFloats(0))
|
|
|
|
endif
|
2018-06-20 03:23:14 +05:30
|
|
|
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
2018-06-22 03:18:34 +05:30
|
|
|
do i = 2_pInt, item%string%pos(1)
|
|
|
|
getFloats = [getFloats,IO_FloatValue(item%string%val,item%string%pos,i)]
|
|
|
|
enddo
|
2018-06-20 03:23:14 +05:30
|
|
|
endif
|
|
|
|
item => item%next
|
|
|
|
end do
|
|
|
|
|
|
|
|
if (present(defaultVal) .and. .not. found) then
|
2018-06-22 03:18:34 +05:30
|
|
|
getFloats = defaultVal
|
2018-06-20 03:23:14 +05:30
|
|
|
found = .true.
|
|
|
|
endif
|
|
|
|
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
|
|
|
|
2018-06-22 03:18:34 +05:30
|
|
|
end function getFloats
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 03:18:34 +05:30
|
|
|
!> @brief gets array of integer values of for a given key from a linked list
|
|
|
|
!> @details for cumulative keys, "()", values from all occurrences are return. Otherwise only all
|
|
|
|
!! values from the last occurrence. If key is not found exits with error unless default is given.
|
2018-06-20 03:23:14 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
function getInts(this,key,defaultVal)
|
|
|
|
use IO, only: &
|
|
|
|
IO_error, &
|
|
|
|
IO_stringValue, &
|
|
|
|
IO_IntValue
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
integer(pInt), dimension(:), allocatable :: getInts
|
|
|
|
class(tPartitionedStringList), intent(in) :: this
|
|
|
|
character(len=*), intent(in) :: key
|
|
|
|
integer(pInt), dimension(:), intent(in), optional :: defaultVal
|
|
|
|
type(tPartitionedStringList), pointer :: item
|
|
|
|
integer(pInt) :: i
|
|
|
|
logical :: found, &
|
|
|
|
cumulative
|
|
|
|
|
|
|
|
cumulative = (key(1:1) == '(' .and. key(len_trim(key):len_trim(key)) == ')')
|
|
|
|
found = .false.
|
|
|
|
|
|
|
|
allocate(getInts(0))
|
|
|
|
|
|
|
|
item => this%next
|
|
|
|
do while (associated(item))
|
|
|
|
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
|
|
|
found = .true.
|
|
|
|
if (.not. cumulative) then
|
|
|
|
deallocate(getInts) ! use here rhs allocation with empty list
|
|
|
|
allocate(getInts(0))
|
|
|
|
endif
|
|
|
|
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
|
|
|
do i = 2_pInt, item%string%pos(1)
|
|
|
|
getInts = [getInts,IO_IntValue(item%string%val,item%string%pos,i)]
|
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
item => item%next
|
|
|
|
end do
|
|
|
|
|
|
|
|
if (present(defaultVal) .and. .not. found) then
|
|
|
|
getInts = defaultVal
|
|
|
|
found = .true.
|
|
|
|
endif
|
|
|
|
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
|
|
|
|
|
|
|
end function getInts
|
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 03:18:34 +05:30
|
|
|
!> @brief gets array of string values of for a given key from a linked list
|
|
|
|
!> @details for cumulative keys, "()", values from all occurrences are return. Otherwise only all
|
|
|
|
!! values from the last occurrence. If key is not found exits with error unless default is given.
|
|
|
|
!! If raw is true, the the complete string is returned, otherwise the individual chunks are returned
|
2018-06-20 03:23:14 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2018-06-22 03:18:34 +05:30
|
|
|
function getStrings(this,key,defaultVal,raw)
|
2018-06-20 03:23:14 +05:30
|
|
|
use IO, only: &
|
|
|
|
IO_error, &
|
2018-06-22 03:18:34 +05:30
|
|
|
IO_StringValue
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
implicit none
|
2018-06-22 03:18:34 +05:30
|
|
|
character(len=65536),dimension(:), allocatable :: getStrings
|
|
|
|
class(tPartitionedStringList), intent(in) :: this
|
|
|
|
character(len=*), intent(in) :: key
|
|
|
|
character(len=65536),dimension(:), intent(in), optional :: defaultVal
|
|
|
|
logical, intent(in), optional :: raw
|
|
|
|
type(tPartitionedStringList), pointer :: item
|
|
|
|
character(len=65536) :: str
|
|
|
|
integer(pInt) :: i
|
|
|
|
logical :: found, &
|
|
|
|
split, &
|
|
|
|
cumulative
|
2018-06-20 03:23:14 +05:30
|
|
|
|
|
|
|
cumulative = (key(1:1) == '(' .and. key(len_trim(key):len_trim(key)) == ')')
|
2018-06-22 03:18:34 +05:30
|
|
|
split = merge(.not. raw,.true.,present(raw))
|
2018-06-20 03:23:14 +05:30
|
|
|
found = .false.
|
|
|
|
|
|
|
|
item => this%next
|
|
|
|
do while (associated(item))
|
|
|
|
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
|
|
|
found = .true.
|
2018-06-22 03:18:34 +05:30
|
|
|
if (allocated(getStrings) .and. .not. cumulative) deallocate(getStrings)
|
2018-06-20 03:23:14 +05:30
|
|
|
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
2018-06-22 03:18:34 +05:30
|
|
|
|
|
|
|
notAllocated: if (.not. allocated(getStrings)) then
|
|
|
|
if (split) then
|
|
|
|
str = IO_StringValue(item%string%val,item%string%pos,2_pInt)
|
|
|
|
allocate(getStrings(1),source=str)
|
|
|
|
do i=3_pInt,item%string%pos(1)
|
|
|
|
str = IO_StringValue(item%string%val,item%string%pos,i)
|
|
|
|
getStrings = [getStrings,str]
|
|
|
|
enddo
|
|
|
|
else
|
|
|
|
str = item%string%val(item%string%pos(4):)
|
|
|
|
getStrings = [str]
|
|
|
|
endif
|
|
|
|
else notAllocated
|
|
|
|
if (split) then
|
|
|
|
do i=2_pInt,item%string%pos(1)
|
|
|
|
str = IO_StringValue(item%string%val,item%string%pos,i)
|
|
|
|
getStrings = [getStrings,str]
|
|
|
|
enddo
|
|
|
|
else
|
|
|
|
getStrings = [getStrings,str]
|
|
|
|
endif
|
|
|
|
endif notAllocated
|
2018-06-20 03:23:14 +05:30
|
|
|
endif
|
|
|
|
item => item%next
|
|
|
|
end do
|
|
|
|
|
|
|
|
if (present(defaultVal) .and. .not. found) then
|
2018-06-22 03:18:34 +05:30
|
|
|
getStrings = defaultVal
|
2018-06-20 03:23:14 +05:30
|
|
|
found = .true.
|
|
|
|
endif
|
|
|
|
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
|
|
|
|
2018-06-22 03:18:34 +05:30
|
|
|
end function getStrings
|
|
|
|
|
|
|
|
|
2018-06-14 10:09:49 +05:30
|
|
|
end module config
|