MOM6
|
This module contains I/O framework code.
This file contains a number of subroutines that manipulate NetCDF files and handle input and output of fields. These subroutines, along with their purpose, are:
Data Types | |
interface | file_exists |
Indicate whether a file exists, perhaps with domain decomposition. More... | |
interface | mom_read_data |
Read a data field from a file. More... | |
interface | mom_read_vector |
Read a pair of data fields representing the two components of a vector from a file. More... | |
type | vardesc |
Type for describing a variable, typically a tracer. More... | |
Functions/Subroutines | |
subroutine, public | create_file (unit, filename, vars, novars, fields, threading, timeunit, G, dG, GV, checksums) |
Routine creates a new NetCDF file. It also sets up structures that describe this file and variables that will later be written to this file. Type for describing a variable, typically a tracer. More... | |
subroutine, public | reopen_file (unit, filename, vars, novars, fields, threading, timeunit, G, dG, GV) |
This routine opens an existing NetCDF file for output. If it does not find the file, a new file is created. It also sets up structures that describe this file and the variables that will later be written to this file. More... | |
subroutine, public | read_axis_data (filename, axis_name, var) |
Read the data associated with a named axis in a file. More... | |
integer function, public | num_timelevels (filename, varname, min_dims) |
This function determines how many time levels a variable has. More... | |
type(vardesc) function, public | var_desc (name, units, longname, hor_grid, z_grid, t_grid, cmor_field_name, cmor_units, cmor_longname, conversion, caller) |
Returns a vardesc type whose elements have been filled with the provided fields. The argument name is required, while the others are optional and have default values that are empty strings or are appropriate for a 3-d tracer field at the tracer cell centers. More... | |
subroutine, public | modify_vardesc (vd, name, units, longname, hor_grid, z_grid, t_grid, cmor_field_name, cmor_units, cmor_longname, conversion, caller) |
This routine modifies the named elements of a vardesc type. All arguments are optional, except the vardesc type to be modified. More... | |
character(len=len(longname)) function, public | cmor_long_std (longname) |
This function returns the CMOR standard name given a CMOR longname, based on the standard pattern of character conversions. More... | |
subroutine, public | query_vardesc (vd, name, units, longname, hor_grid, z_grid, t_grid, cmor_field_name, cmor_units, cmor_longname, conversion, caller) |
This routine queries vardesc. More... | |
subroutine | safe_string_copy (str1, str2, fieldnm, caller) |
Copies a string. More... | |
character(len=len(name)) function, public | ensembler (name, ens_no_in) |
Returns a name with "%#E" or "%E" replaced with the ensemble member number. More... | |
logical function | mom_file_exists (filename, MOM_Domain) |
Returns true if the named file or its domain-decomposed variant exists. More... | |
logical function | fms_file_exists (filename, domain, no_domain) |
Returns true if the named file or its domain-decomposed variant exists. More... | |
subroutine | mom_read_data_1d (filename, fieldname, data, timelevel, scale) |
This function uses the fms_io function read_data to read 1-D data field named "fieldname" from file "filename". More... | |
subroutine | mom_read_data_2d (filename, fieldname, data, MOM_Domain, timelevel, position, scale) |
This function uses the fms_io function read_data to read a distributed 2-D data field named "fieldname" from file "filename". Valid values for "position" include CORNER, CENTER, EAST_FACE and NORTH_FACE. More... | |
subroutine | mom_read_data_3d (filename, fieldname, data, MOM_Domain, timelevel, position, scale) |
This function uses the fms_io function read_data to read a distributed 3-D data field named "fieldname" from file "filename". Valid values for "position" include CORNER, CENTER, EAST_FACE and NORTH_FACE. More... | |
subroutine | mom_read_data_4d (filename, fieldname, data, MOM_Domain, timelevel, position, scale) |
This function uses the fms_io function read_data to read a distributed 4-D data field named "fieldname" from file "filename". Valid values for "position" include CORNER, CENTER, EAST_FACE and NORTH_FACE. More... | |
subroutine | mom_read_vector_2d (filename, u_fieldname, v_fieldname, u_data, v_data, MOM_Domain, timelevel, stagger, scalar_pair, scale) |
This function uses the fms_io function read_data to read a pair of distributed 2-D data fields with names given by "[uv]_fieldname" from file "filename". Valid values for "stagger" include CGRID_NE, BGRID_NE, and AGRID. More... | |
subroutine | mom_read_vector_3d (filename, u_fieldname, v_fieldname, u_data, v_data, MOM_Domain, timelevel, stagger, scalar_pair, scale) |
This function uses the fms_io function read_data to read a pair of distributed 3-D data fields with names given by "[uv]_fieldname" from file "filename". Valid values for "stagger" include CGRID_NE, BGRID_NE, and AGRID. More... | |
subroutine, public | mom_io_init (param_file) |
Initialize the MOM_io module. More... | |
character(len=len(longname)) function, public mom_io::cmor_long_std | ( | character(len=*), intent(in) | longname | ) |
This function returns the CMOR standard name given a CMOR longname, based on the standard pattern of character conversions.
[in] | longname | The CMOR longname being converted |
Definition at line 683 of file MOM_io.F90.
References mom_string_functions::lowercase().
Referenced by mom_tracer_registry::register_tracer_diagnostics().
subroutine, public mom_io::create_file | ( | integer, intent(out) | unit, |
character(len=*), intent(in) | filename, | ||
type(vardesc), dimension(:), intent(in) | vars, | ||
integer, intent(in) | novars, | ||
type(fieldtype), dimension(:), intent(inout) | fields, | ||
integer, intent(in), optional | threading, | ||
real, intent(in), optional | timeunit, | ||
type(ocean_grid_type), intent(in), optional | G, | ||
type(dyn_horgrid_type), intent(in), optional | dG, | ||
type(verticalgrid_type), intent(in), optional | GV, | ||
integer(kind=8), dimension(:,:), intent(in), optional | checksums | ||
) |
Routine creates a new NetCDF file. It also sets up structures that describe this file and variables that will later be written to this file. Type for describing a variable, typically a tracer.
[out] | unit | unit id of an open file or -1 on a nonwriting PE with single file output |
[in] | filename | full path to the file to create |
[in] | vars | structures describing fields written to filename |
[in] | novars | number of fields written to filename |
[in,out] | fields | array of fieldtypes for each variable |
[in] | threading | SINGLE_FILE or MULTIPLE |
[in] | timeunit | length of the units for time [s]. The default value is 86400.0, for 1 day. |
[in] | g | ocean horizontal grid structure; G or dG is required if the new file uses any horizontal grid axes. |
[in] | dg | dynamic horizontal grid structure; G or dG is required if the new file uses any horizontal grid axes. |
[in] | gv | ocean vertical grid structure, which is required if the new file uses any vertical grid axes. |
[in] | checksums | checksums of vars |
Definition at line 93 of file MOM_io.F90.
References mom_error_handler::mom_error().
Referenced by mom_ale::ale_writecoordinatefile(), and reopen_file().
character(len=len(name)) function, public mom_io::ensembler | ( | character(len=*), intent(in) | name, |
integer, intent(in), optional | ens_no_in | ||
) |
Returns a name with "%#E" or "%E" replaced with the ensemble member number.
[in] | name | The name to be modified |
[in] | ens_no_in | The number of the current ensemble member |
Definition at line 763 of file MOM_io.F90.
References mom_error_handler::mom_error().
|
private |
Returns true if the named file or its domain-decomposed variant exists.
[in] | filename | The name of the file being inquired about |
[in] | domain | The mpp domain2d that describes the decomposition |
[in] | no_domain | This file does not use domain decomposition |
Definition at line 835 of file MOM_io.F90.
subroutine, public mom_io::modify_vardesc | ( | type(vardesc), intent(inout) | vd, |
character(len=*), intent(in), optional | name, | ||
character(len=*), intent(in), optional | units, | ||
character(len=*), intent(in), optional | longname, | ||
character(len=*), intent(in), optional | hor_grid, | ||
character(len=*), intent(in), optional | z_grid, | ||
character(len=*), intent(in), optional | t_grid, | ||
character(len=*), intent(in), optional | cmor_field_name, | ||
character(len=*), intent(in), optional | cmor_units, | ||
character(len=*), intent(in), optional | cmor_longname, | ||
real, intent(in), optional | conversion, | ||
character(len=*), intent(in), optional | caller | ||
) |
This routine modifies the named elements of a vardesc type. All arguments are optional, except the vardesc type to be modified.
[in,out] | vd | vardesc type that is modified |
[in] | name | name of variable |
[in] | units | units of variable |
[in] | longname | long name of variable |
[in] | hor_grid | horizonal staggering of variable |
[in] | z_grid | vertical staggering of variable |
[in] | t_grid | time description: s, p, or 1 |
[in] | cmor_field_name | CMOR name |
[in] | cmor_units | CMOR physical dimensions of variable |
[in] | cmor_longname | CMOR long name |
[in] | conversion | for unit conversions, such as needed to convert from intensive to extensive |
[in] | caller | calling routine? |
Definition at line 640 of file MOM_io.F90.
References safe_string_copy().
Referenced by var_desc().
|
private |
Returns true if the named file or its domain-decomposed variant exists.
[in] | filename | The name of the file being inquired about |
[in] | mom_domain | The MOM_Domain that describes the decomposition |
Definition at line 821 of file MOM_io.F90.
subroutine, public mom_io::mom_io_init | ( | type(param_file_type), intent(in) | param_file | ) |
Initialize the MOM_io module.
[in] | param_file | structure indicating the open file to parse for model parameter values. |
Definition at line 1043 of file MOM_io.F90.
|
private |
This function uses the fms_io function read_data to read 1-D data field named "fieldname" from file "filename".
[in] | filename | The name of the file to read |
[in] | fieldname | The variable name of the data in the file |
[in,out] | data | The 1-dimensional array into which the data |
[in] | timelevel | The time level in the file to read |
[in] | scale | A scaling factor that the field is multiplied by before they are returned. |
Definition at line 850 of file MOM_io.F90.
|
private |
This function uses the fms_io function read_data to read a distributed 2-D data field named "fieldname" from file "filename". Valid values for "position" include CORNER, CENTER, EAST_FACE and NORTH_FACE.
[in] | filename | The name of the file to read |
[in] | fieldname | The variable name of the data in the file |
[in,out] | data | The 2-dimensional array into which the data should be read |
[in] | mom_domain | The MOM_Domain that describes the decomposition |
[in] | timelevel | The time level in the file to read |
[in] | position | A flag indicating where this data is located |
[in] | scale | A scaling factor that the field is multiplied by before they are returned. |
Definition at line 870 of file MOM_io.F90.
References mom_domains::get_simple_array_i_ind(), and mom_domains::get_simple_array_j_ind().
|
private |
This function uses the fms_io function read_data to read a distributed 3-D data field named "fieldname" from file "filename". Valid values for "position" include CORNER, CENTER, EAST_FACE and NORTH_FACE.
[in] | filename | The name of the file to read |
[in] | fieldname | The variable name of the data in the file |
[in,out] | data | The 3-dimensional array into which the data should be read |
[in] | mom_domain | The MOM_Domain that describes the decomposition |
[in] | timelevel | The time level in the file to read |
[in] | position | A flag indicating where this data is located |
[in] | scale | A scaling factor that the field is multiplied by before they are returned. |
Definition at line 898 of file MOM_io.F90.
References mom_domains::get_simple_array_i_ind(), and mom_domains::get_simple_array_j_ind().
|
private |
This function uses the fms_io function read_data to read a distributed 4-D data field named "fieldname" from file "filename". Valid values for "position" include CORNER, CENTER, EAST_FACE and NORTH_FACE.
[in] | filename | The name of the file to read |
[in] | fieldname | The variable name of the data in the file |
[in,out] | data | The 4-dimensional array into which the data should be read |
[in] | mom_domain | The MOM_Domain that describes the decomposition |
[in] | timelevel | The time level in the file to read |
[in] | position | A flag indicating where this data is located |
[in] | scale | A scaling factor that the field is multiplied by before they are returned. |
Definition at line 926 of file MOM_io.F90.
References mom_domains::get_simple_array_i_ind(), and mom_domains::get_simple_array_j_ind().
|
private |
This function uses the fms_io function read_data to read a pair of distributed 2-D data fields with names given by "[uv]_fieldname" from file "filename". Valid values for "stagger" include CGRID_NE, BGRID_NE, and AGRID.
[in] | filename | The name of the file to read |
[in] | u_fieldname | The variable name of the u data in the file |
[in] | v_fieldname | The variable name of the v data in the file |
[in,out] | u_data | The 2 dimensional array into which the u-component of the data should be read |
[in,out] | v_data | The 2 dimensional array into which the v-component of the data should be read |
[in] | mom_domain | The MOM_Domain that describes the decomposition |
[in] | timelevel | The time level in the file to read |
[in] | stagger | A flag indicating where this vector is discretized |
[in] | scalar_pair | If true, a pair of scalars are to be read.cretized |
[in] | scale | A scaling factor that the fields are multiplied by before they are returned. |
Definition at line 955 of file MOM_io.F90.
References mom_domains::get_simple_array_i_ind(), and mom_domains::get_simple_array_j_ind().
|
private |
This function uses the fms_io function read_data to read a pair of distributed 3-D data fields with names given by "[uv]_fieldname" from file "filename". Valid values for "stagger" include CGRID_NE, BGRID_NE, and AGRID.
[in] | filename | The name of the file to read |
[in] | u_fieldname | The variable name of the u data in the file |
[in] | v_fieldname | The variable name of the v data in the file |
[in,out] | u_data | The 3 dimensional array into which the u-component of the data should be read |
[in,out] | v_data | The 3 dimensional array into which the v-component of the data should be read |
[in] | mom_domain | The MOM_Domain that describes the decomposition |
[in] | timelevel | The time level in the file to read |
[in] | stagger | A flag indicating where this vector is discretized |
[in] | scalar_pair | If true, a pair of scalars are to be read.cretized |
[in] | scale | A scaling factor that the fields are multiplied by before they are returned. |
Definition at line 1000 of file MOM_io.F90.
References mom_domains::get_simple_array_i_ind(), and mom_domains::get_simple_array_j_ind().
integer function, public mom_io::num_timelevels | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
integer, intent(in), optional | min_dims | ||
) |
This function determines how many time levels a variable has.
[in] | filename | name of the file to read |
[in] | varname | variable whose number of time levels are to be returned |
[in] | min_dims | The minimum number of dimensions a variable must have if it has a time dimension. If the variable has 1 less dimension than this, then 0 is returned. |
Definition at line 478 of file MOM_io.F90.
References mom_string_functions::lowercase(), and mom_error_handler::mom_error().
Referenced by mom_surface_forcing::surface_forcing_init().
subroutine, public mom_io::query_vardesc | ( | type(vardesc), intent(in) | vd, |
character(len=*), intent(out), optional | name, | ||
character(len=*), intent(out), optional | units, | ||
character(len=*), intent(out), optional | longname, | ||
character(len=*), intent(out), optional | hor_grid, | ||
character(len=*), intent(out), optional | z_grid, | ||
character(len=*), intent(out), optional | t_grid, | ||
character(len=*), intent(out), optional | cmor_field_name, | ||
character(len=*), intent(out), optional | cmor_units, | ||
character(len=*), intent(out), optional | cmor_longname, | ||
real, intent(out), optional | conversion, | ||
character(len=*), intent(in), optional | caller | ||
) |
This routine queries vardesc.
[in] | vd | vardesc type that is queried |
[out] | name | name of variable |
[out] | units | units of variable |
[out] | longname | long name of variable |
[out] | hor_grid | horiz staggering of variable |
[out] | z_grid | vert staggering of variable |
[out] | t_grid | time description: s, p, or 1 |
[out] | cmor_field_name | CMOR name |
[out] | cmor_units | CMOR physical dimensions of variable |
[out] | cmor_longname | CMOR long name |
[out] | conversion | for unit conversions, such as needed to convert from intensive to extensive |
[in] | caller | calling routine? |
Definition at line 699 of file MOM_io.F90.
References safe_string_copy().
Referenced by advection_test_tracer::advection_test_stock(), boundary_impulse_tracer::boundary_impulse_stock(), regional_dyes::dye_stock(), ideal_age_example::ideal_age_stock(), advection_test_tracer::initialize_advection_test_tracer(), boundary_impulse_tracer::initialize_boundary_impulse_tracer(), dome_tracer::initialize_dome_tracer(), dyed_obc_tracer::initialize_dyed_obc_tracer(), ideal_age_example::initialize_ideal_age_tracer(), isomip_tracer::initialize_isomip_tracer(), oil_tracer::initialize_oil_tracer(), pseudo_salt_tracer::initialize_pseudo_salt_tracer(), rgc_tracer::initialize_rgc_tracer(), mom_ocmip2_cfc::ocmip2_cfc_stock(), oil_tracer::oil_stock(), pseudo_salt_tracer::pseudo_salt_stock(), boundary_impulse_tracer::register_boundary_impulse_tracer(), regional_dyes::register_dye_tracer(), ideal_age_example::register_ideal_age_tracer(), oil_tracer::register_oil_tracer(), pseudo_salt_tracer::register_pseudo_salt_tracer(), mom_tracer_registry::register_tracer(), user_tracer_example::user_initialize_tracer(), and user_tracer_example::user_tracer_stock().
subroutine, public mom_io::read_axis_data | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | axis_name, | ||
real, dimension(:), intent(out) | var | ||
) |
Read the data associated with a named axis in a file.
[in] | filename | Name of the file to read |
[in] | axis_name | Name of the axis to read |
[out] | var | The axis location data |
Definition at line 438 of file MOM_io.F90.
References mom_error_handler::mom_error().
subroutine, public mom_io::reopen_file | ( | integer, intent(out) | unit, |
character(len=*), intent(in) | filename, | ||
type(vardesc), dimension(:), intent(in) | vars, | ||
integer, intent(in) | novars, | ||
type(fieldtype), dimension(:), intent(inout) | fields, | ||
integer, intent(in), optional | threading, | ||
real, intent(in), optional | timeunit, | ||
type(ocean_grid_type), intent(in), optional | G, | ||
type(dyn_horgrid_type), intent(in), optional | dG, | ||
type(verticalgrid_type), intent(in), optional | GV | ||
) |
This routine opens an existing NetCDF file for output. If it does not find the file, a new file is created. It also sets up structures that describe this file and the variables that will later be written to this file.
[out] | unit | unit id of an open file or -1 on a nonwriting PE with single file output |
[in] | filename | full path to the file to create |
[in] | vars | structures describing fields written to filename |
[in] | novars | number of fields written to filename |
[in,out] | fields | array of fieldtypes for each variable |
[in] | threading | SINGLE_FILE or MULTIPLE |
[in] | timeunit | length of the units for time [s]. The default value is 86400.0, for 1 day. |
[in] | g | ocean horizontal grid structure; G or dG is required if a new file uses any horizontal grid axes. |
[in] | dg | dynamic horizontal grid structure; G or dG is required if a new file uses any horizontal grid axes. |
[in] | gv | ocean vertical grid structure, which is required if a new file uses any vertical grid axes. |
Definition at line 353 of file MOM_io.F90.
References create_file(), and mom_error_handler::mom_error().
|
private |
Copies a string.
[in] | str1 | The string being copied |
[out] | str2 | The string being copied into |
[in] | fieldnm | The name of the field for error messages |
[in] | caller | The calling routine for error messages |
Definition at line 743 of file MOM_io.F90.
References mom_error_handler::mom_error().
Referenced by modify_vardesc(), query_vardesc(), and var_desc().
type(vardesc) function, public mom_io::var_desc | ( | character(len=*), intent(in) | name, |
character(len=*), intent(in), optional | units, | ||
character(len=*), intent(in), optional | longname, | ||
character(len=*), intent(in), optional | hor_grid, | ||
character(len=*), intent(in), optional | z_grid, | ||
character(len=*), intent(in), optional | t_grid, | ||
character(len=*), intent(in), optional | cmor_field_name, | ||
character(len=*), intent(in), optional | cmor_units, | ||
character(len=*), intent(in), optional | cmor_longname, | ||
real, intent(in), optional | conversion, | ||
character(len=*), intent(in), optional | caller | ||
) |
Returns a vardesc type whose elements have been filled with the provided fields. The argument name is required, while the others are optional and have default values that are empty strings or are appropriate for a 3-d tracer field at the tracer cell centers.
[in] | name | variable name |
[in] | units | variable units |
[in] | longname | variable long name |
[in] | hor_grid | variable horizonal staggering |
[in] | z_grid | variable vertical staggering |
[in] | t_grid | time description: s, p, or 1 |
[in] | cmor_field_name | CMOR name |
[in] | cmor_units | CMOR physical dimensions of variable |
[in] | cmor_longname | CMOR long name |
[in] | conversion | for unit conversions, such as needed to convert from intensive to extensive |
[in] | caller | calling routine? |
Definition at line 600 of file MOM_io.F90.
References modify_vardesc(), and safe_string_copy().
Referenced by mom_meke::meke_alloc_register_restart(), mom_mixed_layer_restrat::mixedlayer_restrat_register_restarts(), advection_test_tracer::register_advection_test_tracer(), mom_barotropic::register_barotropic_restarts(), boundary_impulse_tracer::register_boundary_impulse_tracer(), mom_controlled_forcing::register_ctrl_forcing_restarts(), dome_tracer::register_dome_tracer(), regional_dyes::register_dye_tracer(), dyed_obc_tracer::register_dyed_obc_tracer(), ideal_age_example::register_ideal_age_tracer(), isomip_tracer::register_isomip_tracer(), mom_ocmip2_cfc::register_ocmip2_cfc(), oil_tracer::register_oil_tracer(), pseudo_salt_tracer::register_pseudo_salt_tracer(), mom_dynamics_split_rk2::register_restarts_dyn_split_rk2(), rgc_tracer::register_rgc_tracer(), user_tracer_example::user_register_tracer_example(), and mom_coord_initialization::write_vertgrid_file().