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 namming follow the sintax below:

Namming Structures

nc [2d,3d,4d] _ [byte,short,int,float,double] _ll [f,d] _t [i,f,d] _l [i,f]

nc[2d,3d,4d]:dimension nominations. Change [2d,3d,4d] to one of the nominations 2d, 3d, or 4d.
_[byte,short,int,float,double]:
 variable nominations. Change [byte,short,int,float,double] to one of the type nominations: byte, short, int, float or double.
_ll[f,d]:coordinates [longitude, latitude] nomination. Change [f,d] to one of the coordinates nominations: f for float and d for double.
_t[i,f,d]:time nomination (used when 3d denomination is set). Change [i,f,d] to one of the time nomination: i for integer, f for float and d for double.
_l[i,f]:level nomination (used when 4d denomination is set). Change [i,f] to one of the level nomination: i for integer, f for float.

some examples in fortran 90

1
2
3
type(nc2d_double_llf) :: grid2d ! 2d double dataset with float coordinates array.
type(nc3d_int_llf_ti) :: grid3d ! 3d integer dataset with float coordinates  and integer time array.
type(nc4d_short_lld_ti_li) :: grid4d ! 4d short dataset with double coordinates, integer time and integer level array.

Structure Fields

nc[2d,3d,4d]_[byte,short,int,float,double]_ll[f,d]_t[i,f,d]_l[i,f]
Dimension naming:
 

2d, 3d, 4d [1]

Type naming:

byte, short, int, float, double [1]

Coordinates naming:
 

f, d [1]

Time naming:

i, f, d [3d and 4d datasets] [1]

Level naming:

i, f [4d datasets] [1]

Type fields:
  • % varname :: variable name [character] [1]
  • % timename :: time name [character] [3d and 4d datasets] [1]
  • % levelname :: level name [character] [4d datasets] [1]
  • % lonname :: longitude name [character] [1]
  • % latname :: latitude name [character] [1]
  • % long_name :: [long name dataset title] [1] [2]
  • % dimnames :: array of dimension names [character] [2]
  • % varunits :: variable units [character] [1] [2]
  • % lonunits :: longitude units [character] [1] [2]
  • % latunits :: latitude units [character] [1] [2]
  • % timeunits :: time units [character] [3d and 4d datasets] [1] [2]
  • % levelunits :: level units [character] [4d datasets] [1] [2]
  • % dimunits :: dimension units array [character] [2]
  • % ndims :: number of variable dimensions [integer] [2]
  • % dims :: dimension IDs corresponding to the variable dimensions [integer] [2]
  • % dimid :: array of dimension IDs [integer] [2]
  • % dimsize :: array of size of dimensions [integer] [2]
  • % nlons :: number of dataset longitudes [integer] [1] [2]
  • % nlats :: number of dataset latitudes [integer] [1] [2]
  • % ntimes :: number of dataset times [integer] [3d and 4d datasets] [1] [2]
  • % nlevels :: number of dataset level [integer] [4d datasets] [1] [2]
  • % vartype :: type number for NetCDF-fortran library [integer] [2]
  • % varids :: array of variables IDs [integer] [2]
  • % FillValue :: fill value [byte, short, integer, float, double] [1] [2]
  • % levels :: levels array [integer, float] [4d datasets] [1] [2]
  • % times :: times array [integer, float, double] [3d and 4d datasets] [1] [2]
  • % longitudes :: longitudes array [float, double] [1] [2]
  • % latitudes :: latitudes array [float, double] [1] [2]
  • % ncdata :: data array [byte, short, integer, float, double] [1] [2]
[1](1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26) Defined by user
[2](1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24) Defined on read and/or write data

[Code example] Set dataset fields

program main
  use fpl
  implicit none

  !Definition of dataset structures
  type(nc4d_float_llf_ti_li) :: grid4d
 
  !Grid 4d definitions
  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
  
  write(*,*) "Grid 4d info ================================="
  write(*,'(a13,a20)')   "varname:    ", grid4d%varname  
  write(*,'(a13,a20)')   "timename:   ", grid4d%timename
  write(*,'(a13,a20)')   "levelname:  ", grid4d%levelname
  write(*,'(a13,a20)')   "latname:    ", grid4d%latname
  write(*,'(a13,a20)')   "lonname:    ", grid4d%lonname
  write(*,'(a13,a20)')   "long_name:  ", grid4d%long_name
  write(*,'(a13,a20)')   "varunits:   ", grid4d%varunits 
  write(*,'(a13,a20)')   "timeunits:  ", grid4d%timeunits
  write(*,'(a13,a20)')   "levelunits: ", grid4d%levelunits
  write(*,'(a13,a20)')   "lonunits:   ", grid4d%lonunits
  write(*,'(a13,a20)')   "latunits:   ", grid4d%latunits
  write(*,'(a13,i4)')    "nlons:      ", grid4d%nlons
  write(*,'(a13,i4)')    "nlats:      ", grid4d%nlats
  write(*,'(a13,i4)')    "nlevels:    ", grid4d%nlevels
  write(*,'(a13,i4)')    "ntimes:     ", grid4d%ntimes
  write(*,'(a13,f10.4)') "FillValue:  ", grid4d%FillValue

end program main

Save as file (setfields.f90) and compiling using gfortran.

#RedHat based systems
gfortran -o setfields.out setfields.f90 -I/usr/lib64/gfortran/modules/ -lFPL

#Debian based systems
gfortran -o setfields.out setfields.f90 -I/usr/include/ -lFPL

Important

-I<dir> This option specifies where to put .mod files for compiled modules. It is also added to the list of directories to Influencing the linking step. See the GNU Fortran Compiler Documentation .

<dir> is defined in Makefile as $(FPL_moddir). See Build Library.

After compilation run the program ./setfields.out