FMS  2023.04.00
Flexible Modeling System
diag_manager_mod

diag_manager_mod is a set of simple calls for parallel diagnostics on distributed systems. It is geared toward the writing of data in netCDF format. See Diag Manager for diag table information. More...

Files

file  diag_manager.F90
 File for diag_manager_mod.
 

Data Types

interface  diag_field_add_attribute
 Add a attribute to the output field. More...
 
interface  register_diag_field
 Register a diagnostic field for a given module. More...
 
interface  send_data
 Send data over to output fields. More...
 
interface  send_tile_averaged_data
 Send tile-averaged data over to output fields. More...
 

Functions/Subroutines

subroutine add_associated_files (file_num, cm_file_num, cm_ind)
 Add to the associated files attribute. More...
 
subroutine average_tiles (diag_field_id, x, area, mask, out)
 Calculates tile average of a field. More...
 
subroutine average_tiles1d (diag_field_id, x, area, mask, out)
 Calculates average for a field with the given area and land mask. More...
 
subroutine closing_file (file, time)
 Replaces diag_manager_end; close just one file: files(file)
 
subroutine diag_field_add_attribute_i1d (diag_field_id, att_name, att_value)
 Add an integer 1D array attribute to the diag field corresponding to a given id. More...
 
subroutine diag_field_add_attribute_r1d (diag_field_id, att_name, att_value)
 Add a real 1D array attribute to the diag field corresponding to a given id. More...
 
subroutine diag_field_add_attribute_scalar_c (diag_field_id, att_name, att_value)
 Add a scalar character attribute to the diag field corresponding to a given id. More...
 
subroutine diag_field_add_attribute_scalar_i (diag_field_id, att_name, att_value)
 Add a scalar integer attribute to the diag field corresponding to a given id. More...
 
subroutine diag_field_add_attribute_scalar_r (diag_field_id, att_name, att_value)
 Add a scalar real attribute to the diag field corresponding to a given id. More...
 
subroutine, public diag_field_add_cell_measures (diag_field_id, area, volume)
 Add the cell_measures attribute to a diag out field. More...
 
subroutine diag_field_attribute_init (diag_field_id, name, type, cval, ival, rval)
 
subroutine, public diag_manager_end (time)
 Flushes diagnostic buffers where necessary. Close diagnostics files. A warning will be issued here if a field in diag_table is not registered.
 
subroutine, public diag_manager_init (diag_model_subset, time_init, err_msg)
 Initialize Diagnostics Manager. More...
 
subroutine, public diag_manager_set_time_end (Time_end_in)
 
subroutine, public diag_send_complete (time_step, err_msg)
 Saves diagnostic data for the given time value.
 
subroutine, public diag_send_complete_instant (time)
 The subroutine 'diag_send_complete_instant' allows the user to save diagnostic data on variable intervals (user defined in code logic) to the same file. The argument (time_type) will be written to the time axis correspondingly. More...
 
logical function diag_send_data (diag_field_id, field, time, is_in, js_in, ks_in, mask, rmask, ie_in, je_in, ke_in, weight, err_msg)
 
subroutine, public get_base_date (year, month, day, hour, minute, second)
 Return base date for diagnostics. More...
 
type(time_type) function, public get_base_time ()
 Return base time for diagnostics. More...
 
integer function, public get_diag_field_id (module_name, field_name)
 Return the diagnostic field ID of a given variable. More...
 
logical function get_related_field (field, rel_field, out_field_id, out_file_id)
 Finds the corresponding related output field and file for a given input field. More...
 
integer function init_diurnal_axis (n_samples)
 Finds or initializes a diurnal time axis and returns its' ID. More...
 
subroutine init_field_cell_measures (output_field, area, volume, err_msg)
 If needed, add cell_measures and associated_file attribute to out field/file. More...
 
logical function, public need_data (diag_field_id, next_model_time)
 Determine whether data is needed for the current model time step. More...
 
integer function register_diag_field_array (module_name, field_name, axes, init_time, long_name, units, missing_value, range, mask_variant, standard_name, verbose, do_not_log, err_msg, interp_method, tile_count, area, volume, realm)
 Registers an array field. More...
 
integer function register_diag_field_scalar (module_name, field_name, init_time, long_name, units, missing_value, range, standard_name, do_not_log, err_msg, area, volume, realm)
 Registers a scalar field. More...
 
integer function, public register_static_field (module_name, field_name, axes, long_name, units, missing_value, range, mask_variant, standard_name, DYNAMIC, do_not_log, interp_method, tile_count, area, volume, realm)
 Return field index for subsequent call to send_data. More...
 
logical function send_data_0d (diag_field_id, field, time, err_msg)
 
logical function send_data_1d (diag_field_id, field, time, is_in, mask, rmask, ie_in, weight, err_msg)
 
logical function send_data_2d (diag_field_id, field, time, is_in, js_in, mask, rmask, ie_in, je_in, weight, err_msg)
 
logical function send_data_3d (diag_field_id, field, time, is_in, js_in, ks_in, mask, rmask, ie_in, je_in, ke_in, weight, err_msg)
 
logical function send_tile_averaged_data1d (id, field, area, time, mask)
 
logical function send_tile_averaged_data2d (id, field, area, time, mask)
 
