ESMF_CFIOMod
Author: GMAO SI-Team
ESMF_CFIOMod
— Source file for CFIO
The code in this file provides interface specifications
This module provides all the necessary subroutines for users to write/read HDF or GrADS format output using CF convention.
ESMF_CFIODownBit
- GRIB-based compression pre-conditioner
This routine returns a lower precision version of the input array
x
which retains nbits
of precision. See routine
ESMF\_CFIODownBit2D
for additional details. This version for
rank 3 arrays, calls ESMF\_CFIODownBit2D()
for each vertical
level.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real, | intent(in) | :: | x(:,:,:) |
input array |
||
real(kind=REAL32), | intent(out) | :: | xr(:,:,:) |
precision reduced array; can if it has same kind |
||
integer, | intent(in) | :: | nbits |
number of bits per word to retain - no action if nbits<1 |
||
real, | intent(in), | optional | :: | undef | ||
logical, | intent(in), | optional | :: | flops |
if true, uses slower float point based algorithm |
|
integer, | intent(out) | :: | rc |
error code = 0 - all is well /= 0 - something went wrong |
ESMF_CFIODownBit
- GRIB-based compression pre-conditioner
This routine returns a lower precision version of the input array
x
which retains nbits
of precision. Two algorithms are
implemented: 1) a fast one writen in C which downgrades precision
by shifting xbits = 24 - nbits
bits of the mantissa, and 2) a slower
float point based algorithm which is the same algorithm as GRIB
with fixed number of bits packing. Notice that as in GRIB the scaling
factor is forced to be a power of 2 rather than a generic float.
Using this power of 2 binary scaling has the advantage of improving
the GZIP compression rates.
This routine returns an array of the same type and kind as the input array, so no data compression has taken place. The goal here is to reduce the entropy in the input array, thereby improving compression rates by the lossless algorithms implemented internally by HDF-4/5 when writing these data to a file. In fact, these GZIP’ed and pre-conditioned files have sizes comparable to the equivalent GRIB file, while being a bonafide self-describing HDF/NetCDF file.
@note Todo : Perhaps implement GRIB decimal scaling (variable number of bits).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real, | intent(in) | :: | x(:,:) |
input array |
||
real(kind=REAL32), | intent(out) | :: | xr(:,:) |
precision reduced array; can share storage with input array if it has same kind |
||
integer, | intent(in) | :: | nbits |
number of bits per word to retain |
||
real, | intent(in), | optional | :: | undef |
missing value |
|
logical, | intent(in), | optional | :: | flops |
if true, uses slower float point based algorithm |
|
integer, | intent(out) | :: | rc |
error code = 0 - all is well /= 0 - something went wrong |
ESMF_CFIOVarRead3D_
– Read a variable from an existing file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
variable name |
||
real, | pointer | :: | field(:,:,:) |
array contains data |
||
integer, | intent(in), | optional | :: | date |
yyyymmdd |
|
integer, | intent(in), | optional | :: | curTime |
hhmmss |
|
integer, | intent(in), | optional | :: | kbeg |
first level to write |
|
integer, | intent(in), | optional | :: | kount |
number of levels to write |
|
integer, | intent(in), | optional | :: | xBeg |
first point for lon |
|
integer, | intent(in), | optional | :: | xCount |
number of points to read |
|
integer, | intent(in), | optional | :: | yBeg |
first point for lat |
|
integer, | intent(in), | optional | :: | yCount |
number of points to read |
|
character(len=*), | intent(in), | optional | :: | timeString |
string expression for date and time |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well |
ESMF_CFIOVarRead2D_
– Read a variable from an existing file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
variable name |
||
real, | pointer | :: | field(:,:) |
array contains data |
||
integer, | intent(in), | optional | :: | date |
yyyymmdd |
|
integer, | intent(in), | optional | :: | curTime |
hhmmss |
|
integer, | intent(in), | optional | :: | kbeg |
first level to write |
|
integer, | intent(in), | optional | :: | kount |
number of levels to write |
|
integer, | intent(in), | optional | :: | xBeg |
first point for lon |
|
integer, | intent(in), | optional | :: | xCount |
number of points to read |
|
integer, | intent(in), | optional | :: | yBeg |
first point for lat |
|
integer, | intent(in), | optional | :: | yCount |
number of points to read |
|
character(len=*), | intent(in), | optional | :: | timeString |
string expression for date and time |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well |
ESMF_CFIOVarRead1D_
– Read a variable from an existing file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
variable name |
||
real, | pointer | :: | field(:) |
array contains data |
||
integer, | intent(in), | optional | :: | date |
yyyymmdd |
|
integer, | intent(in), | optional | :: | curTime |
hhmmss |
|
integer, | intent(in), | optional | :: | xBeg |
first point for lon |
|
integer, | intent(in), | optional | :: | xCount |
number of points to read |
|
character(len=*), | intent(in), | optional | :: | timeString |
string expression for date and time |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well |
ESMF_CFIOVarReadT3D_
– Read a variable from an existing file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
variable name |
||
real, | pointer | :: | field(:,:,:) |
array contains data |
||
integer, | intent(in), | optional | :: | date |
yyyymmdd |
|
integer, | intent(in), | optional | :: | curTime |
hhmmss |
|
integer, | intent(in), | optional | :: | kbeg |
first level to read |
|
integer, | intent(in), | optional | :: | kount |
number of levels to read |
|
character(len=*), | intent(in), | optional | :: | timeString |
string expression for date and time |
|
type(ESMF_CFIO), | intent(inout), | optional | :: | cfio2 |
second CFIO obj |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well rc = -2 time is inconsistent with increment rc = -3 number of levels is incompatible with file rc = -4 im is incompatible with file rc = -5 jm is incompatible with file rc = -6 time must fall on a minute boundary rc = -7 error in diffdate rc = -12 error determining default precision rc = -13 error determining variable type rc = -19 unable to identify coordinate variable rc = -38 error from NF90_PUT_VAR (dimension variable) rc = -40 error from NF90_INQ_VARID rc = -41 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon) rc = -42 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev) rc = -43 error from NF90_INQ_VARID (time variable) rc = -44 error from NF90_GET_ATT (time attribute) rc = -46 error from NF90_GET_VAR rc = -48 error from NF90_INQUIRE rc = -52 error from NF90_INQUIRE_VARIABLE rc = -99 must specify date/curTime of timeString |
ESMF_CFIOVarReadT2D_
– Read a variable from an existing file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
variable name |
||
real, | pointer | :: | field(:,:) |
array contains data |
||
integer, | intent(in), | optional | :: | date |
yyyymmdd |
|
integer, | intent(in), | optional | :: | curTime |
hhmmss |
|
integer, | intent(in), | optional | :: | kbeg |
first level to read |
|
integer, | intent(in), | optional | :: | kount |
number of levels to read |
|
character(len=*), | intent(in), | optional | :: | timeString |
string expression for date and time |
|
type(ESMF_CFIO), | intent(inout), | optional | :: | cfio2 |
second CFIO obj |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well rc = -2 time is inconsistent with increment rc = -3 number of levels is incompatible with file rc = -4 im is incompatible with file rc = -5 jm is incompatible with file rc = -6 time must fall on a minute boundary rc = -7 error in diffdate rc = -12 error determining default precision rc = -13 error determining variable type rc = -19 unable to identify coordinate variable rc = -38 error from NF90_PUT_VAR (dimension variable) rc = -40 error from NF90_INQ_VARID rc = -41 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon) rc = -42 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev) rc = -43 error from NF90_INQ_VARID (time variable) rc = -44 error from NF90_GET_ATT (time attribute) rc = -46 error from NF90_GET_VAR rc = -48 error from NF90_INQUIRE rc = -52 error from NF90_INQUIRE_VARIABLE rc = -99 must specify date/curTime of timeString |
ESMF_CFIOVarReadT3D_
– Read a variable from an existing file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
variable name |
||
integer, | intent(in) | :: | date |
yyyymmdd |
||
integer, | intent(in) | :: | curTime |
hhmmss |
||
real, | pointer | :: | field(:,:,:) |
array contains data |
||
integer, | intent(in), | optional | :: | kbeg |
first level to read |
|
integer, | intent(in), | optional | :: | kount |
number of levels to read |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well rc = -2 time is inconsistent with increment rc = -3 number of levels is incompatible with file rc = -4 im is incompatible with file rc = -5 jm is incompatible with file rc = -6 time must fall on a minute boundary rc = -7 error in diffdate rc = -12 error determining default precision rc = -13 error determining variable type rc = -19 unable to identify coordinate variable rc = -20 unable to find variable rc = -38 error from NF90_PUT_VAR (dimension variable) rc = -40 error from NF90_INQ_VARID rc = -41 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon) rc = -42 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev) rc = -43 error from NF90_INQ_VARID (time variable) rc = -44 error from NF90_GET_ATT (time attribute) rc = -46 error from NF90_GET_VAR rc = -48 error from NF90_INQUIRE rc = -52 error from NF90_INQUIRE_VARIABLE |
|
type(ESMF_CFIO), | intent(inout), | optional | :: | cfio2 |
second CFIO obj |
ESMF_CFIOVarReadT2D_
– Read a variable from an existing file
!INTERFACE:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
variable name |
||
integer, | intent(in) | :: | date |
yyyymmdd |
||
integer, | intent(in) | :: | curTime |
hhmmss |
||
real, | pointer | :: | field(:,:) |
array contains data |
||
integer, | intent(in), | optional | :: | kbeg |
first level to read |
|
integer, | intent(in), | optional | :: | kount |
number of levels to read |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well rc = -2 time is inconsistent with increment rc = -3 number of levels is incompatible with file rc = -4 im is incompatible with file rc = -5 jm is incompatible with file rc = -6 time must fall on a minute boundary rc = -7 error in diffdate rc = -12 error determining default precision rc = -13 error determining variable type rc = -19 unable to identify coordinate variable rc = -38 error from NF90_PUT_VAR (dimension variable) rc = -40 error from NF90_INQ_VARID rc = -41 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon) rc = -42 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev) rc = -43 error from NF90_INQ_VARID (time variable) rc = -44 error from NF90_GET_ATT (time attribute) rc = -46 error from NF90_GET_VAR rc = -48 error from NF90_INQUIRE rc = -52 error from NF90_INQUIRE_VARIABLE |
|
type(ESMF_CFIO), | intent(inout), | optional | :: | cfio2 |
second CFIO obj |
ESMF_CFIOVarWrite3D_
– Write a variable to a output file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
Variable name |
||
real, | intent(in) | :: | field(:,:,:) |
array contains data |
||
integer, | intent(in), | optional | :: | date |
yyyymmdd |
|
integer, | intent(in), | optional | :: | curTime |
hhmmss |
|
integer, | intent(in), | optional | :: | kbeg |
first level to write |
|
integer, | intent(in), | optional | :: | kount |
number of levels to write |
|
character(len=*), | intent(in), | optional | :: | timeString |
string expression for date and time |
|
logical, | intent(in), | optional | :: | doComp |
do compression |
|
logical, | intent(in), | optional | :: | doChunk |
do chunk compression |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well rc = -2 time is inconsistent with increment rc = -3 number of levels is incompatible with file rc = -4 im is incompatible with file rc = -5 jm is incompatible with file rc = -6 time must fall on a minute boundary rc = -7 error in diffdate rc = -12 error determining default precision rc = -13 error determining variable type rc = -15 data outside of valid range rc = -16 data outside of packing range rc = -17 data outside of pack and valid range rc = -38 error from NF90_PUT_VAR (dimension variable) rc = -40 error from NF90_INQ_VARID rc = -41 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon) rc = -42 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev) rc = -43 error from NF90_INQ_VARID (time variable) rc = -44 error from NF90_GET_ATT (time attribute) rc = -45 error from NF90_PUT_VAR rc = -46 error from NF90_GET_VAR rc = -52 error from NF90_INQUIRE_VARIABLE rc = -53 error from NF90_GET_ATT rc = -54 Format is not known |
ESMF_CFIOVarWrite2D_
– Write a variable to a output file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
Variable name |
||
real, | intent(in) | :: | field(:,:) |
array contains data |
||
integer, | intent(in), | optional | :: | date |
yyyymmdd |
|
integer, | intent(in), | optional | :: | curTime |
hhmmss |
|
integer, | intent(in), | optional | :: | kbeg |
first level to write |
|
integer, | intent(in), | optional | :: | kount |
number of levels to write |
|
character(len=*), | intent(in), | optional | :: | timeString |
string expression for date and time |
|
logical, | intent(in), | optional | :: | doComp |
do compression |
|
logical, | intent(in), | optional | :: | doChunk |
do chunk compression |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well rc = -2 time is inconsistent with increment rc = -3 number of levels is incompatible with file rc = -4 im is incompatible with file rc = -5 jm is incompatible with file rc = -6 time must fall on a minute boundary rc = -7 error in diffdate rc = -12 error determining default precision rc = -13 error determining variable type rc = -15 data outside of valid range rc = -16 data outside of packing range rc = -17 data outside of pack and valid range rc = -38 error from NF90_PUT_VAR (dimension variable) rc = -40 error from NF90_INQ_VARID rc = -41 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon) rc = -42 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev) rc = -43 error from NF90_INQ_VARID (time variable) rc = -44 error from NF90_GET_ATT (time attribute) rc = -45 error from NF90_PUT_VAR rc = -46 error from NF90_GET_VAR rc = -52 error from NF90_INQUIRE_VARIABLE rc = -53 error from NF90_GET_ATT rc = -54 Format is not known |
ESMF_CFIOVarWrite1D_
– Write a variable to a output file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO obj |
||
character(len=*), | intent(in) | :: | vName |
Variable name |
||
real, | intent(in) | :: | field(:) |
array contains data |
||
integer, | intent(in), | optional | :: | date |
yyyymmdd |
|
integer, | intent(in), | optional | :: | curTime |
hhmmss |
|
character(len=*), | intent(in), | optional | :: | timeString |
string expression for date and time |
|
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well rc = -2 time is inconsistent with increment rc = -3 number of levels is incompatible with file rc = -4 im is incompatible with file rc = -5 jm is incompatible with file rc = -6 time must fall on a minute boundary rc = -7 error in diffdate rc = -12 error determining default precision rc = -13 error determining variable type rc = -15 data outside of valid range rc = -16 data outside of packing range rc = -17 data outside of pack and valid range rc = -38 error from NF90_PUT_VAR (dimension variable) rc = -40 error from NF90_INQ_VARID rc = -41 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon) rc = -42 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev) rc = -43 error from NF90_INQ_VARID (time variable) rc = -44 error from NF90_GET_ATT (time attribute) rc = -45 error from NF90_PUT_VAR rc = -46 error from NF90_GET_VAR rc = -52 error from NF90_INQUIRE_VARIABLE rc = -53 error from NF90_GET_ATT rc = -54 Format is not known |
strTemplate_
- expanding a format template to a string
! uc_class=uppercase(tmpl_class)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(out) | :: | str | |||
character(len=*), | intent(in) | :: | tmpl | |||
character(len=*), | intent(in), | optional | :: | class | ||
character(len=*), | intent(in), | optional | :: | xid | ||
integer, | intent(in), | optional | :: | nymd | ||
integer, | intent(in), | optional | :: | nhms | ||
integer, | intent(out), | optional | :: | stat |
ESMF_CFIOFileClose
– close an open CFIO stream
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio | |||
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well -54 error from ncclos (file close) |
ESMF_CFIOFileCreate
– Create a CFIO output file with meta data
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO object |
||
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well -1 Time increment is 0 -2 allocate memory error -3 Num of int/char/real elements and Cnt don’t match -12 error determining default precision -18 incorrect time increment -30 can’t open file -31 error from NF90_DEF_DIM -32 error from NF90_DEF_VAR (dimension variable) -33 error from NF90_PUT_ATT (dimension attribute) -34 error from NF90_DEF_VAR (variable) -35 error from NF90_PUT_ATT (variable attribute) -36 error from NF90_PUT_ATT (global attribute) -37 error from NF90_ENDDEF -38 error from NF90_PUT_VAR (dimension variable) -39 Num of real var elements and Cnt differ -55 error from NF90_REDEF (enter define mode) -56 error from NF90_ENDDEF (exit define mode) |
|
character(len=*), | intent(in), | optional | :: | expid |
Experiment ID |
|
character(len=*), | intent(in), | optional | :: | format |
GrADS or SDF |
ESMF_CFIOFileOpen
– open a CFIO file, and get CFIO meta data into a cfio Object.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_CFIO), | intent(inout) | :: | cfio |
a CFIO object |
||
integer, | intent(in) | :: | fmode |
0 for READ-WRITE non-zero for READ-ONLY |
||
integer, | intent(out), | optional | :: | rc |
Error return code: 0 all is well -1 invalid count -2 type mismatch -12 error determining default precision -10 ngatts is incompatible with file -11 character string not long enough -19 unable to identify coordinate variable -36 error from NF90_PUT_ATT (global attribute) -39 error from NF90_OPEN (file open) -40 error from NF90_INQ_VARID -41 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon) -42 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev) -43 error from NF90_INQ_VARID (time variable) -47 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (time) -48 error from NF90_INQUIRE -51 error from NF90_GET_ATT (global attribute) -52 error from NF90_INQUIRE_VARIABLE -53 error from NF90_GET_ATT -57 error from NF90_INQ_ATTNAME -58 error from NF90_INQUIRE_ATTRIBUTE |
|
character(len=*), | intent(in), | optional | :: | expid |
Experiment ID |
|
logical, | intent(in), | optional | :: | cyclic |
cyclic input file |