Skip Navigation Links 
NOAA logo - Click to go to the NOAA home page National Weather Service   NWS logo - Click to go to the NWS home page
Climate Prediction Center

About Us
   Our Mission
   Who We Are

Contact Us
   CPC Information
   CPC Web Team

HOME > Monitoring_and_Data > Oceanic and Atmospheric Data > Reanalysis: Atmospheric Data > wgrib2-merge_fcst

wgrib2: -merge_fcst


The -merge_fcst option will try to combine adjacent messages by increasing the time period for forecast average, accumulation, minimum and maximum. For example,

$ wgrib2 prate.l.gdas.201404.ts -for 1:4
1:0:d=2014040100:PRATE:surface:0-1 hour ave fcst:
2:13083:d=2014040100:PRATE:surface:1-2 hour ave fcst:
3:26587:d=2014040100:PRATE:surface:2-3 hour ave fcst:
4:40437:d=2014040100:PRATE:surface:3-4 hour ave fcst:

$ wgrib2 preas.201404.ts -for 1:4 -merge_fcst 4 /tmp/all.grb
(listing of input)

$ wgrib2 /tmp/all.grb 
1:0:d=2014040100:PRATE:surface:0-4 hour ave fcst:

$wgrib2 prate.l.gdas.201404.ts -for 1:4 -merge_fcst 2 /tmp/all2.grb
(iisting of input)

$ wgrib2 /tmp/all2.grb 
1:0:d=2014040100:PRATE:surface:0-2 hour ave fcst:
2:29531:d=2014040100:PRATE:surface:2-4 hour ave fcst:
The -merge_fcst option needs the fields to be processed in order. Fields that are not fcst averages/accumlations are ignored. You can sort the field by
$ wgrib2 IN.grb | sort -t: -k4,4 -k5,5 -k6,6n | wgrib2 -i IN.grb -grib OUT.grb


-merge_fcst (N=number fields to combine) (output grib file)

When N > 0, then N fields are merged together and then written to the output grib file
   (requires wgrib2 v2.0.1)
When N == 0, then there is no limit to the number of fields to be merged
             and intermediate steps are written out
              ex. 0-1 + 1-2 + 2-3 -> 0-1, 0-2, 0-3

The most common use would be get the 12-hour, daily, N-day average precipation forecasts from the N hour to N+6 hour precipitation forecasts.


  1. Only 1 time range specificaion is allowed in the PDS (no nested time ranges)
  2. Forecast time units must be the same between message to be merged.
  3. The various metadata in the grib messages to be merged must be identical except for the averaging/accumulation interval.

See also:

NOAA/ National Weather Service
National Centers for Environmental Prediction
Climate Prediction Center
5830 University Research Court
College Park, Maryland 20740
Climate Prediction Center Web Team
Page last modified: Sep 16, 2016
Disclaimer Privacy Policy