rdb_io_netcdf Module

Provides NetCDF read/write primitives and an error-checking helper. Used by bathymetry loader and output writer.


Uses

  • module~~rdb_io_netcdf~~UsesGraph module~rdb_io_netcdf rdb_io_netcdf iso_c_binding iso_c_binding module~rdb_io_netcdf->iso_c_binding iso_fortran_env iso_fortran_env module~rdb_io_netcdf->iso_fortran_env module~rdb_constants rdb_constants module~rdb_io_netcdf->module~rdb_constants module~rdb_error_ring rdb_error_ring module~rdb_io_netcdf->module~rdb_error_ring netcdf netcdf module~rdb_io_netcdf->netcdf pic_logger pic_logger module~rdb_io_netcdf->pic_logger pic_strings pic_strings module~rdb_io_netcdf->pic_strings pic_types pic_types module~rdb_constants->pic_types module~rdb_error_ring->pic_logger

Used by

  • module~~rdb_io_netcdf~~UsedByGraph module~rdb_io_netcdf rdb_io_netcdf module~rdb_bathymetry rdb_bathymetry module~rdb_bathymetry->module~rdb_io_netcdf module~rdb_driver rdb_driver module~rdb_driver->module~rdb_io_netcdf module~rdb_ocean_engine rdb_ocean_engine module~rdb_driver->module~rdb_ocean_engine module~rdb_ocean_console_stats rdb_ocean_console_stats module~rdb_driver->module~rdb_ocean_console_stats module~rdb_ocean_dyn rdb_ocean_dyn module~rdb_driver->module~rdb_ocean_dyn module~rdb_ocean_state rdb_ocean_state module~rdb_driver->module~rdb_ocean_state module~rdb_config rdb_config module~rdb_driver->module~rdb_config module~rdb_ocean_data_input rdb_ocean_data_input module~rdb_ocean_data_input->module~rdb_io_netcdf module~rdb_ocean_data_input->module~rdb_config module~rdb_ocean_diag_netcdf rdb_ocean_diag_netcdf module~rdb_ocean_diag_netcdf->module~rdb_io_netcdf module~rdb_ocean_engine->module~rdb_io_netcdf module~rdb_ocean_engine->module~rdb_ocean_data_input module~rdb_ocean_engine->module~rdb_ocean_diag_netcdf module~rdb_ocean_metrics rdb_ocean_metrics module~rdb_ocean_engine->module~rdb_ocean_metrics module~rdb_ice_evp rdb_ice_evp module~rdb_ocean_engine->module~rdb_ice_evp module~rdb_ice_init rdb_ice_init module~rdb_ocean_engine->module~rdb_ice_init module~rdb_ice_ocean_coupler rdb_ice_ocean_coupler module~rdb_ocean_engine->module~rdb_ice_ocean_coupler module~rdb_ice_transport rdb_ice_transport module~rdb_ocean_engine->module~rdb_ice_transport module~rdb_ocean_cavity_flux rdb_ocean_cavity_flux module~rdb_ocean_engine->module~rdb_ocean_cavity_flux module~rdb_ocean_data_forcing rdb_ocean_data_forcing module~rdb_ocean_engine->module~rdb_ocean_data_forcing module~rdb_ocean_engine->module~rdb_ocean_dyn module~rdb_ocean_setup rdb_ocean_setup module~rdb_ocean_engine->module~rdb_ocean_setup module~rdb_ocean_stability_audit rdb_ocean_stability_audit module~rdb_ocean_engine->module~rdb_ocean_stability_audit module~rdb_ocean_engine->module~rdb_ocean_state module~rdb_ocean_engine->module~rdb_config module~rdb_ocean_diag_derived rdb_ocean_diag_derived module~rdb_ocean_engine->module~rdb_ocean_diag_derived module~rdb_ocean_diag_fills rdb_ocean_diag_fills module~rdb_ocean_engine->module~rdb_ocean_diag_fills module~rdb_decomp rdb_decomp module~rdb_ocean_engine->module~rdb_decomp module~rdb_state rdb_state module~rdb_ocean_engine->module~rdb_state module~rdb_ocean_metrics->module~rdb_io_netcdf module~rdb_ocean_restart_io rdb_ocean_restart_io module~rdb_ocean_restart_io->module~rdb_io_netcdf module~rdb_ocean_restart_io->module~rdb_decomp module~rdb_ocean_z_init rdb_ocean_z_init module~rdb_ocean_z_init->module~rdb_io_netcdf module~rdb_ocean_z_init->module~rdb_config module~rdb_barotropic_coupling rdb_barotropic_coupling module~rdb_barotropic_coupling->module~rdb_ocean_metrics module~rdb_coriolis_adv rdb_coriolis_adv module~rdb_barotropic_coupling->module~rdb_coriolis_adv module~rdb_ocean_bottom_drag rdb_ocean_bottom_drag module~rdb_barotropic_coupling->module~rdb_ocean_bottom_drag module~rdb_ocean_horizontal_viscosity rdb_ocean_horizontal_viscosity module~rdb_barotropic_coupling->module~rdb_ocean_horizontal_viscosity module~rdb_ocean_pressure_force rdb_ocean_pressure_force module~rdb_barotropic_coupling->module~rdb_ocean_pressure_force module~rdb_barotropic_substep rdb_barotropic_substep module~rdb_barotropic_substep->module~rdb_ocean_metrics module~rdb_continuity rdb_continuity module~rdb_continuity->module~rdb_ocean_metrics module~rdb_ocean_gm rdb_ocean_gm module~rdb_continuity->module~rdb_ocean_gm module~rdb_ocean_mle rdb_ocean_mle module~rdb_continuity->module~rdb_ocean_mle module~rdb_coriolis_adv->module~rdb_ocean_metrics module~rdb_handle rdb_handle module~rdb_handle->module~rdb_ocean_engine module~rdb_handle->module~rdb_ocean_state module~rdb_handle->module~rdb_config module~rdb_ice_evp->module~rdb_ocean_metrics module~rdb_ice_init->module~rdb_ocean_metrics module~rdb_ice_ocean_coupler->module~rdb_ocean_metrics module~rdb_ice_transport->module~rdb_ocean_metrics module~rdb_ice_transport->module~rdb_continuity module~rdb_ocean_api rdb_ocean_api module~rdb_ocean_api->module~rdb_ocean_engine module~rdb_ocean_api->module~rdb_handle module~rdb_ocean_api->module~rdb_ocean_dyn module~rdb_ocean_api->module~rdb_config module~rdb_ocean_api->module~rdb_ocean_diag_derived module~rdb_ocean_api->module~rdb_ocean_diag_fills module~rdb_ocean_halo_width rdb_ocean_halo_width module~rdb_ocean_api->module~rdb_ocean_halo_width module~rdb_ocean_bottom_drag->module~rdb_ocean_metrics module~rdb_ocean_bt_wide rdb_ocean_bt_wide module~rdb_ocean_bt_wide->module~rdb_ocean_metrics module~rdb_ocean_bt_wide->module~rdb_barotropic_substep module~rdb_ocean_cavity_flux->module~rdb_ocean_metrics module~rdb_ocean_console_stats->module~rdb_ocean_metrics module~rdb_ocean_data_forcing->module~rdb_ocean_data_input module~rdb_ocean_data_forcing->module~rdb_config module~rdb_ocean_dyn->module~rdb_ocean_metrics module~rdb_ocean_dyn->module~rdb_barotropic_coupling module~rdb_ocean_dyn->module~rdb_barotropic_substep module~rdb_ocean_dyn->module~rdb_continuity module~rdb_ocean_dyn->module~rdb_coriolis_adv module~rdb_ocean_dyn->module~rdb_ocean_bottom_drag module~rdb_ocean_dyn->module~rdb_ocean_bt_wide module~rdb_ocean_dyn->module~rdb_ocean_cavity_flux module~rdb_ocean_dyn->module~rdb_ocean_console_stats module~rdb_ocean_dyn->module~rdb_ocean_gm module~rdb_ocean_hdiff_tracer rdb_ocean_hdiff_tracer module~rdb_ocean_dyn->module~rdb_ocean_hdiff_tracer module~rdb_ocean_dyn->module~rdb_ocean_horizontal_viscosity module~rdb_ocean_isopycnal_slopes rdb_ocean_isopycnal_slopes module~rdb_ocean_dyn->module~rdb_ocean_isopycnal_slopes module~rdb_ocean_ke_probe rdb_ocean_ke_probe module~rdb_ocean_dyn->module~rdb_ocean_ke_probe module~rdb_ocean_lateral_mix rdb_ocean_lateral_mix module~rdb_ocean_dyn->module~rdb_ocean_lateral_mix module~rdb_ocean_meke rdb_ocean_meke module~rdb_ocean_dyn->module~rdb_ocean_meke module~rdb_ocean_dyn->module~rdb_ocean_mle module~rdb_ocean_dyn->module~rdb_ocean_pressure_force module~rdb_ocean_redi rdb_ocean_redi module~rdb_ocean_dyn->module~rdb_ocean_redi module~rdb_ocean_varmix rdb_ocean_varmix module~rdb_ocean_dyn->module~rdb_ocean_varmix module~rdb_ocean_wave_speed rdb_ocean_wave_speed module~rdb_ocean_dyn->module~rdb_ocean_wave_speed module~rdb_ocean_bt_budget_probe rdb_ocean_bt_budget_probe module~rdb_ocean_dyn->module~rdb_ocean_bt_budget_probe module~rdb_ocean_gm->module~rdb_ocean_metrics module~rdb_ocean_gm->module~rdb_ocean_isopycnal_slopes module~rdb_ocean_hdiff_tracer->module~rdb_ocean_metrics module~rdb_ocean_horizontal_viscosity->module~rdb_ocean_metrics module~rdb_ocean_horizontal_viscosity->module~rdb_ocean_lateral_mix module~rdb_ocean_isopycnal_slopes->module~rdb_ocean_metrics module~rdb_ocean_ke_probe->module~rdb_ocean_metrics module~rdb_ocean_ke_probe->module~rdb_coriolis_adv module~rdb_ocean_lateral_mix->module~rdb_ocean_metrics module~rdb_ocean_meke->module~rdb_ocean_metrics module~rdb_ocean_meke->module~rdb_ocean_gm module~rdb_ocean_meke->module~rdb_ocean_varmix module~rdb_ocean_meke->module~rdb_ocean_wave_speed module~rdb_ocean_mle->module~rdb_ocean_metrics module~rdb_ocean_pressure_force->module~rdb_ocean_metrics module~rdb_ocean_redi->module~rdb_ocean_metrics module~rdb_ocean_setup->module~rdb_ocean_metrics module~rdb_ocean_setup->module~rdb_coriolis_adv module~rdb_ocean_setup->module~rdb_ocean_bottom_drag module~rdb_ocean_setup->module~rdb_ocean_dyn module~rdb_ocean_setup->module~rdb_ocean_horizontal_viscosity module~rdb_ocean_setup->module~rdb_ocean_lateral_mix module~rdb_ocean_setup->module~rdb_ocean_pressure_force module~rdb_ocean_setup->module~rdb_ocean_state module~rdb_ocean_setup->module~rdb_config module~rdb_ocean_setup->module~rdb_decomp module~rdb_ocean_stability_audit->module~rdb_ocean_metrics module~rdb_ocean_stability_audit->module~rdb_config module~rdb_ocean_state->module~rdb_bathymetry module~rdb_ocean_state->module~rdb_ocean_data_input module~rdb_ocean_state->module~rdb_ocean_metrics module~rdb_ocean_state->module~rdb_ocean_restart_io module~rdb_ocean_state->module~rdb_ocean_z_init module~rdb_ocean_state->module~rdb_continuity module~rdb_ocean_state->module~rdb_coriolis_adv module~rdb_ocean_state->module~rdb_ocean_bottom_drag module~rdb_ocean_state->module~rdb_ocean_cavity_flux module~rdb_ocean_state->module~rdb_ocean_data_forcing module~rdb_ocean_state->module~rdb_ocean_dyn module~rdb_ocean_state->module~rdb_ocean_gm module~rdb_ocean_state->module~rdb_ocean_hdiff_tracer module~rdb_ocean_state->module~rdb_ocean_horizontal_viscosity module~rdb_ocean_state->module~rdb_ocean_isopycnal_slopes module~rdb_ocean_state->module~rdb_ocean_lateral_mix module~rdb_ocean_state->module~rdb_ocean_meke module~rdb_ocean_state->module~rdb_ocean_mle module~rdb_ocean_state->module~rdb_ocean_pressure_force module~rdb_ocean_state->module~rdb_ocean_redi module~rdb_ocean_state->module~rdb_ocean_varmix module~rdb_ocean_state->module~rdb_ocean_wave_speed module~rdb_ocean_state->module~rdb_config module~rdb_ocean_state->module~rdb_decomp module~rdb_ocean_varmix->module~rdb_ocean_metrics module~rdb_ocean_varmix->module~rdb_ocean_isopycnal_slopes module~rdb_ocean_varmix->module~rdb_ocean_wave_speed module~rdb_ocean_wave_speed->module~rdb_ocean_metrics module~rdb_config->module~rdb_ice_init module~rdb_ocean_bt_budget_probe->module~rdb_coriolis_adv module~rdb_ocean_bt_budget_probe->module~rdb_ocean_bottom_drag module~rdb_ocean_bt_budget_probe->module~rdb_ocean_horizontal_viscosity module~rdb_ocean_bt_budget_probe->module~rdb_ocean_pressure_force module~rdb_ocean_diag_derived->module~rdb_ocean_state module~rdb_ocean_diag_derived->module~rdb_ocean_diag_fills module~rdb_ocean_diag_fills->module~rdb_ocean_state module~rdb_ocean_halo_width->module~rdb_coriolis_adv proc~validate_config validate_config proc~validate_config->module~rdb_coriolis_adv proc~validate_config->module~rdb_ocean_bottom_drag proc~validate_config->module~rdb_ocean_horizontal_viscosity proc~validate_config->module~rdb_ocean_lateral_mix proc~validate_config->module~rdb_ocean_pressure_force module~rdb_config_schema rdb_config_schema module~rdb_config_schema->module~rdb_config module~rdb_decomp->module~rdb_config module~rdb_state->module~rdb_config module~rdb_halo rdb_halo module~rdb_halo->module~rdb_decomp module~rdb_ocean_fold_exchange rdb_ocean_fold_exchange module~rdb_ocean_fold_exchange->module~rdb_decomp module~rdb_ocean_halo rdb_ocean_halo module~rdb_ocean_halo->module~rdb_decomp

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: NC_R4 = nf90_float

