logical_parse Subroutine

private subroutine logical_parse(this, values, err_msg)

Type Bound

nml_logical_key_t

Arguments

Type IntentOptional Attributes Name
class(nml_logical_key_t), intent(inout) :: this
character(len=*), intent(in) :: values(:)
character(len=:), intent(out), allocatable :: err_msg

Calls

proc~~logical_parse~~CallsGraph proc~logical_parse nml_logical_key_t%logical_parse proc~fmt_int fmt_int proc~logical_parse->proc~fmt_int proc~lower lower proc~logical_parse->proc~lower

Variables

Type Visibility Attributes Name Initial
character(len=:), private, allocatable :: tok

Source Code

   subroutine logical_parse(this, values, err_msg)
      class(nml_logical_key_t), intent(inout) :: this
      character(len=*), intent(in) :: values(:)
      character(len=:), allocatable, intent(out) :: err_msg
      character(len=:), allocatable :: tok

      if (size(values) /= 1) then
         err_msg = "key '"//this%name//"' expects 1 value, got "//fmt_int(size(values))
         return
      end if
      tok = lower(trim(adjustl(values(1))))
      select case (tok)
      case (".true.", "t", "true")
         this%tgt = .true.
      case (".false.", "f", "false")
         this%tgt = .false.
      case default
         err_msg = "key '"//this%name//"': cannot parse logical from '"//trim(values(1))//"'"
      end select
   end subroutine logical_parse