Defines vcoord_t, a lightweight config type for the vertical coordinate.
Type-bound procedures dispatch via select case on an integer enum (no
runtime polymorphism) so the type is GPU-safe.
Implemented (VCOORD_*):
- SIGMA — pure terrain-following (no remap).
- ZSIGMA — smoothstep blend sigma (shallow) → fixed z-levels (deep);
reduces sigma PGE on steep bathymetry. Conservative remap.
- ZSTAR — z-lite SSH-tracking: a global z_ref stretched per column
by H/z_ref(nz) so sum(dz)=H, relative spacing preserved as
η changes (no sigma distortion at large SSH).
- ZSTAR_FULL — per-column z_ref from local bathymetry (vanishing layers).
- ZSTAR_SIGMA — smoothstep blend of sigma (shallow) and z-lite (deep).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | STRETCH_LOG | = | 1 | |
| integer, | public, | parameter | :: | STRETCH_UNIFORM | = | 0 | |
| integer, | public, | parameter | :: | VCOORD_HMIN_INERT | = | 0 |
Geometric families (ZSTAR_FULL / Z_FIXED): |
| integer, | public, | parameter | :: | VCOORD_HMIN_KEEPALIVE | = | 1 |
Density families (RHO / HYCOM): collapsed layers carry tracer mass
and must SURVIVE the remap drain ⇒ that path floors at
|
| integer, | public, | parameter | :: | VCOORD_HMIN_UNUSED | = | 2 |
Every other family never reads |
| integer, | public, | parameter | :: | ZFIXED_DZ_ERR_COUNT | = | 1 |
List length (leading positive entries) is not |
| integer, | public, | parameter | :: | ZFIXED_DZ_ERR_PROFILE | = | 4 |
Unrecognised profile code. |
| integer, | public, | parameter | :: | ZFIXED_DZ_ERR_TOO_DEEP | = | 3 |
tanh: |
| integer, | public, | parameter | :: | ZFIXED_DZ_ERR_VALUE | = | 2 |
A tanh parameter is out of range ( |
| integer, | public, | parameter | :: | ZFIXED_DZ_OK | = | 0 |
|
| integer, | public, | parameter | :: | ZFIXED_PROFILE_INVALID | = | -1 |
Unrecognised |
| integer, | public, | parameter | :: | ZFIXED_PROFILE_LIST | = | 1 |
Explicit nominal thicknesses, |
| integer, | public, | parameter | :: | ZFIXED_PROFILE_TANH | = | 2 |
Hyperbolic-tangent stretching from |
| integer, | public, | parameter | :: | ZFIXED_PROFILE_UNIFORM | = | 0 |
|
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | public | :: | blend_width | = | 50.0_wp |
Width of the blending zone (m) |
|
| integer, | public | :: | coord_type | = | VCOORD_SIGMA |
Vertical coordinate type (VCOORD_SIGMA, VCOORD_ZSIGMA, etc.) |
|
| real(kind=wp), | public | :: | depth_transition | = | 100.0_wp |
Depth (m) where sigma-to-z blending begins |
|
| real(kind=wp), | public, | allocatable | :: | dsig_target(:) |
(nz) Target sigma-like layer fractions, sum = 1.0 |
||
| integer, | public | :: | nz | = | 0 |
Number of vertical layers |
|
| integer, | public | :: | remap_method | = | REMAP_PPM |
Remap reconstruction order (REMAP_PCM/PLM/PPM/PPM_H4/PQM). Default PPM.
PQM falls back to PPM for nz < 5 (see |
|
| real(kind=wp), | public, | allocatable | :: | z_ref(:) |
(nz+1) Reference interface depths for z-levels (m, positive down). Only allocated for coord types that use z-levels. |
||
| real(kind=wp), | public | :: | zstar_h_min | = | 1.0e-4_wp |
Vanishing-layer floor (m). Layers that would land below the
local bed get clipped to this thickness rather than going to zero.
Deliberately BELOW |
|
| real(kind=wp), | public | :: | zstar_h_surf_target | = | 0.0_wp |
Target physical thickness of the surface layer (m). 0 => auto: uniform per-column (falls back to lite behaviour per column). Set > 0 to anchor the surface layer at a fixed thickness regardless of total depth H. |
|
| integer, | public | :: | zstar_n_surf | = | 0 |
Number of “fine” near-surface layers using stretching. 0 => auto (use max(1, nz/3)) |
|
| integer, | public | :: | zstar_stretching | = | 1 |
Surface-concentration stretching: 1=log, 0=uniform |
| procedure, public, non_overridable :: cleanup => vcoord_cleanup | |
| procedure, public, non_overridable :: enter_data => vcoord_enter_data | |
| procedure, public, non_overridable :: exit_data => vcoord_exit_data | |
| procedure, public, non_overridable :: init => vcoord_init | |
| procedure, public, non_overridable :: needs_remap => vcoord_needs_remap |
Convert a namelist string to a REMAP_* constant.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | str |
Convert a namelist string to a STRETCH_* constant.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | str |
Convert a namelist string to a VCOORD_* constant (shared by coastal
and ocean backends). Unrecognised ⇒ default_code if given, else
VCOORD_SIGMA. Ocean callers pass default_code = VCOORD_EULERIAN_Z.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | str | |||
| integer, | intent(in), | optional | :: | default_code |
&vcoord_nml z_fixed_profile string -> ZFIXED_PROFILE_* code
(ZFIXED_PROFILE_INVALID for anything else — the caller fails loud).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | str |
Is zstar_h_min coherent with the contract coord_type gives it?
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | coord_type |
|
||
| real(kind=wp), | intent(in) | :: | h_min |
The configured |
Which of the TWO contracts zstar_h_min carries for coord_type.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | coord_type |
|
Returns .true. if this coordinate type requires conservative
vertical remapping after the barotropic step. Pure sigma does
not — layers are simply rescaled by dsig(k) * H.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vcoord_t), | intent(in) | :: | self |
Compute target layer thicknesses for a single water column.
Pure, called from do concurrent (one thread per column).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | coord_type | |||
| integer, | intent(in) | :: | nz | |||
| real(kind=wp), | intent(in) | :: | H |
Total water depth at this column (m) |
||
| real(kind=wp), | intent(in) | :: | dsig(nz) |
Reference sigma fractions (sum = 1), ROMS-ordered: dsig(1) bottom, dsig(nz) surface. Currently uniform 1/nz. |
||
| real(kind=wp), | intent(in) | :: | z_ref(0:nz) |
Reference z-level interface depths (m, positive down).
|
||
| real(kind=wp), | intent(in) | :: | depth_transition |
Depth (m) below which blending begins |
||
| real(kind=wp), | intent(in) | :: | blend_width |
Width of the blending zone (m) |
||
| real(kind=wp), | intent(out) | :: | dz(nz) |
Output target layer thicknesses, ROMS-ordered (sum = H,
|
Compute target layer thicknesses for VCOORD_ZSTAR_FULL. Inputs: z_ref_col(0:nz) local reference (top-down, 0=surface, nz=h_bed); H current total depth (m) = h_bed + η; h_min vanishing-layer floor (m). Output: dz(1:nz) ROMS-ordered (dz(1) bottom, dz(nz) surface), sum(dz) = H exactly, vanishing rows set to h_min. Surface layer absorbs η; if H < h_bed the deepest layers clip to h_min and the surface is trimmed to keep sum = H.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | nz | |||
| real(kind=wp), | intent(in) | :: | H | |||
| real(kind=wp), | intent(in) | :: | z_ref_col(0:nz) | |||
| real(kind=wp), | intent(in) | :: | h_min | |||
| real(kind=wp), | intent(out) | :: | dz(nz) |
Nominal layer thicknesses of a VCOORD_Z_FIXED column, SURFACE
FIRST (dz(1) is the top layer) — the order MOM6 writes
ALE_COORDINATE_CONFIG = "PARAM:..." lists and vgrid files in.
The caller flips to the bottom-up state convention.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | profile |
|
||
| integer, | intent(in) | :: | nz |
Number of layers. |
||
| real(kind=wp), | intent(in) | :: | h_ref |
Reference column depth (m) — |
||
| real(kind=wp), | intent(in) | :: | dz_list(:) |
|
||
| real(kind=wp), | intent(in) | :: | dz_top |
tanh: surface-layer thickness (m). |
||
| real(kind=wp), | intent(in) | :: | center |
tanh: transition centre as a fraction of the index span |
||
| real(kind=wp), | intent(in) | :: | width |
tanh: transition width as a fraction of the index span ( |
||
| real(kind=wp), | intent(out) | :: | dz(nz) |
Nominal thicknesses (m), surface first. |
||
| integer, | intent(out) | :: | ierr |
|
Build a per-column reference z-level pattern for VCOORD_ZSTAR_FULL.
Output z_ref_col(0:nz) monotonically increasing (positive-down),
z_ref_col(0)=0 surface, z_ref_col(nz)=h_bed. Built top-down; the caller
handles ROMS ordering. Top n_surf_use layers use the stretching mode
(log/uniform) toward h_surf_target; below that uniform to the bed;
degenerate (h_bed≤0, nz≤0) ⇒ uniform.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | nz | |||
| real(kind=wp), | intent(in) | :: | h_bed |
Local bed depth (m, positive down). Must be > 0 in normal use. |
||
| real(kind=wp), | intent(in) | :: | h_surf_target |
Target thickness of the surface layer (m). ≤ 0 means “auto” and falls back to uniform spacing. |
||
| integer, | intent(in) | :: | n_surf |
Number of fine near-surface layers. ≤ 0 means auto. |
||
| integer, | intent(in) | :: | stretching |
STRETCH_LOG or STRETCH_UNIFORM |
||
| real(kind=wp), | intent(out) | :: | z_ref_col(0:nz) |
Deallocate all arrays. Safe to call on uninitialised instances.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vcoord_t), | intent(inout) | :: | self |
Map read-only coordinate arrays to GPU.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vcoord_t), | intent(inout) | :: | self |
Unmap coordinate arrays from GPU.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vcoord_t), | intent(inout) | :: | self |
Initialise a vertical coordinate definition. Allocates + populates
dsig_target for the given type. Unknown types: error stop.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vcoord_t), | intent(inout) | :: | self | |||
| integer, | intent(in) | :: | nz |
Number of vertical layers |
||
| integer, | intent(in) | :: | coord_type |
Coordinate type constant (VCOORD_SIGMA, etc.) |
||
| integer, | intent(in) | :: | remap_method |
Remapping method constant (REMAP_PLM, etc.) |