Puts a GEOPOTENTIAL T(z)/S(z) profile onto the seeded layer
centres (&ocean_zinit_nml) and writes the multilayer tracer slots
as hTr = value * h_layer. Two sources, &ocean_zinit_nml source:
"file" (default) — reads pre-regridded T + S from a
model-grid NetCDF and interpolates linearly in depth.
File is PRE-REGRIDDED to nx_phys x ny_phys — no in-core
horizontal interpolation. Vertical interp is
point-linear-in-depth, constant extrapolation beyond the source
range. Dry columns (wet_mask <= 0) get the namelist
land_fill_t/_s constants. Interior cells only — ghosts keep
whatever the analytical IC seeded, because the file carries no
data for them."linear" — an ANALYTIC affine profile,
T(z) = lin_t_ref + lin_dt_dz*z (and the salinity twin) with
z the GEOPOTENTIAL height, positive UP, zero at the z = 0
datum, i.e. z = -z_ctr. Needs no file, so it fills the FULL
array INCLUDING ghosts and land columns (the analytic formula
is defined everywhere — same reasoning as the formula
bathymetry setters, and it keeps a wall-adjacent EOS
evaluation off the rho_0 fallback). This is the profile an
idealised ice-shelf cavity needs: &tracer_nml T_init_surface
/ T_init_bottom are linear in LAYER INDEX, which under a
terrain-following coordinate with a SLOPING lid tilts the
isopycnals with the coordinate and is therefore NOT a state of
rest.z = 0, not from the column topbuild_z_ctr takes the geopotential depth of the column TOP
(z_top, positive-down) and adds the thickness above each layer
centre. In the open ocean z_top = 0 and this is the free-surface
datum. Under an ice shelf the water column starts z_draft metres
down, so z_top = metrics%z_draft(i,j); without it a geopotential
profile lands z_draft metres too shallow on every shelf column
and the isopycnals tilt with the ice base. z_draft reaches here
as an OPTIONAL ghosted (nx_total, ny_total) argument: absent (the
no-cavity path) is z_top = 0 and bit-identical to the original.
Runs at seed time, HOST-side, BEFORE ocean_state_enter_data, so
it uses plain host do loops (NOT do concurrent); the later
enter_data copies the host-resident arrays up. The module is only
compiled with RDB_ENABLE_NETCDF=ON (the file reader needs it), so
the "linear" source currently inherits that build requirement
even though it opens nothing.
match (nx_phys, ny_phys). Returns .false. on mismatch or
I/O error; does NOT error stop — safe from test code.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename | |||
| character(len=*), | intent(in) | :: | t_var | |||
| integer, | intent(in) | :: | nx_phys | |||
| integer, | intent(in) | :: | ny_phys |
True iff z_draft is the FULL ghosted (nx_total, ny_total)
array the seeders index with (ng+i, ng+j) — i.e. it matches
h_layer’s horizontal extent. Guards the (1, 1) placeholder
ocean_metrics_t allocates when the cavity is off from ever
being read as a field.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | z_draft(:,:) | |||
| type(multilayer_state_t), | intent(in) | :: | ms |
Affine profile v(z) = v_ref + dv_dz*z evaluated at
geopotential height z = -z_depth, i.e.
v = v_ref - dv_dz*z_depth.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | v_ref | |||
| real(kind=wp), | intent(in) | :: | dv_dz | |||
| real(kind=wp), | intent(in) | :: | z_depth |
Translate a raw nc_check-style status (0 = ok) from one of the
nc_* reader calls in seed_ts_from_zfile/read_dims into the
caller’s ierr contract: .true. on success; on failure,
.false. with ierr = OCEAN_STATUS_ERR_IO when ierr is
present (closing ncid first, when given, so a mid-read failure
does not leak the file handle), or error stops with the SAME
generic text nc_check itself would have used had ierr never
been threaded through — keeps the legacy (no ierr) behaviour
byte-identical while unblocking the ierr-present return path
(F1/F2 of the P0.1 review).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | local_ierr | |||
| integer, | intent(out), | optional | :: | ierr | ||
| integer, | intent(in), | optional | :: | ncid |
Layer-centre GEOPOTENTIAL depths (positive-down from the z = 0
datum) from a column of layer thicknesses. Bottom-up: k=1 bed,
k=nz_ml surface.
z_ctr(k) = z_top + sum_{k'=k+1..nz_ml} h(k') + 0.5*h(k).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | h_layer(nz_ml) | |||
| integer, | intent(in) | :: | nz_ml | |||
| real(kind=wp), | intent(in) | :: | z_top | |||
| real(kind=wp), | intent(out) | :: | z_ctr(nz_ml) |
Linear-in-depth interpolation of source profile v_src on
ascending depths z_src onto target depths z_ctr, with
CONSTANT extrapolation beyond the source range. Comparisons in
depth space so index orientations never need reconciling.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | z_src(nz_src) | |||
| real(kind=wp), | intent(in) | :: | v_src(nz_src) | |||
| integer, | intent(in) | :: | nz_src | |||
| real(kind=wp), | intent(in) | :: | z_ctr(nz_ml) | |||
| integer, | intent(in) | :: | nz_ml | |||
| real(kind=wp), | intent(out) | :: | v_out(nz_ml) |
Read T/S from the configured z-level NetCDF and overwrite the
tracer slots with the depth-interpolated profiles. Wet columns
interpolate; dry columns get the namelist land-fill constants.
Must be called AFTER bathymetry, the uniform h_layer seed, and
wet_mask are in place. Takes the multilayer slot directly (not
the full ocean state) to avoid a circular dependency.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(multilayer_state_t), | intent(inout) | :: | ms | |||
| type(hgrid_t), | intent(in) | :: | grid | |||
| type(ocean_zinit_config_t), | intent(in) | :: | cfg | |||
| integer, | intent(out), | optional | :: | ierr |
Non-zero on a malformed/mismatched z-level IC file when
present; absent behaves as today ( |
|
| real(kind=wp), | intent(in), | optional | :: | z_draft(:,:) |
Ice-base depth (m, positive-down, |
Seed T and S from the ANALYTIC affine geopotential profiles
T(z) = lin_t_ref + lin_dt_dz*z, S(z) = lin_s_ref +
lin_ds_dz*z (z positive UP, zero at the z = 0 datum),
sampled at each layer centre’s TRUE geopotential depth and
written as hTr = value * h_layer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(multilayer_state_t), | intent(inout) | :: | ms | |||
| type(ocean_zinit_config_t), | intent(in) | :: | cfg | |||
| integer, | intent(out), | optional | :: | ierr |
Non-zero on a malformed |
|
| real(kind=wp), | intent(in), | optional | :: | z_draft(:,:) |
Ice-base depth (m, positive-down), FULL ghosted
|
Resolve a variable id: try the namelist override name first
(when non-blank), then the documented fallbacks in order.
Error-stops with a descriptive message when none is found.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ncid | |||
| character(len=*), | intent(in) | :: | override | |||
| character(len=*), | intent(in) | :: | fallbacks(:) | |||
| character(len=*), | intent(in) | :: | label | |||
| integer, | intent(out) | :: | varid | |||
| integer, | intent(out), | optional | :: | ierr |
Non-zero when no matching variable is found, when present;
absent behaves as today ( |
Validate the T/S variable’s dims against the model grid and
detect whether the file is C-ordered (z, y, x) =>
needs_transpose = .true. (by the first Fortran dim name).
Returns source z-level count nz_src; error-stops on mismatch.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ncid | |||
| integer, | intent(in) | :: | varid | |||
| type(hgrid_t), | intent(in) | :: | grid | |||
| integer, | intent(out) | :: | nz_src | |||
| logical, | intent(out) | :: | needs_transpose | |||
| integer, | intent(out), | optional | :: | ierr |
Non-zero on a dimensionality/shape mismatch when present;
absent behaves as today ( |
Read this tile’s (nx, ny, nz_src) window of a 3D T/S variable
(the file holds the WHOLE grid; the window starts at global cell
(io+1, jo+1)) with a start/count read, permuting from the file’s
Fortran storage order. On an undecomposed grid the window is the
whole variable.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ncid | |||
| integer, | intent(in) | :: | varid | |||
| real(kind=wp), | intent(out) | :: | dst(nx,ny,nz_src) | |||
| integer, | intent(in) | :: | nx | |||
| integer, | intent(in) | :: | ny | |||
| integer, | intent(in) | :: | nz_src | |||
| logical, | intent(in) | :: | needs_transpose | |||
| integer, | intent(in) | :: | io |
Global offsets of the tile ( |
||
| integer, | intent(in) | :: | jo |
Global offsets of the tile ( |
||
| integer, | intent(out), | optional | :: | ierr |
Non-zero on a read failure when present; absent behaves as
today ( |