MI - Fimex
Data Types | Functions/Subroutines
fimex Module Reference

Fimex Fortran90 interface. More...

Data Types

interface  c_mifi_fill_scaled_double_dataslice
 F90-wrapper for mifi_fill_scaled_double_dataslice() More...
 
interface  c_mifi_free_cdm_reader
 F90-wrapper for mifi_free_cdm_reader() More...
 
interface  c_mifi_free_slicebuilder
 F90-wrapper for mifi_free_slicebuilder() More...
 
interface  c_mifi_get_dimension_name
 
interface  c_mifi_get_dimension_number
 
interface  c_mifi_get_dimension_size
 F90-wrapper for mifi_get_variable_type() More...
 
interface  c_mifi_get_filetype
 F90-wrapper for mifi_get_filetype() More...
 
interface  c_mifi_get_unique_forecast_reference_time
 F90-wrapper for mifi_get_unique_forecast_reference_time() More...
 
interface  c_mifi_get_unlimited_dimension_name
 
interface  c_mifi_get_var_latitude
 F90-wrapper for mifi_get_var_latitude() More...
 
interface  c_mifi_get_var_longitude
 F90-wrapper for mifi_get_var_longitude() More...
 
interface  c_mifi_get_variable_name
 
interface  c_mifi_get_variable_number
 
interface  c_mifi_get_variable_type
 F90-wrapper for mifi_get_variable_type() More...
 
interface  c_mifi_new_cdminterpolator
 F90-wrapper for mifi_new_cdminterpolator() More...
 
interface  c_mifi_new_io_reader
 F90-wrapper for mifi_new_io_reader() More...
 
interface  c_mifi_new_lonlat_interpolator
 F90-wrapper for mifi_new_cdminterpolator() More...
 
interface  c_mifi_new_slicebuilder
 F90-wrapper for mifi_new_slicebuilder() More...
 
interface  c_mifi_read_field
 F90-wrapper for mifi_read_field() More...
 
interface  c_mifi_slicebuilder_dimname
 F90-wrapper for mifi_slicebuilder_dimname() More...
 
interface  c_mifi_slicebuilder_get_axistype
 F90-wrapper for mifi_slicebuilder_get_axistype() More...
 
interface  c_mifi_slicebuilder_get_start_size
 F90-wrapper for mifi_slicebuilder_get_start_size() More...
 
interface  c_mifi_slicebuilder_ndims
 F90-wrapper for mifi_slicebuilder_ndims() More...
 
interface  c_mifi_slicebuilder_set_dim_start_size
 F90-wrapper for mifi_slicebuilder_set_dim_start_size() More...
 
interface  c_mifi_write_scaled_double_dataslice
 F90-wrapper for mifi_write_scaled_double_dataslice() More...
 
type  fimexio
 Class to store file-handles for the high-level API. More...
 

Functions/Subroutines

integer function set_filetype (filetype_name, flag)
 translate the filetype from string to internal number More...
 
integer function open_file (this, infile, config, filetype, varName)
 Open a new data-soure. More...
 
integer function new_interpolator (this, fio, method, proj_input, out_x_axis, out_y_axis, out_is_degree)
 Create a new interpolated data-soure from an existing FimexIO. More...
 
integer function new_lonlat_interpolator (this, fio, method, lonvals, latvals)
 Create a new interpolated data-soure from an existing FimexIO. More...
 
real(kind=c_double) function get_unique_forecast_reference_time (this, unit)
 Get the files unique forecast_reference_time. More...
 
character(len=1024) function get_file_ulim_dimension_name (this)
 Get the name of the unlimited dimension (in most cases, time-dimension) More...
 
integer(kind=c_long_long) function get_file_dimensions_size (this)
 Get the number of dimensions in the file. More...
 
character(len=1024) function get_file_dimension_name (this, pos)
 Get the name of the dimension at position pos. More...
 
integer(kind=c_long_long) function get_variables_size (this)
 Get the number of variables in the file. More...
 
character(len=1024) function get_variable_name (this, pos)
 Get the name of the variable at position pos. More...
 
integer(kind=c_long) function get_variable_type (this, varName)
 Get the type of a variable This function will read the type of a variable as the CDM_* enum. More...
 
integer function get_dimensions (this, varName)
 Get the number of dimensions of a variable. This function will internally initialize a slicebuilder, too, so all data and dimension-fetching will be against this variable. More...
 
character(len=1024) function get_dimname (this, pos)
 Get the dimension-name at a position Get the dimension at a position between 1 and get_dimensions() The position is directly related to the position in the return arrays of get_dimension_start_size() More...
 
integer(kind=c_long) function get_dimension_size (this, dimName)
 Get the global size of a file's dimension Get the dimension-size of a dimension of the file. More...
 
integer function get_dimension_start_size (this, start, vsize)
 Get the current start-position and current size for the current variable dimensions. Get the start-position and size for each dimension of the variable set with the last get_dimensions() call. Initially, start is 0 for each dimension and size is the full dimension size. This can be changed with reduce_dimension(). More...
 
integer function get_axistypes (this, atypes)
 Get the types of the axes. The types are the same as in MetNoFimex::CoordinateAxis::AxisType. Compare against AXIS_Time, AXIS_GeoX, ... enumerated constants. More...
 
character(len=1024) function get_var_longitude (this, varName)
 Get the name of the variable with longitude values for the variable varName the data-variable. More...
 
character(len=1024) function get_var_latitude (this, varName)
 Get the name of the variable with latitude values for the variable varName the data-variable. More...
 
integer function reduce_dimension (this, dimName, start, dsize)
 Reduce the dimension by setting a start and size. More...
 
integer function read_data (this, varname, field, cunit)
 Read data to a 1-d field. To work with n-d arrays, use the fortran rank remapping feature of fortran2003: More...
 
integer function write_data (this, varname, field, cunit)
 Write data to a file. More...
 
integer function close_file (this)
 Cleanup internally kept handles and close the file. More...
 

Detailed Description

Fimex Fortran90 interface.

Author
Trygve Aspelien, Heiko Klein

The Fimex F90 interface is devided into two parts. Functions starting with c_mifi are wrapper functions against the Fimex C-interface c_fimex.h . Functions without prefix define a high level F90 interface, which should generally be used

Besides the documented functions, the following constants can be used: AXIS_Undefined = 0, AXIS_GeoX, AXIS_GeoY, AXIS_GeoZ, AXIS_Time, AXIS_Lon, AXIS_Lat, AXIS_Pressure, AXIS_Height, AXIS_ReferenceTime INTERPOL_NEAREST_NEIGHBOR = 0, INTERPOL_BILINEAR, INTERPOL_BICUBIC, INTERPOL_COORD_NN, INTERPOL_COORD_NN_KD, INTERPOL_FORWARD_SUM, INTERPOL_FORWARD_MEAN, INTERPOL_FORWARD_MEDIAN, INTERPOL_FORWARD_MAX, INTERPOL_FORWARD_MIN FILETYPE_UNKNOWN=-1, FILETYPE_FELT, FILETYPE_NETCDF,& FILETYPE_NCML, FILETYPE_GRIB, FILETYPE_WDB, FILETYPE_METGM,& FILETYPE_RW=1024

The fimex.f90 interface is currently not precompiled with building fimex. Please copy the fimex.f90 file to your f90-project and compile it from there, and link with ''-lfimex''.

An example to run against this module can be found in modules/F90/fortran_test.f90

See also
https://svn.met.no/viewvc/fimex/trunk/modules/F90/fimex.f90?view=co

Function/Subroutine Documentation

integer function fimex::close_file ( class(fimexio), intent(inout)  this)

Cleanup internally kept handles and close the file.

integer function fimex::get_axistypes ( class(fimexio), intent(in)  this,
integer(kind=c_int), dimension(:), intent(inout), allocatable, target  atypes 
)

Get the types of the axes. The types are the same as in MetNoFimex::CoordinateAxis::AxisType. Compare against AXIS_Time, AXIS_GeoX, ... enumerated constants.

Parameters
atypespre-allocated integer array of size ndims
Returns
0 on success, negative on error
integer(kind=c_long) function fimex::get_dimension_size ( class(fimexio), intent(in)  this,
character(len=*), intent(in)  dimName 
)

Get the global size of a file's dimension Get the dimension-size of a dimension of the file.

Parameters
dimNamethe dimensions name
Returns
the size of the dimension, or 0
integer function fimex::get_dimension_start_size ( class(fimexio), intent(in)  this,
integer(kind=c_int), dimension(:), intent(inout), allocatable, target  start,
integer(kind=c_int), dimension(:), intent(inout), allocatable, target  vsize 
)

Get the current start-position and current size for the current variable dimensions. Get the start-position and size for each dimension of the variable set with the last get_dimensions() call. Initially, start is 0 for each dimension and size is the full dimension size. This can be changed with reduce_dimension().

Parameters
startpre-allocated array of size get_dimensions(), returns usually 0,0,0,...
vsizepre-allocated array of size get_dimensions(), returns the sizes of the dimension
Returns
0 on success, negative on error
integer function fimex::get_dimensions ( class(fimexio), intent(inout)  this,
character(len=*), intent(in)  varName 
)

Get the number of dimensions of a variable. This function will internally initialize a slicebuilder, too, so all data and dimension-fetching will be against this variable.

Parameters
varNamevariable name
Returns
number of dimensions, negative on error
character(len=1024) function fimex::get_dimname ( class(fimexio), intent(in)  this,
integer, intent(in)  pos 
)

Get the dimension-name at a position Get the dimension at a position between 1 and get_dimensions() The position is directly related to the position in the return arrays of get_dimension_start_size()

Parameters
posPosition in the dimensions-array, 1 <= pos <= get_dimensions()
Returns
string, or "" on error
character(len=1024) function fimex::get_file_dimension_name ( class(fimexio), intent(in)  this,
integer, value  pos 
)

Get the name of the dimension at position pos.

Parameters
posposition of dimension 1 <= pos <= dimension_number()
Returns
name of dimension
integer(kind=c_long_long) function fimex::get_file_dimensions_size ( class(fimexio), intent(in)  this)

Get the number of dimensions in the file.

Returns
number of dimensions
character(len=1024) function fimex::get_file_ulim_dimension_name ( class(fimexio), intent(in)  this)

Get the name of the unlimited dimension (in most cases, time-dimension)

Returns
name of dimension
real(kind=c_double) function fimex::get_unique_forecast_reference_time ( class(fimexio), intent(inout)  this,
character(len=*), intent(in), optional  unit 
)

Get the files unique forecast_reference_time.

Parameters
unitoptional time-unite, defaults to 'seconds since 1970-01-01 +0000'
Returns
double in units, nan on error
character(len=1024) function fimex::get_var_latitude ( class(fimexio), intent(in)  this,
character(len=*), intent(in)  varName 
)

Get the name of the variable with latitude values for the variable varName the data-variable.

Parameters
posposition of variable 1 <= pos <= variable_number()
Returns
name of variable with latitude values, this might be 1d or 2d depending on projection (even more for e.g. sattelite-swath (3d))
character(len=1024) function fimex::get_var_longitude ( class(fimexio), intent(in)  this,
character(len=*), intent(in)  varName 
)

Get the name of the variable with longitude values for the variable varName the data-variable.

Parameters
posposition of variable 1 <= pos <= variable_number()
Returns
name of variable with longitude values, this might be 1d or 2d depending on projection (even more for e.g. sattelite-swath (3d))
character(len=1024) function fimex::get_variable_name ( class(fimexio), intent(in)  this,
integer, value  pos 
)

Get the name of the variable at position pos.

Parameters
posposition of variable 1 <= pos <= variable_number()
Returns
name of variable
integer(kind=c_long) function fimex::get_variable_type ( class(fimexio), intent(in)  this,
character(len=*), intent(in)  varName 
)

Get the type of a variable This function will read the type of a variable as the CDM_* enum.

Parameters
varNamevariable name
Returns
type, on of CDM_* constants, CDM_NAT (Not A Type) in case something goes wrong
integer(kind=c_long_long) function fimex::get_variables_size ( class(fimexio), intent(in)  this)

Get the number of variables in the file.

Returns
number of variables
integer function fimex::new_interpolator ( class(fimexio), intent(out)  this,
class(fimexio), intent(in)  fio,
integer, intent(in)  method,
character(len=*), intent(in)  proj_input,
character(len=*), intent(in)  out_x_axis,
character(len=*), intent(in)  out_y_axis,
logical, intent(in)  out_is_degree 
)

