This article relates to GRIB edition 2
Step-by-step guide
At the moment, the only possible way of detecting if a GRIB file is multi-field is by using the grib tools or the API to turn the support for multiple fields in a single GRIB message on or off and observe the results. For example you can do a "grib_count" and compare the result with "grib_ls", in a multi-field GRIB file the latter will report more messages than the former.
For example:
% grib_count my.grib2 30 % grib_ls my.grib2 edition centre date dataType gridType stepRange typeOfLevel level shortName packingType 2 kwbc 20061128 fc regular_ll 6 isobaricInhPa 100 clwmr grid_jpeg 2 kwbc 20061128 fc regular_ll 6 isobaricInhPa 500 5wavh grid_jpeg 2 kwbc 20061128 fc regular_ll 6 isobaricInhPa 1000 u grid_jpeg 2 kwbc 20061128 fc regular_ll 6 isobaricInhPa 1000 v grid_jpeg ... 56 of 56 messages in my.grib2
Here we have a file with 30 messages (result of grib_count) but grib_ls reports 56 because by default the grib tools 'expand' the messages i.e. convert the multi-field messages to single-field ones before printing. This feature can be turned off by specifying the "-M" option:
% grib_ls -M my.grib2 edition centre date dataType gridType stepRange typeOfLevel level shortName packingType 2 kwbc 20061128 fc regular_ll 6 isobaricInhPa 100 clwmr grid_jpeg 2 kwbc 20061128 fc regular_ll 6 isobaricInhPa 500 5wavh grid_jpeg 2 kwbc 20061128 fc regular_ll 6 isobaricInhPa 1000 u grid_jpeg 2 kwbc 20061128 fc regular_ll 6 isobaricInhPa 975 u grid_jpeg ... 30 of 30 messages in my.grib2
The use of the multi-field feature is not recommended.
Related articles