nml_schema_t Derived Type

type, public :: nml_schema_t

The top-level schema: validated groups plus external (skipped) group names.


Inherits

type~~nml_schema_t~~InheritsGraph type~nml_schema_t nml_schema_t type~nml_group_t nml_group_t type~nml_schema_t->type~nml_group_t groups type~nml_key_box_t nml_key_box_t type~nml_group_t->type~nml_key_box_t keys type~nml_key_t nml_key_t type~nml_key_box_t->type~nml_key_t key

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: external_names(:)

Names of groups whose bodies are skipped without validation.

type(nml_group_t), public, allocatable :: groups(:)

Registered, validated groups.


Type-Bound Procedures

procedure, public :: add_external_group => schema_add_external_group

  • private subroutine schema_add_external_group(this, name)

    Register a group name the schema knows exists but does NOT validate (its body is skipped silently).

    Arguments

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

procedure, public :: add_group => schema_add_group

  • private subroutine schema_add_group(this, g)

    MOVE a locally-built group into the schema — g is consumed (allocatables transferred). Move semantics on purpose: intrinsic assignment deep-copies the polymorphic key boxes, which NVHPC miscompiles (heap corruption); move_alloc transfers descriptors only. Error stop on duplicate name.

    Arguments

    Type IntentOptional Attributes Name
    class(nml_schema_t), intent(inout) :: this
    type(nml_group_t), intent(inout) :: g

procedure, public :: find_group => schema_find_group

  • private function schema_find_group(this, name) result(idx)

    Index of name in the schema’s groups, 0 if absent.

    Arguments

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

    Return Value integer

procedure, public :: is_external => schema_is_external

  • private function schema_is_external(this, name) result(yes)

    True if name is a registered external group.

    Arguments

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

    Return Value logical

procedure, public :: parse => schema_parse

  • private subroutine schema_parse(this, path, status, errors)

    Parse and validate the namelist file at path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(nml_schema_t), intent(inout) :: this
    character(len=*), intent(in) :: path
    integer, intent(out), optional :: status
    character(len=:), intent(out), optional, allocatable :: errors(:)

procedure, public :: parse_lines => schema_parse_lines

  • private subroutine schema_parse_lines(this, lines, n_lines, status, errors)

    In-memory sibling of schema_parse: validate + apply a namelist already held as a lines(:) character array (no file touch). Same error-return convention as schema_parse.

    Arguments

    Type IntentOptional Attributes Name
    class(nml_schema_t), intent(inout) :: this
    character(len=*), intent(in) :: lines(:)
    integer, intent(in) :: n_lines
    integer, intent(out), optional :: status
    character(len=:), intent(out), optional, allocatable :: errors(:)

procedure, public :: render_json => schema_render_json

  • private subroutine schema_render_json(this, path)

    Emit the schema as JSON: one object per group, nesting one object per key. This is the ONLY thing tools/gen_python_config.py reads – it parses no Fortran source, mirroring the precedent schema_render_markdown already set for docs/generated_nml_knobs.md. &ocean_bc_nml is NOT here – it is registered via add_external_group (see rdb_config.F90), so it carries no keys on this schema; python/rdb/_config_bc.py is a hand-written stub with its own drift test (see docs D5.7).

    Arguments

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

procedure, public :: render_markdown => schema_render_markdown

  • private subroutine schema_render_markdown(this, path)

    Render the schema as Markdown: per group a heading, doc line, and a knob table.

    Arguments

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

procedure, public :: write_doc_all => schema_write_doc_all

  • private subroutine schema_write_doc_all(this, path)

    Write every group and key as valid namelist with aligned docs.

    Arguments

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

procedure, public :: write_doc_short => schema_write_doc_short

  • 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.

    Arguments

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

Source Code

   type :: nml_schema_t
      !! The top-level schema: validated groups plus external (skipped)
      !! group names.
      type(nml_group_t), allocatable :: groups(:)
         !! Registered, validated groups.
      character(len=:), allocatable :: external_names(:)
         !! Names of groups whose bodies are skipped without validation.
   contains
      procedure :: add_group => schema_add_group
      procedure :: add_external_group => schema_add_external_group
      procedure :: parse => schema_parse
      procedure :: parse_lines => schema_parse_lines
      procedure :: write_doc_all => schema_write_doc_all
      procedure :: write_doc_short => schema_write_doc_short
      procedure :: render_markdown => schema_render_markdown
      procedure :: render_json => schema_render_json
      procedure :: find_group => schema_find_group
      procedure :: is_external => schema_is_external
   end type nml_schema_t