logical function send_tile_averaged_data3d (id, field, area, time, mask)
 
integer function writing_field (out_num, at_diag_end, error_string, time)
 

Detailed Description

diag_manager_mod is a set of simple calls for parallel diagnostics on distributed systems. It is geared toward the writing of data in netCDF format. See Diag Manager for diag table information.

Author
Matt Harrison, Giang Nong, Seth Underwood

diag_manager_mod provides a convenient set of interfaces for writing data to disk. It is built upon the parallel I/O interface of FMS code /shared/mpp/mpp_io.F90.

A single group of calls to the diag_manager_mod interfaces provides data to disk at any number of sampling and/or averaging intervals specified at run-time. Run-time specification of diagnostics are input through the diagnostics table.

Usage

Use of diag_manager includes the following steps:

  1. Create diag_table as described in the diag_table_mod documentation.
  2. Call diag_manager_init to initialize diag_manager_mod.
  3. Call register_diag_field to register the field to be output. NOTE: ALL fields in diag_table should be registered BEFORE the first send_data call
  4. Call send_data to send data to output fields
  5. Call diag_manager_end to exit diag_manager

Features

Features of diag_manager_mod:

  1. Ability to output from 0D arrays (scalars) to 3D arrays.
  2. Ability to output time average of fields that have time dependent mask.
  3. Give optional warning if register_diag_field fails due to misspelled module name or field name.
  4. Check if a field is registered twice.
  5. Check for duplicate lines in diag_table.
  6. diag_table_mod can contain fields that are NOT written to any files. The file name in diag_table of these fields is null.
  7. By default, a field is output in its global grid. The user can now output a field in a specified region. See send_data for more details.
  8. To check if the diag table is set up correctly, user should set debug_diag_manager=.true. in diag_manager namelist, then the the content of diag_table is printed in stdout.
  9. New optional format of file information in diag_table_mod. It is possible to have just one file name and reuse it many times. A time string will be appended to the base file name each time a new file is opened. The time string can be any combination from year to second of current model time.

    Here is an example file line:

    "file2_yr_dy%1yr%3dy",2,"hours",1,"hours","Time", 10, "days", "1 1 7 0 0 0", 6, "hours"


    From left to right we have:

    • file name
    • output frequency
    • output frequency unit
    • Format (should always be 1)
    • time axis unit
    • time axis name
    • frequency for creating new file
    • unit for creating new file
    • start time of the new file
    • file duration
    • file duration unit.

    The 'file duration', if absent, will be equal to frequency for creating a new file.

    Thus, the above means: create a new file every 10 days, each file will last 6 hours from creation time, no files will be created before time "1 1 7 0 0 0".

    In this example the string 10, "days", "1 1 7 0 0 0", 6, "hours" is optional.

    Keywords for the time string suffix is xyr,xmo,xdy,xhr,xmi,xsc where x is a mandatory 1 digit number specifying the width of field used in writing the string

  10. New time axis for time averaged fields. Users can use a namelist option to handle the time value written to time axis for time averaged fields.

    If mix_snapshot_average_fields=.true. then a time averaged file will have time values corresponding to ending time_bound e.g. January monthly average is labeled Feb01. Users can have both snapshot and averaged fields in one file.

    If mix_snapshot_average_fields=.false. The time value written to time axis for time averaged fields is the middle on the averaging time. For example, January monthly mean will be written at Jan 16 not Feb 01 as before. However, to use this new feature users should separate snapshot fields and time averaged fields in different files or a fatal error will occur.

    The namelist default value is mix_snapshot_average_fields=.false.

  11. Time average, Root Mean Square, Max and Min, and diurnal. In addition to time average users can also get then Root Mean Square, Max or Min value during the same interval of time as time average. For this purpose, in the diag table users must replace .true. or .false. by rms, max or min. Note: Currently, max and min are not available for regional output.

    A diurnal average or the average of an integer power can also be requested using diurnal## or pow## where ## are the number of diurnal sections or integer power to average.

  12. standard_name is added as optional argument in register_diag_field.
  13. When namelist variable debug_diag_manager = .true. array bounds are checked in send_data.
  14. Coordinate attributes can be written in the output file if the argument "aux" is given in diag_axis_mod::diag_axis_init . The corresponding fields (geolat/geolon) should also be written to the same file.

Data Type Documentation

◆ diag_manager_mod::diag_field_add_attribute

interface diag_manager_mod::diag_field_add_attribute

Add a attribute to the output field.

Definition at line 363 of file diag_manager.F90.

Private Member Functions

subroutine diag_field_add_attribute_i1d (diag_field_id, att_name, att_value)
 Add an integer 1D array attribute to the diag field corresponding to a given id. More...
 
subroutine diag_field_add_attribute_r1d (diag_field_id, att_name, att_value)
 Add a real 1D array attribute to the diag field corresponding to a given id. More...
 
subroutine diag_field_add_attribute_scalar_c (diag_field_id, att_name, att_value)
 Add a scalar character attribute to the diag field corresponding to a given id. More...
 
subroutine diag_field_add_attribute_scalar_i (diag_field_id, att_name, att_value)
 Add a scalar integer attribute to the diag field corresponding to a given id. More...
 
