gridtemplates.c(3)
β¨ NAME β¨
gridtemplates.c β Returns grid template information for a specified Grid Definition Template for Section 3 - the Grid Definition Section (GDS).
okay bestie so real quick β this whole page lives in the Library Functions Manual, and it's literally the cheat sheet for every grid template lookup in NCEPLIBS-g2c. no cap. let's get into it π
πΈ SYNOPSIS πΈ
#include 'grib2_int.h'
π§ Functions
gtemplate * extgridtemplate (g2int number, g2int *template)β This subroutine generates the remaining octet map for a given Grid Definition Template, if required.int g2c_get_gdt_len (int grid_template_num, int *maplen)β Get initial length (number of entries) in static part of Grid Definition Template.int g2c_get_grid_template (int grid_template_num, int *maplen, int *map, int *needext)β Get grid template information.int g2c_get_grid_template_extension (int grid_template_num, int *template, int *extlen, int *ext)β Get grid template extension information.static g2int getgridindex (g2int number)β This function returns the index of specified Grid Definition Template in arraytemplatesfor[Section 3 - the Grid Definition Section (GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml).gtemplate * getgridtemplate (g2int number)β This subroutine returns grid template information for a specified Grid Definition Template for[Section 3 - the Grid Definition Section (GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml).
π Variables
static const struct gridtemplate templatesgrid [G2C_MAX_GDS_TEMPLATE]β Templates grid.
π« Detailed Description π«
Returns grid template information for a specified Grid Definition Template for Section 3 - the Grid Definition Section (GDS).
Every single Template has three parts, and yes you need all three:
- The number of entries in the template (
mapgridlen). - A map of the template (
mapgrid), which contains the number of octets in which to pack each of the template values. - A logical value (
needext) that indicates whether the Template needs to be extended.
In some cases the number of entries in a template can vary depending upon values specified in the "static" part of the template. (See Template 3.120 as an example).
Note π¨ Arraymapgridcontains the number of octets in which the corresponding template values will be stored. A negative value inmapgridis used to indicate that the corresponding template entry can contain negative values. This information is used later when packing (or unpacking) the template data values. Negative data values in GRIB are stored with the left most bit set to one, and a negative number of octets value inmapgridindicates that this possibility should be considered. The number of octets used to store the data value in this case would be the absolute value of the negative value inmapgrid. read it twice bestie, it matters π
π Program History Log
2001-06-28β Gilbert β Initial2007-08-16β Vuong β Added GDT 3.204 Curvilinear Orthogonal Grid2008-07-08β Vuong β Added GDT 3.32768 Rotate Lat/Lon E-grid (Arakawa)2009-01-14β Vuong β Changed structure nametemplatetogtemplate2010-05-11β Vuong β Added GDT 3.32769 Rotate Lat/Lon Non-E Staggered grid (Arakawa)2013-08-06β Vuong β Added GDT 3.4, 3.5, 3.12, 3.101, 3.1402022-10-16β Hartnett β Addedg2c_get_grid_template().2025-01-06β Stahl β Added GDT 3.13, 3.23, 3.33, 3.61, 3.62, 3.63, 3.150
π Author
Stephen Gilbert
π Date
2001-06-28
Definition in file gridtemplates.c.
π Function Documentation π
π gtemplate * extgridtemplate (g2int number, g2int * template)
This subroutine generates the remaining octet map for a given Grid Definition Template, if required. Some Templates can vary depending on data values given in an earlier part of the Template, and it is necessary to know some of the earlier entry values to generate the full octet map of the Template.
This function allocates memory for the extension. The pointer ext in the gtemplate struct must be freed to prevent memory leaks. fr fr, free it or leak it π«Ά
Parameters
- number β The number of the Grid Definition Template that is being requested.
- template β The grid definition template array.
Returns
Pointer to the returned template struct. Returns NULL pointer, if template not found.
Author
Stephen Gilbert
Date
2000-05-09
Definition at line 241 of file gridtemplates.c.
References getgridindex(), and getgridtemplate().
Referenced by g2_addgrid(), g2_unpack3(), and g2c_get_grid_template_extension().
π¦ int g2c_get_gdt_len (int grid_template_num, int * maplen)
Get initial length (number of entries) in static part of Grid Definition Template.
Parameters
- grid_template_num β The Grid template number.
- maplen β Pointer that gets the length of the map. Ignored if
NULL.
Returns
G2C_NOERRORβ No error.G2C_ENOTEMPLATEβ Template not found.
Author
Alyson Stahl
Date
01/21/25
Definition at line 433 of file gridtemplates.c.
References G2C_ENOTEMPLATE, G2C_MAX_GDS_TEMPLATE, G2C_NOERROR, and templatesgrid.
π int g2c_get_grid_template (int grid_template_num, int * maplen, int * map, int * needext)
Get grid template information. The grid template consists of a template map, its length, and, for some templates, an extra extension map, and its length. If an extension is needed, use g2c_get_grid_template_extension() to get it.
Parameters
- grid_template_num β The grid template number.
- maplen β Pointer that gets the length of the map. Ignored if
NULL. - map β Pointer that gets the map as an array of
int. Memory must be allocated by caller. Ignored ifNULL. - needext β Pointer that a non-zero value if an extension to this template is needed. Ignored if
NULL.
Returns
G2C_NOERRORβ No error.G2C_ENOTEMPLATEβ Template not found.
Author
Ed Hartnett
Date
10/16/22
Definition at line 391 of file gridtemplates.c.
References G2C_ENOTEMPLATE, G2C_MAX_GDS_TEMPLATE, G2C_NOERROR, and templatesgrid.
Referenced by g2c_rw_section3_metadata().
πΈ int g2c_get_grid_template_extension (int grid_template_num, int * template, int * extlen, int * ext)
Get grid template extension information.
Parameters
- grid_template_num β The grid template number.
- template β Pointer to array that contains the template values.
- extlen β Pointer that gets the length of the extension. Ignored if
NULL. - ext β Pointer that gets template extension array, if there is one. Memory must be allocated by the caller. Ignored if
NULL.
Returns
G2C_NOERRORβ No error.G2C_EINVALβ Invalid input.G2C_ENOTEMPLATEβ Template not found.G2C_ENOMEMβ Out of memory.
Author
Ed Hartnett
Date
10/16/22
Definition at line 316 of file gridtemplates.c.
References gtemplate::ext, extgridtemplate(), gtemplate::extlen, G2C_EINVAL, G2C_ENOMEM, G2C_ENOTEMPLATE, G2C_MAX_GDS_TEMPLATE, G2C_NOERROR, and templatesgrid.
π g2int getgridindex (g2int number) [static]
This function returns the index of specified Grid Definition Template in array templates for [Section 3 - the Grid Definition Section (GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml).
Parameters
- number β The number of the Grid Definition Template being requested.
Returns
Index of the Grid Definition Template(GDT) in array templates, if template exists. -1, otherwise.
Author
Stephen Gilbert
Date
2001-06-28
Definition at line 155 of file gridtemplates.c.
References G2C_MAX_GDS_TEMPLATE, getgridindex(), and templatesgrid.
Referenced by extgridtemplate(), getgridindex(), and getgridtemplate().
π gtemplate * getgridtemplate (g2int number)
This subroutine returns grid template information for a specified Grid Definition Template for [Section 3 - the Grid Definition Section (GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml). The number of entries in the template is returned along with a map of the number of octets occupied by each entry. Also, a flag is returned to indicate whether the template would need to be extended.
This function allocates storage for the template. The returned pointer must be freed by the caller. π your memory, your responsibility.
Parameters
- number β The number of the Grid Definition Template that is being requested.
Returns
Pointer to the returned template struct (must be freed by caller). Returns NULL pointer, if template not found.
Author
Stephen Gilbert
Date
2000-05-09
Definition at line 193 of file gridtemplates.c.
References getgridindex(), and templatesgrid.
Referenced by extgridtemplate(), g2_addgrid(), and g2_unpack3().
π Variable Documentation π
π§ const struct gridtemplate templatesgrid[G2C_MAX_GDS_TEMPLATE] [static]
Templates grid.
Definition at line 58 of file gridtemplates.c.
Referenced by g2c_get_gdt_len(), g2c_get_grid_template(), g2c_get_grid_template_extension(), getgridindex(), and getgridtemplate().
β Author β
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
and that's the whole page bestie!! π«Ά this absolute icon of a manpage shipped out as part of NCEPLIBS-g2c, Version 2.3.0, and its manual page tag is gridtemplates.c(3) β go forth and template responsibly πβ¨π
π¦ where this page comes from
- ubuntu resolute: libg2c-dev 2.3.0-4 Β· LGPL-3.0-only
- ubuntu stonking: libg2c-dev 2.3.0-7 Β· LGPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms