emcsfc_snow2mdl  1.13.0
grib_utils.F90 File Reference

Determine whether file is grib or not. More...

Go to the source code of this file.

Functions/Subroutines

subroutine gdt_to_gds (igdtnum, igdstmpl, igdtlen, kgds, ni, nj, res)
 Convert from the grib2 grid description template array used by the ncep grib2 library, to the grib1 grid description section array used by ncep ipolates library. More...
 
subroutine grib2_check (kgds, igdstmplen)
 Determine length of grib2 gds template array, which is a function of the map projection. More...
 
subroutine grib2_free (gfld)
 Deallocate the grib2 gribfield pointers. More...
 
subroutine grib2_null (gfld)
 Nullify the grib2 gribfield pointers. More...
 
subroutine grib_check (file_name, isgrib)
 Determine whether file is grib or not. More...
 
subroutine init_grib2 (century, year, month, day, hour, kgds, lat11, latlast, lon11, lonlast, listsec0, listsec1, igds, ipdstmpl, ipdsnum, igdstmpl, igdstmplen, idefnum, ideflist, ngrdpts)
 Initialize grib2 arrays required by the ncep g2 library according to grib1 gds information. More...
 
subroutine skgb2 (LUGB, ISEEK, MSEEK, LSKIP, LGRIB, I1)
 Determine whether file is grib or not. More...
 

Detailed Description

Determine whether file is grib or not.

Author
gayno org: w/np2
Date
2007-nov-28

Definition in file grib_utils.F90.

Function/Subroutine Documentation

◆ gdt_to_gds()

subroutine gdt_to_gds ( integer, intent(in)  igdtnum,
integer, dimension(igdtlen), intent(in)  igdstmpl,
integer, intent(in)  igdtlen,
integer, dimension(200), intent(out)  kgds,
integer, intent(out)  ni,
integer, intent(out)  nj,
real, intent(out)  res 
)

Convert from the grib2 grid description template array used by the ncep grib2 library, to the grib1 grid description section array used by ncep ipolates library.

Parameters
[in]igdtnumgrib2 grid desc template number
[in]igdstmplgrib2 grid desc template array
[in]igdtlengrib2 grid desc template array size
[out]kgdsgrib1 grid description section array used by ncep ipolates library.
[out]nii grid dimensions
[out]njj grid dimensions
[out]resgrid resolution in km

condition codes: 50 - unrecognized model grid type; fatal

Author
George Gayno org: w/np2
Date
2014-Sep-26

Definition at line 140 of file grib_utils.F90.

Referenced by model_grid::read_mdl_grid_info(), snowdat::readafwa(), snowdat::readautosnow(), and snowdat::readnesdis().

◆ grib2_check()

subroutine grib2_check ( integer, dimension(200), intent(in)  kgds,
integer, intent(out)  igdstmplen 
)

Determine length of grib2 gds template array, which is a function of the map projection.

Note
call this routine before init_grib2.
Parameters
[in]kgdsgrib1 gds array
[in]igdstmplenlength of gds template array.

condition codes: 47 - unrecognized grid type; fatal

Author
George Gayno org: w/np2
Date
2014-Sep-28

Definition at line 351 of file grib_utils.F90.

Referenced by snow2mdl::write_grib2().

◆ grib2_free()

subroutine grib2_free ( type(gribfield), intent(inout)  gfld)

Deallocate the grib2 gribfield pointers.

Parameters
[in]gflda gribfield data structure
Author
George Gayno org: w/np2
Date
2014-Sep-28

Definition at line 636 of file grib_utils.F90.

Referenced by snowdat::nh_climo_check(), model_grid::read_mdl_grid_info(), snowdat::readautosnow(), and snowdat::readnesdis().

◆ grib2_null()

subroutine grib2_null ( type(gribfield), intent(inout)  gfld)

Nullify the grib2 gribfield pointers.

Parameters
[in]gflda gribfield data structure
Author
George Gayno org: w/np2
Date
2014-Sep-28

Definition at line 611 of file grib_utils.F90.

Referenced by snowdat::nh_climo_check(), model_grid::read_mdl_grid_info(), snowdat::readafwa(), snowdat::readautosnow(), and snowdat::readnesdis().

◆ grib_check()

subroutine grib_check ( character*(*), intent(in)  file_name,
integer, intent(out)  isgrib 
)

Determine whether file is grib or not.

program history log:

  • 2007-nov-28 gayno - initial version
  • 2011-apr-26 gayno - replace my simple-minded logic with call to w3lib routin skgb.
  • 2014-feb-07 gayno - determine whether file is grib1 or grib2.
Parameters
[in]file_name- file to be checked
[out]isgrib- '1' or '2' if grib1/2 file '0' if not grib

input files:

  • file to be checked, fort.11

condition codes: all fatal

  • bad file open, fort.11

Definition at line 24 of file grib_utils.F90.

References skgb2().

Referenced by model_grid::read_mdl_grid_info(), snowdat::readafwa(), and snowdat::readnesdis().

◆ init_grib2()

subroutine init_grib2 ( integer, intent(in)  century,
integer, intent(in)  year,
integer, intent(in)  month,
integer, intent(in)  day,
integer, intent(in)  hour,
integer, dimension(200), intent(in)  kgds,
real, intent(in)  lat11,
real, intent(in)  latlast,
real, intent(in)  lon11,
real, intent(in)  lonlast,
integer, dimension(2), intent(out)  listsec0,
integer, dimension(13), intent(out)  listsec1,
integer, dimension(5), intent(out)  igds,
integer, dimension(15), intent(out)  ipdstmpl,
integer, intent(out)  ipdsnum,
integer, dimension(igdstmplen), intent(out)  igdstmpl,
integer, intent(in)  igdstmplen,
integer, intent(out)  idefnum,
integer, intent(out)  ideflist,
integer, intent(out)  ngrdpts 
)

Initialize grib2 arrays required by the ncep g2 library according to grib1 gds information.

The grib1 gds is held in the kgds array, which is used by the ncep ipolates and w3nco (grib 1) libraries.

Call routine grib2_check first to determine igdstmplen.

Parameters
[in]centurycurrent date/time info
[in]yearcurrent date/time info
[in]monthcurrent date/time info
[in]daycurrent date/time info
[in]hourcurrent date/time info
[in]kgdsgrib1 gds information
[in]igdstmplenlength of grib2 gdt template.
[in]lat11lat of first grid point
[in]lon11lon of first grid point
[in]latlastlat of last grid point
[in]lonlastlon of last grid point
[out]igdsgrib2 section 3 information.
[out]listsec0grib2 section 0 information.
[out]listsec1grib2 section 1 information.
[out]ipdsnumgrib2 pds template number
[out]ipdstmplgrib2 pds template array
[out]igdstmplgrib2 gds template array
[out]idefnuminformation for non-reg grid, grid points in each row.
[out]ideflistinformation for non-reg grid, grid points in each row.
[out]ngrdptsnumber of model grid points.
Author
George Gayno org: w/np2
Date
2014-Sep-28

Definition at line 401 of file grib_utils.F90.

Referenced by snow2mdl::write_grib2().

◆ skgb2()

subroutine skgb2 ( integer, intent(in)  LUGB,
integer, intent(in)  ISEEK,
integer, intent(in)  MSEEK,
integer, intent(out)  LSKIP,
integer, intent(out)  LGRIB,
integer, intent(out)  I1 
)

Determine whether file is grib or not.

Based on w3nco library routine skgb.

Parameters
[in]lugbfile unit number
[in]iseeknumber of bits to skip before search.
[in]mseekmax number of bytes to search.
[out]lskipnumber of bytes to skip before message
[out]lgribnumber of bytes in message. '0' if not grib.
[out]i1'1' or '2' if grib1/2 file. '0' if not grib.

input file:

  • file to be checked, unit=lugb
Author
George Gayno org: w/np2
Date
2014-Feb-07

Definition at line 76 of file grib_utils.F90.

Referenced by grib_check().