FMS  2024.01.00
Flexible Modeling System
fms_netcdf_domain_io_mod

Domain-specific I/O wrappers. More...

Data Types

interface  compute_global_checksum
 
type  domaindimension_t
 Domain variable. More...
 
type  fmsnetcdfdomainfile_t
 netcdf domain file type. More...
 

Functions/Subroutines

subroutine add_domain_attribute (fileobj, variable_name)
 Add a "domain_decomposed" attribute to the axis variables because it is required by mppnccombine. More...
 
subroutine append_domain_decomposed_dimension (name_, position_, array, size_)
 Add a domain decomposed dimension to an array. More...
 
subroutine, public close_domain_file (fileobj)
 Close a domain netcdf file. More...
 
character(len=32) function compute_global_checksum_2d (fileobj, variable_name, variable_data, is_decomposed)
 @briefs Calculates a variable's checksum across all ranks in the current pelist. More...
 
character(len=32) function compute_global_checksum_3d (fileobj, variable_name, variable_data, is_decomposed)
 @briefs Calculates a variable's checksum across all ranks in the current pelist. More...
 
character(len=32) function compute_global_checksum_4d (fileobj, variable_name, variable_data, is_decomposed)
 @briefs Calculates a variable's checksum across all ranks in the current pelist. More...
 
subroutine domain_offsets (data_xsize, data_ysize, domain, xpos, ypos, isd, isc, xc_size, jsd, jsc, yc_size, buffer_includes_halos, extra_x_point, extra_y_point, msg)
 Utility routine that retrieves domain indices. More...
 
subroutine, public get_compute_domain_dimension_indices (fileobj, dimname, indices)
 Return an array of compute domain indices. More...
 
integer function get_domain_decomposed_dimension_index (fileobj, variable_name, xory, broadcast)
 Given a variable, get the index of the "x" or "y" domain decomposed dimension. More...
 
integer function get_domain_decomposed_index (name_, array, size_)
 Get the index of a domain decomposed dimension. More...
 
integer function get_domain_position (name_, array, size_)
 Given a domain decomposed dimension, get its domain position. More...
 
subroutine, public get_global_io_domain_indices (fileobj, dimname, is, ie, indices)
 Get starting/ending global indices of the I/O domain for a domain decomposed file. More...
 
subroutine, public get_mosaic_tile_grid (grid_file, mosaic_file, domain, tile_count)
 Read a mosaic_file and get the grid filename for the current tile or for the tile specified. More...
 
logical function, public is_dimension_registered (fileobj, dimension_name)
 Determine whether a domain-decomposed dimension has been registered to the file object. More...
 
logical function is_variable_domain_decomposed (fileobj, variable_name, broadcast, xindex, yindex, xpos, ypos)
 Determine if a variable is "domain decomposed.". More...
 
logical function, public open_domain_file (fileobj, path, mode, domain, nc_format, is_restart, dont_add_res_to_filename)
 Open a domain netcdf file. More...
 
subroutine, public register_domain_decomposed_dimension (fileobj, dim_name, xory, domain_position)
 Add a dimension to a file associated with a two-dimensional domain. More...
 
subroutine, public register_domain_variable (fileobj, variable_name, variable_type, dimensions)
 Add a domain decomposed variable. More...
 
subroutine, public restore_domain_state (fileobj, unlim_dim_level, ignore_checksum)
 Loop through registered restart variables and read them from a netcdf file. More...
 
subroutine, public save_domain_restart (fileobj, unlim_dim_level)
 Loop through registered restart variables and write them to a netcdf file. More...
 

Variables

integer, parameter default_domain_position = center
 
character(len=16), parameter domain_axis_att_name = "domain_axis"
 
character(len=16), parameter domain_pos_att = "domain_position"
 
integer, parameter, public max_num_domain_decomposed_dims = 10
 
integer, parameter variable_not_found = 0
 
character(len=16), parameter x = "x"
 
character(len=16), parameter y = "y"
 

Detailed Description

Domain-specific I/O wrappers.


Data Type Documentation

◆ fms_netcdf_domain_io_mod::compute_global_checksum

interface fms_netcdf_domain_io_mod::compute_global_checksum

Definition at line 104 of file fms_netcdf_domain_io.F90.

