Writes the diag manager’s per-fire output to a per-rank NetCDF
file. Serial only (one file per process). Each diag var carries its
own time_<name> unlimited dim + coord var, so vars firing at
different cadences stay independent. CF-1.8 attributes.
Usage:
call open_stream(state%diag, “rdb_diag.nc”)
! … step the diag manager as usual …
call close_stream(state%diag)
After open_stream, the diag manager emits a slice on every
cadence-fire via the emit_post_fire pointer bound here.
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.
private function diag_io_ok(local_ierr, ierr, ncid) result(ok)
Translate a raw nc_check-style status (0 = ok) from one of the
nc_* calls in open_stream 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-create failure does not leak
the file handle), or error stops with the same generic text
nc_check itself would use had ierr never been threaded
through — byte-identical legacy behaviour when ierr is
omitted. Mirrors rdb_bathymetry’s bathy_io_ok (P0.1 F1).
Create the NetCDF file, define dims + vars for every
currently-registered diag var, and bind the post-fire emit hook.
Must be called AFTER all register calls land — vars registered
later get no NetCDF binding and are not written.
Number of ranks in the x direction (process grid).
integer,
intent(in),
optional
::
py
Number of ranks in the y direction (process grid).
integer,
intent(in),
optional
::
i_start
1-based global column index of this rank’s first physical cell.
integer,
intent(in),
optional
::
j_start
1-based global row index of this rank’s first physical cell.
integer,
intent(in),
optional
::
nx_global
Total number of physical columns in the global domain.
integer,
intent(in),
optional
::
ny_global
Total number of physical rows in the global domain.
integer,
intent(in),
optional
::
nx_local
Number of physical columns on this rank (excluding ghost cells).
integer,
intent(in),
optional
::
ny_local
Number of physical rows on this rank (excluding ghost cells).
integer,
intent(in),
optional
::
nghost
Number of ghost cells on each side of the local domain.
character(len=*),
intent(in),
optional
::
output_precision
"double" (default / absent) or "single" — element type of
the DATA variables. Absent => NC_WP => byte-identical to the
pre-knob writer. Time coordinate variables stay NC_WP
regardless: they are a handful of values per frame and are
routinely differenced.
integer,
intent(out),
optional
::
ierr
Non-zero (OCEAN_STATUS_ERR_IO) on any NetCDF failure when
present; absent behaves as today (error stop).