allow defaultVal string of variable length

This commit is contained in:
Martin Diehl 2019-03-28 07:04:48 +01:00
parent 4470ecfe4a
commit 9f2559baf5
2 changed files with 20 additions and 16 deletions

View File

@ -295,7 +295,7 @@ character(len=65536) function getString(this,key,defaultVal,raw)
implicit none
class(tPartitionedStringList), target, intent(in) :: this
character(len=*), intent(in) :: key
character(len=65536), intent(in), optional :: defaultVal
character(len=*), intent(in), optional :: defaultVal
logical, intent(in), optional :: raw
type(tPartitionedStringList), pointer :: item
logical :: found, &
@ -308,8 +308,8 @@ character(len=65536) function getString(this,key,defaultVal,raw)
found = present(defaultVal)
if (found) then
if (len_trim(defaultVal) > len(getString)) call IO_error(0,ext_msg='getString')
getString = trim(defaultVal)
if (len_trim(getString) /= len_trim(defaultVal)) call IO_error(0,ext_msg='getString')
endif
item => this
@ -445,9 +445,9 @@ function getStrings(this,key,defaultVal,raw)
implicit none
character(len=65536),dimension(:), allocatable :: getStrings
class(tPartitionedStringList), target, intent(in) :: this
class(tPartitionedStringList),target, intent(in) :: this
character(len=*), intent(in) :: key
character(len=65536),dimension(:), intent(in), optional :: defaultVal
character(len=*), dimension(:), intent(in), optional :: defaultVal
logical, intent(in), optional :: raw
type(tPartitionedStringList), pointer :: item
character(len=65536) :: str
@ -499,7 +499,12 @@ function getStrings(this,key,defaultVal,raw)
enddo
if (.not. found) then
if (present(defaultVal)) then; getStrings = defaultVal; else; call IO_error(140,ext_msg=key); endif
if (present(defaultVal)) then
if (len(defaultVal) > len(getStrings)) call IO_error(0,ext_msg='getStrings')
getStrings = defaultVal
else
call IO_error(140,ext_msg=key)
endif
endif
end function getStrings

View File

@ -9,8 +9,7 @@
!--------------------------------------------------------------------------------------------------
module plastic_isotropic
use prec, only: &
pReal, &
pInt
pReal
implicit none
private