subroutine diag_field_add_attribute_scalar_r (diag_field_id, att_name, att_value)
 Add a scalar real attribute to the diag field corresponding to a given id. More...
 

Member Function/Subroutine Documentation

◆ diag_field_add_attribute_i1d()

subroutine diag_field_add_attribute_i1d ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
integer, dimension(:), intent(in)  att_value 
)
private

Add an integer 1D array attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4249 of file diag_manager.F90.

◆ diag_field_add_attribute_r1d()

subroutine diag_field_add_attribute_r1d ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
real, dimension(:), intent(in)  att_value 
)
private

Add a real 1D array attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4240 of file diag_manager.F90.

◆ diag_field_add_attribute_scalar_c()

subroutine diag_field_add_attribute_scalar_c ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
character(len=*), intent(in)  att_value 
)
private

Add a scalar character attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4231 of file diag_manager.F90.

◆ diag_field_add_attribute_scalar_i()

subroutine diag_field_add_attribute_scalar_i ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
integer, intent(in)  att_value 
)
private

Add a scalar integer attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4222 of file diag_manager.F90.

◆ diag_field_add_attribute_scalar_r()

subroutine diag_field_add_attribute_scalar_r ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
real, intent(in)  att_value 
)
private

Add a scalar real attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4213 of file diag_manager.F90.

◆ diag_manager_mod::register_diag_field

interface diag_manager_mod::register_diag_field

Register a diagnostic field for a given module.

Definition at line 348 of file diag_manager.F90.

Private Member Functions

integer function register_diag_field_array (module_name, field_name, axes, init_time, long_name, units, missing_value, range, mask_variant, standard_name, verbose, do_not_log, err_msg, interp_method, tile_count, area, volume, realm)
 Registers an array field. More...
 
integer function register_diag_field_scalar (module_name, field_name, init_time, long_name, units, missing_value, range, standard_name, do_not_log, err_msg, area, volume, realm)
 Registers a scalar field. More...
 

Member Function/Subroutine Documentation

◆ register_diag_field_array()

integer function register_diag_field_array ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  field_name,
integer, dimension(:), intent(in)  axes,
type(time_type), intent(in), optional  init_time,
character(len=*), intent(in), optional  long_name,
character(len=*), intent(in), optional  units,
class(*), intent(in), optional  missing_value,
class(*), dimension(:), intent(in), optional  range,
logical, intent(in), optional  mask_variant,
character(len=*), intent(in), optional  standard_name,
logical, intent(in), optional  verbose,
logical, intent(in), optional  do_not_log,
character(len=*), intent(out), optional  err_msg,
character(len=*), intent(in), optional  interp_method,
integer, intent(in), optional  tile_count,
integer, intent(in), optional  area,
integer, intent(in), optional  volume,
character(len=*), intent(in), optional  realm 
)
private

Registers an array field.

Returns
field index for subsequent call to send_data.
Parameters
[in]module_nameModule where the field comes from
[in]field_nameName of the field
[in]axesIds corresponding to the variable axis
[in]init_timeTime to start writing data from
[in]long_nameLong_name to add as a variable attribute
[in]unitsUnits to add as a variable_attribute
[in]missing_valueMissing value to add as a variable attribute
[in]rangeRange to add a variable attribute
[in]mask_variantMask variant
[in]standard_nameStandard_name to name the variable in the file
[in]verbosePrint more information
[in]do_not_logIf TRUE, field information is not logged
[out]err_msgError_msg from call
[in]interp_methodThe interp method to be used when regridding the field in post-processing. Valid options are "conserve_order1", "conserve_order2", and "none".
[in]tile_countThe current tile number
[in]areaId of the area field
[in]volumeId of the volume field
[in]realmString to set as the modeling_realm attribute

Definition at line 416 of file diag_manager.F90.

◆ register_diag_field_scalar()

integer function register_diag_field_scalar ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  field_name,
type(time_type), intent(in), optional  init_time,
character(len=*), intent(in), optional  long_name,
character(len=*), intent(in), optional  units,
class(*), intent(in), optional  missing_value,
class(*), dimension(:), intent(in), optional  range,
character(len=*), intent(in), optional  standard_name,
logical, intent(in), optional  do_not_log,
character(len=*), intent(out), optional  err_msg,
integer, intent(in), optional  area,
integer, intent(in), optional  volume,
character(len=*), intent(in), optional  realm 
)
private

Registers a scalar field.

Returns
field index for subsequent call to send_data.
Parameters
[in]module_nameModule where the field comes from
[in]field_nameName of the field
[in]init_timeTime to start writing data from
[in]long_nameLong_name to add as a variable attribute
[in]unitsUnits to add as a variable_attribute
[in]standard_nameStandard_name to name the variable in the file
[in]missing_valueMissing value to add as a variable attribute
[in]rangeRange to add a variable attribute
[in]do_not_logIf TRUE, field information is not logged
[out]err_msgError_msg from call
[in]areaId of the area field
[in]volumeId of the volume field
[in]realmString to set as the modeling_realm attribute

Definition at line 377 of file diag_manager.F90.

◆ diag_manager_mod::send_data

interface diag_manager_mod::send_data

Send data over to output fields.

