From ea27e84613a587a4e8b829c2c0d9211007c17b82 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 30 Apr 2026 08:47:01 -0500 Subject: [PATCH] fix(hrdps): wgrib2 needs USE_G2CLIB_LOW for JPEG2000 (packing type 40) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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)?". --- Dockerfile | 18 ++++++++++-------- rust/prop_grid_rs/Dockerfile | 11 ++++++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 742231e7..52de4e5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/rust/prop_grid_rs/Dockerfile b/rust/prop_grid_rs/Dockerfile index a87ae4de..83a83014 100644 --- a/rust/prop_grid_rs/Dockerfile +++ b/rust/prop_grid_rs/Dockerfile @@ -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