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


Basic file input/output routines More...

Data Types

interface  io_add_attribute
 

Generic interface to the netcdf add_attribute_TYPE routines

More...
 
interface  io_read
 

Generic interface to the netcdf read routines

More...
 
interface  io_read_attribute
 

Generic interface to the netcdf read_attribute_TYPE routines

More...
 
interface  io_write
 

Generic interface to the netcdf write routines

More...
 

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
 

Detailed Description


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)

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

Member Function/Subroutine Documentation

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.

Parameters
statusinteger return code from nc_* routines
extraOPTIONAL string with extra context to print in case of an error

Here is the caller graph for this function:

logical function io_routines::file_exists ( character(len=*), intent(in)  filename)


Tests to see if a file exists

Parameters
filenamename of file to look for
Return values
logicaltrue if file exists, false if it doesn't

Here is the caller graph for this function:

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

Parameters
filenamenetcdf file to write the attribute to
att_namename of attribute to write
att_valueoutput value to be written (character)
var_nameOPTIONAL name of variable to write attribute to

Here is the call graph for this function:

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

Parameters
filenamenetcdf file to write the attribute to
att_namename of attribute to write
att_valueoutput value to be written (integer)
var_nameOPTIONAL name of variable to write attribute to

Here is the call graph for this function:

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

Parameters
filenamenetcdf file to write the attribute to
att_namename of attribute to write
att_valueoutput value to be written (real*4)
var_nameOPTIONAL name of variable to write attribute to

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to look at
varnameName of the NetCDF variable to find the dimensions of
[out]dimsAllocated array to store output
Return values
dims(:)dims[1]=ndims, dims[i+1]=length of dimension i for a given variable

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
filenameName of an ICAR NetCDF output file
mjdModified Julian day to find. If on a noleap calendar, it assumes MJD is days since 1900
Return values
integerIndex into the time dimension (last dim)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters
[out]unitOPTIONAL integer to store the file logical unit number
Return values
integera file logical unit number

Here is the caller graph for this function:

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

Parameters
filenameName of NetCDF file to look at
varnameName of the NetCDF variable to read
[out]data_inAllocatable 1-dimensional array to store output
extradimOPTIONAL: specify the position to read for any extra (e.g. time) dimension
Return values
data_inAllocated 1-dimensional array with the netCDF data

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to look at
varnameName of the NetCDF variable to read
[out]data_inAllocatable 2-dimensional array to store output
extradimOPTIONAL: specify the position to read for any extra (e.g. time) dimension
Return values
data_inAllocated 2-dimensional array with the netCDF data

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to look at
varnameName of the NetCDF variable to read
[out]data_inAllocatable 2-dimensional array to store output
extradimOPTIONAL: specify the position to read for any extra (e.g. time) dimension
Return values
data_inAllocated 2-dimensional array with the netCDF data

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to look at
varnameName of the NetCDF variable to read
[out]data_inAllocatable 3-dimensional array to store output
extradimOPTIONAL: specify the position to read for any extra (e.g. time) dimension
Return values
data_inAllocated 3-dimensional array with the netCDF data

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to look at
varnameName of the NetCDF variable to read
[out]data_inAllocatable 6-dimensional array to store output
extradimOPTIONAL: specify the position to read for any extra (e.g. time) dimension
Return values
data_inAllocated 6-dimensional array with the netCDF data

Here is the call graph for this function:

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

Parameters
filenamenetcdf file to read the attribute from
att_namename of attribute to read
att_valueoutput value to be returned (character)
var_nameOPTIONAL name of variable to read attribute from

Here is the call graph for this function:

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

Parameters
filenamenetcdf file to read the attribute from
att_namename of attribute to read
att_valueoutput value to be returned (integer)
var_nameOPTIONAL name of variable to read attribute from

Here is the call graph for this function:

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

Parameters
filenamenetcdf file to read the attribute from
att_namename of attribute to read
att_valueoutput value to be returned (real*4)
var_nameOPTIONAL name of variable to read attribute from

Here is the call graph for this function:

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

Parameters
filenamename of NetCDF file
variable_namename of variable to search for in filename
Return values
logicalTrue if variable_name is present in filename

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters
filenameName of NetCDF file to write/create
varnameName of the NetCDF variable to write
data_out2-dimensional array to write to the file

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to write/create
varnameName of the NetCDF variable to write
data_out3-dimensional array to write to the file

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to write/create
varnameName of the NetCDF variable to write
data_out3-dimensional array to write to the file

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to write/create
varnameName of the NetCDF variable to write
data_out4-dimensional array to write to the file

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to write/create
varnameName of the NetCDF variable to write
data_out4-dimensional array to write to the file

Here is the call graph for this function:

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

Parameters
filenameName of NetCDF file to write/create
varnameName of the NetCDF variable to write
data_out6-dimensional array to write to the file

Here is the call graph for this function:

Member Data Documentation

integer, parameter io_routines::io_maxdims =10
integer, parameter io_routines::maxdimlength =255

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