send_data is overloaded for fields having zero dimension (scalars) to 3 dimension. diag_field_id corresponds to the id returned from a previous call to register_diag_field. The field array is restricted to the computational range of the array. Optional argument is_in can be used to update sub-arrays of the entire field. Additionally, an optional logical or real mask can be used to apply missing values to the array.

If a field is declared to be mask_variant in register_diag_field logical mask should be mandatory.

For the real mask, the mask is applied if the mask value is less than 0.5.

By default, a field will be written out entirely in its global grid. Users can also specify regions in which the field will be output. The region is specified in diag-table just before the end of output_field replacing "none".

For example, by default:

"ocean_mod","Vorticity","vorticity","file1","all",.false.,"none",2

for regional output:

"ocean_mod","Vorticity","vorticity_local","file2","all",.false.,"0.5 53.5 -89.5 -28.5 -1 -1",2

The format of a region is "<TT>xbegin xend ybegin yend zbegin zend</TT>". If it is a 2D field use (-1 -1) for (zbegin zend) as in the example above. For a 3D field use (-1 -1) for (zbegin zend) when you want to write the entire vertical extent, otherwise specify real coordinates. The units used for region are the actual units used in grid_spec.nc (for example degrees for lat, lon). NOTE: A FATAL error will occur if the region's boundaries are not found in grid_spec.nc.

Regional output on the cubed sphere grid is also supported. To use regional output on the cubed sphere grid, first the grid information needs to be sent to diag_manager_mod using the diag_grid::diag_grid_init subroutine.

Note
When using regional output the files containing regional outputs should be different from files containing global (default) output. It is a FATAL error to have one file containing both regional and global results. For maximum flexibility and independence from PE counts one file should contain just one region.

Time averaging is supported in regional output.

Physical fields (written in "physics windows" of atmospheric code) are fully supported for regional outputs.

NOTE: Most fields are defined in the data domain but use the compute domain. In send_data the field can be passed in either the data domain or in the compute domain. If the data domain is used, the start and end indicies of the compute domain (isc, iec, . . .) should be passed. If the compute domain is used no indices are needed. The indices are for determining halo exclusively. If users want to output the field partially they should use regional output as mentioned above.

Weight in Time averaging is now supported, each time level may have a different weight. The default of weight is 1.

Definition at line 339 of file diag_manager.F90.

Private Member Functions

logical function send_data_0d (diag_field_id, field, time, err_msg)
 
logical function send_data_1d (diag_field_id, field, time, is_in, mask, rmask, ie_in, weight, err_msg)
 
logical function send_data_2d (diag_field_id, field, time, is_in, js_in, mask, rmask, ie_in, je_in, weight, err_msg)
 
logical function send_data_3d (diag_field_id, field, time, is_in, js_in, ks_in, mask, rmask, ie_in, je_in, ke_in, weight, err_msg)
 

Member Function/Subroutine Documentation

◆ send_data_0d()

logical function send_data_0d ( integer, intent(in)  diag_field_id,
class(*), intent(in)  field,
type(time_type), intent(in), optional  time,
character(len=*), intent(out), optional  err_msg 
)
private
Returns
true if send is successful

Definition at line 1294 of file diag_manager.F90.

◆ send_data_1d()

logical function send_data_1d ( integer, intent(in)  diag_field_id,
class(*), dimension(:), intent(in)  field,
type (time_type), intent(in), optional  time,
integer, intent(in), optional  is_in,
logical, dimension(:), intent(in), optional  mask,
class(*), dimension(:), intent(in), optional  rmask,
integer, intent(in), optional  ie_in,
class(*), intent(in), optional  weight,
character(len=*), intent(out), optional  err_msg 
)
private
Returns
true if send is successful

Definition at line 1323 of file diag_manager.F90.

◆ send_data_2d()

logical function send_data_2d ( integer, intent(in)  diag_field_id,
class(*), dimension(:,:), intent(in)  field,
type (time_type), intent(in), optional  time,
integer, intent(in), optional  is_in,
integer, intent(in), optional  js_in,
logical, dimension(:,:), intent(in), optional  mask,
class(*), dimension(:,:), intent(in), optional  rmask,
integer, intent(in), optional  ie_in,
integer, intent(in), optional  je_in,
class(*), intent(in), optional  weight,
character(len=*), intent(out), optional  err_msg 
)
private
Returns
true if send is successful

Definition at line 1391 of file diag_manager.F90.

◆ send_data_3d()

logical function send_data_3d ( integer, intent(in)  diag_field_id,
class(*), dimension(:,:,:), intent(in)  field,
type (time_type), intent(in), optional  time,
integer, intent(in), optional  is_in,
integer, intent(in), optional  js_in,
integer, intent(in), optional  ks_in,
logical, dimension(:,:,:), intent(in), optional  mask,
class(*), dimension(:,:,:), intent(in), optional  rmask,
integer, intent(in), optional  ie_in,
integer, intent(in), optional  je_in,
integer, intent(in), optional  ke_in,
class(*), intent(in), optional  weight,
character(len=*), intent(out), optional  err_msg 
)
private
Returns
true if send is successful

Definition at line 1451 of file diag_manager.F90.

◆ diag_manager_mod::send_tile_averaged_data

interface diag_manager_mod::send_tile_averaged_data

Send tile-averaged data over to output fields.

Definition at line 355 of file diag_manager.F90.

Private Member Functions

