The Intermediate Complexity Atmospheric Research model (ICAR)
A computationally efficient atmospheric model for downscaling.
 All Classes Files Functions Variables
Data Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
linear_theory_lut_disk_io Module Reference


Handle reading and writing Linear wind Look up tables to/from disk More...

Data Types

interface  check_attribute
 
interface  write_var
 

Public Member Functions

integer function, public write_lut (filename, uLUT, vLUT, dz, options)
 

Write linear wind look up tables to disk along with the parameters for that table More...

 
integer function, public read_lut (filename, uLUT, vLUT, dz, dims, options)
 

Write linear wind look up tables to disk along with the parameters for that table More...

 

Private Member Functions

logical function dims_match (filename, dimensions)
 

Check that the dimensions of a LUT file and current expected LUT match More...

 
integer function check_dz (filename, model_dz)
 

Check that the dz level thicknesses of a LUT file and current domain match More...

 
integer function write_var_6d (filename, varname, data_out, dimnames, open_new_file)
 

Write a 6D variable to a netCDF file More...

 
integer function write_var_1d (filename, varname, data_out, dimnames, open_new_file)
 

Same as write_var_6d but for a 1D variable More...

 
integer function setup_var (ncid, varname, varid, dimids, dims)
 

Setup a new variable to be written More...

 
integer function setup_dim (ncid, dimname, dimid, n)
 

Setup a new dimension in a given netcdf file More...

 
integer function check_attribute_r (filename, default_value, value_name)
 

Check that a named real attribute matches the value in a file More...

 
integer function check_attribute_i (filename, default_value, value_name)
 

Check that a named integer attribute matches the value in a file More...

 
integer function check_attribute_c (filename, default_value, value_name)
 

Check that a named character attribute matches the value in a file More...

 

Private Attributes

character(len=10), parameter lt_lut_version ="1.0"
 

Detailed Description


Handle reading and writing Linear wind Look up tables to/from disk

Look up tables are written from disk in a documented netCDF file (e.g. with all LUT options) When a LUT is read from disk, the options stored in that file are checked against the options specified for the current run. If they are compatible (x, y, and z shape) the LUT will be read If the options for the current run are not the same as those in the file, a warning is printed but and an error will be thrown, the model will continue, it will just use the options stored in the file so the LUT does not need to be regenerated.

Author
Ethan Gutmann (gutma.nosp@m.nn@u.nosp@m.car.e.nosp@m.du)

Member Function/Subroutine Documentation

integer function linear_theory_lut_disk_io::check_attribute_c ( character(len=*), intent(in)  filename,
character(len=*), intent(in)  default_value,
character(len=*), intent(in)  value_name 
)
private


Check that a named character attribute matches the value in a file

Takes a filename, attribute name, and expected attribute value Reads the attribute from the file, and compares the results to the expected value. If the results match the function is successful and 0 is returned, else 1 is returned

Parameters
filenamename of the netCDF file
default_valueexpected value of the attribute
value_namename of the attribute to read
Return values
error0 if expected matches read, 1 otherwise
integer function linear_theory_lut_disk_io::check_attribute_i ( character(len=*), intent(in)  filename,
integer, intent(in)  default_value,
character(len=*), intent(in)  value_name 
)
private


Check that a named integer attribute matches the value in a file

Takes a filename, attribute name, and expected attribute value Reads the attribute from the file, and compares the results to the expected value. If the results match the function is successful and 0 is returned, else 1 is returned

Parameters
filenamename of the netCDF file
default_valueexpected value of the attribute
value_namename of the attribute to read
Return values
error0 if expected matches read, 1 otherwise
integer function linear_theory_lut_disk_io::check_attribute_r ( character(len=*), intent(in)  filename,
real, intent(in)  default_value,
character(len=*), intent(in)  value_name 
)
private


Check that a named real attribute matches the value in a file

Takes a filename, attribute name, and expected attribute value Reads the attribute from the file, and compares the results to the expected value. If the results are within 1e-20 of each other. they are assumed to match, and 0 is returned, else 1 is returned

Parameters
filenamename of the netCDF file
default_valueexpected value of the attribute
value_namename of the attribute to read
Return values
error0 if expected matches read, 1 otherwise
integer function linear_theory_lut_disk_io::check_dz ( character(len=*), intent(in)  filename,
real, dimension(:), intent(in)  model_dz 
)
private


Check that the dz level thicknesses of a LUT file and current domain match

Takes a filename and the dz thicknesses of the current model run. Checks the expected dz against the LUT file dz.

Parameters
filenameName of LUT file to check
model_dzArray to hold current model thicknesses (1D real)
Return values
error0 if they match, 1 otherwise

Here is the caller graph for this function:

logical function linear_theory_lut_disk_io::dims_match ( character(len=*), intent(in)  filename,
integer, dimension(3,2), intent(in)  dimensions 
)
private


Check that the dimensions of a LUT file and current expected LUT match

Takes a filename and the dimensions of the LUT the model is expecting Checks the expected dimensions against the dimension lengths for both the vLUT and the uLUT in the specified file.

Parameters
filenameName of LUT file to check
dimensionsArray to hold u and v dimensions array is (3 x 2)
Return values
dims_matchTrue if they match, false if not

Here is the call graph for this function:

Here is the caller graph for this function:

integer function, public linear_theory_lut_disk_io::read_lut ( character(len=*), intent(in)  filename,
real, dimension(:,:,:,:,:,:), intent(inout), allocatable  uLUT,
real, dimension(:,:,:,:,:,:), intent(inout), allocatable  vLUT,
real, dimension(:), intent(in)  dz,
integer, dimension(3,2), intent(in)  dims,
type(lt_options_type), intent(in)  options 
)


