write_key_line Subroutine

private subroutine write_key_line(unit, box, short_only, wrote_any)

Write one aligned key = value ! [units] doc line. When short_only, skip default-valued keys (and leave wrote_any).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit
type(nml_key_box_t), intent(in) :: box
logical, intent(in) :: short_only
logical, intent(inout) :: wrote_any

Calls

proc~~write_key_line~~CallsGraph proc~write_key_line write_key_line default_string default_string proc~write_key_line->default_string is_default is_default proc~write_key_line->is_default value_string value_string proc~write_key_line->value_string

Called by

proc~~write_key_line~~CalledByGraph proc~write_key_line write_key_line proc~schema_write_doc_all nml_schema_t%schema_write_doc_all proc~schema_write_doc_all->proc~write_key_line proc~schema_write_doc_short nml_schema_t%schema_write_doc_short proc~schema_write_doc_short->proc~write_key_line

Variables

Type Visibility Attributes Name Initial
character(len=:), private, allocatable :: comment
logical, private :: is_def
character(len=:), private, allocatable :: lhs
character(len=:), private, allocatable :: ustr

Source Code

   subroutine write_key_line(unit, box, short_only, wrote_any)
      !! Write one aligned `key = value  ! [units] doc` line.  When
      !! `short_only`, skip default-valued keys (and leave wrote_any).
      integer, intent(in) :: unit
      type(nml_key_box_t), intent(in) :: box
      logical, intent(in) :: short_only
      logical, intent(inout) :: wrote_any
      character(len=:), allocatable :: lhs, comment, ustr
      logical :: is_def

      is_def = box%key%is_default()
      if (short_only .and. is_def) return
      wrote_any = .true.

      lhs = "  "//box%key%name//" = "//box%key%value_string()
      ustr = ""
      if (len_trim(box%key%units) > 0) ustr = "["//trim(box%key%units)//"] "
      if (is_def) then
         comment = "  ! "//ustr//trim(box%key%doc)//" (default)"
      else
         comment = "  ! "//ustr//trim(box%key%doc)// &
                   " *** non-default (default: "//box%key%default_string()//")"
      end if
      write (unit, "(A)") lhs//comment
   end subroutine write_key_line