string_parse Subroutine

private subroutine string_parse(this, values, err_msg)

Type Bound

nml_string_key_t

Arguments

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

Calls

proc~~string_parse~~CallsGraph proc~string_parse nml_string_key_t%string_parse proc~fmt_int fmt_int proc~string_parse->proc~fmt_int

Variables

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

Source Code

   subroutine string_parse(this, values, err_msg)
      class(nml_string_key_t), intent(inout) :: this
      character(len=*), intent(in) :: values(:)
      character(len=:), allocatable, intent(out) :: err_msg
      character(len=:), allocatable :: v

      if (size(values) /= 1) then
         err_msg = "key '"//this%name//"' expects 1 value, got "//fmt_int(size(values))
         return
      end if
      v = trim(values(1))
      if (len(v) > len(this%tgt)) then
         err_msg = "key '"//this%name//"': value '"//v//"' ("//fmt_int(len(v))// &
                   " chars) exceeds target length "//fmt_int(len(this%tgt))
         return
      end if
      this%tgt = v
   end subroutine string_parse