0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
mo_ncread Module Reference

Reading netcdf files. More...

Data Types

interface  get_ncvar
 Read array from NC file. More...
 

Functions/Subroutines

integer(i4) function, dimension(5), public get_ncdim (filename, variable, printinfo, ndims)
 Dimension of netcdf variable.
 
subroutine, public get_ncdimatt (filename, variable, dimname, dimlen)
 Name and size of variable in netcdf.
 
subroutine, public get_ncvaratt (filename, varname, attname, attvalues, fid, dtype)
 Get attribute of netcdf variable.
 
subroutine get_ncvar_0d_sp (filename, varname, dat, fid)
 
subroutine get_ncvar_0d_dp (filename, varname, dat, fid)
 
subroutine get_ncvar_1d_sp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_1d_dp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_2d_sp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_2d_dp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_3d_sp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_3d_dp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_4d_sp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_4d_dp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_5d_sp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_5d_dp (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_0d_i4 (filename, varname, dat, fid)
 
subroutine get_ncvar_1d_i4 (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_2d_i4 (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_3d_i4 (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_4d_i4 (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_5d_i4 (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_0d_i1 (filename, varname, dat, fid)
 
subroutine get_ncvar_1d_i1 (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_2d_i1 (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_3d_i1 (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_4d_i1 (filename, varname, dat, start, a_count, fid)
 
subroutine get_ncvar_5d_i1 (filename, varname, dat, start, a_count, fid)
 
integer(i4) function, public ncopen (fname)
 Open netcdf file.
 
subroutine, public ncclose (ncid)
 Closes netcdf file.
 
subroutine get_info (varname, ncid, varid, xtype, dl, info, ndims)
 Get variable info from netcdf files.
 
subroutine check (status)
 

Detailed Description

Reading netcdf files.

Subroutines for reading arrays from nc file using the netcdf4 library.

Author
Stephan Thober, Matthias Cuntz
Date
Nov 2011

Function/Subroutine Documentation

◆ check()

subroutine mo_ncread::check ( integer(i4), intent(in)  status)
private

Definition at line 2170 of file mo_ncread.f90.

◆ get_info()

subroutine mo_ncread::get_info ( character(len = *), intent(in)  varname,
integer(i4), intent(in)  ncid,
integer(i4), intent(out)  varid,
integer(i4), intent(out)  xtype,
integer(i4), dimension(:), intent(inout), optional  dl,
logical, intent(in), optional  info,
integer(i4), intent(out), optional  ndims 
)
private

Get variable info from netcdf files.

This subroutine is PRIVATE and therefore does not exist outside of this module.

This subroutine inquires the nc file. Given the Variable name and the stream of the nc file, this subroutine determines the variable id, the kind of the variable and the length of the dimensions in the file.

See: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90/ -> NF90-INQUIRE for detailed information.

Author
Matthias Cuntz,
Date
Nov 2012
  • default dimension length -1

Definition at line 2119 of file mo_ncread.f90.

Referenced by get_ncdim(), get_ncdimatt(), and get_ncvaratt().

Here is the caller graph for this function:

◆ get_ncdim()

integer(i4) function, dimension(5), public mo_ncread::get_ncdim ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  variable,
logical, intent(in), optional  printinfo,
integer(i4), intent(out), optional  ndims 
)

Dimension of netcdf variable.

Gets the dimensions of variable in a netcdf file.

Literature

  1. http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html
Parameters
[in]character(len=*) :: FilenameFilename of netcdf file
[in]character(len=*) :: VariableVariable name exactly as specified in the file
[in]logical, optional :: PrintInfoIf given and true, information about dimension and their lengths will be printed to standard output.
Return values
integer(i4), dimension(5) :: Get_NcDimDimension length, -1 if dimension does not exist
Parameters
[out]integer(i4), optional :: ndims# of dimensions
Author
Stephan Thober
Date
Dec 2011
Author
Matthias Cuntz
Date
Jan 2012
  • ndims

Definition at line 127 of file mo_ncread.f90.

References get_info(), and get_ncdim().

Referenced by get_ncdim(), get_ncdimatt(), and get_ncvaratt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_ncdimatt()

subroutine, public mo_ncread::get_ncdimatt ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  variable,
character(len = *), dimension(:), intent(out), allocatable  dimname,
integer(i4), dimension(:), intent(out), optional, allocatable  dimlen 
)

Name and size of variable in netcdf.

Gets the name and size of the dimensions of a variable in a netcdf file

Example

 Filename = 'test.nc'
 Varname  = 'data'
 call Get_NcDimAtt(Filename, Varname, DimNames, DimLen)

See example in test directory.

Literature

  1. http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html
Parameters
[in]character(len=*), intent(in) :: FilenameFilename of netcdf file.
[in]character(len=*), intent(in) :: VariableVariable name exactly as specified in the file.
[out]integer(i4), dimension(:), allocatable, optional, intent(out) :: DimLenAllocatable array with the size of the dimensions
Return values
character(len=*), dimension(:), allocatable, intent(out) :: DimNameAllocatable array with the names of the dimensions.
Note
DimName and DimLen are both allocated within the subroutine, so please just provide an 1 dimensional allocatable array to the subroutine.
Author
Matthias Zink
Date
Oct 2012

Definition at line 192 of file mo_ncread.f90.

References get_info(), and get_ncdim().

Here is the call graph for this function:

◆ get_ncvar_0d_dp()

subroutine mo_ncread::get_ncvar_0d_dp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(dp), intent(inout)  dat,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 380 of file mo_ncread.f90.

◆ get_ncvar_0d_i1()

subroutine mo_ncread::get_ncvar_0d_i1 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(1), intent(inout)  dat,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1621 of file mo_ncread.f90.

◆ get_ncvar_0d_i4()

subroutine mo_ncread::get_ncvar_0d_i4 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(i4), intent(inout)  dat,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1202 of file mo_ncread.f90.

◆ get_ncvar_0d_sp()

subroutine mo_ncread::get_ncvar_0d_sp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(sp), intent(inout)  dat,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 341 of file mo_ncread.f90.

◆ get_ncvar_1d_dp()

subroutine mo_ncread::get_ncvar_1d_dp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(dp), dimension(:), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 497 of file mo_ncread.f90.

◆ get_ncvar_1d_i1()

subroutine mo_ncread::get_ncvar_1d_i1 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(1), dimension(:), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1661 of file mo_ncread.f90.

◆ get_ncvar_1d_i4()

subroutine mo_ncread::get_ncvar_1d_i4 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(i4), dimension(:), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1242 of file mo_ncread.f90.

◆ get_ncvar_1d_sp()

subroutine mo_ncread::get_ncvar_1d_sp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(sp), dimension(:), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 419 of file mo_ncread.f90.

◆ get_ncvar_2d_dp()

subroutine mo_ncread::get_ncvar_2d_dp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(dp), dimension(:, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 654 of file mo_ncread.f90.

◆ get_ncvar_2d_i1()

subroutine mo_ncread::get_ncvar_2d_i1 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(1), dimension(:, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1737 of file mo_ncread.f90.

◆ get_ncvar_2d_i4()

subroutine mo_ncread::get_ncvar_2d_i4 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(i4), dimension(:, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1318 of file mo_ncread.f90.

◆ get_ncvar_2d_sp()

subroutine mo_ncread::get_ncvar_2d_sp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(sp), dimension(:, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 575 of file mo_ncread.f90.

◆ get_ncvar_3d_dp()

subroutine mo_ncread::get_ncvar_3d_dp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(dp), dimension(:, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 812 of file mo_ncread.f90.

◆ get_ncvar_3d_i1()

subroutine mo_ncread::get_ncvar_3d_i1 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(1), dimension(:, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1813 of file mo_ncread.f90.

◆ get_ncvar_3d_i4()

subroutine mo_ncread::get_ncvar_3d_i4 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(i4), dimension(:, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1394 of file mo_ncread.f90.

◆ get_ncvar_3d_sp()

subroutine mo_ncread::get_ncvar_3d_sp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(sp), dimension(:, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 732 of file mo_ncread.f90.

◆ get_ncvar_4d_dp()

subroutine mo_ncread::get_ncvar_4d_dp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(dp), dimension(:, :, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 968 of file mo_ncread.f90.

◆ get_ncvar_4d_i1()

subroutine mo_ncread::get_ncvar_4d_i1 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(1), dimension(:, :, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1889 of file mo_ncread.f90.

◆ get_ncvar_4d_i4()

subroutine mo_ncread::get_ncvar_4d_i4 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(i4), dimension(:, :, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1470 of file mo_ncread.f90.

◆ get_ncvar_4d_sp()

subroutine mo_ncread::get_ncvar_4d_sp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(sp), dimension(:, :, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 890 of file mo_ncread.f90.

◆ get_ncvar_5d_dp()

subroutine mo_ncread::get_ncvar_5d_dp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(dp), dimension(:, :, :, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1124 of file mo_ncread.f90.

◆ get_ncvar_5d_i1()

subroutine mo_ncread::get_ncvar_5d_i1 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(1), dimension(:, :, :, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1965 of file mo_ncread.f90.

◆ get_ncvar_5d_i4()

subroutine mo_ncread::get_ncvar_5d_i4 ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
integer(i4), dimension(:, :, :, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1546 of file mo_ncread.f90.

◆ get_ncvar_5d_sp()

subroutine mo_ncread::get_ncvar_5d_sp ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
real(sp), dimension(:, :, :, :, :), intent(inout), allocatable  dat,
integer(i4), dimension(:), intent(in), optional  start,
integer(i4), dimension(:), intent(in), optional  a_count,
integer(i4), intent(in), optional  fid 
)
private

Definition at line 1046 of file mo_ncread.f90.

◆ get_ncvaratt()

subroutine, public mo_ncread::get_ncvaratt ( character(len = *), intent(in)  filename,
character(len = *), intent(in)  varname,
character(len = *), intent(in)  attname,
character(len = *), intent(out)  attvalues,
integer(i4), intent(in), optional  fid,
integer(i4), intent(out), optional  dtype 
)

Get attribute of netcdf variable.

Gets the values of an particular attribute of an variable.

Example

 Filename = 'test.nc'
 VarName  = 'data'
 AttName  = 'units'
 call Get_NcDimAtt(Filename, Varname, AttName, AttValues)

See example in test directory.

Literature

  1. http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html
    Parameters
    [in]character(len=*), intent(in) :: FileNameFilename of netcdf file.
    [in]character(len=*), intent(in) :: VarNameVariable name exactly as specified in the file.
    [in]character(len=*), intent(in) :: AttNameAttribute name exactly as specified for the Variable.
    [in]integer(i4), optional, intent(in) :: fidFile handle of opened netcdf file
    [in]integer(i4), optional, intent(in) :: dtypeDatatype (ineteger,float) see NetCDF convention (unidata.ucar)
    Return values
    character(len=*), intent(out) :: AttValuesValues of the Attribute.
    Note
    AttValues are restricted to be of character type.
    The name of the variable (VarName) has to be known beforehand.
    The name of the attribute (AttName) has to be known beforehand.
    Author
    Matthias Zink
    Date
    Oct 2012
    Author
    Matthias Cuntz & Juliane Mai
    Date
    Nov 2014
    • correct data type detection.

Definition at line 270 of file mo_ncread.f90.

References get_info(), and get_ncdim().

Here is the call graph for this function:

◆ ncclose()

subroutine, public mo_ncread::ncclose ( integer(i4), intent(in)  ncid)

Closes netcdf file.

Closes a netcdf file by file handle

Example

call NcClose(ncid)

Literature

  1. http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html
    Parameters
    [in]ncid- file handle of open netcdf file
    Author
    Stephan Thober
    Date
    May 2012

Definition at line 2093 of file mo_ncread.f90.

◆ ncopen()

integer(i4) function, public mo_ncread::ncopen ( character(len = *), intent(in)  fname)

Open netcdf file.

Opens a netcdf file and returns file handle

Example

id = ncopen(fname)

Literature

  1. http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html
    Parameters
    [in]character(len=*) :: FnameFilename of file to open
    [out]integer(i4) :: NcOpenid of opened stream
    Author
    Stephan Thober,
    Date
    May 2012

Definition at line 2061 of file mo_ncread.f90.

References ncopen().

Referenced by ncopen().

Here is the call graph for this function:
Here is the caller graph for this function: