NCEPLIBS-g2 4.0.0
Loading...
Searching...
No Matches
copygb.F90 File Reference

Compare grib files. More...

Go to the source code of this file.

Functions/Subroutines

program copygb
 The command copygb copies all or part of one GRIB file to another GRIB file, interpolating if necessary.
 
subroutine cpgb (lg1, lx1, lgb, lxb, lgm, lxm, lg2, igi, kgdsi, ip, ipopt, jpds1, nuv, iuv, jpdsb, jb, jbk, lab, ab, lam, am, lxx, lwg, ids, ibs, nbs)
 Copy grib files.
 
subroutine cpgb1 (lg1, lx1, m1, cbuf1, nlen1, nnum1, mnum1, mbuf, mf, mi, igi, kgdsi, ip, ipopt, jpds1, nuv, iuv, jpdsb, jb, jbk, lab, ab, lam, am, ids, ibs, nbs, lgb, lxb, mb, cbufb, nlenb, nnumb, mnumb, lgm, lxm, mm, cbufm, nlenm, nnumm, mnumm, lg2, lxx, ks1, no, iret)
 Copy one grib field.
 
subroutine eusage
 Print proper usage to stderr.
 
subroutine intgrib (iv, ip, ipopt, kgds1, k1, ib1, l1, f1, g1, kgds2, k2, ib2, l2, f2, g2, iret)
 Interpolate field.
 
subroutine intgrib1 (k1f, kgds1f, k2f, kgds2f, mrl, mro, iv, ip, ipopt, kgds1, k1, ib1, l1, f1, g1, kgds2, k2, ib2, l2, f2, g2, iret)
 Interpolate field.
 
function lengdsf (kgds, kgdsf)
 Return the length of a filled grid.
 

Detailed Description

Compare grib files.

Author
Mark Iredell
Date
1998-10-22

Definition in file copygb.F90.

Function/Subroutine Documentation

◆ copygb()

program copygb

The command copygb copies all or part of one GRIB file to another GRIB file, interpolating if necessary.

Unless otherwise directed (-x option), the GRIB index file is also used to speed the reading. The fields are interpolated to an output grid if specified (-g option). The interpolation type defaults to bilinear but may be specified directly (-i option). The copying may be limited to specific fields (-k option). It may also be limited to a specified subgrid of the output grid or to a subrange of the input fields (-B and -b, -A, and -K options). Fields can be identified as scalars or vectors (-v option), which are interpolated differently. The invalid data in the output field can be filled with mask values or merged with a merge field (-M and -m options). The output GRIB message can also be appended to a file (-a option). Some defaults can be overridden in a namelist file (-N option).

Command Line Options

-a Appends rather than overwrites the output GRIB file.

-A "<> mapthreshold" Inequality and threshold used in determining where on the map the data will be copied. The data are copied only where the given map field is on the correct side of the threshold. The mapthreshold defaults to '>-1.e30'; in this case, only the map field's bitmap will limit the domain.

-b mapindex Optional index file used to get the map field.

-B mapgrib GRIB file used to get the map field. The map field is read from the GRIB file and compared to the map threshold to determine for which region on the map the data will be copied. The mapgrib can be the name of an actual GRIB file (in which case the index file may be specified with the -b option) or it can be '-1'. If mapgrib is '-1', then the input GRIB file (first positional argument) is used. The -K option specifies which field to read from the mapgrib GRIB file. If mapgrib is an actual file, then the first field is taken if -K is not specified. On the other hand, if mapgrib is '-1', then if the if -K is not specified, the current field is taken as the map field. A special exception is if -K '-1' is specified, in which case the current field is taken as the map field and it is applied before any interpolation; otherwise the map field is always applied after interpolation.

-g "grid [kgds]" Output grid identification. If grid=-1 (the default), then the output grid is the same as the input grid. If grid=-4, then the grid is that of the map field. If grid=-5, then the grid is that of the merge field. If 0<grid<255, then grid designates an NCEP grid. If grid=255, then the grid must be specified by the full set of kgds parameters determining a GRIB GDS (grid description section) in the W3FI63 format.

-i "ip [ipopts]" Interpolation options. The default is bilinear interpolation (ip=0). Other interpolation options are bicubic (ip=1), neighbor (ip=2), budget (ip=3), and spectral (ip=4). Spectral interpolation is forced even if the input and output grids are the same. See the documentation for iplib for further details.

-k "kpds" Full set of kpds parameters determing a GRIB PDS (product definition section) in the W3FI63 format determining the field(s) to be copied. Note that kpds(5) is the parameter indicator (PDS octet 9). A wildcard is specified by -1 (the defaults). If "kpds" is equal to "w", then the requested record numbers are read in from standard input instead, one record per line and possibly delimited by a colon (so that wgrib could pipe requests to copygb). If the -k is not specified, then copygb will attempt to copy every field in the input GRIB file.

-K "mapkpds" Full set of kpds parameters determing a GRIB PDS (product definition section) in the W3FI63 format determining the map field to be used to determine where on the map the data will be copied. A wildcard is specified by -1 (the defaults).

-m mergeindex Optional index file used to get the merge field.

-M "mask"/mergegrib Mask used to fill out bitmapped areas of the map. If specified, there will be no bitmap in the output. The mask must be in the format '#value' where value is the real number used to fill out the field. Otherwise, the argument is interpreted as a merge GRIB file. Then for each GRIB message copied, a merge field is found in the merge GRIB file with the same parameter and level indicators as the copied field. This merge field is interpolated to the output grid and used to fill out the bitmapped areas of the map, at least where the merge field is not bitmapped. No merging is done if no merge field is found.

-N namelist Namelist file to override default output options. The namelist must start with " &NLCOPYGB" and end with "/". Namelist variables are IDS(255) Output decimal scaling by parameter IBS(255) Output binary scaling by parameter NBS(255) Output number of bits by parameter

-v "uparms" Parameter indicator(s) for the u-component of vectors. The parameter indicator for the v-component is assumed to be one more than that of the u-component. If the -v option is not specified, then the wind components (parameters 33 and 34) are the only fields assumed to be vector components in the GRIB file.

-x Turns off the use of an index file. The index records are then extracted from the GRIB file, which will increase the time taken by copygb.

-X Turns on verbose printout. This option is incompatible with GRIB output to standard output.

Input Files

  • unit 11 input grib file
  • unit 14 map grib file
  • unit 15 merge grib file
  • unit 31 input grib index file
  • unit 34 map grib index file
  • unit 35 merge grib index file

output files

  • unit 51 output grib file
Returns
0 for success.
Author
Stephen Gilbert
Date
2000-05-02

Definition at line 149 of file copygb.F90.

References cpgb(), and eusage().

◆ cpgb()

subroutine cpgb (   lg1,
  lx1,
  lgb,
  lxb,
  lgm,
  lxm,
  lg2,
  igi,
integer, dimension(200)  kgdsi,
  ip,
integer, dimension(20)  ipopt,
integer, dimension(100)  jpds1,
  nuv,
integer, dimension(100)  iuv,
integer, dimension(100)  jpdsb,
  jb,
  jbk,
  lab,
  ab,
  lam,
  am,
  lxx,
  lwg,
integer, dimension(255)  ids,
integer, dimension(255)  ibs,
integer, dimension(255)  nbs 
)

Copy grib files.

Parameters
[in]lg1integer unit number for grib file 1
[in]lx1integer unit number for grib index file 1
[in]lgbinteger unit number for grib file map
[in]lxbinteger unit number for grib index file map
[in]lgminteger unit number for grib file merge
[in]lxminteger unit number for grib index file merge
[in]lg2integer unit number for grib file 2
[in]igiinteger output grid identification
[in]kgdsiinteger (200) output grid parameters
[in]ipinteger interpolation type
[in]ipoptinteger (20) interpolation options
[in]jpds1integer (100) kpds search options
[in]nuvinteger number of vector parameter ids
[in]iuvinteger (100) vector parameter ids
[in]jpdsbinteger (100) kpds search options (map)
[in]jbinteger flag for map optiion
[in]jbkinteger flag for map optiion
[in]labinteger flag for map threshold inequality
[in]abreal map threshold
[in]laminteger flag for mask value
[in]amreal mask value
[in]lxxinteger flag for verbose output
[in]lwginteger flag for stdin selection
[in]idsinteger (255) decimal scaling (-9999 for no change)
[in]ibsinteger (255) binary scaling (-9999 for no change)
[in]nbsinteger (255) number of bits (-9999 for no change)
Author
Iredell
Date
96-07-19

Definition at line 562 of file copygb.F90.

References cpgb1().

Referenced by copygb(), and copygb2().

◆ cpgb1()

subroutine cpgb1 (   lg1,
  lx1,
  m1,
character, dimension(mbuf)  cbuf1,
  nlen1,
  nnum1,
  mnum1,
  mbuf,
  mf,
  mi,
  igi,
integer, dimension(200)  kgdsi,
  ip,
integer, dimension(20)  ipopt,
integer, dimension(100)  jpds1,
  nuv,
integer, dimension(100)  iuv,
integer, dimension(100)  jpdsb,
  jb,
  jbk,
  lab,
  ab,
  lam,
  am,
integer, dimension(255)  ids,
integer, dimension(255)  ibs,
integer, dimension(255)  nbs,
  lgb,
  lxb,
  mb,
character, dimension(mbuf)  cbufb,
  nlenb,
  nnumb,
  mnumb,
  lgm,
  lxm,
  mm,
character, dimension(mbuf)  cbufm,
  nlenm,
  nnumm,
  mnumm,
  lg2,
  lxx,
  ks1,
  no,
  iret 
)

Copy one grib field.

Parameters
[in]lg1integer unit number for grib file 1
[in]lx1integer unit number for grib index file 1
[in]m1integer dimension of grib field 1
[in]cbuf1character (mbuf) index buffer 1
[in]nlen1integer record length of index buffer 1
[in]nnum1integer number of index records 1
[in]mnum1integer number of index records 1 skipped
[in]mbufinteger dimension of index buffers
[in]mfinteger dimension of field
[in]miinteger dimension of output grid
[in]igiinteger output grid identification
[in]kgdsiinteger (200) output grid parameters
[in]ipinteger interpolation type
[in]ipoptinteger (20) interpolation options
[in]jpds1integer (100) kpds search options
[in]nuvinteger number of vector parameter ids
[in]iuvinteger (100) vector parameter ids
[in]jpdsbinteger (100) kpds search options (map)
[in]jbinteger flag for map optiion
[in]jbkinteger flag for map optiion
[in]labinteger flag for map threshold inequality
[in]abreal map threshold
[in]laminteger flag for mask value
[in]amreal mask value
[in]idsinteger (255) decimal scaling (-9999 for no change)
[in]ibsinteger (255) binary scaling (-9999 for no change)
[in]nbsinteger (255) number of bits (-9999 for no change)
[in]lgbinteger unit number for grib file map
[in]lxbinteger unit number for grib index file map
[in]mbinteger dimension of grib field map
[in]cbufbcharacter (mbuf) index buffer map
[in]nlenbinteger record length of index buffer map
[in]nnumbinteger number of records in index buffer map
[in]mnumbinteger number of index records map skipped
[in]lgminteger unit number for grib file merge
[in]lxminteger unit number for grib index file merge
[in]mminteger dimension of grib field merge
[in]cbufmcharacter (mbuf) index buffer merge
[in]nlenminteger record length of index buffer merge
[in]nnumminteger number of records in index buffer merge
[in]mnumminteger number of index records merge skipped
[in]lg2integer unit number for grib file 2
[in]lxxinteger flag for verbose output
[in]ks1integer input record counter
[out]nointeger output record counter
[out]iretinteger return code
Author
Iredell
Date
96-07-19

Definition at line 779 of file copygb.F90.

References intgrib().

Referenced by copygb2(), and cpgb().

◆ eusage()

subroutine eusage

Print proper usage to stderr.