logical function send_tile_averaged_data1d (id, field, area, time, mask)
 
logical function send_tile_averaged_data2d (id, field, area, time, mask)
 
logical function send_tile_averaged_data3d (id, field, area, time, mask)
 

Member Function/Subroutine Documentation

◆ send_tile_averaged_data1d()

logical function send_tile_averaged_data1d ( integer, intent(in)  id,
real, dimension(:,:), intent(in)  field,
real, dimension (:,:), intent(in)  area,
type(time_type), intent(in)  time,
logical, dimension (:,:), intent(in), optional  mask 
)
private
Returns
true if send is successful
Parameters
[in]idid od the diagnostic field
[in]fieldfield to average and send
[in]areaarea of tiles (== averaging weights), arbitrary units
[in]timecurrent time
[in]maskland mask

Definition at line 3258 of file diag_manager.F90.

◆ send_tile_averaged_data2d()

logical function send_tile_averaged_data2d ( integer, intent(in)  id,
real, dimension(:,:,:), intent(in)  field,
real, dimension (:,:,:), intent(in)  area,
type(time_type), intent(in)  time,
logical, dimension (:,:,:), intent(in), optional  mask 
)
private
Returns
true if send is successful
Parameters
[in]idid od the diagnostic field
[in]fieldfield to average and send
[in]areaarea of tiles (== averaging weights), arbitrary units
[in]timecurrent time
[in]maskland mask

Definition at line 3325 of file diag_manager.F90.

◆ send_tile_averaged_data3d()

logical function send_tile_averaged_data3d ( integer, intent(in)  id,
real, dimension(:,:,:,:), intent(in)  field,
real, dimension (:,:,:), intent(in)  area,
type(time_type), intent(in)  time,
logical, dimension(:,:,:), intent(in), optional  mask 
)
private
Returns
true if send is successful
Parameters
[in]idid of the diagnostic field
[in]field(lon, lat, tile, lev) field to average and send
[in]area(lon, lat, tile) tile areas ( == averaging weights), arbitrary units
[in]timecurrent time
[in]mask(lon, lat, tile) land mask

Definition at line 3345 of file diag_manager.F90.

Function/Subroutine Documentation

◆ add_associated_files()

subroutine diag_manager_mod::add_associated_files ( integer, intent(in)  file_num,
integer, intent(in)  cm_file_num,
integer, intent(in)  cm_ind 
)
private

Add to the associated files attribute.

Exceptions
FATAL,Length of asso_file_name is not long enough to hold the associated file name.The length of character array asso_file_name is not long enough to hold the full file name of the associated_file. Please contact the developer to increase the length of the variable.
Parameters
[in]file_numFile number that needs the associated_files attribute
[in]cm_file_numfile number that contains the associated field
[in]cm_indindex of the output_field in the associated file

Definition at line 1246 of file diag_manager.F90.

◆ average_tiles()

subroutine diag_manager_mod::average_tiles ( integer, intent(in)  diag_field_id,
real, dimension(:,:,:), intent(in)  x,
real, dimension(:,:,:), intent(in)  area,
logical, dimension(:,:,:), intent(in)  mask,
real, dimension(:,:), intent(out)  out 
)
private

Calculates tile average of a field.

Parameters
[in]x(lon, lat, tile) field to average
[in]area(lon, lat, tile) fractional area
[in]mask(lon, lat, tile) land mask
[out]out(lon, lat) result of averaging

Definition at line 3376 of file diag_manager.F90.

◆ average_tiles1d()

subroutine diag_manager_mod::average_tiles1d ( integer, intent(in)  diag_field_id,
real, dimension(:,:), intent(in)  x,
real, dimension(:,:), intent(in)  area,
logical, dimension(:,:), intent(in)  mask,
real, dimension(:), intent(out)  out 
)
private

Calculates average for a field with the given area and land mask.

Parameters
[in]x(ug_index, tile) field to average
[in]area(ug_index, tile) fractional area
[in]mask(ug_index, tile) land mask
[out]out(ug_index) result of averaging

Definition at line 3278 of file diag_manager.F90.

◆ diag_field_add_attribute_i1d()

subroutine diag_manager_mod::diag_field_add_attribute_i1d ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
integer, dimension(:), intent(in)  att_value 
)
private

Add an integer 1D array attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4249 of file diag_manager.F90.

◆ diag_field_add_attribute_r1d()

subroutine diag_manager_mod::diag_field_add_attribute_r1d ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
real, dimension(:), intent(in)  att_value 
)
private

Add a real 1D array attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4240 of file diag_manager.F90.

◆ diag_field_add_attribute_scalar_c()

subroutine diag_manager_mod::diag_field_add_attribute_scalar_c ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
character(len=*), intent(in)  att_value 
)
private

Add a scalar character attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4231 of file diag_manager.F90.

◆ diag_field_add_attribute_scalar_i()

subroutine diag_manager_mod::diag_field_add_attribute_scalar_i ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
integer, intent(in)  att_value 
)
private

Add a scalar integer attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4222 of file diag_manager.F90.

◆ diag_field_add_attribute_scalar_r()

subroutine diag_manager_mod::diag_field_add_attribute_scalar_r ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  att_name,
real, intent(in)  att_value 
)
private