Private Member Functions

 compute_global_checksum_2d
 
 compute_global_checksum_3d
 
 compute_global_checksum_4d
 

◆ fms_netcdf_domain_io_mod::domaindimension_t

type fms_netcdf_domain_io_mod::domaindimension_t

Domain variable.

Definition at line 50 of file fms_netcdf_domain_io.F90.

Collaboration diagram for domaindimension_t:
[legend]

Private Attributes

integer pos
 Domain position.
 
character(len=nf90_max_name) varname
 Variable name.
 

◆ fms_netcdf_domain_io_mod::fmsnetcdfdomainfile_t

type fms_netcdf_domain_io_mod::fmsnetcdfdomainfile_t

netcdf domain file type.

Definition at line 58 of file fms_netcdf_domain_io.F90.

Collaboration diagram for fmsnetcdfdomainfile_t:
[legend]

Public Attributes

logical adjust_indices
 Flag telling if indices need to be adjusted for domain-decomposed read.
 
type(dimension_informationbc_dimensions
 information about the current dimensions for regional restart variables
 
type(compresseddimension_t), dimension(:), allocatable compressed_dims
 "Compressed" dimension.
 
type(domain2ddomain
 Two-dimensional domain.
 
integer io_root
 I/O root rank of the pelist.
 
logical is_diskless
 Flag telling whether this is a diskless file.
 
logical is_netcdf4
 Flag indicating if the netcdf file type is netcdf4.
 
logical, allocatable is_open
 Allocated and set to true if opened.
 
logical is_readonly
 Flag telling if the file is readonly.
 
logical is_restart
 Flag telling if the this file is a restart file (that has internal pointers to data).
 
logical is_root
 Flag telling if the current rank is the I/O root.
 
logical mode_is_append
 
character(len=256) nc_format
 Netcdf file format.
 
integer ncid
 Netcdf file id.
 
character(len=256) non_mangled_path
 Non-domain-mangled file path.
 
integer num_compressed_dims
 Number of compressed dimensions.
 
integer num_restart_vars
 Number of registered restart variables.
 
integer nx
 Number of "x" dimensions.
 
integer ny
 Number of "y" dimensions.
 
character(len=256) path
 File path.
 
integer, dimension(:), allocatable pelist
 List of ranks who will communicate.
 
type(restartvariable_t), dimension(:), allocatable restart_vars
 Array of registered restart variables.
 
integer tile_comm =MPP_COMM_NULL
 MPI communicator used for collective reads. To be replaced with a real communicator at user request.
 
character(len=20) time_name
 
logical use_collective = .false.
 Flag indicating if we should open the file for collective input this should be set to .true. in the user application if they want collective reads (put before open_file())
 
type(domaindimension_t), dimension(:), allocatable xdims
 Dimensions associated with the "x" axis of a 2d domain.
 
type(domaindimension_t), dimension(:), allocatable ydims
 Dimensions associated with the "y" axis of a 2d domain.
 

Function/Subroutine Documentation

◆ add_domain_attribute()

subroutine fms_netcdf_domain_io_mod::add_domain_attribute ( type(fmsnetcdfdomainfile_t), intent(inout)  fileobj,
character(len=*), intent(in)  variable_name 
)
private

Add a "domain_decomposed" attribute to the axis variables because it is required by mppnccombine.

Parameters
[in,out]fileobjFile object.
[in]variable_nameVariable name.

Definition at line 498 of file fms_netcdf_domain_io.F90.

◆ append_domain_decomposed_dimension()

subroutine fms_netcdf_domain_io_mod::append_domain_decomposed_dimension ( character(len=*), intent(in)  name_,
integer, intent(in)  position_,
type(domaindimension_t), dimension(:), intent(inout)  array,
integer, intent(inout)  size_ 
)
private

Add a domain decomposed dimension to an array.

Parameters
[in]name_Variable name.
[in]position_Domain position.
[in,out]arrayArray to search through.
[in,out]size_Number of spots to look in.

Definition at line 139 of file fms_netcdf_domain_io.F90.

◆ close_domain_file()

subroutine, public fms_netcdf_domain_io_mod::close_domain_file ( type(fmsnetcdfdomainfile_t), intent(inout)  fileobj)

Close a domain netcdf file.

Parameters
[in,out]fileobjFile object.

Definition at line 429 of file fms_netcdf_domain_io.F90.

◆ compute_global_checksum_2d()

character(len=32) function compute_global_checksum_2d ( class(fmsnetcdfdomainfile_t), intent(in)  fileobj,
character(len=*), intent(in)  variable_name,
class(*), dimension(:,:), intent(in)  variable_data,
logical, intent(out)  is_decomposed 
)

@briefs Calculates a variable's checksum across all ranks in the current pelist.

Returns
A hex string containing the checksum.
Parameters
[in]fileobjFile object.
[in]variable_nameVariable name.
[in]variable_dataData to be checksummed.
[out]is_decomposedFlag telling if the variable is decomposed.

Definition at line 27 of file compute_global_checksum.inc.

◆ compute_global_checksum_3d()

character(len=32) function compute_global_checksum_3d ( class(fmsnetcdfdomainfile_t), intent(in)  fileobj,
character(len=*), intent(in)  variable_name,
class(*), dimension(:,:,:), intent(in)  variable_data,
logical, intent(out)  is_decomposed 
)

@briefs Calculates a variable's checksum across all ranks in the current pelist.

Returns
A hex string containing the checksum.
Parameters
[in]fileobjFile object.
[in]variable_nameVariable name.
[in]variable_dataData to be checksummed.
[out]is_decomposedFlag telling if the variable is decomposed.

Definition at line 144 of file compute_global_checksum.inc.

◆ compute_global_checksum_4d()

character(len=32) function compute_global_checksum_4d ( class(fmsnetcdfdomainfile_t), intent(in)  fileobj,
character(len=*), intent(in)  variable_name,
class(*), dimension(:,:,:,:), intent(in)  variable_data,
logical, intent(out)  is_decomposed 
)

@briefs Calculates a variable's checksum across all ranks in the current pelist.

Returns
A hex string containing the checksum.
Parameters
[in]fileobjFile object.
[in]variable_nameVariable name.
[in]variable_dataData to be checksummed.
[out]is_decomposedFlag telling if the variable is decomposed.

Definition at line 260 of file compute_global_checksum.inc.

◆ domain_offsets()

subroutine fms_netcdf_domain_io_mod::domain_offsets ( integer, intent(in)  data_xsize,
integer, intent(in)  data_ysize,
type(domain2d), intent(in)  domain,
integer, intent(in)  xpos,
integer, intent(in)  ypos,
integer, intent(out)  isd,
integer, intent(out)  isc,
integer, intent(out)  xc_size,
integer, intent(out)  jsd,
integer, intent(out)  jsc,
integer, intent(out)  yc_size,
logical, intent(out)  buffer_includes_halos,
logical, intent(out), optional  extra_x_point,
logical, intent(out), optional  extra_y_point,
character(len=*), intent(in), optional  msg 
)
private

Utility routine that retrieves domain indices.

Parameters
[in]data_xsizeSize of buffer's domain "x" dimension.
[in]data_ysizeSize of buffer's domain "y" dimension.
[in]domainParent domain.
[in]xposVariable's domain x dimension position.
[in]yposVariable's domain y dimension position.
[out]isdStarting index for x dimension of data domain.
[out]iscStarting index for x dimension of compute domain.
[out]xc_sizeSize of x dimension of compute domain.
[out]jsdStarting index for y dimension of data domain.
[out]jscStarting index for y dimension of compute domain.
[out]yc_sizeSize of y dimension of compute domain.
[out]buffer_includes_halosFlag telling if input buffer includes space for halos.
[out]extra_x_pointFlag indicating if data_array has an extra point in x
[out]extra_y_pointFlag indicating if data_array has an extra point in y
[in]msgMessage appended to fatal error

Definition at line 756 of file fms_netcdf_domain_io.F90.

◆ get_compute_domain_dimension_indices()

subroutine, public fms_netcdf_domain_io_mod::get_compute_domain_dimension_indices ( type(fmsnetcdfdomainfile_t), intent(in)  fileobj,
character(len=*), intent(in)  dimname,
integer, dimension(:), intent(inout), allocatable  indices 
)

Return an array of compute domain indices.

Parameters
[in]fileobjFile object.
[in]dimnameName of dimension variable.
[in,out]indicesCompute domain indices.

Definition at line 717 of file fms_netcdf_domain_io.F90.

◆ get_domain_decomposed_dimension_index()

integer function fms_netcdf_domain_io_mod::get_domain_decomposed_dimension_index ( type(fmsnetcdfdomainfile_t), intent(in), target  fileobj,
character(len=*), intent(in)  variable_name,
character(len=*), intent(in)  xory,
logical, intent(in), optional  broadcast 
)
private

Given a variable, get the index of the "x" or "y" domain decomposed dimension.

Returns
Index of the domain decomposed dimension or else no_domain_decomposed_dimension.
Parameters
[in]fileobjFile object.
[in]variable_nameVariable name.
[in]xoryString telling which dimension to look for. Valid values are "x" or "y".
[in]broadcastFlag controlling whether or not the index will be broadcast to non "I/O root" ranks. The broadcast will be done by default.

Definition at line 183 of file fms_netcdf_domain_io.F90.

◆ get_domain_decomposed_index()

integer function fms_netcdf_domain_io_mod::get_domain_decomposed_index ( character(len=*), intent(in)  name_,
type(domaindimension_t), dimension(:), intent(in)  array,
integer, intent(in)  size_ 
)
private

Get the index of a domain decomposed dimension.

Returns
Index of domain decomposed dimension.
Parameters
[in]name_Name.
[in]arrayArray to search through.
[in]size_Number of spots to look in.

Definition at line 118 of file fms_netcdf_domain_io.F90.

◆ get_domain_position()

integer function fms_netcdf_domain_io_mod::get_domain_position ( character(len=*), intent(in)  name_,
type(domaindimension_t), dimension(:), intent(in)  array,
integer, intent(in)  size_ 
)
private

Given a domain decomposed dimension, get its domain position.

Returns
Position of the domain decomposed variable.
Parameters
[in]name_Variable name.
[in]arrayArray to search through.

Definition at line 164 of file fms_netcdf_domain_io.F90.

◆ get_global_io_domain_indices()

subroutine, public fms_netcdf_domain_io_mod::get_global_io_domain_indices ( type(fmsnetcdfdomainfile_t), intent(in)  fileobj,
character(len=*), intent(in)  dimname,
integer, intent(out)  is,
integer, intent(out)  ie,
integer, dimension(:), intent(out), optional, allocatable  indices 
)

Get starting/ending global indices of the I/O domain for a domain decomposed file.

Parameters
[in]fileobjFile object.
[in]dimnameName of dimension variable.
[out]isStaring index of I/O global domain.
[out]ieEnding index of I/O global domain.
[out]indicesGlobal domain indices

Definition at line 827 of file fms_netcdf_domain_io.F90.

◆ get_mosaic_tile_grid()

subroutine, public fms_netcdf_domain_io_mod::get_mosaic_tile_grid ( character(len=*), intent(out)  grid_file,
character(len=*), intent(in)  mosaic_file,
type(domain2d), intent(in)  domain,
integer, intent(in), optional  tile_count 
)

Read a mosaic_file and get the grid filename for the current tile or for the tile specified.

Parameters
[out]grid_fileFilename of the grid file for the current domain tile or for tile specified in tile_count
[in]mosaic_fileFilename that will be read
[in]domainInput domain
[in]tile_countOptional argument indicating the tile you want grid file name for this is for when a pe is in more than tile.

Definition at line 872 of file fms_netcdf_domain_io.F90.

◆ is_dimension_registered()

logical function, public fms_netcdf_domain_io_mod::is_dimension_registered ( type(fmsnetcdfdomainfile_t), intent(in)  fileobj,
character(len=*), intent(in)  dimension_name 
)

Determine whether a domain-decomposed dimension has been registered to the file object.

Returns
Flag telling if the dimension is registered to the file object
Parameters
[in]fileobjFile object.
[in]dimension_nameDimension name.

Definition at line 300 of file fms_netcdf_domain_io.F90.

◆ is_variable_domain_decomposed()

logical function fms_netcdf_domain_io_mod::is_variable_domain_decomposed ( type(fmsnetcdfdomainfile_t), intent(in)  fileobj,
character(len=*), intent(in)  variable_name,
logical, intent(in), optional  broadcast,
integer, intent(out), optional  xindex,
integer, intent(out), optional  yindex,
integer, intent(out), optional  xpos,
integer, intent(out), optional  ypos 
)
private

Determine if a variable is "domain decomposed.".

Returns
Flag telling if the variable is "domain decomposed."
Parameters
[in]fileobjFile object.
[in]variable_nameVariable name.
[in]broadcastFlag controlling whether or not the index will be broadcast to non "I/O root" ranks. The broadcast will be done by default.
[out]xindexThe index of the domain x dimension.
[out]yindexThe index of the domain y dimension.
[out]xposDomain position of the x dimension.
[out]yposDomain position of the y dimension.

Definition at line 239 of file fms_netcdf_domain_io.F90.

◆ open_domain_file()

logical function, public fms_netcdf_domain_io_mod::open_domain_file ( type(fmsnetcdfdomainfile_t), intent(inout)  fileobj,
character(len=*), intent(in)  path,
character(len=*), intent(in)  mode,
type(domain2d), intent(in)  domain,
character(len=*), intent(in), optional  nc_format,
logical, intent(in), optional  is_restart,
logical, intent(in), optional  dont_add_res_to_filename 
)

Open a domain netcdf file.

Returns
Flag telling if the open completed successfully.
Parameters
[in,out]fileobjFile object.
[in]pathFile path.
[in]modeFile mode. Allowed values are "read", "append", "write", or "overwrite".
[in]domainTwo-dimensional domain.
[in]nc_formatNetcdf format that new files are written as. Allowed values are: "64bit", "classic", or "netcdf4". Defaults to "64bit".
[in]is_restartFlag telling if this file is a restart file. Defaults to false.
[in]dont_add_res_to_filenameFlag indicating not to add ".res" to the filename

Definition at line 325 of file fms_netcdf_domain_io.F90.

◆ register_domain_decomposed_dimension()

subroutine, public fms_netcdf_domain_io_mod::register_domain_decomposed_dimension ( type(fmsnetcdfdomainfile_t), intent(inout)  fileobj,
character(len=*), intent(in)  dim_name,
character(len=*), intent(in)  xory,
integer, intent(in), optional  domain_position 
)

Add a dimension to a file associated with a two-dimensional domain.

Parameters
[in,out]fileobjFile object.
[in]dim_nameDimension name.
[in]xoryFlag telling if the dimension is associated with the "x" or "y" axis of the 2d domain. Allowed values are "x" or "y".
[in]domain_positionDomain position.

Definition at line 442 of file fms_netcdf_domain_io.F90.

◆ register_domain_variable()

subroutine, public fms_netcdf_domain_io_mod::register_domain_variable ( type(fmsnetcdfdomainfile_t), intent(inout)  fileobj,
character(len=*), intent(in)  variable_name,
character(len=*), intent(in)  variable_type,
character(len=*), dimension(:), intent(in), optional  dimensions 
)

Add a domain decomposed variable.

Parameters
[in,out]fileobjFile object.
[in]variable_nameVariable name.
[in]variable_typeVariable type. Allowed values are: "int", "int64", "float", or "double".
[in]dimensionsDimension names.

Definition at line 538 of file fms_netcdf_domain_io.F90.

◆ restore_domain_state()

subroutine, public fms_netcdf_domain_io_mod::restore_domain_state ( type(fmsnetcdfdomainfile_t), intent(inout)  fileobj,
integer, intent(in), optional  unlim_dim_level,
logical, intent(in), optional  ignore_checksum 
)

Loop through registered restart variables and read them from a netcdf file.

Parameters
[in,out]fileobjFile object.
[in]unlim_dim_levelUnlimited dimension level.
[in]ignore_checksumChecksum data integrity flag.

Definition at line 628 of file fms_netcdf_domain_io.F90.

◆ save_domain_restart()

subroutine, public fms_netcdf_domain_io_mod::save_domain_restart ( type(fmsnetcdfdomainfile_t), intent(in)  fileobj,
integer, intent(in), optional  unlim_dim_level 
)

Loop through registered restart variables and write them to a netcdf file.

Parameters
[in]fileobjFile object.
[in]unlim_dim_levelUnlimited dimension level.

Definition at line 560 of file fms_netcdf_domain_io.F90.