Explicit 32-bit NetCDF element type. Used ONLY by the ocean diagnostic stream when &ocean_diag_nml output_precision="single" asks for a halved-width output file. Restarts, gauges, coastal output and console/conservation totals stay on NC_WP — a lossy restart must not be requestable. The 64-bit counterpart is NC_WP itself — deliberately NOT given an NC_R8 alias, so “double” has exactly one spelling and cannot drift away from the build’s working precision.

integer, public, parameter :: NC_WP = nf90_float

NetCDF type matching working precision


Functions

public function output_rank_filename(base_dir, prefix, rank) result(fname)

Generate a per-rank filename: /_rank_NNNNNN.nc

Arguments

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

Output directory

character(len=*), intent(in) :: prefix

File prefix (e.g. “output” or “restart”)

integer, intent(in) :: rank

MPI rank number

Return Value character(len=512)

private pure function path_to_c_string(s) result(c)

Pack a Fortran string into a null-terminated c_char array for the mkdir binding above. Private duplicate of rdb_ocean_restart_io’s string_to_c (that one is private to its own module) — small enough that sharing it is not worth a cross-module dependency for a two-line helper.

Arguments

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

Return Value character(kind=c_char, len=1), allocatable, (:)


Subroutines

public subroutine ensure_directory_exists(path, ierr)

Create path via libc mkdir(2) if it does not already exist (single path component — not a recursive mkdir -p; a missing grandparent still fails, loudly, at the inquire re-check below). Exists to close the headline P7 crash: &ocean_diag_nml/ &output_nml default output_dir = "./output" (rdb_config.F90:2316), so a first-time create() against a fresh checkout with no ./output/ directory would otherwise reach nc_create_file -> nf90_create -> ENOENT -> error stop, killing the whole host process.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: path
integer, intent(out), optional :: ierr

Non-zero iff path still does not exist after the mkdir attempt. Absent is legal — the routine just does its best and lets the caller’s own I/O call fail loud.

public subroutine nc_check(status, context, ierr)

Check NetCDF return status and log error if it failed

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: status

Return code from nf90_* call

character(len=*), intent(in) :: context

Description of what was being attempted

integer, intent(out), optional :: ierr

Non-zero (the raw nf90_* status) on failure when present; absent behaves as today (error stop). The specific reason is always logged via global_logger%error first, so the caller-facing code only needs to say THAT a read/write failed.

public subroutine nc_close(ncid, ierr)

Close a NetCDF file

Arguments

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

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_create_file(filename, ncid, ierr)

Create a new NetCDF-4 file (overwrites if exists)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
integer, intent(out) :: ncid
integer, intent(out), optional :: ierr