Author
Iredell
Date
96-07-19

Definition at line 513 of file copygb.F90.

Referenced by copygb(), and copygb2().

◆ intgrib()

subroutine intgrib (   iv,
  ip,
integer, dimension(20)  ipopt,
integer, dimension(200)  kgds1,
  k1,
  ib1,
logical*1, dimension(k1)  l1,
real, dimension(k1)  f1,
real, dimension(k1)  g1,
integer, dimension(200)  kgds2,
  k2,
  ib2,
logical*1, dimension(k2)  l2,
real, dimension(k2)  f2,
real, dimension(k2)  g2,
  iret 
)

Interpolate field.

Parameters
[in]ivinteger vector flag
[in]ipinteger interpolation type
[in]ipoptinteger (20) interpolation options
[in]kgds1integer (200) input grid parameters
[in]k1integer input dimension
[in]ib1integer input bitmap flag
[in]l1logical*1 (k1) input bitmap if ib1=1
[in]f1real (k1) input field
[in]g1real (k1) input y-component if iv=1
[in]kgds2integer (200) output grid parameters
[in]k2integer output dimension
[in]ib2integer output bitmap flag
[in]l2logical*1 (k2) output bitmap
[in]f2real (k2) output field
[in]g2real (k2) output y-component if iv=1
[out]iretinteger return code
Author
Iredell
Date
96-07-19

Definition at line 1093 of file copygb.F90.

References intgrib1(), and lengdsf().

Referenced by cpgb1().

◆ intgrib1()

subroutine intgrib1 (   k1f,
integer, dimension(200)  kgds1f,
  k2f,
integer, dimension(200)  kgds2f,
  mrl,
  mro,
  iv,
  ip,
integer, dimension(20)  ipopt,
integer, dimension(200)  kgds1,
  k1,
  ib1,
logical*1, dimension(k1)  l1,
real, dimension(k1)  f1,
real, dimension(k1)  g1,
integer, dimension(200)  kgds2,
  k2,
  ib2,
logical*1, dimension(k2)  l2,
real, dimension(k2)  f2,
real, dimension(k2)  g2,
  iret 
)

Interpolate field.

Parameters
[in]k1finteger regularized input dimension
[in]kgds1finteger (200) regularized input grid parameters
[in]k2finteger regularized output dimension
[in]kgds2finteger (200) regularized output grid parameters
[in]mrlinteger dimension of rlat and rlon
[in]mrointeger dimension of crot and srot
[in]ivinteger vector flag
[in]ipinteger interpolation type
[in]ipoptinteger (20) interpolation options
[in]kgds1integer (200) input grid parameters
[in]k1integer input dimension
[in]ib1integer input bitmap flag
[in]l1logical*1 (k1) input bitmap if ib1=1
[in]f1real (k1) input field
[in]g1real (k1) input y-component if iv=1
[in]kgds2integer (200) output grid parameters
[in]k2integer output dimension
[in]ib2integer output bitmap flag
[in]l2logical*1 (k2) output bitmap
[in]f2real (k2) output field
[in]g2real (k2) output y-component if iv=1
[out]iretinteger return code
Author
Iredell
Date
96-07-19

Definition at line 1172 of file copygb.F90.

Referenced by copygb2(), and intgrib().

◆ lengdsf()

function lengdsf ( integer, dimension(200)  kgds,
integer, dimension(200)  kgdsf 
)

Return the length of a filled grid.

Given a grid description section (in w3fi63 format), return the grid description section and size of its regularized counterpart. That is, if the input grid is regular, then itself is returned along with its grid size; however if the input grid is only quasi-regular (such as the wafs grids), then its filled regular version is returned along with its filled grid size.

Parameters
[in]kgdsinteger (200) gds parameters in w3fi63 format
[out]kgdsfinteger (200) regular gds parameters in w3fi63 format
Returns
integer size of regularized grid
Author
Mark Iredell
Date
96-07-19

Definition at line 1343 of file copygb.F90.

References lengdsf().

Referenced by copygb2(), intgrib(), and lengdsf().