register_ocean_diag Subroutine

private subroutine register_ocean_diag(cfg, schema)

&ocean_diag_nml: ocean diag-manager output controls. dt_out is interpreted in time_unit and converted by the post-parse cascade in read_config. vgrid enum is {layer, z_fixed}.

Arguments

Type IntentOptional Attributes Name
type(config_t), intent(in), target :: cfg
type(nml_schema_t), intent(inout) :: schema

Calls

proc~~register_ocean_diag~~CallsGraph proc~register_ocean_diag register_ocean_diag proc~group_add nml_group_t%group_add proc~register_ocean_diag->proc~group_add proc~nml_enum nml_enum proc~register_ocean_diag->proc~nml_enum proc~nml_int nml_int proc~register_ocean_diag->proc~nml_int proc~nml_logical nml_logical proc~register_ocean_diag->proc~nml_logical proc~nml_real nml_real proc~register_ocean_diag->proc~nml_real proc~nml_real_array nml_real_array proc~register_ocean_diag->proc~nml_real_array proc~nml_string nml_string proc~register_ocean_diag->proc~nml_string proc~schema_add_group nml_schema_t%schema_add_group proc~register_ocean_diag->proc~schema_add_group error error proc~group_add->error proc~lower lower proc~group_add->proc~lower proc~schema_add_group->error proc~schema_add_group->proc~lower proc~move_group move_group proc~schema_add_group->proc~move_group

Called by

proc~~register_ocean_diag~~CalledByGraph proc~register_ocean_diag register_ocean_diag proc~build_rdb_schema build_rdb_schema proc~build_rdb_schema->proc~register_ocean_diag proc~read_config_from_string_impl read_config_from_string_impl proc~read_config_from_string_impl->proc~build_rdb_schema proc~read_config_impl read_config_impl proc~read_config_impl->proc~build_rdb_schema proc~read_config read_config proc~read_config->proc~read_config_impl proc~read_config_from_string read_config_from_string proc~read_config_from_string->proc~read_config_from_string_impl proc~build_pending_handle build_pending_handle proc~build_pending_handle->proc~read_config_from_string proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~build_pending_handle proc~rdb_ocean_create_pending rdb_ocean_create_pending proc~rdb_ocean_create_pending->proc~build_pending_handle

Variables

Type Visibility Attributes Name Initial
type(nml_group_t), private :: g
integer, private, pointer :: pi
logical, private, pointer :: pl
real(kind=wp), private, pointer :: pr
real(kind=wp), private, pointer :: pra(:)
character(len=:), private, pointer :: ps