Non-zero (e.g. a missing output directory) when present; absent behaves as today (error stop).

public subroutine nc_def_dim(ncid, name, length, dimid, ierr)

Define a dimension (use nf90_unlimited for unlimited)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
integer, intent(in) :: length
integer, intent(out) :: dimid
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_def_var_2d(ncid, name, dimids, varid, deflate_level, ierr)

Define a 2D variable with working precision type

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
integer, intent(in) :: dimids(2)
integer, intent(out) :: varid
integer, intent(in), optional :: deflate_level

Compression level (0=none, 1-9=deflate). Enables shuffle when > 0.

integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_def_var_3d(ncid, name, dimids, varid, deflate_level, xtype, ierr)

Define a 3D variable (x, y, time) with working precision type

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
integer, intent(in) :: dimids(3)
integer, intent(out) :: varid
integer, intent(in), optional :: deflate_level

Compression level (0=none, 1-9=deflate). Enables shuffle when > 0.

integer, intent(in), optional :: xtype

NetCDF element type. Absent => NC_WP (working precision), so every legacy call site is unchanged. The ocean diagnostic stream passes NC_R4 when single-precision output is requested; the caller is then responsible for handing nf90_put_var real32 data (see nc_put_var_3d_slice_r4).

integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_def_var_4d(ncid, name, dimids, varid, deflate_level, xtype, ierr)