Add a scalar real attribute to the diag field corresponding to a given id.

Parameters
[in]diag_field_idID number for field to add attribute to
[in]att_namenew attribute name
[in]att_valuenew attribute value

Definition at line 4213 of file diag_manager.F90.

◆ diag_field_add_cell_measures()

subroutine, public diag_manager_mod::diag_field_add_cell_measures ( integer, intent(in)  diag_field_id,
integer, intent(in), optional  area,
integer, intent(in), optional  volume 
)

Add the cell_measures attribute to a diag out field.

Add the cell_measures attribute to a give diag field. This is useful if the area/volume fields for the diagnostic field are defined in another module after the diag_field.

Parameters
[in]areadiag ids of area
[in]volumediag ids of volume

Definition at line 4262 of file diag_manager.F90.

◆ diag_field_attribute_init()

subroutine diag_manager_mod::diag_field_attribute_init ( integer, intent(in)  diag_field_id,
character(len=*), intent(in)  name,
integer, intent(in)  type,
character(len=*), intent(in), optional  cval,
integer, dimension(:), intent(in), optional  ival,
real, dimension(:), intent(in), optional  rval 
)
private
Parameters
[in]diag_field_idinput field ID, obtained from diag_manager_mod::register_diag_field.
[in]nameName of the attribute
[in]typeNetCDF type (NF90_FLOAT, NF90_INT, NF90_CHAR)
[in]cvalCharacter string attribute value
[in]ivalInteger attribute value(s)
[in]rvalReal attribute value(s)

Definition at line 4049 of file diag_manager.F90.

◆ diag_manager_init()

subroutine, public diag_manager_mod::diag_manager_init ( integer, intent(in), optional  diag_model_subset,
integer, dimension(6), intent(in), optional  time_init,
character(len=*), intent(out), optional  err_msg 
)

Initialize Diagnostics Manager.

Open and read diag_table. Select fields and files for diagnostic output.

Parameters
[in]time_initModel time diag_manager initialized

Initialize fnum_for_domain with "dn" which stands for done

Definition at line 3778 of file diag_manager.F90.

◆ diag_send_complete_instant()

subroutine, public diag_manager_mod::diag_send_complete_instant ( type (time_type), intent(in)  time)

The subroutine 'diag_send_complete_instant' allows the user to save diagnostic data on variable intervals (user defined in code logic) to the same file. The argument (time_type) will be written to the time axis correspondingly.

The user is responsible for any averaging of accumulated data as this routine is not designed for instantaneous values. This routine works only for send_data calls within OpenMP regions as they are buffered until the complete signal is given.

Definition at line 3598 of file diag_manager.F90.

◆ diag_send_data()

logical function diag_manager_mod::diag_send_data ( integer, intent(in)  diag_field_id,
class(*), dimension(:,:,:), intent(in)  field,
type (time_type), intent(in), optional  time,
integer, intent(in), optional  is_in,
integer, intent(in), optional  js_in,
integer, intent(in), optional  ks_in,
logical, dimension(:,:,:), intent(in), optional, target, contiguous  mask,
class(*), dimension(:,:,:), intent(in), optional, target  rmask,
integer, intent(in), optional  ie_in,
integer, intent(in), optional  je_in,
integer, intent(in), optional  ke_in,
class(*), intent(in), optional  weight,
character(len=*), intent(out), optional  err_msg 
)
private
Returns
true if send is successful

Definition at line 1478 of file diag_manager.F90.

◆ get_base_date()

subroutine, public diag_manager_mod::get_base_date ( integer, intent(out)  year,
integer, intent(out)  month,
integer, intent(out)  day,
integer, intent(out)  hour,
integer, intent(out)  minute,
integer, intent(out)  second 
)

Return base date for diagnostics.

Return date information for diagnostic reference time.

Definition at line 3958 of file diag_manager.F90.

◆ get_base_time()

type(time_type) function, public diag_manager_mod::get_base_time

Return base time for diagnostics.

Returns
time_type get_base_time

Return base time for diagnostics (note: base time must be >= model time).

Definition at line 3947 of file diag_manager.F90.

◆ get_diag_field_id()

integer function, public diag_manager_mod::get_diag_field_id ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  field_name 
)

Return the diagnostic field ID of a given variable.

Returns
get_diag_field_id will return the ID returned during the register_diag_field call. If the variable is not in the diag_table, then the value "DIAG_FIELD_NOT_FOUND" will be returned.
Parameters
[in]module_nameModule name that registered the variable
[in]field_nameVariable name

Definition at line 1099 of file diag_manager.F90.

◆ get_related_field()

logical function diag_manager_mod::get_related_field ( integer, intent(in)  field,
type(output_field_type), intent(in)  rel_field,
integer, intent(out)  out_field_id,
integer, intent(out)  out_file_id 
)
private

Finds the corresponding related output field and file for a given input field.

Returns
Logical get_related_field
Parameters
[in]fieldinput field ID to find the corresponding
[in]rel_fieldOutput field that field must correspond to
[out]out_field_idoutput_field index of related output field
[out]out_file_idfile index of the out_field_id output field

Definition at line 1110 of file diag_manager.F90.

◆ init_diurnal_axis()

integer function diag_manager_mod::init_diurnal_axis ( integer, intent(in)  n_samples)
private

