Walks a restart_registry_t and writes/reads each registered field
as a FULL local array (interior + ghosts) to/from a per-rank NetCDF
file, alongside the scalar checkpoint metadata (time, step
counters), the decomposition attributes that gate a same-decomp
resume, and the grid/vcoord/tracer metadata that gates a same-schema
resume.
Durability: the write goes to <filename>.tmp, then a POSIX
rename(2) atomically swaps it into place — a crash mid-write
leaves the previous checkpoint intact.
Nodes of different colours represent the following:
Solid arrows point from a submodule to the (sub)module which it is
descended from. Dashed arrows point from a module or program unit to
modules which it uses.
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 submodule to the (sub)module which it is
descended from. Dashed arrows point from a module or program unit to
modules which it uses.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Grid/coordinate/tracer fingerprint validated on read. Distinct
from the decomposition metadata (px/py/dims) so a file built with
a different vertical resolution, ghost width, vcoord, or tracer
set is rejected loudly rather than silently mis-mapped.
Components
Type
Visibility
Attributes
Name
Initial
integer,
public
::
idx_salinity
=
0
tracers(:) index of salinity (0 = none).
integer,
public
::
idx_temperature
=
0
tracers(:) index of temperature (0 = none).
integer,
public
::
n_tracers
=
0
Registered tracer count.
integer,
public
::
nghost
=
0
Ghost width.
integer,
public
::
nz_ml
=
0
Multilayer layer count.
character(len=32),
public
::
vcoord_name
=
""
Human-readable vcoord tag (for the mismatch message).
integer,
public
::
vcoord_type
=
0
Vertical-coordinate enum (VCOORD_*).
Functions
private function posix_rename(oldpath, newpath) result(rc)
Atomically rename oldpath -> newpath via libc rename(2).
Returns 0 on success, -1 on error.
Arguments
Type
Intent
Optional
Attributes
Name
character(len=*),
intent(in)
::
oldpath
character(len=*),
intent(in)
::
newpath
Return Value
integer
private function restart_io_ok(local_ierr, ierr, ncid) result(ok)
Translate a raw nc_check-style status (0 = ok) from one of the
nc_* calls in ocean_restart_write_local into the caller’s
ierr contract. Mirrors rdb_bathymetry’s bathy_io_ok /
rdb_ocean_diag_netcdf’s diag_io_ok (P0.1 F1 / P7 F1): closes
ncid (when given) on failure so a mid-write error does not
leak the file handle, sets ierr = OCEAN_STATUS_ERR_IO when
present, or error stops with the generic nc_check text when
ierr is absent (byte-identical legacy behaviour).
public subroutine ocean_restart_read_local(filename, reg, decomp, meta, t, step, outer_step_count, ierr)
Read a per-rank ocean restart into the registry’s host arrays
(FULL local extent) + return the scalar metadata. Validates
decomp + grid/vcoord/tracer metadata first and error-stops on
mismatch unless ierr is present. A REQUIRED field absent from
the file is FATAL; only optional entries warn-and-seed. Must
run BEFORE ocean_state_enter_data so the H->D copy carries the
restored values up.
public subroutine ocean_restart_write_local(filename, reg, decomp, meta, t, step, outer_step_count, ierr)
Write a per-rank ocean restart file from the registry durably
(to <filename>.tmp then POSIX-rename). Device sync
(!$acc update self) on the device-mapped arrays must already
have been done by the caller — this is pure host NetCDF I/O.