Fortran/GribApi

From mn/geo/geoit
Jump to: navigation, search

<rst>

    • Compiling with the GRIB_API**

The new grib_api replaces the old gribex library. The most obvious advantage is that it provides support for both, GRIB1 and GRIB2. In addition, it compiles on billy (i.e. on a 64Bit platform). The currently installed version is now 1.9.9. ECMWF claims that several performance improvements have been made, and better memory management has been implemented.

For support with the GRIB_API, the include paths and the linkage paths and libraries must be set like this (example for 64 bit):

 -I/xnilu_wrk/flex_wrk/bin64/grib_api/include
 -L/xnilu_wrk/flex_wrk/bin64/grib_api/lib
 -L/xnilu_wrk/flex_wrk/lib64/jasper/lib
 -lgrib_api_f90 -lgrib_api -lm -ljasper

For the compilation on 64 bit machines. Note that the grib_api directory is linked to the latest version built.

All makefiles should be modified accordingly.

In addition, you must include a uses statement to import the module file with the routine declarations:

 uses GRIB_API


Note that for the gfortran compiler, a small-case version of the module file grib_api.mod exists, while the absoft compiler uses the upper-case version GRIB_API.mod in the directory /nilu/home/flexpart/lib(64)/grib_api/include

This should be all. I managed to compile and run some test files (see the examples directory in the grib_api) without problems.

There are also the extremely useful ECMWF grib tools available from the command line. Use e.g.

 grib_dump <GRIBFILE>
 grib_copy
 grib_add
 grib_debug
 grib_histogram
 grib_get
 grib_set
 grib_convert
 grib_filter
 grib_ls

to name a few. Type grib_<TAB> to see them all.

To see all the contents of a grib file in detail, type

 grib_dump -O file | more

Documentation in html is available at

 /nilu/home/flexpart/lib/grib_api-1.6.1/html/index.html

or `at the ECMWF web page <http://www.ecmwf.int/publications/manuals/grib_api/>`_ (Requires login)

The jasper library is required for jpeg2000 support with the grib_api.

The sources to the grib_api and to jasper can be found at

 /xnilu_wrk/flex_wrk/bin64/grib_api-1.9.9
 /xnilu_wrk/flex_wrk/lib64/jasper
    • Using the GRIB_API**

It seems that using the grib_api is quite straightforward. Values are retrieved by a Name-Value coding.

Using the grib_api will be documented here as we go along with the code changes in FLEXPART.


</rst>