cable_output_variable_t Derived Type

type, public :: cable_output_variable_t

Type for describing one use of an output variable in an output stream.

Uses are built from a cable_output_variable_definition_t and the aggregation, reduction and NetCDF name chosen in the output configuration, and are what the output module defines and writes in each output stream. The constructor taking the individual settings is used for the coordinate variables written to every file.


Components

Type Visibility Attributes Name Initial
character(len=64), public :: field_name

The name of the variable as used in the CABLE code. This name is used as the netCDF variable name when writing CABLE restart files.

character(len=64), public :: netcdf_name = ""

The name of the variable as it should appear in netCDF output files. If not specified, this defaults to field_name.

character(len=64), public :: accumulation_frequency = "timestep"

The frequency at which the variable is accumulated when computing time aggregations. Please refer to the cable_timing_frequency_matches procedure for more information on the available frequency settings. If not specified, this defaults to "timestep", meaning that the variable is accumulated at every CABLE time step.

character(len=64), public :: reduction_method = "none"

The grid cell reduction method to apply to the variable. The allowed reduction methods are specified in allowed_reduction_methods. Please refer to cable_grid_reductions_mod for more details on grid reductions.

character(len=64), public :: aggregation_method = "instant"

The time aggregation method to apply when sampling a diagnostic. Please refer to allowed_aggregation_methods for more details on the available aggregation methods.

logical, public :: parameter = .false.

A flag indicating whether the variable is a non-time varying parameter. Variables with parameter = .true. are written once on the first time step via cable_output_write_parameters.

logical, public :: distributed = .true.

A flag indicating whether the variable is distributed across multiple processes. If distributed = .true., the output module will infer an appropriate parallel I/O decomposition from data_shape to perform a distributed write to disk. If distributed = .false., it is assumed by the output module that each process has a copy of the data, and only the data on the root process will be written.

integer, public :: var_type = CABLE_OUTPUT_VAR_TYPE_UNDEFINED

The netCDF variable type using CABLE_NETCDF_<type> constants. If not specified, the output module will use the native type of the data as the netCDF variable type.

real, public :: scale_by = 1.0

A multiplicative factor to apply to the native diagnostic values when writing output.

real, public :: divide_by = 1.0

A divisional factor to apply to the native diagnostic values when writing output.

real, public :: offset_by = 0.0

An additive offset to apply to the native diagnostic values when writing output.

real, public :: range(2) = [-huge(0.0), huge(0.0)]

The valid range of physical values for the output variable. If a unit conversion is applied to the native diagnostic via the scale_by, divide_by, or offset_by components, the range should be given in the units of the output variable after applying the unit conversion. If unspecified, all values are considered valid.

type(cable_output_dim_t), public, allocatable :: data_shape(:)

An array of in-memory dimensions describing the shape of the variable data. The dimensions must be created via cable_output_get_dimension to ensure that reserved dimension names are handled correctly by the output module. If not specified, the data shape is assumed to be a scalar.

class(aggregator_t), public, allocatable :: aggregator

The aggregator object associated with the diagnostic working variable to be written for this output variable. The aggregator object should not be initialised by the caller; this is done internally in the output module when the stream containing the variable is started.

type(cable_output_attribute_t), public, allocatable :: metadata(:)

NetCDF variable attributes to be written with the variable.


Constructor

public interface cable_output_variable_t

  • private function cable_output_variable_constructor(field_name, aggregator, netcdf_name, accumulation_frequency, reduction_method, aggregation_method, parameter, distributed, var_type, scale_by, divide_by, offset_by, range, data_shape, metadata) result(this)

    Constructor for cable_output_variable_t.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: field_name
    class(aggregator_t), intent(in) :: aggregator
    character(len=*), intent(in), optional :: netcdf_name
    character(len=*), intent(in), optional :: accumulation_frequency
    character(len=*), intent(in), optional :: reduction_method
    character(len=*), intent(in), optional :: aggregation_method
    logical, intent(in), optional :: parameter
    logical, intent(in), optional :: distributed
    integer, intent(in), optional :: var_type
    real, intent(in), optional :: scale_by
    real, intent(in), optional :: divide_by
    real, intent(in), optional :: offset_by
    real, intent(in), optional :: range(:)
    type(cable_output_dim_t), intent(in), optional :: data_shape(:)
    type(cable_output_attribute_t), intent(in), optional :: metadata(:)

    Return Value type(cable_output_variable_t)

  • private function cable_output_variable_from_definition(definition, aggregation, reduction, netcdf_name, metadata) result(this)

    Constructs the use of a variable definition described by the arguments: the definition says what the variable is, the arguments say how it is written. The result owns its own copy of the aggregator, so one definition can be used in several streams.

    Arguments

    Type IntentOptional Attributes Name
    type(cable_output_variable_definition_t), intent(in) :: definition
    character(len=*), intent(in) :: aggregation

    One of allowed_aggregation_methods.

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

    One of allowed_reduction_methods.

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

    Name of the variable in the NetCDF file.

    type(cable_output_attribute_t), intent(in), optional :: metadata(:)

    Attributes to add to those of the definition.

    Return Value type(cable_output_variable_t)


Type-Bound Procedures

procedure, private :: get_netcdf_name => cable_output_variable_get_netcdf_name

Return the netCDF variable name, which defaults to field_name if not specified via netcdf_name.

  • private elemental function cable_output_variable_get_netcdf_name(this) result(netcdf_name)

    Return the netCDF variable name, which defaults to field_name if not specified via netcdf_name.

    Arguments

    Type IntentOptional Attributes Name
    class(cable_output_variable_t), intent(in) :: this

    Return Value character(len=64)