Finds or initializes a diurnal time axis and returns its' ID.

Returns
Integer init_diurnal_axis

Given number of time intervals in the day, finds or initializes a diurnal time axis and returns its ID. It uses get_base_date, so should be in the file where it's accessible. The units are 'days since BASE_DATE', all diurnal axes belong to the set 'diurnal'

Parameters
[in]n_samplesnumber of intervals during the day

Definition at line 4005 of file diag_manager.F90.

◆ init_field_cell_measures()

subroutine diag_manager_mod::init_field_cell_measures ( type(output_field_type), intent(inout)  output_field,
integer, intent(in), optional  area,
integer, intent(in), optional  volume,
character(len=*), intent(out), optional  err_msg 
)
private

If needed, add cell_measures and associated_file attribute to out field/file.

Parameters
[in,out]output_fieldOutput field that needs the cell_measures
[in]areaField ID for area
[in]volumeField ID for volume

Definition at line 1170 of file diag_manager.F90.

◆ need_data()

logical function, public diag_manager_mod::need_data ( integer, intent(in)  diag_field_id,
type(time_type), intent(in)  next_model_time 
)

Determine whether data is needed for the current model time step.

Returns
Logical need_data

Determine whether data is needed for the current model time step. Since diagnostic data are buffered, the "next" model time is passed instead of the current model time. This call can be used to minimize overhead for complicated diagnostics.

Parameters
[in]next_model_timenext_model_time = current model time + model time_step

Definition at line 3978 of file diag_manager.F90.

◆ register_diag_field_array()

integer function diag_manager_mod::register_diag_field_array ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  field_name,
integer, dimension(:), intent(in)  axes,
type(time_type), intent(in), optional  init_time,
character(len=*), intent(in), optional  long_name,
character(len=*), intent(in), optional  units,
class(*), intent(in), optional  missing_value,
class(*), dimension(:), intent(in), optional  range,
logical, intent(in), optional  mask_variant,
character(len=*), intent(in), optional  standard_name,
logical, intent(in), optional  verbose,
logical, intent(in), optional  do_not_log,
character(len=*), intent(out), optional  err_msg,
character(len=*), intent(in), optional  interp_method,
integer, intent(in), optional  tile_count,
integer, intent(in), optional  area,
integer, intent(in), optional  volume,
character(len=*), intent(in), optional  realm 
)
private

Registers an array field.

Returns
field index for subsequent call to send_data.
Parameters
[in]module_nameModule where the field comes from
[in]field_nameName of the field
[in]axesIds corresponding to the variable axis
[in]init_timeTime to start writing data from
[in]long_nameLong_name to add as a variable attribute
[in]unitsUnits to add as a variable_attribute
[in]missing_valueMissing value to add as a variable attribute
[in]rangeRange to add a variable attribute
[in]mask_variantMask variant
[in]standard_nameStandard_name to name the variable in the file
[in]verbosePrint more information
[in]do_not_logIf TRUE, field information is not logged
[out]err_msgError_msg from call
[in]interp_methodThe interp method to be used when regridding the field in post-processing. Valid options are "conserve_order1", "conserve_order2", and "none".
[in]tile_countThe current tile number
[in]areaId of the area field
[in]volumeId of the volume field
[in]realmString to set as the modeling_realm attribute

Definition at line 416 of file diag_manager.F90.

◆ register_diag_field_scalar()

integer function diag_manager_mod::register_diag_field_scalar ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  field_name,
type(time_type), intent(in), optional  init_time,
character(len=*), intent(in), optional  long_name,
character(len=*), intent(in), optional  units,
class(*), intent(in), optional  missing_value,
class(*), dimension(:), intent(in), optional  range,
character(len=*), intent(in), optional  standard_name,
logical, intent(in), optional  do_not_log,
character(len=*), intent(out), optional  err_msg,
integer, intent(in), optional  area,
integer, intent(in), optional  volume,
character(len=*), intent(in), optional  realm 
)
private

Registers a scalar field.

Returns
field index for subsequent call to send_data.
Parameters
[in]module_nameModule where the field comes from
[in]field_nameName of the field
[in]init_timeTime to start writing data from
[in]long_nameLong_name to add as a variable attribute
[in]unitsUnits to add as a variable_attribute
[in]standard_nameStandard_name to name the variable in the file
[in]missing_valueMissing value to add as a variable attribute
[in]rangeRange to add a variable attribute
[in]do_not_logIf TRUE, field information is not logged
[out]err_msgError_msg from call
[in]areaId of the area field
[in]volumeId of the volume field
[in]realmString to set as the modeling_realm attribute

Definition at line 377 of file diag_manager.F90.

◆ register_static_field()

integer function, public diag_manager_mod::register_static_field ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  field_name,
integer, dimension(:), intent(in)  axes,
character(len=*), intent(in), optional  long_name,
character(len=*), intent(in), optional  units,
class(*), intent(in), optional  missing_value,
class(*), dimension(:), intent(in), optional  range,
logical, intent(in), optional  mask_variant,
character(len=*), intent(in), optional  standard_name,
logical, intent(in), optional  DYNAMIC,
logical, intent(in), optional  do_not_log,
character(len=*), intent(in), optional  interp_method,
integer, intent(in), optional  tile_count,
integer, intent(in), optional  area,
integer, intent(in), optional  volume,
character(len=*), intent(in), optional  realm 
)