Write linear wind look up tables to disk along with the parameters for that table

Takes a filename, the allocatable LUT arrays, and the options structure that defines the LUT parameters A file is read and checked for appropriate dimensions, along with parameters.

If the parameters do not match the parameters in the LUT file, the parameters structure is updated to match ... or at least they would if options was an inout variable... for now no update is performed an error is returned so that the requested LUT can be computed instead.

Parameters
filenameName of LUT file to write
uLUTArray to hold u wind look up table
vLUTArray to hold v wind look up table
dims1D array containtin dimension sizes of the model domain
optionsLinear wind options to compare with the LUT file and update if necessary
Return values
error0 if there were no errors, 1 if parameters did not match, 2 if dimensions don't match, 3 if file doesn't exist, 4 if the version in the LUT file doesn't match that of the code

Here is the call graph for this function:

Here is the caller graph for this function:

integer function linear_theory_lut_disk_io::setup_dim ( integer, intent(in)  ncid,
character(len=*), intent(in)  dimname,
integer, intent(inout)  dimid,
integer, intent(in)  n 
)
private


Setup a new dimension in a given netcdf file

Takes an open netcdf file id and a dimension name. returns the dimension id for the given dimension name and if given a dimension length (n) it is checked to make sure any existing dimension with this name has the write length.

Parameters
ncidinteger an open netcdf file id
dimnamethe name of the dimension to be checked
[out]dimidthe existing or newly created dimension id.
nThe length of the dimension
Return values
error0 if successful, 1 otherwise

Here is the call graph for this function:

Here is the caller graph for this function:

integer function linear_theory_lut_disk_io::setup_var ( integer, intent(in)  ncid,
character(len=*), intent(in)  varname,
integer, intent(out)  varid,
integer, dimension(:), intent(in)  dimids,
integer, dimension(:), intent(in)  dims 
)
private


Setup a new variable to be written

Takes an open netCDF file id, variable name, dimension ids, and dimension lengths. If the variable doesn't exist it is created with the matching dimension ids. These dimension lengths are then checked against the dimension lengths supplied. This check is performed in case a variable with this name but different dims already existed in the file. Supplied netCDF if must be a file that is in define mode

Parameters
ncidinteger open netcdf file id
varnamename of the variable to be created
[out]varidid of the existing or newly created variable
dimidsarray of dimension ids to be used when creating the variable
dimsarray of dimension lengths to be checked for existing variables
Return values
error0 if successful 3 otherwise

Here is the call graph for this function:

Here is the caller graph for this function:

integer function, public linear_theory_lut_disk_io::write_lut ( character(len=*), intent(in)  filename,
real, dimension(:,:,:,:,:,:), intent(in)  uLUT,
real, dimension(:,:,:,:,:,:), intent(in)  vLUT,
real, dimension(:), intent(in)  dz,
type(lt_options_type), intent(in)  options 
)


Write linear wind look up tables to disk along with the parameters for that table

Takes a filename, the LUTs, and the options structure that defines the LUT parameters A file is created with appropriate dimension names and attributes, along with variables for each of the relevant.

If the parameters do not match the parameters in the LUT file, the parameters structure is updated to match

Parameters
filenameName of LUT file to write
uLUTArray to hold u wind look up table
vLUTArray to hold v wind look up table
optionsLinear wind options to compare with the LUT file and update if necessary
Return values
error0 on success other values indicate and error

Here is the call graph for this function:

Here is the caller graph for this function:

integer function linear_theory_lut_disk_io::write_var_1d ( character(len=*), intent(in)  filename,
character(len=*), intent(in)  varname,
real, dimension(:), intent(in)  data_out,
character(len=*), dimension(ndims), intent(in), optional  dimnames,
logical, intent(in), optional  open_new_file 
)
private


Same as write_var_6d but for a 1D variable

Takes a filename variable name, data, dimension names and optionally a flag to clobber existing files. If the specified dimensions don't exist they are created based on the size if the data_out variable. Then the netcdf variable is created with those dimensions and the data are written.

Parameters
filenameName of LUT file to open or create
varnameName of variable to create
data_outArray with the data to be output to the file (1D real)
dimnamesArray of dimension names (1 element 1D character)
open_new_fileFlag to clobber any existing file if true
Return values
error0 if the file was successfully written

Here is the call graph for this function:

integer function linear_theory_lut_disk_io::write_var_6d ( character(len=*), intent(in)  filename,
character(len=*), intent(in)  varname,
real, dimension(:,:,:,:,:,:), intent(in)  data_out,
character(len=*), dimension(ndims), intent(in), optional  dimnames,
logical, intent(in), optional  open_new_file 
)
private


Write a 6D variable to a netCDF file

Takes a filename variable name, data, dimension names and optionally a flag to clobber existing files. If the specified dimensions don't exist they are created based on the size if the data_out variable. Then the netcdf variable is created with those dimensions and the data are written.

Parameters
filenameName of LUT file to open or create
varnameName of variable to create
data_outArray with the data to be output to the file (6D real)
dimnamesArray of dimension names (6 element 1D character)
open_new_fileFlag to clobber any existing file if true
Return values
error0 if the file was successfully written

Here is the call graph for this function:

Member Data Documentation

character(len=10), parameter linear_theory_lut_disk_io::lt_lut_version ="1.0"
private

The documentation for this module was generated from the following file: