consistent description
This commit is contained in:
parent
367e6a4eee
commit
c5b00e7a6c
226
src/config.f90
226
src/config.f90
|
@ -20,6 +20,7 @@ module config
|
||||||
type, public :: tPartitionedStringList
|
type, public :: tPartitionedStringList
|
||||||
type(tPartitionedString) :: string
|
type(tPartitionedString) :: string
|
||||||
type(tPartitionedStringList), pointer :: next => null()
|
type(tPartitionedStringList), pointer :: next => null()
|
||||||
|
|
||||||
contains
|
contains
|
||||||
procedure :: add => add
|
procedure :: add => add
|
||||||
procedure :: show => show
|
procedure :: show => show
|
||||||
|
@ -28,14 +29,14 @@ module config
|
||||||
procedure :: countKeys => countKeys
|
procedure :: countKeys => countKeys
|
||||||
|
|
||||||
procedure :: getFloat => getFloat
|
procedure :: getFloat => getFloat
|
||||||
procedure :: getFloats => getFloats
|
|
||||||
|
|
||||||
procedure :: getInt => getInt
|
procedure :: getInt => getInt
|
||||||
|
procedure :: getString => getString
|
||||||
|
|
||||||
|
procedure :: getFloats => getFloats
|
||||||
procedure :: getInts => getInts
|
procedure :: getInts => getInts
|
||||||
|
procedure :: getStrings => getStrings
|
||||||
|
|
||||||
procedure :: getStringsRaw => strings
|
procedure :: getStringsRaw => strings
|
||||||
procedure :: getString => getString
|
|
||||||
procedure :: getStrings => getStrings
|
|
||||||
|
|
||||||
end type tPartitionedStringList
|
end type tPartitionedStringList
|
||||||
|
|
||||||
|
@ -352,38 +353,9 @@ end function countKeys
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief DEPRECATED: REMOVE SOON
|
!> @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
|
||||||
function strings(this)
|
!! error unless default is given
|
||||||
use IO, only: &
|
|
||||||
IO_error, &
|
|
||||||
IO_stringValue
|
|
||||||
|
|
||||||
implicit none
|
|
||||||
class(tPartitionedStringList), intent(in) :: this
|
|
||||||
character(len=65536), dimension(:), allocatable :: strings
|
|
||||||
character(len=65536) :: string
|
|
||||||
type(tPartitionedStringList), pointer :: item
|
|
||||||
|
|
||||||
item => this%next
|
|
||||||
do while (associated(item))
|
|
||||||
string = item%string%val
|
|
||||||
GfortranBug86033: if (.not. allocated(strings)) then
|
|
||||||
allocate(strings(1),source=string)
|
|
||||||
else GfortranBug86033
|
|
||||||
strings = [strings,string]
|
|
||||||
endif GfortranBug86033
|
|
||||||
item => item%next
|
|
||||||
end do
|
|
||||||
|
|
||||||
if (size(strings) < 0_pInt) call IO_error(142_pInt) ! better to check for "allocated"?
|
|
||||||
|
|
||||||
end function strings
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief gets float value of first string that matches given key (i.e. first chunk)
|
|
||||||
!> @details gets one float value. If key is not found exits with error unless default is given
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
real(pReal) function getFloat(this,key,defaultVal)
|
real(pReal) function getFloat(this,key,defaultVal)
|
||||||
use IO, only : &
|
use IO, only : &
|
||||||
|
@ -417,8 +389,9 @@ end function getFloat
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief gets integer value for given key
|
!> @brief gets integer value of for a given key from a linked list
|
||||||
!> @details gets one integer value. If key is not found exits with error unless default is given
|
!> @details gets the last value if the key occurs more than once. If key is not found exits with
|
||||||
|
!! error unless default is given
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
integer(pInt) function getInt(this,key,defaultVal)
|
integer(pInt) function getInt(this,key,defaultVal)
|
||||||
use IO, only: &
|
use IO, only: &
|
||||||
|
@ -452,8 +425,10 @@ end function getInt
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief gets string value for given key
|
!> @brief gets string value of for a given key from a linked list
|
||||||
!> @details if key is not found exits with error unless default is given
|
!> @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
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
character(len=65536) function getString(this,key,defaultVal,raw)
|
character(len=65536) function getString(this,key,defaultVal,raw)
|
||||||
use IO, only: &
|
use IO, only: &
|
||||||
|
@ -494,74 +469,60 @@ end function getString
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief ...
|
!> @brief gets array of float values of for a given key from a linked list
|
||||||
!> @details ...
|
!> @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.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
function getStrings(this,key,defaultVal,raw)
|
function getFloats(this,key,defaultVal)
|
||||||
use IO
|
use IO, only: &
|
||||||
|
IO_error, &
|
||||||
|
IO_stringValue, &
|
||||||
|
IO_FloatValue
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
character(len=65536),dimension(:), allocatable :: getStrings
|
real(pReal), dimension(:), allocatable :: getFloats
|
||||||
class(tPartitionedStringList), intent(in) :: this
|
class(tPartitionedStringList), intent(in) :: this
|
||||||
character(len=*), intent(in) :: key
|
character(len=*), intent(in) :: key
|
||||||
character(len=65536),dimension(:), intent(in), optional :: defaultVal
|
real(pReal), dimension(:), intent(in), optional :: defaultVal
|
||||||
logical, intent(in), optional :: raw
|
type(tPartitionedStringList), pointer :: item
|
||||||
type(tPartitionedStringList), pointer :: item
|
integer(pInt) :: i
|
||||||
character(len=65536) :: str
|
|
||||||
integer(pInt) :: i
|
|
||||||
logical :: found, &
|
logical :: found, &
|
||||||
split, &
|
cumulative
|
||||||
cumulative
|
|
||||||
|
|
||||||
cumulative = (key(1:1) == '(' .and. key(len_trim(key):len_trim(key)) == ')')
|
cumulative = (key(1:1) == '(' .and. key(len_trim(key):len_trim(key)) == ')')
|
||||||
split = merge(.not. raw,.true.,present(raw))
|
|
||||||
found = .false.
|
found = .false.
|
||||||
|
|
||||||
|
allocate(getFloats(0))
|
||||||
|
|
||||||
item => this%next
|
item => this%next
|
||||||
do while (associated(item))
|
do while (associated(item))
|
||||||
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
||||||
found = .true.
|
found = .true.
|
||||||
if (allocated(getStrings) .and. .not. cumulative) deallocate(getStrings)
|
if (.not. cumulative) then
|
||||||
|
deallocate(getFloats) ! use here rhs allocation with empty list
|
||||||
|
allocate(getFloats(0))
|
||||||
|
endif
|
||||||
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
||||||
|
do i = 2_pInt, item%string%pos(1)
|
||||||
arrayAllocated: if (.not. allocated(getStrings)) then
|
getFloats = [getFloats,IO_FloatValue(item%string%val,item%string%pos,i)]
|
||||||
if (split) then
|
enddo
|
||||||
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 arrayAllocated
|
|
||||||
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 arrayAllocated
|
|
||||||
endif
|
endif
|
||||||
item => item%next
|
item => item%next
|
||||||
end do
|
end do
|
||||||
|
|
||||||
if (present(defaultVal) .and. .not. found) then
|
if (present(defaultVal) .and. .not. found) then
|
||||||
getStrings = defaultVal
|
getFloats = defaultVal
|
||||||
found = .true.
|
found = .true.
|
||||||
endif
|
endif
|
||||||
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
||||||
|
|
||||||
end function getStrings
|
end function getFloats
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief gets array of int values for given key
|
!> @brief gets array of integer values of for a given key from a linked list
|
||||||
!> @details if key is not found exits with error unless default is given
|
!> @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.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
function getInts(this,key,defaultVal)
|
function getInts(this,key,defaultVal)
|
||||||
use IO, only: &
|
use IO, only: &
|
||||||
|
@ -610,53 +571,104 @@ end function getInts
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief gets array of float values for given key
|
!> @brief gets array of string values of for a given key from a linked list
|
||||||
!> @details if key is not found exits with error unless default is given
|
!> @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
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
function getFloats(this,key,defaultVal)
|
function getStrings(this,key,defaultVal,raw)
|
||||||
use IO, only: &
|
use IO, only: &
|
||||||
IO_error, &
|
IO_error, &
|
||||||
IO_stringValue, &
|
IO_StringValue
|
||||||
IO_FloatValue
|
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
real(pReal), dimension(:), allocatable :: getFloats
|
character(len=65536),dimension(:), allocatable :: getStrings
|
||||||
class(tPartitionedStringList), intent(in) :: this
|
class(tPartitionedStringList), intent(in) :: this
|
||||||
character(len=*), intent(in) :: key
|
character(len=*), intent(in) :: key
|
||||||
real(pReal), dimension(:), intent(in), optional :: defaultVal
|
character(len=65536),dimension(:), intent(in), optional :: defaultVal
|
||||||
type(tPartitionedStringList), pointer :: item
|
logical, intent(in), optional :: raw
|
||||||
integer(pInt) :: i
|
type(tPartitionedStringList), pointer :: item
|
||||||
logical :: found, &
|
character(len=65536) :: str
|
||||||
cumulative
|
integer(pInt) :: i
|
||||||
|
logical :: found, &
|
||||||
|
split, &
|
||||||
|
cumulative
|
||||||
|
|
||||||
cumulative = (key(1:1) == '(' .and. key(len_trim(key):len_trim(key)) == ')')
|
cumulative = (key(1:1) == '(' .and. key(len_trim(key):len_trim(key)) == ')')
|
||||||
|
split = merge(.not. raw,.true.,present(raw))
|
||||||
found = .false.
|
found = .false.
|
||||||
|
|
||||||
allocate(getFloats(0))
|
|
||||||
|
|
||||||
item => this%next
|
item => this%next
|
||||||
do while (associated(item))
|
do while (associated(item))
|
||||||
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
if (trim(IO_stringValue(item%string%val,item%string%pos,1)) == trim(key)) then
|
||||||
found = .true.
|
found = .true.
|
||||||
if (.not. cumulative) then
|
if (allocated(getStrings) .and. .not. cumulative) deallocate(getStrings)
|
||||||
deallocate(getFloats) ! use here rhs allocation with empty list
|
|
||||||
allocate(getFloats(0))
|
|
||||||
endif
|
|
||||||
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
if (item%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
||||||
do i = 2_pInt, item%string%pos(1)
|
|
||||||
getFloats = [getFloats,IO_FloatValue(item%string%val,item%string%pos,i)]
|
notAllocated: if (.not. allocated(getStrings)) then
|
||||||
enddo
|
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
|
||||||
endif
|
endif
|
||||||
item => item%next
|
item => item%next
|
||||||
end do
|
end do
|
||||||
|
|
||||||
if (present(defaultVal) .and. .not. found) then
|
if (present(defaultVal) .and. .not. found) then
|
||||||
getFloats = defaultVal
|
getStrings = defaultVal
|
||||||
found = .true.
|
found = .true.
|
||||||
endif
|
endif
|
||||||
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
if (.not. found) call IO_error(140_pInt,ext_msg=key)
|
||||||
|
|
||||||
end function getFloats
|
end function getStrings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
!> @brief DEPRECATED: REMOVE SOON
|
||||||
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
function strings(this)
|
||||||
|
use IO, only: &
|
||||||
|
IO_error, &
|
||||||
|
IO_stringValue
|
||||||
|
|
||||||
|
implicit none
|
||||||
|
class(tPartitionedStringList), intent(in) :: this
|
||||||
|
character(len=65536), dimension(:), allocatable :: strings
|
||||||
|
character(len=65536) :: string
|
||||||
|
type(tPartitionedStringList), pointer :: item
|
||||||
|
|
||||||
|
item => this%next
|
||||||
|
do while (associated(item))
|
||||||
|
string = item%string%val
|
||||||
|
GfortranBug86033: if (.not. allocated(strings)) then
|
||||||
|
allocate(strings(1),source=string)
|
||||||
|
else GfortranBug86033
|
||||||
|
strings = [strings,string]
|
||||||
|
endif GfortranBug86033
|
||||||
|
item => item%next
|
||||||
|
end do
|
||||||
|
|
||||||
|
if (size(strings) < 0_pInt) call IO_error(142_pInt) ! better to check for "allocated"?
|
||||||
|
|
||||||
|
end function strings
|
||||||
|
|
||||||
|
|
||||||
end module config
|
end module config
|
||||||
|
|
Loading…
Reference in New Issue