subroutine register_default_diags(state, dt_out, specs, default_coord)
!! Register the canonical ocean diagnostic variable set. Called once
!! from setup (driver init or test) after `state%diag%init`. When
!! `specs` (parsed `&ocean_diag_nml diags`) is present, each canonical
!! diagnostic consults it: a `:off` entry skips registration entirely,
!! and `:cadence` / `:op` / `:coord` attributes override the defaults.
!! `default_coord` (the global `&ocean_diag_nml vgrid`, default LAYER)
!! sets the output vgrid for layered diagnostics absent a per-diag
!! `:coord`. Absent `specs` + LAYER default => the canonical defaults,
!! bit-identical to the legacy behaviour. The canonical set also
!! gains `ice_conc` / `ice_thick` when `&ocean_ice_nml enable`.
type(ocean_state_t), intent(inout), target :: state
real(wp), intent(in), optional :: dt_out
type(diag_spec_t), intent(in), optional :: specs(:)
integer, intent(in), optional :: default_coord
integer :: nz, dcoord
real(wp) :: dtout
dtout = 3600.0_wp
if (present(dt_out)) dtout = dt_out
dcoord = DIAG_VGRID_LAYER
if (present(default_coord)) dcoord = default_coord
nz = state%multilayer%nz_ml
call register_one_canonical(state, specs, dcoord, dtout, "SSH", "m", fill_ssh, &
1, DIAG_OP_INSTANT, "sea_surface_height_above_geoid", &
"sea_surface_height")
if (state%multilayer%idx_temperature > 0) then
call register_one_canonical(state, specs, dcoord, dtout, "temperature", "degC", &
fill_temperature, nz, DIAG_OP_MEAN, &
"sea_water_potential_temperature", &
"sea_water_potential_temperature")
end if
if (state%multilayer%idx_salinity > 0) then
call register_one_canonical(state, specs, dcoord, dtout, "salinity", "psu", &
fill_salinity, nz, DIAG_OP_MEAN, &
"sea_water_salinity", "sea_water_salinity")
end if
if (state%multilayer%idx_age > 0) then
call register_one_canonical(state, specs, dcoord, dtout, "age", "s", fill_age, &
nz, DIAG_OP_MEAN, "ideal_age_of_sea_water", &
"age_of_sea_water")
end if
if (state%multilayer%idx_pseudo_salt > 0) then
call register_one_canonical(state, specs, dcoord, dtout, "pseudo_salt", "psu", &
fill_pseudo_salt, nz, DIAG_OP_MEAN, &
"pseudo_salt_passive_tracer")
call register_one_canonical(state, specs, dcoord, dtout, "pseudo_salt_diff", "psu", &
fill_pseudo_salt_diff, nz, DIAG_OP_MEAN, &
"difference_between_pseudo_salt_and_salt")
end if
call register_one_canonical(state, specs, dcoord, dtout, "u", "m s-1", fill_u_centre, &
nz, DIAG_OP_MEAN, "eastward_velocity_at_cell_centre")
call register_one_canonical(state, specs, dcoord, dtout, "v", "m s-1", fill_v_centre, &
nz, DIAG_OP_MEAN, "northward_velocity_at_cell_centre")
call register_one_canonical(state, specs, dcoord, dtout, "KE", "m2 s-2", fill_ke, &
nz, DIAG_OP_MEAN, "kinetic_energy_per_unit_mass")
if (state%epbl%enable) then
call register_one_canonical(state, specs, dcoord, dtout, "MLD_EPBL", "m", &
fill_mld_epbl, 1, DIAG_OP_MEAN, &
"epbl_active_mixing_layer_depth")
call register_one_canonical(state, specs, dcoord, dtout, "Kd_EPBL", "m2 s-1", &
fill_kd_epbl, nz, DIAG_OP_MEAN, &
"epbl_diffusivity_at_layer_bottom_interface")
end if
if (state%kshear%enable) then
call register_one_canonical(state, specs, dcoord, dtout, "Kd_KSHEAR", "m2 s-1", &
fill_kd_kshear, nz, DIAG_OP_MEAN, &
"kappa_shear_diffusivity_at_layer_bottom_interface")
end if
if (state%ice%enable) then
call register_one_canonical(state, specs, dcoord, dtout, "ice_conc", "1", &
fill_ice_conc, 1, DIAG_OP_MEAN, &
"sea_ice_area_fraction", "sea_ice_area_fraction")
! ice_thick carries NO CF standard_name: the CF `sea_ice_thickness`
! conventionally means actual floe thickness, but this is the
! grid-mean (effective) thickness mice/ICE_RHO_ICE — so only the
! long_name identifies it (omit standard_name, as u/v/KE do).
call register_one_canonical(state, specs, dcoord, dtout, "ice_thick", "m", &
fill_ice_thick, 1, DIAG_OP_MEAN, &
"grid_mean_sea_ice_thickness")
end if
end subroutine register_default_diags