The Intermediate Complexity Atmospheric Research model (ICAR)
A computationally efficient atmospheric model for downscaling.
|
Basic file input/output routines More...
Data Types | |
interface | io_add_attribute |
Generic interface to the netcdf add_attribute_TYPE routinesMore... | |
interface | io_read |
Generic interface to the netcdf read routinesMore... | |
interface | io_read_attribute |
Generic interface to the netcdf read_attribute_TYPE routinesMore... | |
interface | io_write |
Generic interface to the netcdf write routinesMore... | |
Public Member Functions | |
logical function | file_exists (filename) |
Tests to see if a file exists More... | |
logical function | io_variable_is_present (filename, variable_name) |
Tests to see if a variable is present in a netcdf file returns true of it is, false if it isn't More... | |
integer function | io_nearest_time_step (filename, mjd) |
Finds the nearest time step in a file to a given MJD Uses the "time" variable from filename. More... | |
subroutine | io_getdims (filename, varname, dims) |
Read the dimensions of a variable in a given netcdf file More... | |
subroutine | io_read6d (filename, varname, data_in, extradim) |
Reads in a variable from a netcdf file, allocating memory in data_in for it. More... | |
subroutine | io_read3d (filename, varname, data_in, extradim) |
Same as io_read6d but for 3-dimensional data More... | |
subroutine | io_read2d (filename, varname, data_in, extradim) |
Same as io_read3d but for 2-dimensional data More... | |
subroutine | io_read2di (filename, varname, data_in, extradim) |
Same as io_read2d but for integer data More... | |
subroutine | io_read1d (filename, varname, data_in, extradim) |
Same as io_read3d but for 1-dimensional data More... | |
subroutine | io_write6d (filename, varname, data_out, dimnames) |
Write a 6-dimensional variable to a netcdf file More... | |
subroutine | io_write4d (filename, varname, data_out) |
Same as io_write6d but for 4-dimensional data More... | |
subroutine | io_write4di (filename, varname, data_out) |
Same as io_write4d but for integer data More... | |
subroutine | io_write3d (filename, varname, data_out) |
Same as io_write6d but for 3-dimensional data More... | |
subroutine | io_write3di (filename, varname, data_out) |
Same as io_write3d but for integer arrays More... | |
subroutine | io_write2d (filename, varname, data_out) |
Same as io_write3d but for 2-dimensional arrays More... | |
subroutine | io_read_attribute_r (filename, att_name, att_value, var_name) |
Read a real type attribute from a named file from an optional variable More... | |
subroutine | io_read_attribute_i (filename, att_name, att_value, var_name) |
Read a integer type attribute from a named file from an optional variable More... | |
subroutine | io_read_attribute_c (filename, att_name, att_value, var_name) |
Read a character type attribute from a named file from an optional variable More... | |
subroutine | io_add_attribute_r (filename, att_name, att_value, varname) |
Write a real type attribute to a named file for an optional variable More... | |
subroutine | io_add_attribute_i (filename, att_name, att_value, varname) |
Write an integer type attribute to a named file for an optional variable More... | |
subroutine | io_add_attribute_c (filename, att_name, att_value, varname) |
Write an character type attribute to a named file for an optional variable More... | |
subroutine | check (status, extra) |
Simple error handling for common netcdf file errors More... | |
integer function | io_newunit (unit) |
Find an available file unit number. More... | |
Public Attributes | |
integer, parameter | io_maxdims =10 |
integer, parameter | maxdimlength =255 |
Basic file input/output routines
Primary use is io_read2d/3d io_write* routines are more used for debugging model output is performed in the output module
Generic interfaces are supplied for io_read and io_write but most code still uses the explicit read/write 2d/3d/etc. this keeps the code a little more obvious (at least 2D vs 3D)
subroutine io_routines::check | ( | integer, intent(in) | status, |
character(len=*), intent(in), optional | extra | ||
) |
Simple error handling for common netcdf file errors
If status does not equal nf90_noerr, then print an error message and STOP the entire program.
status | integer return code from nc_* routines |
extra | OPTIONAL string with extra context to print in case of an error |
logical function io_routines::file_exists | ( | character(len=*), intent(in) | filename | ) |
Tests to see if a file exists
filename | name of file to look for |
logical | true if file exists, false if it doesn't |
subroutine io_routines::io_add_attribute_c | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | att_name, | ||
character(len=*), intent(in) | att_value, | ||
character(len=*), intent(in), optional | varname | ||
) |
Write an character type attribute to a named file for an optional variable
If a variable name is given writes the named attribute to that variable otherwise the named attribute is assumed to be a global attribute
filename | netcdf file to write the attribute to |
att_name | name of attribute to write |
att_value | output value to be written (character) |
var_name | OPTIONAL name of variable to write attribute to |
subroutine io_routines::io_add_attribute_i | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | att_name, | ||
integer, intent(in) | att_value, | ||
character(len=*), intent(in), optional | varname | ||
) |
Write an integer type attribute to a named file for an optional variable
If a variable name is given writes the named attribute to that variable otherwise the named attribute is assumed to be a global attribute
filename | netcdf file to write the attribute to |
att_name | name of attribute to write |
att_value | output value to be written (integer) |
var_name | OPTIONAL name of variable to write attribute to |
subroutine io_routines::io_add_attribute_r | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | att_name, | ||
real*4, intent(in) | att_value, | ||
character(len=*), intent(in), optional | varname | ||
) |
Write a real type attribute to a named file for an optional variable
If a variable name is given writes the named attribute to that variable otherwise the named attribute is assumed to be a global attribute
filename | netcdf file to write the attribute to |
att_name | name of attribute to write |
att_value | output value to be written (real*4) |
var_name | OPTIONAL name of variable to write attribute to |
subroutine io_routines::io_getdims | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
integer, dimension(:), intent(out) | dims | ||
) |
Read the dimensions of a variable in a given netcdf file
filename | Name of NetCDF file to look at | |
varname | Name of the NetCDF variable to find the dimensions of | |
[out] | dims | Allocated array to store output |
dims(:) | dims[1]=ndims, dims[i+1]=length of dimension i for a given variable |
integer function io_routines::io_nearest_time_step | ( | character(len=*), intent(in) | filename, |
double precision, intent(in) | mjd | ||
) |
Finds the nearest time step in a file to a given MJD Uses the "time" variable from filename.
filename | Name of an ICAR NetCDF output file |
mjd | Modified Julian day to find. If on a noleap calendar, it assumes MJD is days since 1900 |
integer | Index into the time dimension (last dim) |
integer function io_routines::io_newunit | ( | integer, intent(out), optional | unit | ) |
Find an available file unit number.
LUN_MIN and LUN_MAX define the range of possible LUNs to check. The UNIT value is returned by the function, and also by the optional argument. This allows the function to be used directly in an OPEN statement, and optionally save the result in a local variable. If no units are available, -1 is returned. Newer versions of fortran can do this automatically, but this keeps one thing a little more backwards compatible
[out] | unit | OPTIONAL integer to store the file logical unit number |
integer | a file logical unit number |
subroutine io_routines::io_read1d | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
real, dimension(:), intent(out), allocatable | data_in, | ||
integer, intent(in), optional | extradim | ||
) |
Same as io_read3d but for 1-dimensional data
Reads in a variable from a netcdf file, allocating memory in data_in for it.
if extradim is provided specifies this index for any extra dimensions (dims>1) e.g. we may only want one time slice from a 1d variable
filename | Name of NetCDF file to look at | |
varname | Name of the NetCDF variable to read | |
[out] | data_in | Allocatable 1-dimensional array to store output |
extradim | OPTIONAL: specify the position to read for any extra (e.g. time) dimension |
data_in | Allocated 1-dimensional array with the netCDF data |
subroutine io_routines::io_read2d | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
real, dimension(:,:), intent(out), allocatable | data_in, | ||
integer, intent(in), optional | extradim | ||
) |
Same as io_read3d but for 2-dimensional data
Reads in a variable from a netcdf file, allocating memory in data_in for it.
if extradim is provided specifies this index for any extra dimensions (dims>2) e.g. we may only want one time slice from a 2d variable
filename | Name of NetCDF file to look at | |
varname | Name of the NetCDF variable to read | |
[out] | data_in | Allocatable 2-dimensional array to store output |
extradim | OPTIONAL: specify the position to read for any extra (e.g. time) dimension |
data_in | Allocated 2-dimensional array with the netCDF data |
subroutine io_routines::io_read2di | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
integer, dimension(:,:), intent(out), allocatable | data_in, | ||
integer, intent(in), optional | extradim | ||
) |
Same as io_read2d but for integer data
Reads in a variable from a netcdf file, allocating memory in data_in for it.
if extradim is provided specifies this index for any extra dimensions (dims>2) e.g. we may only want one time slice from a 2d variable
filename | Name of NetCDF file to look at | |
varname | Name of the NetCDF variable to read | |
[out] | data_in | Allocatable 2-dimensional array to store output |
extradim | OPTIONAL: specify the position to read for any extra (e.g. time) dimension |
data_in | Allocated 2-dimensional array with the netCDF data |
subroutine io_routines::io_read3d | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
real, dimension(:,:,:), intent(out), allocatable | data_in, | ||
integer, intent(in), optional | extradim | ||
) |
Same as io_read6d but for 3-dimensional data
Reads in a variable from a netcdf file, allocating memory in data_in for it.
if extradim is provided specifies this index for any extra dimensions (dims>3) e.g. we may only want one time slice from a 3d variable
filename | Name of NetCDF file to look at | |
varname | Name of the NetCDF variable to read | |
[out] | data_in | Allocatable 3-dimensional array to store output |
extradim | OPTIONAL: specify the position to read for any extra (e.g. time) dimension |
data_in | Allocated 3-dimensional array with the netCDF data |
subroutine io_routines::io_read6d | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
real, dimension(:,:,:,:,:,:), intent(out), allocatable | data_in, | ||
integer, intent(in), optional | extradim | ||
) |
Reads in a variable from a netcdf file, allocating memory in data_in for it.
if extradim is provided specifies this index for any extra dimensions (dims>6) e.g. we may only want one time slice from a 6d variable
filename | Name of NetCDF file to look at | |
varname | Name of the NetCDF variable to read | |
[out] | data_in | Allocatable 6-dimensional array to store output |
extradim | OPTIONAL: specify the position to read for any extra (e.g. time) dimension |
data_in | Allocated 6-dimensional array with the netCDF data |
subroutine io_routines::io_read_attribute_c | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | att_name, | ||
character(len=*), intent(out) | att_value, | ||
character(len=*), intent(in), optional | var_name | ||
) |
Read a character type attribute from a named file from an optional variable
If a variable name is given reads the named attribute of that variable otherwise the named attribute is assumed to be a global attribute
filename | netcdf file to read the attribute from |
att_name | name of attribute to read |
att_value | output value to be returned (character) |
var_name | OPTIONAL name of variable to read attribute from |
subroutine io_routines::io_read_attribute_i | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | att_name, | ||
integer, intent(out) | att_value, | ||
character(len=*), intent(in), optional | var_name | ||
) |
Read a integer type attribute from a named file from an optional variable
If a variable name is given reads the named attribute of that variable otherwise the named attribute is assumed to be a global attribute
filename | netcdf file to read the attribute from |
att_name | name of attribute to read |
att_value | output value to be returned (integer) |
var_name | OPTIONAL name of variable to read attribute from |
subroutine io_routines::io_read_attribute_r | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | att_name, | ||
real*4, intent(out) | att_value, | ||
character(len=*), intent(in), optional | var_name | ||
) |
Read a real type attribute from a named file from an optional variable
If a variable name is given reads the named attribute of that variable otherwise the named attribute is assumed to be a global attribute
filename | netcdf file to read the attribute from |
att_name | name of attribute to read |
att_value | output value to be returned (real*4) |
var_name | OPTIONAL name of variable to read attribute from |
logical function io_routines::io_variable_is_present | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | variable_name | ||
) |
Tests to see if a variable is present in a netcdf file returns true of it is, false if it isn't
filename | name of NetCDF file |
variable_name | name of variable to search for in filename |
logical | True if variable_name is present in filename |
subroutine io_routines::io_write2d | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
real, dimension(:,:), intent(in) | data_out | ||
) |
Same as io_write3d but for 2-dimensional arrays
Write a 2-dimensional variable to a netcdf file
Create a netcdf file:filename with a variable:varname and write data_out to it
filename | Name of NetCDF file to write/create |
varname | Name of the NetCDF variable to write |
data_out | 2-dimensional array to write to the file |
subroutine io_routines::io_write3d | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
real, dimension(:,:,:), intent(in) | data_out | ||
) |
Same as io_write6d but for 3-dimensional data
Write a 3-dimensional variable to a netcdf file
Create a netcdf file:filename with a variable:varname and write data_out to it
filename | Name of NetCDF file to write/create |
varname | Name of the NetCDF variable to write |
data_out | 3-dimensional array to write to the file |
subroutine io_routines::io_write3di | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
integer, dimension(:,:,:), intent(in) | data_out | ||
) |
Same as io_write3d but for integer arrays
Write a 3-dimensional variable to a netcdf file
Create a netcdf file:filename with a variable:varname and write data_out to it
filename | Name of NetCDF file to write/create |
varname | Name of the NetCDF variable to write |
data_out | 3-dimensional array to write to the file |
subroutine io_routines::io_write4d | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
real, dimension(:,:,:,:), intent(in) | data_out | ||
) |
Same as io_write6d but for 4-dimensional data
Write a 4-dimensional variable to a netcdf file
Create a netcdf file:filename with a variable:varname and write data_out to it
filename | Name of NetCDF file to write/create |
varname | Name of the NetCDF variable to write |
data_out | 4-dimensional array to write to the file |
subroutine io_routines::io_write4di | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
integer, dimension(:,:,:,:), intent(in) | data_out | ||
) |
Same as io_write4d but for integer data
Write a 4-dimensional variable to a netcdf file
Create a netcdf file:filename with a variable:varname and write data_out to it
filename | Name of NetCDF file to write/create |
varname | Name of the NetCDF variable to write |
data_out | 4-dimensional array to write to the file |
subroutine io_routines::io_write6d | ( | character(len=*), intent(in) | filename, |
character(len=*), intent(in) | varname, | ||
real, dimension(:,:,:,:,:,:), intent(in) | data_out, | ||
character(len=*), dimension(6), intent(in), optional | dimnames | ||
) |
Write a 6-dimensional variable to a netcdf file
Create a netcdf file:filename with a variable:varname and write data_out to it
filename | Name of NetCDF file to write/create |
varname | Name of the NetCDF variable to write |
data_out | 6-dimensional array to write to the file |
integer, parameter io_routines::io_maxdims =10 |
integer, parameter io_routines::maxdimlength =255 |