ESMF_CFIOUtilMod
Author: GMAO SI-Team
ESMF_CFIOUtilMod
- utility subroutines for CFIO
The module ESMF_CFIOUtilMod
provides all the necessary utility subroutines for CFIO.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=*), | public, | parameter | :: | myname | = | 'm_StrTemplate' | |
character(len=3), | public, | parameter, dimension(12) | :: | mon_lc | = | (/'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'/) | |
character(len=3), | public, | parameter, dimension(12) | :: | mon_uc | = | (/'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'/) | |
character(len=3), | public, | parameter, dimension(12) | :: | mon_wd | = | (/'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'/) | |
character(len=7), | public, | parameter | :: | GRID_NAME | = | 'EOSGRID' | |
integer, | public, | parameter | :: | GCTP_GEO | = | 0 | |
integer, | public, | parameter | :: | HDFE_GD_LL | = | 2 | |
integer, | public, | parameter | :: | HDFE_NOMERGE | = | 0 | |
integer, | public, | parameter | :: | MAXCHR | = | 256 | |
integer, | public, | parameter | :: | MAX_VAR_DIMS | = | 32 | |
integer, | public, | parameter | :: | MLEN | = | 1024 | |
integer, | public, | parameter | :: | MVARLEN | = | 256 | |
integer, | public, | parameter | :: | NDIMS_MAX | = | 4 | |
integer, | public, | parameter | :: | PACK_BITS | = | 32766 | |
integer, | public, | parameter | :: | PACK_FILL | = | 32767 | |
integer, | public, | parameter | :: | stderr | = | 6 |
GetDateInt8
— Returns a new date/time from an initial date/time and offset
This subroutine returns a new date and time in yyyymmdd and hhmmss format given and initial date, time, and offset in seconds. The routine converts the input date and time to julian seconds, adds the offset, and converts back to yyyymmdd and hhmmss format. This routine has been tested for Y2K compiance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | yyyymmdd_1 |
Initial date in YYYYYMMDD format |
|||
integer | :: | hhmmss_1 |
Initial time in HHMMSS format |
|||
integer(kind=INT64) | :: | offset |
Offset to add (in seconds) |
|||
integer | :: | yyyymmdd_2 |
New date in YYYYMMDD format |
|||
integer | :: | hhmmss_2 |
New time in HHMMSS format |
|||
integer | :: | rc |
Return code. (<0 = error) |
GetDateInt4
— Returns a new date/time from an initial date/time and offset
This subroutine returns a new date and time in yyyymmdd and hhmmss format given and initial date, time, and offset in seconds. The routine converts the input date and time to julian seconds, adds the offset, and converts back to yyyymmdd and hhmmss format. This routine has been tested for Y2K compiance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | yyyymmdd_1 |
Initial date in YYYYYMMDD format |
|||
integer | :: | hhmmss_1 |
Initial time in HHMMSS format |
|||
integer | :: | offset |
Offset to add (in seconds) |
|||
integer | :: | yyyymmdd_2 |
New date in YYYYMMDD format |
|||
integer | :: | hhmmss_2 |
New time in HHMMSS format |
|||
integer | :: | rc |
Return code. (<0 = error) |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=MLEN), | public | :: | charData | ||||
character(len=MVARLEN), | public | :: | name | ||||
character(len=MVARLEN), | public | :: | vName | ||||
integer, | public | :: | count | ||||
type(cNode), | public, | pointer | :: | next | => | null() |
IdentifyDim
- Identify a cooridate variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*) | :: | dimName |
Name of the coordinate variable |
|||
character(len=*) | :: | dimUnits |
Units of the coordinate variable |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*) | :: | outstring | ||||
integer | :: | iret | ||||
integer | :: | ec |
DiffDate
— Calculates the number of seconds between two times.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | yyyymmhh_1 | ||||
integer | :: | hhmmss_1 | ||||
integer | :: | yyyymmhh_2 | ||||
integer | :: | hhmmss_2 |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | mm | ||||
integer | :: | id | ||||
integer | :: | iyyy |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid | ||||
integer | :: | rc |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=INT64) | :: | JULIAN | ||||
integer | :: | MM | ||||
integer | :: | ID | ||||
integer | :: | IYYY |
CFIO_AttInquire
– Get information about an attribute
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | name |
Name of attribute |
|||
integer | :: | type |
Code for attribute type 0 = integer 1 = real 2 = character 3 = 64-bit real 4 = 64-bit integer -1 = other |
|||
integer | :: | count |
Number of items (length of array) |
|||
integer | :: | rc |
Error return code: rc = 0 all is well |
CFIO_Close
– Closes file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
integer | :: | rc |
Error return code: rc = 0 all is well |
CFIO_DimInquire
– Gets dimension information from a CFIO file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid | ||||
integer | :: | im |
Size of longitudinal dimension |
|||
integer | :: | jm |
Size of latitudinal dimension |
|||
integer | :: | km |
Size of vertical dimension km=0 if surface-only file |
|||
integer | :: | lm |
Number of times |
|||
integer | :: | nvars |
Number of variables |
|||
integer | :: | ngatts |
Number of global attributes |
|||
integer, | optional | :: | vdir |
Positive vertical direction.
If |
||
integer, | optional | :: | rc |
Error return code: rc = 0 all is well rc = -19 unable to identify coordinate variable |
CFIO_GetAttNames
– Get global attribute names
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
integer | :: | ngatts |
Expected number of attributes (input) Actual number of attributes (output if rc=-2) |
|||
character(len=*) | :: | aname(ngatts) |
Array of attribute names |
|||
integer | :: | rc |
Error return code: rc = 0 all is well rc = -10 ngatts is incompatible with file rc = -11 character string not long enough |
CFIO_GetCharAtt
– Read a user-defined character attribute
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | name |
Name of attribute |
|||
integer | :: | count |
On input: Number of items in attribute On output: If rc = -1, count will contain the correct number of attributes |
|||
character(len=1) | :: | buf(count) |
Buffer with character values |
|||
integer | :: | rc |
Error return code: rc = 0 all is well rc = -1 invalid count rc = -2 type mismatch |
CFIO_GetIntAtt
– Read a user-defined integer attribute
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | name |
Name of attribute |
|||
integer | :: | count |
On input: Number of items in attribute On output: If rc = -1, count will contain the correct count of this attribute |
|||
integer | :: | buf(count) |
Buffer with integer values |
|||
integer | :: | rc |
Error return code: rc = 0 all is well rc = -1 invalid count rc = -2 type mismatch rc = -12 error determining default precision |
CFIO_GetRealAtt
– Read a user-defined real attribute
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | name |
Name of attribute |
|||
integer | :: | count |
On input: Number of items in attribute On output: If rc = -1, count will contain the correct number of attributes |
|||
real | :: | buf(count) |
Buffer with real values |
|||
integer | :: | rc |
Error return code: rc = 0 all is well rc = -1 invalid count rc = -2 type mismatch rc = -12 error determining default precision |
CFIO_GetVar
– Read a variable from the file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | vname |
Variable name |
|||
integer | :: | yyyymmdd |
Year-month-day, e.g., 19971003 |
|||
integer | :: | hhmmss |
Hour-minute-second, e.g., 120000 |
|||
integer | :: | im |
size of longitudinal dimension |
|||
integer | :: | jm |
size of latitudinal dimension |
|||
integer | :: | kbeg |
first level to read; if 2-D grid set kbeg = 0. |
|||
integer | :: | kount |
number of levels to read |
|||
integer | :: | lm |
number of time steps |
|||
real | :: | grid(im,jm,kount) |
Gridded data read for this time |
|||
logical | :: | cyclic |
input file is cyclic or not |
|||
logical | :: | useFaceDim | ||||
integer | :: | rc |
Error return code: rc = 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 |
CFIO_Open
– Opens an existing DAO gridded file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*) | :: | fname |
File name |
|||
integer | :: | fmode |
File mode: 0 for READ-WRITE non-zero for READ-ONLY |
|||
integer | :: | fid |
File handle |
|||
integer | :: | rc |
Error return code: rc = 0 All is well rc = -39 error from ncopn (file open) |
CFIO_PutCharAtt
– Write a user-defined character attribute
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | name |
Name of attribute |
|||
integer | :: | count |
Number of characters to write |
|||
character(len=MLEN) | :: | buf |
Buffer containing string |
|||
integer | :: | rc |
Error return code: rc = 0 all is well |
CFIO_PutIntAtt
– Write a user-defined integer attribute
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | name |
Name of attribute |
|||
integer | :: | count |
Number of integers to write |
|||
integer | :: | buf(count) |
Buffer with integer values |
|||
integer | :: | prec |
Desired precision of attribute value: 0 = 32 bit 1 = 64 bit |
|||
integer | :: | rc |
Error return code: rc = 0 all is well rc = -12 error determining default precision |
CFIO_PutRealAtt
– Write a user-defined real attribute
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | name |
Name of attribute |
|||
integer | :: | count |
Number of integers to write |
|||
real | :: | buf(count) |
Buffer with real values |
|||
integer | :: | prec |
Desired precision of attribute value: 0 = 32 bit 1 = 64 bit |
|||
integer | :: | rc |
Error return code: rc = 0 all is well rc = -12 error determining default precision |
CFIO_PutVar
– Write a variable to the file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | vname |
Variable name |
|||
integer | :: | yyyymmdd |
Year-month-day, e.g., 19971003 |
|||
integer | :: | hhmmss |
Hour-minute-second, e.g., 120000 |
|||
integer | :: | im |
size of longitudinal dimension |
|||
integer | :: | jm |
size of latitudinal dimension |
|||
integer | :: | kbeg |
first level to write; if 2-D grid use kbeg = 0. |
|||
integer | :: | kount |
number of levels to write |
|||
real | :: | grid(im,jm,kount) |
Gridded data to write at this time |
|||
logical | :: | useFaceDim | ||||
integer | :: | rc |
Error return code: rc = 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 |
CFIO_SGetVar
– Read a variable from the file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | vname |
Variable name |
|||
integer | :: | yyyymmdd |
Year-month-day, e.g., 19971003 |
|||
integer | :: | hhmmss |
Hour-minute-second, e.g., 120000 |
|||
integer | :: | im |
size of longitudinal dimension |
|||
integer | :: | jm |
size of latitudinal dimension |
|||
integer | :: | kbeg |
first level to read; if 2-D grid set kbeg = 0. |
|||
integer | :: | kount |
number of levels to read |
|||
integer | :: | lm |
number of time steps |
|||
real | :: | grid(im,kount) |
Gridded data read for this time |
|||
logical | :: | cyclic |
input file is cyclic or not |
|||
integer | :: | rc |
Error return code: rc = 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 |
CFIO_SPutVar
– Write a variable to the file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | vname |
Variable name |
|||
integer | :: | yyyymmdd |
Year-month-day, e.g., 19971003 |
|||
integer | :: | hhmmss |
Hour-minute-second, e.g., 120000 |
|||
integer | :: | im |
size of longitudinal dimension |
|||
integer | :: | jm |
size of latitudinal dimension |
|||
integer | :: | kbeg |
first level to write; if 2-D grid use kbeg = 0. |
|||
integer | :: | kount |
number of levels to write |
|||
real | :: | grid(im,kount) |
Gridded data to write at this time |
|||
integer | :: | rc |
Error return code: rc = 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 |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | hhmmss | |||
integer, | intent(out) | :: | hour | |||
integer, | intent(out) | :: | min | |||
integer, | intent(out) | :: | sec |
GX_
- evaluate a GrADS style string template
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(out) | :: | str | |||
character(len=*), | intent(in) | :: | tmpl | |||
character(len=*), | intent(in), | optional | :: | xid | ||
integer, | intent(in), | optional | :: | nymd | ||
integer, | intent(in), | optional | :: | nhms | ||
integer, | intent(out), | optional | :: | stat |
GetBegDateTime
- Get begin date/time of file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
file ID |
|||
integer | :: | begDate |
beginning date |
|||
integer | :: | begTime |
beginning time |
|||
integer | :: | incSecs |
time increment in secs |
|||
integer | :: | rc |
error return code |
GetDateInt4
— Returns a new date/time from an initial date/time and offset
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | yyyymmdd_1 |
Initial date in YYYYYMMDD format |
|||
integer | :: | hhmmss_1 |
Initial time in HHMMSS format |
|||
integer | :: | offset |
Offset to add (in seconds) |
|||
integer | :: | yyyymmdd_2 |
New date in YYYYMMDD format |
|||
integer | :: | hhmmss_2 |
New time in HHMMSS format |
|||
integer | :: | rc |
Return code. (<0 = error) |
GetDateInt8
— Returns a new date/time from an initial date/time and offset
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | yyyymmdd_1 |
Initial date in YYYYYMMDD format |
|||
integer | :: | hhmmss_1 |
Initial time in HHMMSS format |
|||
integer(kind=INT64) | :: | offset |
Offset to add (in seconds) |
|||
integer | :: | yyyymmdd_2 |
New date in YYYYMMDD format |
|||
integer | :: | hhmmss_2 |
New time in HHMMSS format |
|||
integer | :: | rc |
Return code. (<0 = error) |
GetDateTimeVec
- Get date/time of file samples
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
file ID |
|||
integer | :: | begDate |
Beginning date |
|||
integer | :: | begTime |
Beginning time |
|||
integer(kind=INT64) | :: | incVec(:) |
Vector of offsets (seconds) |
|||
integer | :: | rc |
error return code |
ParseTimeUnits
– Parse the COARDS time units string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=MAXCHR) | :: | TimeUnits |
Units metadata string from the Time coord var |
|||
integer | :: | year |
4-digit year |
|||
integer | :: | month |
month |
|||
integer | :: | day |
day |
|||
integer | :: | hour |
hour |
|||
integer | :: | min |
minute |
|||
integer | :: | sec |
second |
|||
integer | :: | rc |
return code 0 = no error -1 = problem parsing string |
addList
– put user defined attribute into a list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | name | |||
integer, | intent(in) | :: | count | |||
character(len=*), | intent(in), | optional | :: | vName | ||
integer, | intent(in), | optional | :: | attInt(*) | ||
character(len=MLEN), | intent(in), | optional | :: | attChar | ||
real, | intent(in), | optional | :: | attReal(*) | ||
type(iNode), | optional, | pointer | :: | iList |
int list |
|
type(rNode), | optional, | pointer | :: | rList |
real list |
|
type(cNode), | optional, | pointer | :: | cList |
char list |
getList
– retrieve defined attributes from a list
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(iNode), | optional, | pointer | :: | iList |
int list |
|
integer, | optional | :: | nIntAtt |
num of int att |
||
character(len=MLEN), | optional, | pointer | :: | intAttNames(:) | ||
integer, | optional, | pointer | :: | intAttCnts(:) |
data count in int att |
|
integer, | optional, | pointer | :: | intAtts(:,:) |
int attribute |
|
type(rNode), | optional, | pointer | :: | rList |
char list |
|
integer, | optional | :: | nRealAtt |
num of real att |
||
character(len=MLEN), | optional, | pointer | :: | realAttNames(:) | ||
integer, | optional, | pointer | :: | realAttCnts(:) |
data count in real att |
|
real, | optional, | pointer | :: | realAtts(:,:) |
real attribute |
|
type(cNode), | optional, | pointer | :: | cList |
real list |
|
integer, | optional | :: | nCharAtt |
num of char att |
||
character(len=MLEN), | optional, | pointer | :: | charAttNames(:) | ||
integer, | optional, | pointer | :: | charAttCnts(:) |
data count in char att |
|
character(len=MLEN), | optional, | pointer | :: | charAtts(:) |
char att |
|
character(len=MLEN), | optional, | pointer | :: | vNames(:) |
getMaxLenCnt
– get length of a list and max number of data in the nodes
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(out) | :: | maxLen | |||
integer, | intent(out) | :: | count | |||
type(iNode), | optional, | pointer | :: | iList | ||
type(rNode), | optional, | pointer | :: | rList | ||
type(cNode), | optional, | pointer | :: | cList |
strTemplate_
- expanding a format template to a string
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 |
strToInt
- convert timeString to integer date and time
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | timeString |
string expression of data and time |
||
integer, | intent(out) | :: | date | |||
integer, | intent(out) | :: | begTime |