schema_write_doc_short Subroutine

private subroutine schema_write_doc_short(this, path)

Write only non-default keys (MOM6 parameter_doc.short). Groups with no non-default keys are omitted entirely.

Type Bound

nml_schema_t

Arguments

Type IntentOptional Attributes Name
class(nml_schema_t), intent(in) :: this
character(len=*), intent(in) :: path

Calls

proc~~schema_write_doc_short~~CallsGraph proc~schema_write_doc_short nml_schema_t%schema_write_doc_short is_default is_default proc~schema_write_doc_short->is_default proc~write_key_line write_key_line proc~schema_write_doc_short->proc~write_key_line proc~write_key_line->is_default default_string default_string proc~write_key_line->default_string value_string value_string proc~write_key_line->value_string

Variables

Type Visibility Attributes Name Initial
integer, private :: ig
integer, private :: ik
integer, private :: u
logical, private :: wrote_any

Source Code

   subroutine schema_write_doc_short(this, path)
      !! Write only non-default keys (MOM6 parameter_doc.short).  Groups
      !! with no non-default keys are omitted entirely.
      class(nml_schema_t), intent(in) :: this
      character(len=*), intent(in) :: path
      integer :: u, ig, ik
      logical :: wrote_any

      open (newunit=u, file=path, status="replace", action="write")
      do ig = 1, size(this%groups)
         wrote_any = .false.
         if (allocated(this%groups(ig)%keys)) then
            ! First pass: does any non-default key exist in this group?
            do ik = 1, size(this%groups(ig)%keys)
               if (.not. this%groups(ig)%keys(ik)%key%is_default()) wrote_any = .true.
            end do
         end if
         if (.not. wrote_any) cycle
         write (u, "(A)") "&"//this%groups(ig)%name//"_nml"
         do ik = 1, size(this%groups(ig)%keys)
            call write_key_line(u, this%groups(ig)%keys(ik), .true., wrote_any)
         end do
         write (u, "(A)") "/"
      end do
      close (u)
   end subroutine schema_write_doc_short