NCEPLIBS-g2  3.4.7
addfield.f File Reference

Pack up Sections 4 through 7 for a given field and add them to a GRIB2 message. More...

Go to the source code of this file.

Functions/Subroutines

subroutine addfield (cgrib, lcgrib, ipdsnum, ipdstmpl, ipdstmplen, coordlist, numcoord, idrsnum, idrstmpl, idrstmplen, fld, ngrdpts, ibmap, bmap, ierr)
 Pack up Sections 4 through 7 for a given field and add them to a GRIB2 message. More...
 

Detailed Description

Pack up Sections 4 through 7 for a given field and add them to a GRIB2 message.

Author
Stephen Gilbert
Date
2000-05-02

Definition in file addfield.f.

Function/Subroutine Documentation

◆ addfield()

subroutine addfield ( character(len=1), dimension(lcgrib), intent(inout)  cgrib,
integer, intent(in)  lcgrib,
integer, intent(in)  ipdsnum,
integer, dimension(*), intent(in)  ipdstmpl,
integer, intent(in)  ipdstmplen,
real, dimension(numcoord), intent(in)  coordlist,
integer, intent(in)  numcoord,
integer, intent(in)  idrsnum,
integer, dimension(*), intent(inout)  idrstmpl,
integer, intent(in)  idrstmplen,
real, dimension(ngrdpts), intent(in), target  fld,
integer, intent(in)  ngrdpts,
integer, intent(in)  ibmap,
logical*1, dimension(ngrdpts), intent(in)  bmap,
integer, intent(out)  ierr 
)

Pack up Sections 4 through 7 for a given field and add them to a GRIB2 message.

They are the Product Definition Section, Data Representation Section, Bit-Map Section and Data Sections.

This routine is used with routines gribcreate(), addlocal(), addgrid(), and gribend() to create a complete GRIB2 message. Subroutine gribcreate() must be called first to initialize a new GRIB2 message. Subroutine addgrid() must be called after gribcreate() and before this routine to add the appropriate grid description to the GRIB2 message. A call to gribend() is required to complete GRIB2 message after all fields have been added.

Parameters
[in,out]cgribCharacter array to contain the GRIB2 message.
[in]lcgribMaximum length (bytes) of array cgrib.
[in]ipdsnumProduct Definition Template Number (see Code Table 4.0).
[in]ipdstmplContains the data values for the Product Definition Template specified by ipdsnum.
[in]ipdstmplenMax dimension of ipdstmpl.
[out]coordlistArray containg floating point values intended to document the vertical discretisation associated to model data on hybrid coordinate vertical levels (part of Section 4).
[in]numcoord- number of values in array coordlist.
[in]idrsnum- Data Representation Template Number (see Code Table 5.0).
[in]idrstmplContains the data values for the Data Representation Template specified by idrsnum. Note that some values in this template (eg. reference values, number of bits, etc...) may be changed by the data packing algorithms. Use this to specify scaling factors and order of spatial differencing, if desired.
[in]idrstmplenMax dimension of idrstmpl. This must be at least as large as the length of the selected PDS template.
[in]fldArray of data points to pack.
[out]ngrdptsNumber of data points in grid. i.e. size of fld and bmap.
[out]ibmapBitmap indicator (see Code Table 6.0).
  • 0 bitmap applies and is included in Section 6.
  • 1-253 Predefined bitmap applies
  • 254 Previously defined bitmap applies to this field
  • 255 Bit map does not apply to this product.
[out]bmapLogical*1 array containing bitmap to be added (if ibmap=0 or ibmap=254).
[out]ierrError return code.
  • 0 no error.
  • 1 GRIB message was not initialized. Need to call routine gribcreate first.
  • 2 GRIB message already complete. Cannot add new section.
  • 3 Sum of Section byte counts does not add to total byte count.
  • 4 Previous Section was not 3 or 7.
  • 5 Could not find requested Product Definition Template.
  • 6 Section 3 (GDS) not previously defined in message.
  • 7 Tried to use unsupported Data Representationi Template.
  • 8 Specified use of a previously defined bitmap, but one does not exist in the GRIB message.
  • 9 GDT of one of 5.50 through 5.53 required to pack using DRT 5.51.
  • 10 Error packing data field.
Author
Stephen Gilbert
Date
2000-05-02

Definition at line 72 of file addfield.f.

References cmplxpack(), pdstemplates::extpdstemplate(), g2_gbytec(), g2_sbytec(), g2_sbytesc(), getdim(), drstemplates::getdrstemplate(), pdstemplates::getpdstemplate(), getpoly(), jpcpack(), mkieee(), pngpack(), simpack(), and specpack().

Referenced by putgb2().