Define a 4D variable (x, y, z, time) with working precision type

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
integer, intent(in) :: dimids(4)
integer, intent(out) :: varid
integer, intent(in), optional :: deflate_level

Compression level (0=none, 1-9=deflate). Enables shuffle when > 0.

integer, intent(in), optional :: xtype

NetCDF element type. Absent => NC_WP (working precision). See nc_def_var_3d — same contract, 4D shape.

integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_enddef(ncid, ierr)

End define mode, switch to data mode

Arguments

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

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_get_att_int(ncid, name, value, ierr)

Read a global integer attribute

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
integer, intent(out) :: value
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_get_att_text(ncid, varid, name, value, ok)

Read a character (text) attribute from a variable — used for the CF units attribute on a time axis. Non-fail-loud: ok is .false. (and value blank) when the attribute is absent or the wrong type, so callers can fall back to a default rather than aborting on a missing/optional attribute.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
character(len=*), intent(in) :: name
character(len=:), intent(out), allocatable :: value

Deferred-length (not assumed-length intent(out), which risks silent truncation — fortitude C072): filled from a fixed local buffer sized for a CF units string.

logical, intent(out) :: ok

public subroutine nc_get_dim_len(ncid, name, length, ierr)

Get the length of a named dimension

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
integer, intent(out) :: length
integer, intent(out), optional :: ierr

Non-zero (missing dimension) when present; absent behaves as today (error stop).

public subroutine nc_get_var_1d(ncid, varid, data, ierr)

Read a full 1D array (the read sibling of rdb_put_var_1d).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=wp), intent(inout) :: data(:)
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_get_var_2d(ncid, varid, data, ierr)

Read a full 2D array

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=wp), intent(inout) :: data(:,:)
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_get_var_3d(ncid, varid, data, ierr)

Read a full 3D array. Mirrors nc_get_var_2d; the target’s shape must match the file variable’s Fortran storage order (the caller handles any C/Fortran dimension reversal, as rdb_bathymetry does for 2D).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=wp), intent(inout) :: data(:,:,:)
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_get_var_slab_2d(ncid, varid, start, count, data, ierr)

Windowed read of a 2D variable: start/count (length 2, FORTRAN dimension order) select the block that lands in data, whose shape must equal count. The per-rank readers (bathymetry, supergrid) use it to load only the rows their tile needs.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
integer, intent(in) :: start(2)
integer, intent(in) :: count(2)
real(kind=wp), intent(inout) :: data(:,:)
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_get_var_slab_3d(ncid, varid, start, count, data, ierr)

