get_option Subroutine

private subroutine get_option(self, val, error)

for getting option data value (scalar).

Arguments

TypeIntentOptionalAttributesName
class(option), intent(in) :: self

Option data.

class(*), intent(inout) :: val

Value.

integer(kind=I4P), intent(out), optional :: error

Error code.


Contents

Source Code


Source Code

  subroutine get_option(self, val, error)
  !< for getting option data value (scalar).
  class(option), intent(in)            :: self   !< Option data.
  class(*),      intent(inout)         :: val    !< Value.
  integer(I4P),  intent(out), optional :: error  !< Error code.
  integer(I4P)                         :: errd   !< Error code.
  character(len=:), allocatable        :: buffer !< Dummy buffer.

  errd = ERR_OPTION_VALS
  if (self%ovals%is_allocated()) then
    select type(val)
#ifdef _R16P
    type is(real(R16P))
      val = self%ovals%to_number(kind=1._R16P)
#endif
    type is(real(R8P))
      val = self%ovals%to_number(kind=1._R8P)
    type is(real(R4P))
      val = self%ovals%to_number(kind=1._R4P)
    type is(integer(I8P))
      val = self%ovals%to_number(kind=1_I8P)
    type is(integer(I4P))
      val = self%ovals%to_number(kind=1_I4P)
#ifndef _NVF
    type is(integer(I2P))
      val = self%ovals%to_number(kind=1_I2P)
#endif
    type is(integer(I1P))
      val = self%ovals%to_number(kind=1_I1P)
    type is(logical)
      buffer = self%ovals%chars()
      read(buffer, *)val
    type is(character(*))
      val = self%ovals%chars()
    endselect
    errd = 0
  endif
  if (present(error)) error = errd
  endsubroutine get_option