Skip to main content

Data Type Structures

Structures can be defined in five data types (byte, short, integer, float, double) and in up to 4 dimensions. The FPL structure naming follows the syntax below:

Naming Convention

nc[2d,3d,4d]_[byte,short,int,float,double]_ll[f,d]_t[i,f,d]_l[i,f]
ComponentOptionsDescription
nc[2d,3d,4d]2d, 3d, 4dDimension nomination
_[type]byte, short, int, float, doubleVariable data type
_ll[f,d]f (float), d (double)Coordinate (lon/lat) type
_t[i,f,d]i (integer), f (float), d (double)Time type (3D and 4D only)
_l[i,f]i (integer), f (float)Level type (4D only)

Examples

type(nc2d_double_llf) :: grid2d          ! 2D double, float coordinates
type(nc3d_int_llf_ti) :: grid3d ! 3D integer, float coords, integer time
type(nc4d_short_lld_ti_li) :: grid4d ! 4D short, double coords, int time, int level

Structure Fields

All types share common fields. Fields marked with [U] are set by the user; fields marked with [R] are populated when reading data.

FieldTypeDescription
varnamecharacterVariable name [U]
lonnamecharacterLongitude dimension name [U]
latnamecharacterLatitude dimension name [U]
timenamecharacterTime dimension name (3D/4D) [U]
levelnamecharacterLevel dimension name (4D) [U]
long_namecharacterLong name / title [U][R]
varunitscharacterVariable units [U][R]
lonunitscharacterLongitude units [U][R]
latunitscharacterLatitude units [U][R]
timeunitscharacterTime units (3D/4D) [U][R]
levelunitscharacterLevel units (4D) [U][R]
dimnamecharacter(:)Dimension names array [R]
dimunitscharacter(:)Dimension units array [R]
nlonsintegerNumber of longitudes [U][R]
nlatsintegerNumber of latitudes [U][R]
ntimesintegerNumber of time steps (3D/4D) [U][R]
nlevelsintegerNumber of levels (4D) [U][R]
ndimsintegerNumber of dimensions [R]
vartypeintegerNetCDF type number [R]
FillValuevariesFill / missing value [U][R]
longitudesfloat/double(:)Longitude array [R]
latitudesfloat/double(:)Latitude array [R]
timesint/float/double(:)Time array (3D/4D) [R]
levelsint/float(:)Level array (4D) [R]
ncdatavariesData array [R]
dimidinteger(:)Dimension IDs [R]
dimsizeinteger(:)Dimension sizes [R]
varidsinteger(:)Variable IDs [R]
dimsinteger(2/3/4)Variable dimension IDs [R]

Code Example — Set Dataset Fields

program main
use fpl
implicit none

type(nc4d_float_llf_ti_li) :: grid4d

! Set metadata
grid4d%long_name = "My Grid ~ 1 degree"
grid4d%varname = "grid"
grid4d%lonname = "lon"
grid4d%latname = "lat"
grid4d%timename = "time"
grid4d%levelname = "level"

grid4d%varunits = "dimensionless"
grid4d%lonunits = "degrees_east"
grid4d%latunits = "degrees_north"
grid4d%timeunits = "hour"
grid4d%levelunits = "m"

grid4d%ntimes = 10
grid4d%nlevels = 5
grid4d%FillValue = -9999

! Print metadata
write(*,*) "Grid 4d info ================================="
write(*,'(a13,a20)') "varname: ", grid4d%varname
write(*,'(a13,a20)') "timename: ", grid4d%timename
write(*,'(a13,a20)') "levelname: ", grid4d%levelname
write(*,'(a13,i4)') "ntimes: ", grid4d%ntimes
write(*,'(a13,i4)') "nlevels: ", grid4d%nlevels
write(*,'(a13,f10.4)') "FillValue: ", grid4d%FillValue
end program main

Compile & Run

gfortran -o setfields.out setfields.f90 -I/usr/lib64/gfortran/modules/ -lFPL
./setfields.out