Create a new interpolated data-soure from an existing FimexIO.

Parameters
thisthe new FimexIO object. It must be closed with close_file.
fiothe input data-source
methodone of INTERPOL_bilinear, INTERPOL_.... methods
proj_inputa proj4 text string
out_x_axisa description string of the x-axis, e.g. "10,20,...,1000", see MetNoFimex::SpatialAxisSpec
out_y_axisa description string of the y-axis, e.g. "10,20,...,1000", see MetNoFimex::SpatialAxisSpec
out_is_degreeoutput-axis are in degree (true) or meter (false)
Returns
negative value on error, >= 0 on success
integer function fimex::new_lonlat_interpolator ( class(fimexio), intent(out)  this,
class(fimexio), intent(in)  fio,
integer, intent(in)  method,
real(kind=c_double), dimension(:), intent(in), allocatable, target  lonvals,
real(kind=c_double), dimension(:), intent(in), allocatable, target  latvals 
)

Create a new interpolated data-soure from an existing FimexIO.

Parameters
thisthe new FimexIO object. It must be closed with close_file.
fiothe input data-source
methodone of INTERPOL_bilinear, INTERPOL_.... methods
lonvalslongitude positions
latvalslongitude positions
Returns
negative value on error, >= 0 on success
integer function fimex::open_file ( class(fimexio), intent(out)  this,
character(len=*), intent(in)  infile,
character(len=*), intent(in)  config,
integer, intent(in)  filetype,
character(len=*), intent(in), optional  varName 
)

Open a new data-soure.

Parameters
thisthe new FimexIO object.
infilefilename (or URL) of input
configconfiguration-file, use "" if not applicable
filetypesee set_filetype(), to open a file read-writable use IOR(FILETYPE_NETCDF,FILETYPE_RW)
varNameoptional varname, if used, will call get_dimensions() and return the number of dimensions
Returns
negative value on error, >= 0 on success, positive number indicate dimensions of varName
integer function fimex::read_data ( class(fimexio), intent(in)  this,
character(len=*), intent(in)  varname,
real(kind=c_double), dimension(:), intent(inout), allocatable, target  field,
character(len=*), intent(in), optional  cunit 
)

Read data to a 1-d field. To work with n-d arrays, use the fortran rank remapping feature of fortran2003:

REAL(KIND=8),DIMENSION(:),ALLOCATABLE,TARGET :: target
REAL(KIND=8),DIMENSION(:,:,:,:),ALLOCATABLE,POINTER :: field4d
ALLOCATE(target(product(vsize))
ierr=read_data(varname,cunit,target)
! remap to 4-d
field4d(1:vsize(1),1:vsize(2),1:vsize(3),1:vsize(4)) => target
Parameters
varNamethe variable name to read, must be similar or equal to the one set in get_dimensions()
fieldthe preallocated multi-dimensional field
cunitthe unit to read the variable in. "" or unset ignore units.
Returns
0 on success
integer function fimex::reduce_dimension ( class(fimexio), intent(in)  this,
character(len=*), intent(in)  dimName,
integer(kind=c_int), intent(in)  start,
integer(kind=c_int), intent(in)  dsize 
)

Reduce the dimension by setting a start and size.

Parameters
dimNamedimension name, e.g. retrieved by get_dimname()
startstart-position in the dimension to retrieve the data, first position is 0!
dsizesize of the dimension. This may not be too large, e.g. start+size must be < total dimension size
Returns
0 on success, otherwise error
integer function fimex::set_filetype ( character(len=*), intent(in)  filetype_name,
integer, intent(in), optional  flag 
)

translate the filetype from string to internal number

Parameters
filetype_namefiletype as "fimex", "netcdf", "grib", ...
Returns
integer filetype

Referenced by fimex2d_example(), and fortran_test().

integer function fimex::write_data ( class(fimexio), intent(in)  this,
character(len=*), intent(in)  varname,
real(kind=c_double), dimension(:), intent(inout), allocatable, target  field,
character(len=*), intent(in), optional  cunit 
)

Write data to a file.

Parameters
varNamethe variable name to write, must be similar or equal to the one set in get_dimensions()
fieldthe data, which must be 1d-allocatable
cunitthe unit the variable is currently in. "" or unset ignores units.
Returns
0 on success