fix(hrdps): wgrib2 needs USE_G2CLIB_LOW for JPEG2000 (packing type 40)

Production wgrib2 3.8.0 still hit `*** FATAL ERROR: packing type 40
not supported ***` on HRDPS files. ldd confirmed wgrib2 was linking
only libc/libm — no OpenJPEG, no Jasper, no g2c.

wgrib2 3.8.0 cmake doesn't have USE_OPENJPEG or USE_JASPER options.
The legacy flag names we passed were silently ignored. The actual
knob is USE_G2CLIB_LOW, which links wgrib2 to the external g2c lib
(already built in the previous stage with OpenJPEG support). Dropped
the bogus USE_PNG / USE_OPENJPEG flags and added USE_G2CLIB_LOW=ON
in both Dockerfiles.

Verified by reading wgrib2 v3.8.0's CMakeLists.txt: the documented
JPEG2000 path is "USE_G2CLIB_LOW: Use g2c low-level decoders
(png,jpeg2000)?".
This commit is contained in:
Graham McIntire 2026-04-30 08:47:01 -05:00
parent 89eccb7d50
commit ea27e84613
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
2 changed files with 20 additions and 9 deletions

View file

@ -73,20 +73,22 @@ RUN wget -q --content-disposition "https://github.com/NOAA-EMC/NCEPLIBS-g2c/arch
WORKDIR /tmp/wgrib2
# wgrib2 flags:
# * USE_PNG / USE_OPENJPEG / USE_AEC each turn on the matching
# encoder path inside wgrib2 and add the compression name to the
# -config output. With g2c v2.1.0 underneath (which exports the
# g2c_enc_* / g2c_dec_* new-API symbols) all three can be enabled
# together — the earlier build failure was not about the flag
# combination, it was g2c v1.9.0 shipping without BUILD_G2C.
# wgrib2 3.8.0 cmake flags:
# * USE_AEC turns on AEC compression decode for HRRR files.
# * USE_G2CLIB_LOW links wgrib2 to the external g2c lib for png +
# jpeg2000 decode. The previous USE_PNG / USE_OPENJPEG flags don't
# exist in wgrib2 3.8.0 — they were silently ignored, leaving
# wgrib2 unable to read GRIB2 packing type 40 (HRDPS uses it).
# Verified 2026-04-30 by ldd showing only libc/libm linked.
# * The g2c v2.1.0 build above carries the actual OpenJPEG support;
# wgrib2 dispatches to g2c via USE_G2CLIB_LOW.
RUN wget -q --content-disposition "https://github.com/NOAA-EMC/wgrib2/archive/refs/tags/v${WGRIB2_VERSION}.tar.gz" \
-O wgrib2.tar.gz \
&& tar xzf wgrib2.tar.gz \
&& cd wgrib2-${WGRIB2_VERSION} \
&& mkdir build && cd build \
&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release \
-DUSE_PNG=ON -DUSE_OPENJPEG=ON -DUSE_AEC=ON \
-DUSE_AEC=ON -DUSE_G2CLIB_LOW=ON \
&& make -j$(nproc) \
&& make install \
&& strip /usr/local/bin/wgrib2

View file

@ -51,13 +51,22 @@ RUN wget -q --content-disposition "https://github.com/NOAA-EMC/NCEPLIBS-g2c/arch
&& make install
WORKDIR /tmp/wgrib2
# JPEG2000 decode (GRIB2 packing type 40 — used by HRDPS) comes from the
# external g2c lib via USE_G2CLIB_LOW. Without that flag wgrib2's stock
# build links neither g2c nor any JPEG2000 backend (verified 2026-04-30
# by `ldd /usr/local/bin/wgrib2` showing only libc/libm and a runtime
# `*** FATAL ERROR: packing type 40 not supported ***` from HRDPS files).
#
# wgrib2 3.8.0 does NOT have USE_OPENJPEG or USE_JASPER cmake options —
# the only knob is USE_G2CLIB_LOW for png/jpeg2000 decode. The g2c lib
# we built above carries the actual OpenJPEG support.
RUN wget -q --content-disposition "https://github.com/NOAA-EMC/wgrib2/archive/refs/tags/v${WGRIB2_VERSION}.tar.gz" \
-O wgrib2.tar.gz \
&& tar xzf wgrib2.tar.gz \
&& cd wgrib2-${WGRIB2_VERSION} \
&& mkdir build && cd build \
&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release \
-DUSE_PNG=ON -DUSE_OPENJPEG=ON -DUSE_AEC=ON \
-DUSE_AEC=ON -DUSE_G2CLIB_LOW=ON \
&& make -j$(nproc) \
&& make install \
&& strip /usr/local/bin/wgrib2