first try of unifying getInts and getIntArray
This commit is contained in:
parent
7388cbb940
commit
999d0d774e
|
@ -433,7 +433,6 @@ function getStrings(this,key)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief gets array of int values for given key
|
!> @brief gets array of int values for given key
|
||||||
!> @details if key is not found exits with error unless default is given
|
!> @details if key is not found exits with error unless default is given
|
||||||
|
@ -451,25 +450,34 @@ function getIntArray(this,key,defaultVal)
|
||||||
integer(pInt),dimension(:), intent(in), optional :: defaultVal
|
integer(pInt),dimension(:), intent(in), optional :: defaultVal
|
||||||
type(tPartitionedStringList), pointer :: list_tmp
|
type(tPartitionedStringList), pointer :: list_tmp
|
||||||
integer(pInt) :: i
|
integer(pInt) :: i
|
||||||
|
logical :: found
|
||||||
|
logical :: cumulative
|
||||||
|
|
||||||
|
cumulative = (key(1:1) == '(' .and. key(len_trim(key):len_trim(key)) == ')')
|
||||||
|
found = present(defaultVal)
|
||||||
|
|
||||||
|
if (present(defaultVal)) then
|
||||||
|
getIntArray = defaultVal
|
||||||
|
else
|
||||||
allocate(getIntArray(0))
|
allocate(getIntArray(0))
|
||||||
|
endif
|
||||||
|
|
||||||
list_tmp => this%next
|
list_tmp => this%next
|
||||||
do
|
do
|
||||||
endOfList: if (.not. associated(list_tmp)) then
|
endOfList: if (.not. associated(list_tmp)) then
|
||||||
if(present(defaultVal)) then
|
if(.not. found) call IO_error(140_pInt,ext_msg=key)
|
||||||
getIntArray = defaultVal
|
|
||||||
exit
|
exit
|
||||||
else
|
|
||||||
call IO_error(140_pInt,ext_msg=key)
|
|
||||||
endif
|
|
||||||
endif endOfList
|
endif endOfList
|
||||||
foundKey: if (trim(IO_stringValue(list_tmp%string%val,list_tmp%string%pos,1))==trim(key)) then
|
foundKey: if (trim(IO_stringValue(list_tmp%string%val,list_tmp%string%pos,1))==trim(key)) then
|
||||||
|
if (.not. cumulative) then
|
||||||
|
deallocate(getIntArray) ! use here rhs allocation with empty list
|
||||||
|
allocate(getIntArray(0))
|
||||||
|
endif
|
||||||
|
found = .true.
|
||||||
if (list_tmp%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
if (list_tmp%string%pos(1) < 2_pInt) call IO_error(143_pInt,ext_msg=key)
|
||||||
do i = 2_pInt, list_tmp%string%pos(1)
|
do i = 2_pInt, list_tmp%string%pos(1)
|
||||||
getIntArray = [getIntArray,IO_IntValue(list_tmp%string%val,list_tmp%string%pos,i)]
|
getIntArray = [getIntArray,IO_IntValue(list_tmp%string%val,list_tmp%string%pos,i)]
|
||||||
enddo
|
enddo
|
||||||
exit
|
|
||||||
endif foundKey
|
endif foundKey
|
||||||
list_tmp => list_tmp%next
|
list_tmp => list_tmp%next
|
||||||
end do
|
end do
|
||||||
|
|
Loading…
Reference in New Issue