Problem

I get an error when decoding a GRIB2 file that has been encoded using JPEG compression:

% grib_get_data input.grib2
ECCODES ERROR : JPEG support not enabled.
ECCODES ERROR : unable to get values as double array (Functionality not enabled)

Solution

You need to make sure that you have compiled ecCodes with support for JPEG decoding. CMake will detect at build time if either the Jasper or the OpenJPEG libraries are installed, including the headers. If that is the case the support will be built in. If you have not compiled the package yourself and you are using a binary package then you must check with the distributors how the library has been compiled. For all we know, most binary packages offered by conda or major Linux distributions do come with JPEG support.

Installing dependencies in a Centos8 Linux distribution

For example these are the required packages for a CentosOS 8 Linux distribution

For OpenJPEG

[root@3c2158284b2a /]# rpm -qa | grep jpeg  
openjpeg2-tools-2.3.0-8.el8.x86_64
openjpeg2-2.3.0-8.el8.x86_64
openjpeg2-devel-2.3.0-8.el8.x86_64

For Jasper

[root@3c2158284b2a /]# rpm -qa | grep jasper
jasper-devel-2.0.14-4.el8.x86_64
jasper-libs-2.0.14-4.el8.x86_64
[root@3c2158284b2a /]# 

If not already installed, you get them with the following procedure

[root@3c2158284b2a /]# yum install openjpeg2-tools openjpeg2-devel openjpeg2
[root@3c2158284b2a /]# yum install jasper-devel jasper-libs

Please note that other Linux distributions may have other ways of installing packages and the packages may be named differently. Also, be reminded that installing the packages after installing ecCodes is not going to enable JPEG support. The dependencies must be there before the compilation.