NCEPLIBS-g2  3.5.0
g2grids Module Reference

Allow access to predefined GRIB2 Grid Definition Templates (GDT) stored in a file. More...

Functions/Subroutines

subroutine freegridlist ()
 This subroutine frees the memory allocated for the linked list of grid templates stored in module variable gridlist. More...
 
subroutine getgridbyname (lunit, name, igdtn, igdtmpl, iret)
 This subroutine searches a file referenced by fortran unit lunit for a Grid Definition Template assigned to the requested name. More...
 
subroutine getgridbynum (lunit, number, igdtn, igdtmpl, iret)
 This subroutine searches a file referenced by fortran unit lunit for a Grid Definition Template assigned to the requested number. More...
 
integer function readgrids (lunit)
 This function reads the list of GDT entries in the file associated with fortran unit, lunit. More...
 

Variables

integer, parameter maxtemp = 200
 maximum template number for grid definition. More...
 
integer num_grids = 0
 the number of grids. More...
 

Detailed Description

Allow access to predefined GRIB2 Grid Definition Templates (GDT) stored in a file.

The GDTs are represented by a predefined number or a character abbreviation. At the first request, all the grid GDT entries in the file associated with input Fortran file unit number, lunit, are read into a linked list named gridlist. This list is searched for the requested entry. Users of this Fortran module should only call routines getgridbynum() and getgridbyname(), and freegridlist() to release all allocated memory.

The format of the file scanned by routines in this module is as follows. Each line contains one Grid entry containing five fields, each separated by a colon, ":". The fields are:

  1. predefined grid number
  2. Up to an 8 character abbreviation
  3. Grid Definition Template number
  4. Number of entries in the Grid Definition Template
  5. A list of values for each entry in the Grid Definition Template.

As an example, this is the entry for the 1x1 GFS global grid:

 3:gbl_1deg: 0:19: 0 0 0 0 0 0 0 360 181 0 0 90000000 0 48 -90000000 359000000 1000000 1000000 0
 
Author
Stephen Gilbert
Date
2004-04-27

Function/Subroutine Documentation

◆ freegridlist()

subroutine g2grids::freegridlist

This subroutine frees the memory allocated for the linked list of grid templates stored in module variable gridlist.

Author
Ed Hartnett
Date
July 16, 2022

Definition at line 241 of file g2grids.F90.

References num_grids.

◆ getgridbyname()

subroutine g2grids::getgridbyname ( integer, intent(in)  lunit,
character(len = 8), intent(in)  name,
integer, intent(out)  igdtn,
integer, dimension(*), intent(out)  igdtmpl,
integer, intent(out)  iret 
)

This subroutine searches a file referenced by fortran unit lunit for a Grid Definition Template assigned to the requested name.

The input file format is described at the top of this module.

Callers should call freegridlist() to free the memory allocated when this function is called.

Parameters
[in]lunitUnit number of file containing Grid definitions
[in]nameGrid name of the requested Grid definition
[out]igdtnNN, indicating the number of the Grid Definition Template 3.NN
[out]igdtmplAn array containing the values of each entry in the Grid Definition Template.
[out]iretError return code.
  • 0 no error
  • -1 Undefined Grid name.
  • 3 Could not read any grids from file.
Author
Stephen Gilbert
Date
2004-04-26

Definition at line 200 of file g2grids.F90.

References num_grids, and readgrids().

◆ getgridbynum()

subroutine g2grids::getgridbynum ( integer, intent(in)  lunit,
integer, intent(in)  number,
integer, intent(out)  igdtn,
integer, dimension(*), intent(out)  igdtmpl,
integer, intent(out)  iret 
)

This subroutine searches a file referenced by fortran unit lunit for a Grid Definition Template assigned to the requested number.

The input file format is described at the top of this module.

Callers should call freegridlist() to free the memory allocated when this function is called.

Parameters
[in]lunitUnit number of file containing Grid definitions
[in]numberGrid number of the requested Grid definition
[out]igdtnNN, indicating the number of the Grid Definition Template 3.NN
[out]igdtmplAn array containing the values of each entry in the Grid Definition Template.
[out]iretError return code.
  • 0 no error
  • -1 Undefined Grid number.
  • 3 Could not read any grids from file.
Author
Stephen Gilbert
Date
2004-04-26

Definition at line 144 of file g2grids.F90.

References num_grids, and readgrids().

◆ readgrids()

integer function g2grids::readgrids ( integer, intent(in)  lunit)

This function reads the list of GDT entries in the file associated with fortran unit, lunit.

All the entries are stored in a linked list called gridlist.

Parameters
[in]lunitFortran unit number associated the the GDT file.
Returns
The number of Grid Definition Templates read in.
Author
Stephen Gilbert
Date
2001-06-28

Definition at line 58 of file g2grids.F90.

Referenced by getgridbyname(), and getgridbynum().

Variable Documentation

◆ maxtemp

integer, parameter g2grids::maxtemp = 200

maximum template number for grid definition.

Definition at line 35 of file g2grids.F90.

◆ num_grids

integer g2grids::num_grids = 0

the number of grids.

Definition at line 47 of file g2grids.F90.

Referenced by freegridlist(), getgridbyname(), and getgridbynum().