This was a doubt I had some time ago: Is it possible to concatenate different-sized grib data files? I mean, do something like:
cat file1 file2 file... > very_big_file
so that I could use a single ctl to access all data?
At the time I had a set of "non-templatable" like this:
1st binary file, 4 years of montly data 2nd binary file, 6 years of montly data ... (n-1)th binary file, 6 years of montly data n-th binary file, 2 years of montly data
Since I had different years in the same file, I couldn't use templates (see comment below for newer versions of grads). So either I splited everything into yearly files, or I joined all of them into a single file.
To complicate even further, the grib files were from ECMWF, so there were some junk bytes at the end of each file.
After some testing, I found out how to do it. Here's the walktrou:
cat file1 file2 ... fileN > my_big_file grib2ctl.pl -verf my_big_file > my_big_file.ctl gribmap -E -i my_big_file.ctl
Step 1: cat all files together:
Step 2: Use grib2ctl.pl to generate the proper ctl.
Step 3: Use gribmap to generate the a new map for the new file.
The upper case option '-E' tells gribmap to ignore those junk bytes both at the end and in the middle of the grib file!! (that's the trick) Now it is possible to open the concatenated file.
What if my grib file don't have junk bytes?
You can do the same thing, just remove the '-E' option for gribmap.
In the lastest versions of GrADS a new feature was implemented that allows for
a solution of this problem in a much clever way. Now it is possible to
build a template ctl that points to different files depending on
a userdefined format.
It is easier to understand if you see an example. This one if from
the GrADS manuals:
Here are two netcdf files, one containing 50 years of monthly data
(600 time steps), the other 100 years (1200 time steps):
pr.1851-1900.nc
pr.1901-2000.nc Your descriptor file should include the following entries:
DSET ^pr.%ch.nc
CHSUB 1 600 1851-1900
CHSUB 601 1800 1901-2000
OPTIONS template
DTYPE netcdf
TDEF 1800 linear jan1851 1mo
Pay attention to what is going on here. For instante, the keyword
CHSUB1 defines that for the time steps 1st to 600th the string
"1851-1900" will be assigned to variable '%ch'. Therefore GrADS
will look for data in the write file, i.e., pr.1851-1900.nc for time
steps up to the 600th.
If these two data files were located on different disks, you could write
out the relevant descriptor file entries this way instead:
DSET %ch
CHSUB 1 600 /disk1/pr.1851-1900.nc
CHSUB 601 1800 /disk2/pr.1901-2000.nc
Don't concatenate, use GrADS v1.9
Pages you should read:
Doing GRIB in GrADS
About grib2ctl
About gribmap
About templates