API¶
FPL module¶
FPL works as a module and can be compiled with other programs. Its structure is composed of several files containing all definitions of data types, external libraries and intrinsic functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | !:=========================== FPL Main Module =================================
module FPL
use omp_lib
use netcdf
use iso_c_binding
implicit none
include "FPL_constants.f90" !Parameter variables
include "FPL_datatypes.f90" !Datatype structure declarations
include "FPL_interfaces.f90" !Interfaces for subroutines definitions and datatypes
contains
include "FPL_checkerror.f90" !Error checker subroutines
include "FPL_datetime.f90" !System date-time subroutine
include "FPL_griddims.f90" !Subroutines to get the number of coordinates from NetCDF file
include "FPL_readgrid.f90" !NetCDF file reader subroutines
include "FPL_writegrid.f90" !NetCDF file writer subroutines
include "FPL_setfillvalue.f90" !Set FillValue and mask creator subroutines
include "FPL_gengrid.f90" !Generate custom grid
include "FPL_dealloc.f90" !Deallocate subroutines
include "FPL_fileutils.f90" !File Utilities
include "FPL_misc.f90" !Miscelanious
include "FPL_sort.f90" !Bubble sort subroutine
end module FPL
|
Data Types and Parameter Definitions¶
FPL supports 5 datatype structures: BYTE, SHORT, INTEGER, FLOAT and DOUBLE.
Type | Minimum value | Maximum value | Default FillValue | |
---|---|---|---|---|
byte | -128 | 127 | -127 | |
short | -32768 | 32767 | -32767 | |
integer | -2147483648 | 2147483647 | 2147483647 | |
float | +/- 1.175494e-38 | +/- 1.701411e+38 | 9.96921e+36 | |
double | +/- 2.22507e-308 | +/- 8.98846e+307 | 9.969209968386869e+36 |
Numeric datatypes are defined using ISO_C_BINDINGS module into the file FPL_constants.f90. Parameters can be defined into this file too.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | integer, parameter :: byte = C_SIGNED_CHAR
integer, parameter :: short = C_SHORT
integer, parameter :: intgr = C_INT
integer, parameter :: float = C_FLOAT
integer, parameter :: double = C_DOUBLE
real(kind=double), parameter :: pi = 4*atan(1.0) ! pi
real(kind=double), parameter :: earth_radius = 6371.0 ! average radius of earth ~ km
real(kind=double), parameter :: acc_gravity = 9.80616 ! acceleration of gravity ~ m/s^2
real(kind=double), parameter :: stefan_boltzmann = 5.670373e-8 ! Stefan-Boltzmann constant ~ W/m^2K^4
real(kind=double), parameter :: boltzmann = 1.38064852e-23 ! Boltzmann constant ~ JK^-1
real(kind=double), parameter :: speed_of_light = 299792458.0 ! Speed of the light ~ m/s
real(kind=double), parameter :: atomic_mass = 1.660539040e-27 ! Atomic mass constant ~ kg
real(kind=double), parameter :: avogadro = 6.022140857e23 ! Avogadro constant ~ mol^-1
|
FPL can read and write data up to 4 dimensions in a much simpler way using dynamic data structures and dynamic modules as follows:
Type Structures¶
Interfaces¶
Interfaces can be used to invoke different functions using the same name.
Functions and Subroutines¶
- gengrid2d (2-dimensional Dataset)
- gengrid3d (3-dimensional Dataset)
- gengrid4d (3-dimensional Dataset)
- griddims2d (2-dimensional Dataset)
- griddims3d (3-dimensional Dataset)
- griddims4d (4-dimensional Dataset)
- readgrid2d (2-dimensional Dataset)
- readgrid3d (3-dimensional Dataset)
- readgrid4d (4-dimensional Dataset)
- writegrid2d (2-dimensional Dataset)
- writegrid3d (3-dimensional Dataset)
- writegrid4d (4-dimensional Dataset)
- setfillvalue2d (2-dimensional Dataset)
- setfillvalue3d (3-dimensional Dataset)
- setfillvalue4d (4-dimensional Dataset)
- dealloc2d (2-dimensional Dataset)
- dealloc3d (2-dimensional Dataset)
- dealloc4d (2-dimensional Dataset)