rdb_ocean_diag_netcdf Module

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.


Uses

  • module~~rdb_ocean_diag_netcdf~~UsesGraph module~rdb_ocean_diag_netcdf rdb_ocean_diag_netcdf iso_fortran_env iso_fortran_env module~rdb_ocean_diag_netcdf->iso_fortran_env module~rdb_constants rdb_constants module~rdb_ocean_diag_netcdf->module~rdb_constants module~rdb_io_netcdf rdb_io_netcdf module~rdb_ocean_diag_netcdf->module~rdb_io_netcdf module~rdb_ocean_diag rdb_ocean_diag module~rdb_ocean_diag_netcdf->module~rdb_ocean_diag module~rdb_ocean_status rdb_ocean_status module~rdb_ocean_diag_netcdf->module~rdb_ocean_status netcdf netcdf module~rdb_ocean_diag_netcdf->netcdf pic_logger pic_logger module~rdb_ocean_diag_netcdf->pic_logger pic_types pic_types module~rdb_constants->pic_types module~rdb_io_netcdf->iso_fortran_env module~rdb_io_netcdf->module~rdb_constants module~rdb_io_netcdf->netcdf module~rdb_io_netcdf->pic_logger iso_c_binding iso_c_binding module~rdb_io_netcdf->iso_c_binding module~rdb_error_ring rdb_error_ring module~rdb_io_netcdf->module~rdb_error_ring pic_strings pic_strings module~rdb_io_netcdf->pic_strings module~rdb_ocean_diag->iso_fortran_env module~rdb_ocean_diag->module~rdb_constants module~rdb_ocean_diag->module~rdb_ocean_status module~rdb_ocean_diag->pic_logger ieee_arithmetic ieee_arithmetic module~rdb_ocean_diag->ieee_arithmetic module~rdb_ocean_diag->module~rdb_error_ring module~rdb_grid rdb_grid module~rdb_ocean_diag->module~rdb_grid module~rdb_mem_report rdb_mem_report module~rdb_ocean_diag->module~rdb_mem_report module~rdb_ocean_diag_mask rdb_ocean_diag_mask module~rdb_ocean_diag->module~rdb_ocean_diag_mask module~rdb_error_ring->pic_logger module~rdb_grid->module~rdb_constants module~rdb_mem_report->iso_fortran_env module~rdb_mem_report->module~rdb_constants module~rdb_mem_report->pic_logger module~rdb_mem_report->pic_strings module~rdb_ocean_diag_mask->iso_fortran_env module~rdb_ocean_diag_mask->module~rdb_constants module~rdb_ocean_diag_mask->module~rdb_grid module~rdb_ocean_diag_mask->module~rdb_mem_report

Used by

  • module~~rdb_ocean_diag_netcdf~~UsedByGraph module~rdb_ocean_diag_netcdf rdb_ocean_diag_netcdf module~rdb_ocean_engine rdb_ocean_engine module~rdb_ocean_engine->module~rdb_ocean_diag_netcdf module~rdb_driver rdb_driver module~rdb_driver->module~rdb_ocean_engine module~rdb_handle rdb_handle module~rdb_handle->module~rdb_ocean_engine module~rdb_ocean_api rdb_ocean_api module~rdb_ocean_api->module~rdb_ocean_engine module~rdb_ocean_api->module~rdb_handle

Functions

public function diag_xtype_from_name(name) result(xtype)

Map the &ocean_diag_nml output_precision string onto a NetCDF element type for the diagnostic DATA variables.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Return Value integer

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).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: local_ierr
integer, intent(out), optional :: ierr
integer, intent(in), optional :: ncid

Return Value logical


Subroutines

public subroutine close_stream(diag)

Flush + close the NetCDF file. Idempotent.

Arguments

Type IntentOptional Attributes Name
class(ocean_diag_t), intent(inout) :: diag

public subroutine open_stream(diag, filename, deflate_level, px, py, i_start, j_start, nx_global, ny_global, nx_local, ny_local, nghost, output_precision, ierr)

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.

Read more…

Arguments

Type IntentOptional Attributes Name
class(ocean_diag_t), intent(inout) :: diag
character(len=*), intent(in) :: filename
integer, intent(in), optional :: deflate_level
integer, intent(in), optional :: px

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).

private subroutine nc_emit_post_fire(diag, ivar, t)

Post-fire emit hook. Appends one slice + time value for the var that just fired. Bound to diag%emit_post_fire by open_stream.

Arguments

Type IntentOptional Attributes Name
class(*), intent(inout) :: diag
integer, intent(in) :: ivar
real(kind=wp), intent(in) :: t