Source Code

   subroutine register_ocean_diag(cfg, schema)
      !! `&ocean_diag_nml`: ocean diag-manager output controls.  `dt_out`
      !! is interpreted in `time_unit` and converted by the post-parse
      !! cascade in read_config.  `vgrid` enum is {layer, z_fixed}.
      type(config_t), target, intent(in) :: cfg
      type(nml_schema_t), intent(inout) :: schema
      type(nml_group_t) :: g
      logical, pointer :: pl
      real(wp), pointer :: pr
      real(wp), pointer :: pra(:)
      integer, pointer :: pi
      character(len=:), pointer :: ps

      g%name = "ocean_diag"
      g%doc = "Ocean diag-manager output controls."
      pl => cfg%ocean%diag%enabled
      call g%add(nml_logical("enabled", pl, "Enable the per-step diag-manager hook"))
      ps => cfg%ocean%diag%filename
      call g%add(nml_string("filename", ps, "Output file basename (per-rank suffix appended)"))
      pr => cfg%ocean%diag%dt_out
      call g%add(nml_real("dt_out", pr, "Diag-fire cadence (in time_unit)"))
      ps => cfg%ocean%diag%vgrid
      call g%add(nml_enum("vgrid", ps, "Default output vertical grid for layer-shaped diags", &
                          allowed=[character(len=7) :: "layer", "z_fixed", "sigma", "zstar", "density"]))
      pra => cfg%ocean%diag%z_levels
      call g%add(nml_real_array("z_levels", pra, "Output z-levels when vgrid=z_fixed (positive down)", &
                                units="m"))
      pi => cfg%ocean%diag%n_z_levels
      call g%add(nml_int("n_z_levels", pi, "Number of z_levels entries used (0 = none)", min=0))
      pra => cfg%ocean%diag%sigma_levels
      call g%add(nml_real_array("sigma_levels", pra, &
                                "Output sigma fractions (0..1) for sigma output; empty = auto-uniform"))
      pi => cfg%ocean%diag%n_sigma_levels
      call g%add(nml_int("n_sigma_levels", pi, "Number of sigma_levels entries used (0 = auto)", min=0))
      pra => cfg%ocean%diag%zstar_levels
      call g%add(nml_real_array("zstar_levels", pra, &
                                "Output z* reference depths for zstar output; empty = auto-uniform", &
                                units="m"))
      pi => cfg%ocean%diag%n_zstar_levels
      call g%add(nml_int("n_zstar_levels", pi, "Number of zstar_levels entries used (0 = auto)", min=0))
      ! NVHPC 26.5 codegen workaround (verified by bisection, see PR-9 report):
      ! passing a 4th `nml_real_array(...)` function-result temporary
      ! directly to `g%add(...)` inside THIS subroutine corrupts unrelated
      ! heap state (manifests as a SIGSEGV deep in an unrelated later
      ! namelist read, e.g. the old hand-rolled `read_ocean_bc_nml`, since
      ! removed by the P4.5 schema migration — `register_ocean_bc` uses
      ! the same workaround for its twelve real_array knobs).  z_levels/sigma_levels/
      ! zstar_levels (the first 3 real_array calls here) are unaffected;
      ! materialising the result into an explicit local variable before
      ! `g%add` avoids the miscompile.  Do not "simplify" this back to the
      ! one-line call-expression form.
      block
         type(nml_real_array_key_t) :: rho_key
         pra => cfg%ocean%diag%rho_levels
         rho_key = nml_real_array("rho_levels", pra, &
                                  "Output potential-density bin edges when vgrid=density; "// &
                                  "strictly increasing, light->dense", &
                                  units="kg/m^3")
         call g%add(rho_key)
      end block
      pi => cfg%ocean%diag%n_rho_levels
      call g%add(nml_int("n_rho_levels", pi, "Number of rho_levels entries used (0 = none)", min=0))
      pl => cfg%ocean%diag%mask_vanished_layers
      call g%add(nml_logical("mask_vanished_layers", pl, &
                             "Mask below-bottom/pinched remap cells to missing_value (default off)"))
      pl => cfg%ocean%diag%reproducing_sums
      call g%add(nml_logical("reproducing_sums", pl, &
                             "Order-invariant EFP console totals + budget terms: identical "// &
                             "console on every rank count, exact drift residual "// &
                             "(.false. = the pre-v0.1.0 FP sums)"))
      ps => cfg%ocean%diag%output_precision
      call g%add(nml_enum("output_precision", ps, &
                          "Element width of the diag NetCDF data vars; "// &
                          "'single' halves the bytes written (restarts/gauges/"// &
                          "console totals stay double regardless)", &
                          allowed=[character(len=6) :: "double", "single"]))
      ps => cfg%ocean%diag%diag_remap_scheme
      call g%add(nml_enum("diag_remap_scheme", ps, &
                          "Reconstruction for the conservative diagnostic vertical remap", &
                          allowed=[character(len=6) :: "pcm", "plm", "ppm", "ppm_h4", "pqm"]))
      ps => cfg%ocean%diag%diags
      call g%add(nml_string("diags", ps, &
                            "Unified diag list modifying the default set: name[:off][:cadence][:op] "// &
                            "(e.g. 'vorticity_z:1d  KE:off  temperature:6h:mean'); "// &
                            "default empty = canonical set"))
      call schema%add_group(g)
   end subroutine register_ocean_diag