Strided slab read: start/count are the NetCDF start/count vectors in FORTRAN dimension order, with length matching the target variable’s rank (3 for a 2D-field-plus-time variable, 4 for a 3D-field-plus-time variable). data is always a plain 3D Fortran array; for the 2D-plus-time case pass a target with a trailing singleton extent (data(:,:,1)) — the netcdf-fortran generic interface dispatches on the array RANK of data, not the length of start/count, so one routine covers both shapes. This is the first strided (non-full-variable) read in the tree — mirrors nc_put_var_4d_slice for the start/count shape, on the read side.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
integer, intent(in) :: start(:)
integer, intent(in) :: count(:)
real(kind=wp), intent(inout) :: data(:,:,:)
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_get_varid(ncid, name, varid, ierr)

Get the variable ID for a named variable

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
integer, intent(out) :: varid
integer, intent(out), optional :: ierr

Non-zero (no matching variable) when present; absent behaves as today (error stop).

public subroutine nc_open_read(filename, ncid, ierr)

Open an existing NetCDF file for reading

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
integer, intent(out) :: ncid
integer, intent(out), optional :: ierr

Non-zero (a missing/unreadable file) when present; absent behaves as today (error stop).

public subroutine nc_open_write(filename, ncid, ierr)

Open an existing NetCDF file for writing

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
integer, intent(out) :: ncid
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_att(ncid, varid, name, value, ierr)

Write a character attribute to a variable

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
character(len=*), intent(in) :: name
character(len=*), intent(in) :: value
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_att_global(ncid, name, value, ierr)

Write a global character attribute

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
character(len=*), intent(in) :: value
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_att_global_int(ncid, name, value, ierr)

Write a global integer attribute

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
integer, intent(in) :: value
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_att_int(ncid, varid, name, value, ierr)

Write an integer attribute to a variable

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
character(len=*), intent(in) :: name
integer, intent(in) :: value
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_att_real(ncid, varid, name, value, ierr)

Write a real-valued attribute to a variable

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
character(len=*), intent(in) :: name
real(kind=wp), intent(in) :: value
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_att_real_r4(ncid, varid, name, value, ierr)

Write a 32-bit real attribute to a variable. NetCDF rejects a _FillValue whose type differs from the variable’s, so a variable defined with NC_R4 must have its _FillValue / missing_value written through here, not through nc_put_att_real (real64).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
character(len=*), intent(in) :: name
real(kind=real32), intent(in) :: value
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_var_2d(ncid, varid, data, ierr)

Write a full 2D array

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=wp), intent(in) :: data(:,:)
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_var_3d_slice(ncid, varid, data, time_index, ierr)

Write a 2D slice into a 3D variable at a given time index

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=wp), intent(in) :: data(:,:)
integer, intent(in) :: time_index
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_var_3d_slice_r4(ncid, varid, data, time_index, ierr)

Write a 32-bit 2D slice into a 3D variable at a given time index. The real32 twin of nc_put_var_3d_slice: handing real64 data to an NF90_FLOAT variable is legal (netcdf converts) but writes the same bytes at twice the host->library traffic, so the diag writer stages the conversion itself and calls this.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=real32), intent(in) :: data(:,:)
integer, intent(in) :: time_index
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_var_4d_slice(ncid, varid, data, time_index, ierr)

Write a 3D slice into a 4D variable at a given time index

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=wp), intent(in) :: data(:,:,:)
integer, intent(in) :: time_index
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine nc_put_var_4d_slice_r4(ncid, varid, data, time_index, ierr)

Write a 32-bit 3D slice into a 4D variable at a given time index. The real32 twin of nc_put_var_4d_slice.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=real32), intent(in) :: data(:,:,:)
integer, intent(in) :: time_index
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine rdb_def_var_1d(ncid, name, dimid, varid, deflate_level, ierr)

Define a 1D variable with working precision type

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
character(len=*), intent(in) :: name
integer, intent(in) :: dimid
integer, intent(out) :: varid
integer, intent(in), optional :: deflate_level

Compression level (0=none, 1-9=deflate). Enables shuffle when > 0.

integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine rdb_put_var_1d(ncid, varid, data, ierr)

Write a full 1D array

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=wp), intent(in) :: data(:)
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).

public subroutine rdb_put_var_2d_slice(ncid, varid, data, time_index, ierr)

Write a 1D slice into a 2D variable at a given time index

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(in) :: varid
real(kind=wp), intent(in) :: data(:)
integer, intent(in) :: time_index
integer, intent(out), optional :: ierr

Non-zero on failure when present; absent behaves as today (error stop).