NCEPLIBS-g2  3.4.7
gf_getfld.F90 File Reference

Contains subroutines returns the Grid Definition, and Product Definition for a given data field. More...

Go to the source code of this file.

Functions/Subroutines

subroutine gf_getfld (cgrib, lcgrib, ifldnum, unpack, expand, gfld, ierr)
 This subroutine returns the Grid Definition, Product Definition, Bit-map (if applicable), and the unpacked data for a given data field. More...
 

Detailed Description

Contains subroutines returns the Grid Definition, and Product Definition for a given data field.

Author
Stephen Gilbert
Date
2000-05-26

Definition in file gf_getfld.F90.

Function/Subroutine Documentation

◆ gf_getfld()

subroutine gf_getfld ( character(len = 1), dimension(lcgrib), intent(in)  cgrib,
integer, intent(in)  lcgrib,
integer, intent(in)  ifldnum,
logical, intent(in)  unpack,
logical, intent(in)  expand,
type(gribfield), intent(out)  gfld,
integer, intent(out)  ierr 
)

This subroutine returns the Grid Definition, Product Definition, Bit-map (if applicable), and the unpacked data for a given data field.

All of the information returned is stored in a derived type variable, gfld. Gfld is of type gribfield, which is defined in module grib_mod, so users of this routine will need to include the line "USE GRIB_MOD" in their calling routine.

Since there can be multiple data fields packed into a GRIB2 message, the calling routine indicates which field is being requested with the ifldnum argument.

Parameters
[in]cgribCharacter array that contains the GRIB2 message.
[in]lcgribLength (in bytes) of GRIB message array cgrib.
[in]ifldnumSpecifies which field in the GRIB2 message to return.
[in]unpackLogical value indicating whether to unpack bitmap/data. .true. = unpack bitmap and data values; .false. = do not unpack bitmap and data values.
[in]expandBoolean value indicating whether the data points should be expanded to the correspond grid, if a bit-map is present.
  • 1 if possible, expand data field to grid, inserting zero values at gridpoints that are bitmapped out.
  • 0 do not expand data field, leaving it an array of consecutive data points for each "1" in the bitmap. This argument is ignored if unpack == 0 OR if the returned field does not contain a bit-map.
[out]gfldderived type grib_mod::gribfield.
[out]ierrError return code.
  • 0 no error.
  • 1 Beginning characters "GRIB" not found.
  • 2 GRIB message is not Edition 2.
  • 3 The data field request number was not positive.
  • 4 End string "7777" found, but not where expected.
  • 5 End string "7777" not found at end of message.
  • 6 GRIB message did not contain the requested number of data fields.
  • 7 End string "7777" not found at end of message.
  • 9 Data Representation Template 5.NN not yet implemented.
  • 10 Error unpacking Section 3.
  • 11 Error unpacking Section 4.
  • 12 Error unpacking Section 5.
  • 13 Error unpacking Section 6.
  • 14 Error unpacking Section 7.
  • 17 Previous bitmap specified, but none exists.
Note
Note that derived type grib_mod::gribfield contains pointers to many arrays of data. The memory for these arrays is allocated when the values in the arrays are set, to help minimize problems with array overloading. Because of this users should free this memory, when it is no longer needed, by a call to subroutine gf_free(). Subroutine gb_info() can be used to first determine how many data fields exist in a given GRIB message.

It may not always be possible to expand a bit-mapped data field. If a pre-defined bit-map is used and not included in the GRIB2 message itself, this routine would not have the necessary information to expand the data. In this case, gfld%expanded would be set to 0 (false), regardless of the value of input argument expand.

Author
Stephen Gilbert
Date
2000-05-26

Definition at line 67 of file gf_getfld.F90.

References g2_gbytec(), gf_free(), gf_unpack1(), gf_unpack2(), gf_unpack3(), gf_unpack4(), gf_unpack5(), gf_unpack6(), and gf_unpack7().