public subroutine apply_diag_selection(state, spec, dt_out, default_coord)
Configure the ocean diagnostic set from the unified
&ocean_diag_nml diags selection string. Single production entry
point: parses spec once, registers the canonical defaults
(consulting the spec for per-diagnostic :off skips and
:cadence / :op / :coord overrides), then registers any spec
entries that name a derived-catalog diagnostic (with their overrides).
default_coord (a DIAG_VGRID_*, default LAYER) is the global
output vgrid (&ocean_diag_nml vgrid) applied to layered diagnostics
that don’t carry a per-diag :coord.
An empty / blank spec + LAYER default reproduces the canonical set
exactly (bit-identical). A spec name that is neither canonical nor
in the derived catalog fails loud via register_derived. A :off
on a non-canonical name that is not registered is a harmless no-op.
Must be called AFTER the output-level setters (set_output_z_levels
/ set_output_sigma_levels / set_output_zstar_levels /
set_output_density_levels) so non-layer diagnostics size their
remap targets correctly.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
subroutine apply_diag_selection(state,spec,dt_out,default_coord)!! Configure the ocean diagnostic set from the unified!! `&ocean_diag_nml diags` selection string. Single production entry!! point: parses `spec` once, registers the canonical defaults!! (consulting the spec for per-diagnostic `:off` skips and!! `:cadence` / `:op` / `:coord` overrides), then registers any spec!! entries that name a derived-catalog diagnostic (with their overrides).!!!! `default_coord` (a `DIAG_VGRID_*`, default LAYER) is the global!! output vgrid (`&ocean_diag_nml vgrid`) applied to layered diagnostics!! that don't carry a per-diag `:coord`.!!!! An empty / blank `spec` + LAYER default reproduces the canonical set!! exactly (bit-identical). A spec name that is neither canonical nor!! in the derived catalog fails loud via `register_derived`. A `:off`!! on a non-canonical name that is not registered is a harmless no-op.!!!! Must be called AFTER the output-level setters (`set_output_z_levels`!! / `set_output_sigma_levels` / `set_output_zstar_levels` /!! `set_output_density_levels`) so non-layer diagnostics size their!! remap targets correctly.type(ocean_state_t),intent(inout),target::statecharacter(len=*),intent(in)::specreal(wp),intent(in),optional::dt_outinteger,intent(in),optional::default_coordtype(diag_spec_t),allocatable::specs(:)integer::i,op,dcoord,coordreal(wp)::dtout,dtodtout=3600.0_wpif(present(dt_out))dtout=dt_outdcoord=DIAG_VGRID_LAYERif(present(default_coord))dcoord=default_coordspecs=parse_diag_spec(spec)! Canonical set, with the spec's per-diagnostic skips / overrides.call register_default_diags(state,dt_out=dtout,specs=specs,default_coord=dcoord)! Derived-catalog additions: any spec entry that is not a canonical! diagnostic and is not turned off.do i=1,size(specs)if(specs(i)%off)cycle if(is_canonical_diag_name(trim(specs(i)%name)))then if(.not.state%diag%is_registered(trim(specs(i)%name)))then call global_logger%warning(&"&ocean_diag_nml diags requested '"//trim(specs(i)%name)//&"', which is a canonical diagnostic but is NOT registered — it will "//&"be absent from the output. "//gate_clause(trim(specs(i)%name)))end if cycle end ifop=DIAG_OP_INSTANTif(specs(i)%time_op/=DIAG_OP_UNSET)op=specs(i)%time_opdto=dtoutif(specs(i)%dt_out>0.0_wp)dto=specs(i)%dt_outcoord=dcoordif(specs(i)%coord/=DIAG_COORD_UNSET)coord=specs(i)%coordcall register_derived(state,trim(specs(i)%name),time_op=op,dt_out=dto,coord=coord)end do end subroutine apply_diag_selection