Handle reading and writing Linear wind Look up tables to/from disk
More...
|
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...
|
|
|
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...
|
|
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)
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
-
filename | name of the netCDF file |
default_value | expected value of the attribute |
value_name | name of the attribute to read |
- Return values
-
error | 0 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
-
filename | name of the netCDF file |
default_value | expected value of the attribute |
value_name | name of the attribute to read |
- Return values
-
error | 0 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
-
filename | name of the netCDF file |
default_value | expected value of the attribute |
value_name | name of the attribute to read |
- Return values
-
error | 0 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
-
filename | Name of LUT file to check |
model_dz | Array to hold current model thicknesses (1D real) |
- Return values
-
error | 0 if they match, 1 otherwise
|
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
-
filename | Name of LUT file to check |
dimensions | Array to hold u and v dimensions array is (3 x 2) |
- Return values
-
dims_match | True if they match, false if not
|
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
-
filename | Name of LUT file to write |
uLUT | Array to hold u wind look up table |
vLUT | Array to hold v wind look up table |
dims | 1D array containtin dimension sizes of the model domain |
options | Linear wind options to compare with the LUT file and update if necessary |
- Return values
-
error | 0 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
|
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
-
| ncid | integer an open netcdf file id |
| dimname | the name of the dimension to be checked |
[out] | dimid | the existing or newly created dimension id. |
| n | The length of the dimension |
- Return values
-
error | 0 if successful, 1 otherwise
|
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
-
| ncid | integer open netcdf file id |
| varname | name of the variable to be created |
[out] | varid | id of the existing or newly created variable |
| dimids | array of dimension ids to be used when creating the variable |
| dims | array of dimension lengths to be checked for existing variables |
- Return values
-
error | 0 if successful 3 otherwise
|
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
-
filename | Name of LUT file to write |
uLUT | Array to hold u wind look up table |
vLUT | Array to hold v wind look up table |
options | Linear wind options to compare with the LUT file and update if necessary |
- Return values
-
error | 0 on success other values indicate and error
|
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
-
filename | Name of LUT file to open or create |
varname | Name of variable to create |
data_out | Array with the data to be output to the file (1D real) |
dimnames | Array of dimension names (1 element 1D character) |
open_new_file | Flag to clobber any existing file if true |
- Return values
-
error | 0 if the file was successfully written
|
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
-
filename | Name of LUT file to open or create |
varname | Name of variable to create |
data_out | Array with the data to be output to the file (6D real) |
dimnames | Array of dimension names (6 element 1D character) |
open_new_file | Flag to clobber any existing file if true |
- Return values
-
error | 0 if the file was successfully written
|
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: