diff --git a/.github/workflows/Linux_options.yml b/.github/workflows/Linux_options.yml index 037b2376..7d1f1cb6 100644 --- a/.github/workflows/Linux_options.yml +++ b/.github/workflows/Linux_options.yml @@ -39,6 +39,9 @@ jobs: - { options: "-DBUILD_WGRIB=ON" } + - { + options: "-DUSE_OPENJPEG=ON" + } steps: @@ -67,7 +70,7 @@ jobs: if: steps.cache-jasper.outputs.cache-hit != 'true' run: | cd jasper - ./configure --prefix=$HOME/Jasper + ./configure --prefix=$HOME/jasper make make install diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 9ece03e8..f8734021 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -53,7 +53,7 @@ jobs: if: steps.cache-jasper.outputs.cache-hit != 'true' run: | cd jasper - ./configure --prefix=$HOME/Jasper + ./configure --prefix=$HOME/jasper make make install @@ -141,7 +141,7 @@ jobs: export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' - cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/ip2;~/sp" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON + cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/ip2;~/sp;~/jasper" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON make VERBOSE=1 ctest --verbose --output-on-failure --rerun-failed gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null diff --git a/CMakeLists.txt b/CMakeLists.txt index ee33723e..a51ebd82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,10 @@ if(USE_NETCDF4) list(APPEND definitions_list -DUSE_NETCDF4 -DUSE_HDF5 -DHDF5="hdf5") endif() +if(USE_OPENJPEG AND USE_JASPER) + message(FATAL_ERROR "USE_OPENJPEG OR USE_JASPER, not both") +endif() + message(STATUS "Checking if the user wants to use Jasper...") if(USE_JASPER) list(APPEND definitions_list -DUSE_JASPER) @@ -113,6 +117,12 @@ if(USE_JASPER) endif() endif() +# Find required packages to use OpenJPEG +message(STATUS "Checking if the user wants to use OpenJPEG...") +if(USE_OPENJPEG) + find_package(OpenJPEG REQUIRED) +endif() + message(STATUS "Checking if the user want to use OpenMP...") if(USE_OPENMP) find_package(OpenMP) @@ -124,20 +134,14 @@ if(USE_OPENMP) # endif() endif() -message(STATUS "Checking of the user wants to use PNG...") +message(STATUS "Checking if the user wants to use PNG...") if(USE_PNG) find_package(ZLIB REQUIRED) find_package(PNG REQUIRED) endif() -# Find required packages to use OpenJPEG -message(STATUS "Checking of the user wants to use OpenJPEG...") -if(USE_OPENJPEG) - find_package(OpenJPEG REQUIRED) -endif() - # Find required packages to use AEC -message(STATUS "Checking of the user wants to use AEC...") +message(STATUS "Checking if the user wants to use AEC...") if(USE_AEC) find_package(libaec 1.0.6 REQUIRED) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d069ec38..4889a49c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -155,6 +155,10 @@ endif() if (USE_AEC) shell_test(run_wgrib2_aec_tests) endif() +if (USE_JASPER OR USE_OPENJPEG) + shell_test(run_jpeg_tests) + copy_test_data(ref_jpeg2simple.txt) +endif() if (FTP_TEST_FILES) copy_test_data(ref_WW3_Regional_US_West_Coast_20220718_0000.grib2.inv) diff --git a/tests/data/ref_jpeg2simple.txt b/tests/data/ref_jpeg2simple.txt new file mode 100644 index 00000000..194644cb --- /dev/null +++ b/tests/data/ref_jpeg2simple.txt @@ -0,0 +1,19 @@ +1:0:00Z30nov2021:WIND Wind Speed [m/s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +2:19910:00Z30nov2021:WDIR Wind Direction (from which blowing) [deg]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +3:46720:00Z30nov2021:UGRD U-Component of Wind [m/s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +4:66630:00Z30nov2021:VGRD V-Component of Wind [m/s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +5:87920:00Z30nov2021:HTSGW Significant Height of Combined Wind Waves and Swell [m]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +6:105070:00Z30nov2021:PERPW Primary Wave Mean Period [s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +7:123600:00Z30nov2021:DIRPW Primary Wave Direction [deg]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +8:147650:00Z30nov2021:WVHGT Significant Height of Wind Waves [m]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +9:158136:00Z30nov2021:SWELL Significant Height of Swell Waves [m]:lvl1=(241,1) lvl2=(255,missing):1 in sequence:anl: +10:175286:00Z30nov2021:SWELL Significant Height of Swell Waves [m]:lvl1=(241,2) lvl2=(255,missing):2 in sequence:anl: +11:190969:00Z30nov2021:SWELL Significant Height of Swell Waves [m]:lvl1=(241,3) lvl2=(255,missing):3 in sequence:anl: +12:204751:00Z30nov2021:WVPER Mean Period of Wind Waves [s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +13:216517:00Z30nov2021:SWPER Mean Period of Swell Waves [s]:lvl1=(241,1) lvl2=(255,missing):1 in sequence:anl: +14:236427:00Z30nov2021:SWPER Mean Period of Swell Waves [s]:lvl1=(241,2) lvl2=(255,missing):2 in sequence:anl: +15:256219:00Z30nov2021:SWPER Mean Period of Swell Waves [s]:lvl1=(241,3) lvl2=(255,missing):3 in sequence:anl: +16:275175:00Z30nov2021:WVDIR Direction of Wind Waves [deg]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +17:290139:00Z30nov2021:SWDIR Direction of Swell Waves [deg]:lvl1=(241,1) lvl2=(255,missing):1 in sequence:anl: +18:314189:00Z30nov2021:SWDIR Direction of Swell Waves [deg]:lvl1=(241,2) lvl2=(255,missing):2 in sequence:anl: +19:340827:00Z30nov2021:SWDIR Direction of Swell Waves [deg]:lvl1=(241,3) lvl2=(255,missing):3 in sequence:anl: diff --git a/tests/run_jpeg_tests.sh b/tests/run_jpeg_tests.sh new file mode 100644 index 00000000..fbaf1d3a --- /dev/null +++ b/tests/run_jpeg_tests.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# This tests support for jpeg2000 compressed grib files. +# Only available if USE_JASPER=ON or USE_OPENJPEG=ON CMake. +# +# Alyson Stahl 7/26/2024 + +echo "*** Converting from jpeg to simple packing" +../wgrib2/wgrib2 data/gdaswave.t00z.wcoast.0p16.f000.grib2 -set_grib_type simple -grib_out jpeg2simple.grb +../wgrib2/wgrib2 jpeg2simple.grb -v2 -s > jpeg2simple.txt +touch jpeg2simple.txt +diff -w jpeg2simple.txt data/ref_jpeg2simple.txt + +echo "*** SUCCESS!" +exit 0 \ No newline at end of file diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index dfd4881b..2afc7325 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -90,6 +90,7 @@ if(USE_NETCDF4) endif() if(USE_JASPER) + include_directories(${JASPER_INCLUDE_DIR}) target_include_directories(obj_lib PUBLIC ${JASPER_INCLUDE_DIR}) target_link_libraries(obj_lib PUBLIC ${JASPER_LIBRARIES}) endif()