Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding cmake support and tests for openjpeg #220

Merged
merged 15 commits into from
Jul 30, 2024
5 changes: 4 additions & 1 deletion .github/workflows/Linux_options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
- {
options: "-DBUILD_WGRIB=ON"
}
- {
options: "-DUSE_OPENJPEG=ON"
}

steps:

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions tests/data/ref_jpeg2simple.txt
Original file line number Diff line number Diff line change
@@ -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:
14 changes: 14 additions & 0 deletions tests/run_jpeg_tests.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions wgrib2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading