Write one aligned key = value ! [units] doc line. When
short_only, skip default-valued keys (and leave wrote_any).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | unit | |||
| type(nml_key_box_t), | intent(in) | :: | box | |||
| logical, | intent(in) | :: | short_only | |||
| logical, | intent(inout) | :: | wrote_any |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=:), | private, | allocatable | :: | comment | |||
| logical, | private | :: | is_def | ||||
| character(len=:), | private, | allocatable | :: | lhs | |||
| character(len=:), | private, | allocatable | :: | ustr |
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