Get option data values (array).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(option), | intent(in) | :: | self | Option data. |
||
class(*), | intent(inout) | :: | val(1:) | Value. |
||
character, | intent(in), | optional | :: | delimiter | Delimiter used for separating values. |
|
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
subroutine get_a_option(self, val, delimiter, error)
!< Get option data values (array).
class(option), intent(in) :: self !< Option data.
class(*), intent(inout) :: val(1:) !< Value.
character(*), intent(in), optional :: delimiter !< Delimiter used for separating values.
integer(I4P), intent(out), optional :: error !< Error code.
character(len=:), allocatable :: dlm !< Dummy string for delimiter handling.
integer(I4P) :: Nv !< Number of values.
type(string), allocatable :: valsV(:) !< String array of values.
integer(I4P) :: errd !< Error code.
character(len=:), allocatable :: buffer !< Dummy buffer.
integer(I4P) :: v !< Counter.
errd = ERR_OPTION_VALS
dlm = ' ' ; if (present(delimiter)) dlm = delimiter
if (self%ovals%is_allocated()) then
call self%ovals%split(tokens=valsV, sep=dlm)
Nv = size(valsV, dim=1)
select type(val)
#ifdef _R16P
type is(real(R16P))
do v=1, Nv
val(v) = valsV(v)%to_number(kind=1._R16P)
enddo
#endif
type is(real(R8P))
do v=1, Nv
val(v) = valsV(v)%to_number(kind=1._R8P)
enddo
type is(real(R4P))
do v=1, Nv
val(v) = valsV(v)%to_number(kind=1._R4P)
enddo
type is(integer(I8P))
do v=1, Nv
val(v) = valsV(v)%to_number(kind=1_I8P)
enddo
type is(integer(I4P))
do v=1, Nv
val(v) = valsV(v)%to_number(kind=1_I4P)
enddo
#ifndef _NVF
type is(integer(I2P))
do v=1, Nv
val(v) = valsV(v)%to_number(kind=1_I2P)
enddo
#endif
type is(integer(I1P))
do v=1, Nv
val(v) = valsV(v)%to_number(kind=1_I1P)
enddo
type is(logical)
do v=1, Nv
buffer = valsV(v)%chars()
read(buffer, *)val(v)
enddo
type is(character(*))
do v=1, Nv
val(v) = valsV(v)%chars()
enddo
endselect
errd = 0
endif
if (present(error)) error = errd
endsubroutine get_a_option