There are a number of subroutines which can be called from FORTRAN to handle GRIB and BUFR products in an unblocked binary file. These routines skip over any padding bytes between products such as those present in data files retrieved from the ECMWF Mars archives.
Debug output can be triggered from the PB routines using the environment variable PBIO_DEBUG (set to 1,2,..).
PBOPEN | To open a file for processing with calls to PB subroutines. (This supplies an index into an internal table which contains a C file pointer which must be given as an input argument to other routines) |
PBGRIB | To read a GRIB product |
PBBUFR | To read a BUFR product |
PBPSEU | To read a BUDG/TIDE/DIAG product |
PBSIZE | To give the size of a following GRIB or BUFR product |
PBCLOSE | To close a file |
PBFLUSH | To flush data written to a file |
File handling subroutines
There are routines which provide FORTRAN-callable methods for file handling; it is not normally necessary to use these routines for reading BUFR or GRIB products.
PBSEEK | To position a file |
PBREAD | To read a given number of bytes from a file |
PBREAD2 | To read a given number of bytes from a file (different behaviour from PBREAD on end-of-file) |
PBWRITE | To write a given number of bytes to a file |
PBTELL | To tell the current byte offset in a file. |
These subroutines are written in C and use standard C library functions for file handling (fopen, fclose, fseek, fread and fwrite).
C functions
There are three C functions to handle unblocked binary files.
readgrib | To read GRIB products |
readbufr | To read BUFR products |
readnext | To read any mixture of GRIB and BUFR products. |
These functions are written in C and use C standard library functions for file handling (fopen, fclose, fseek, fread and fwrite).
Libraries.
The library defined by the environment variable EMOSLIB contains the routines. The library name follows the normal UNIX convention and can be specified in the compile/link command using the usual method, for example:
f77 -o program program.F $EMOSLIB or cc -o program program.c $EMOSLIB