Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

CDO supports GRIB2 but needs the GRIB_API library from ECMWF in order to succeedwork correctly. If you find the CDO command commands below do not work, you can either build CDO yourself, making sure a recent version of grib_api is used, or you can use a workaround . In order to work around this, use below. Use the grib_set command (from the grib_api installation) to change the GRIB edition number for all messages. Note this will only work if you are using less than 128 model levels and it does not actually convert the message to GRIB1 if there are any GRIB2 specific elements in the messages.

Code Block
titleWorkaround if CDO does not understand GRIB2
grib_set -s editionNumber=1 <input grib2 file> <output grib1 file>

...

Code Block
titleSeparate multiple z axes into individual files
cdo splitzaxis <input file> <output file>

Then finally convert Convert the resulting output files to netcdf. The -t option tells CDO to use the predefined ECMWF parameter tables (see CDO documentation for more details). Without this option parameter names are not preserved. If the - t option doesn't work this is usually because CDO is using an old version of the ECMWF GRIB_API software.

...

Code Block
titleSample script to convert OpenIFS GRIB output to netCDF
for i in 000 024 048 072
do

grib_set -s editionNumber=1 ICMGGfpp4+000${i} ICMGGfpp4+000${i}.grb
cdo -R copy ICMGGfpp4+000${i}.grb ICMGGfpp4+000${i}_R.grb
cdo splitzaxis ICMGGfpp4+000${i}_R.grb ICMGGfpp4+000${i}
cdo -t ecmwf -f nc copy ICMGGfpp4+000${i}01.grb ICMGGfpp4+000${i}_PLGG.nc
cdo -t ecmwf -f nc copy ICMGGfpp4+000${i}02.grb ICMGGfpp4+000${i}_MLGG.nc


grib_set -s editionNumber=1 ICMSHfpp4+000${i} ICMSHfpp4+000${i}.grb
cdo splitzaxis ICMSHfpp4+000${i}.grb ICMSHfpp4+000${i}
cdo sp2gpl ICMSHfpp4+000${i}01.grb ICMSHfpp4+000${i}01_GP.grb
cdo sp2gpl ICMSHfpp4+000${i}03.grb ICMSHfpp4+000${i}03_GP.grb
cdo sp2gpl ICMSHfpp4+000${i}04.grb ICMSHfpp4+000${i}04_GP.grb
cdo -t ecmwf -f nc copy ICMSHfpp4+000${i}03_GP.grb ICMSHfpp4+000${i}_ML.nc
cdo -t ecmwf -f nc copy ICMSHfpp4+000${i}01_GP.grb ICMSHfpp4+000${i}_PL.nc
cdo -t ecmwf -f nc copy ICMSHfpp4+000${i}04_GP.grb ICMSHfpp4+000${i}_surf.nc

done

...