Return field index for subsequent call to send_data.

Returns
field index for subsequent call to send_data.
Parameters
[in]do_not_logif TRUE, field information is not logged
[in]interp_methodThe interp method to be used when regridding the field in post-processing. Valid options are "conserve_order1", "conserve_order2", and "none".
[in]areaField ID for the area field associated with this field
[in]volumeField ID for the volume field associated with this field
[in]realmString to set as the value to the modeling_realm attribute

Definition at line 617 of file diag_manager.F90.

◆ send_data_0d()

logical function diag_manager_mod::send_data_0d ( integer, intent(in)  diag_field_id,
class(*), intent(in)  field,
type(time_type), intent(in), optional  time,
character(len=*), intent(out), optional  err_msg 
)
private
Returns
true if send is successful

Definition at line 1294 of file diag_manager.F90.

◆ send_data_1d()

logical function diag_manager_mod::send_data_1d ( integer, intent(in)  diag_field_id,
class(*), dimension(:), intent(in)  field,
type (time_type), intent(in), optional  time,
integer, intent(in), optional  is_in,
logical, dimension(:), intent(in), optional  mask,
class(*), dimension(:), intent(in), optional  rmask,
integer, intent(in), optional  ie_in,
class(*), intent(in), optional  weight,
character(len=*), intent(out), optional  err_msg 
)
private
Returns
true if send is successful

Definition at line 1323 of file diag_manager.F90.

◆ send_data_2d()

logical function diag_manager_mod::send_data_2d ( integer, intent(in)  diag_field_id,
class(*), dimension(:,:), intent(in)  field,
type (time_type), intent(in), optional  time,
integer, intent(in), optional  is_in,
integer, intent(in), optional  js_in,
logical, dimension(:,:), intent(in), optional  mask,
class(*), dimension(:,:), intent(in), optional  rmask,
integer, intent(in), optional  ie_in,
integer, intent(in), optional  je_in,
class(*), intent(in), optional  weight,
character(len=*), intent(out), optional  err_msg 
)
private
Returns
true if send is successful

Definition at line 1391 of file diag_manager.F90.

◆ send_data_3d()

logical function diag_manager_mod::send_data_3d ( integer, intent(in)  diag_field_id,
class(*), dimension(:,:,:), intent(in)  field,
type (time_type), intent(in), optional  time,
integer, intent(in), optional  is_in,
integer, intent(in), optional  js_in,
integer, intent(in), optional  ks_in,
logical, dimension(:,:,:), intent(in), optional  mask,
class(*), dimension(:,:,:), intent(in), optional  rmask,
integer, intent(in), optional  ie_in,
integer, intent(in), optional  je_in,
integer, intent(in), optional  ke_in,
class(*), intent(in), optional  weight,
character(len=*), intent(out), optional  err_msg 
)
private
Returns
true if send is successful

Definition at line 1451 of file diag_manager.F90.

◆ send_tile_averaged_data1d()

logical function diag_manager_mod::send_tile_averaged_data1d ( integer, intent(in)  id,
real, dimension(:,:), intent(in)  field,
real, dimension (:,:), intent(in)  area,
type(time_type), intent(in)  time,
logical, dimension (:,:), intent(in), optional  mask 
)
private
Returns
true if send is successful
Parameters
[in]idid od the diagnostic field
[in]fieldfield to average and send
[in]areaarea of tiles (== averaging weights), arbitrary units
[in]timecurrent time
[in]maskland mask

Definition at line 3258 of file diag_manager.F90.

◆ send_tile_averaged_data2d()

logical function diag_manager_mod::send_tile_averaged_data2d ( integer, intent(in)  id,
real, dimension(:,:,:), intent(in)  field,
real, dimension (:,:,:), intent(in)  area,
type(time_type), intent(in)  time,
logical, dimension (:,:,:), intent(in), optional  mask 
)
private
Returns
true if send is successful
Parameters
[in]idid od the diagnostic field
[in]fieldfield to average and send
[in]areaarea of tiles (== averaging weights), arbitrary units
[in]timecurrent time
[in]maskland mask

Definition at line 3325 of file diag_manager.F90.

◆ send_tile_averaged_data3d()

logical function diag_manager_mod::send_tile_averaged_data3d ( integer, intent(in)  id,
real, dimension(:,:,:,:), intent(in)  field,
real, dimension (:,:,:), intent(in)  area,
type(time_type), intent(in)  time,
logical, dimension(:,:,:), intent(in), optional  mask 
)
private
Returns
true if send is successful
Parameters
[in]idid of the diagnostic field
[in]field(lon, lat, tile, lev) field to average and send
[in]area(lon, lat, tile) tile areas ( == averaging weights), arbitrary units
[in]timecurrent time
[in]mask(lon, lat, tile) land mask

Definition at line 3345 of file diag_manager.F90.

◆ writing_field()

integer function diag_manager_mod::writing_field ( integer, intent(in)  out_num,
logical, intent(in)  at_diag_end,
character(len=*), intent(out)  error_string,
type(time_type), intent(in)  time 
)
private
Returns
Integer writing_field

Definition at line 3423 of file diag_manager.F90.