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).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nml_schema_t), | intent(in) | :: | this | |||
| character(len=*), | intent(in) | :: | path |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | ig | ||||
| integer, | private | :: | ik | ||||
| integer, | private | :: | nk | ||||
| integer, | private | :: | u |
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). class(nml_schema_t), intent(in) :: this character(len=*), intent(in) :: path integer :: u, ig, ik, nk open (newunit=u, file=path, status="replace", action="write") write (u, "(A)") "{" write (u, "(A)") ' "groups": [' do ig = 1, size(this%groups) write (u, "(A)") " {" write (u, "(A)") ' "name": "'//json_escape(this%groups(ig)%name)//'",' write (u, "(A)") ' "doc": "'//json_escape(trim(this%groups(ig)%doc))//'",' write (u, "(A)") ' "keys": [' nk = 0 if (allocated(this%groups(ig)%keys)) nk = size(this%groups(ig)%keys) do ik = 1, nk call write_key_json(u, this%groups(ig)%keys(ik), ik == nk) end do write (u, "(A)") " ]" if (ig < size(this%groups)) then write (u, "(A)") " }," else write (u, "(A)") " }" end if end do write (u, "(A)") " ]" write (u, "(A)") "}" close (u) end subroutine schema_render_json