Skip to content

Commit

Permalink
Merge branch 'develop' into grids
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA authored Oct 18, 2024
2 parents a298321 + 25fd33c commit 16f3c3c
Show file tree
Hide file tree
Showing 24 changed files with 286 additions and 382 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/Linux_options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ concurrency:

jobs:
Linux_options:
runs-on: ubuntu-latest
env:
FC: gfortran
CC: gcc
runs-on: ubuntu-24.04

strategy:
# fail-fast: true
matrix:
config:
- {
options: "-DUSE_IPOLATES=ON"
options: "-DUSE_IPOLATES=ON -DBLA_VENDOR=OpenBLAS"
}
- {
options: "-DUSE_AEC=ON"
Expand All @@ -42,21 +39,30 @@ jobs:
- {
options: "-DUSE_OPENJPEG=ON"
}
gcc-version: [12]
include:
- gcc-version: 14

steps:

- name: install
run: |
sudo apt-get update
sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config
sudo apt-get install libpng-dev autotools-dev autoconf libaec-dev
sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config \
libpng-dev autotools-dev autoconf libaec-dev libopenblas-serial-dev \
libopenjp2-7 libopenjp2-7-dev
if [ -z $(type -P gcc-${{ matrix.gcc-version }}) ]; then
sudo apt-get install gcc-${{ matrix.gcc-version }} gfortran-${{ matrix.gcc-version }}
fi
echo "CC=gcc-${{ matrix.gcc-version }}" >> $GITHUB_ENV
echo "FC=gfortran-${{ matrix.gcc-version }}" >> $GITHUB_ENV
- name: cache-jasper
id: cache-jasper
uses: actions/cache@v3
with:
path: ~/jasper
key: jasper-${{ runner.os }}-1.900.1
key: jasper-${{ runner.os }}-gcc${{ matrix.gcc-version }}-1.900.1

- name: checkout-jasper
if: steps.cache-jasper.outputs.cache-hit != 'true'
Expand All @@ -70,7 +76,7 @@ jobs:
if: steps.cache-jasper.outputs.cache-hit != 'true'
run: |
cd jasper
./configure --prefix=$HOME/jasper
CFLAGS="-Wno-implicit-function-declaration -Wno-incompatible-pointer-types" ./configure --prefix=$HOME/jasper
make
make install
Expand All @@ -79,7 +85,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/ip
key: ip-${{ runner.os }}-develop
key: ip-${{ runner.os }}-gcc${{ matrix.gcc-version }}-develop

- name: checkout-ip
if: steps.cache-ip.outputs.cache-hit != 'true'
Expand Down
41 changes: 29 additions & 12 deletions .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
FC: gfortran
CC: gcc
LD_LIBRARY_PATH: "/home/runner/jasper/lib/"

permissions:
id-token: write
Expand All @@ -31,31 +32,31 @@ jobs:
- name: install
run: |
sudo apt-get update
sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config
sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config libopenblas-dev
sudo apt-get install libpng-dev autotools-dev libaec-dev autoconf gcovr doxygen
- name: cache-jasper
id: cache-jasper
uses: actions/cache@v4
with:
path: ~/jasper
key: jasper-${{ runner.os }}-1.900.1
key: jasper-${{ runner.os }}-4.0.0

- name: checkout-jasper
if: steps.cache-jasper.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: jasper-software/jasper
path: jasper
ref: version-1.900.1
ref: version-4.0.0

- name: build-jasper
if: steps.cache-jasper.outputs.cache-hit != 'true'
run: |
cd jasper
./configure --prefix=$HOME/jasper
make
make install
cmake -B build_dir -DCMAKE_INSTALL_PREFIX=~/jasper
cmake --build build_dir
cmake --install build_dir
- name: checkout-ip
uses: actions/checkout@v4
Expand All @@ -71,7 +72,23 @@ jobs:
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/ip -DCMAKE_PREFIX_PATH=~
make -j2
make install
make install
- name: checkout-g2c
uses: actions/checkout@v4
with:
repository: NOAA-EMC/NCEPLIBS-g2c
path: g2c
ref: develop

- name: build-g2c
run: |
cd g2c
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/g2c -DCMAKE_PREFIX_PATH="~/jasper"
make -j2
make install
- name: checkout
uses: actions/checkout@v4
Expand All @@ -90,10 +107,10 @@ jobs:
cd wgrib2
mkdir build
cd build
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;~/jasper" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON
export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -I/home/runner/g2c/include'
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;~/jasper;~/g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON -DMAKE_FTN_API=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 All @@ -115,4 +132,4 @@ jobs:
- name: Upload built documentation
uses: actions/upload-pages-artifact@v1
with:
path: wgrib2/build/docs/html # Path to the built site files
path: wgrib2/build/docs/html # Path to the built site files
35 changes: 17 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.15)
file(STRINGS "VERSION" pVersion)

# Set up project with version number from VERSION file.
project(wgrib2 VERSION ${pVersion} LANGUAGES Fortran C)
project(wgrib2 VERSION ${pVersion} LANGUAGES C)

# Handle user build options.
option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)
Expand Down Expand Up @@ -35,10 +35,19 @@ option(FTP_EXTRA_TEST_FILES "Fetch even more large files from FTP and test them.
option(MAKE_FTN_API "add ftn api?" off)
option(DISABLE_STAT "disable posix feature" off)
set(BUILD_COMMENTS "stock build")

option(BUILD_LIB "Build wgrib2 library?" on)
option(BUILD_SHARED_LIB "Build shared library?" off)
# if BUILD_LIB, then code is compiled as relocatable
option(BUILD_SHARED_LIB "Build shared library?" on)
# To create libwgrib2.so for python, you have to build with BUILD_SHARED_LIB off
# and manually create libwgrib2.so from the needed *.a files

option(BUILD_WGRIB "Build wgrib code?" off)

if (MAKE_FTN_API OR USE_IPOLATES)
enable_language(Fortran)
endif()

# Developers can use this option to specify a local directory which
# holds the test files. They will be copied instead of fetching the
# files via FTP.
Expand Down Expand Up @@ -78,10 +87,10 @@ if(USE_G2CLIB)
if(USE_PNG)
message(FATAL_ERROR "If USE_G2CLIB is on, USE_PNG must be off")
endif()
endif()

if(USE_JASPER)
message(FATAL_ERROR "If USE_G2CLIB is on, USE_JASPER must be off")
endif()
if (BUILD_SHARED_LIB AND NOT BUILD_LIB)
message(FATAL_ERROR "BUILD_SHARED_LIB is on but BUILD_LIB is off")
endif()

# If user wants to use NCEPLIBS-ip, find it and the sp library.
Expand All @@ -103,28 +112,18 @@ endif()

message(STATUS "Checking if the user wants to use Jasper...")
if(USE_JASPER)
list(APPEND definitions_list -DUSE_JASPER)
find_package(Jasper REQUIRED)
if(JASPER_VERSION_STRING VERSION_GREATER_EQUAL "1.900.25")
list(APPEND definitions_list -DJAS_VERSION_MAJOR=2)
endif()
find_package(g2c 1.9.0 CONFIG REQUIRED)
endif()

# Find required packages to use OpenJPEG
message(STATUS "Checking if the user wants to use OpenJPEG...")
if(USE_OPENJPEG)
find_package(OpenJPEG REQUIRED)
find_package(OpenJPEG REQUIRED)
endif()

message(STATUS "Checking if the user want to use OpenMP...")
if(USE_OPENMP)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(MyTarget PUBLIC OpenMP::OpenMP_CXX)
endif()
# if(OpenMP_Fortran_FOUND)
# target_link_libraries(MyTarget PUBLIC OpenMP::OpenMP_Fortran)
# endif()
find_package(OpenMP REQUIRED COMPONENTS C)
endif()

message(STATUS "Checking if the user wants to use PNG...")
Expand Down
5 changes: 4 additions & 1 deletion spack/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,15 @@ def url_for_version(self, version):
conflicts("+openmp", when="%apple-clang")

depends_on("[email protected]:", when="@develop +ipolates")
depends_on("lapack", when="@develop +ipolates")
depends_on("[email protected]:", when="@3.2: +aec")
depends_on("netcdf-c", when="@3.2: +netcdf4")
depends_on("jasper@:2", when="@3.2: +jasper")
depends_on("jasper@:2", when="@3.2:3.4 +jasper")
depends_on("g2c", when="@develop +jasper")
depends_on("zlib-api", when="@3.2: +png")
depends_on("libpng", when="@3.2: +png")
depends_on("openjpeg", when="@3.2: +openjpeg")


@when("@:2 ^[email protected]:")

Expand Down
11 changes: 11 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ if (USE_JASPER OR USE_OPENJPEG)
copy_test_data(ref_jpeg2simple.txt)
endif()

if (MAKE_FTN_API)
shell_test(test_ftn_api)
endif()
if (BUILD_LIB)
shell_test(test_lib)
endif()
if (BUILD_SHARED_LIB)
shell_test(test_shared_lib)
endif()


if (FTP_TEST_FILES)
copy_test_data(ref_WW3_Regional_US_West_Coast_20220718_0000.grib2.inv)
copy_test_data(ref_merge_fcst.aqm.t12z.max_8hr_o3.227.grib2.txt)
Expand Down
10 changes: 5 additions & 5 deletions tests/run_jpeg_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ echo ""
echo "*** Running wgrib2 jpeg tests"

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
../wgrib2/wgrib2 data/gdaswave.t00z.wcoast.0p16.f000.grib2 -set_grib_type simple -grib_out junk_jpeg2simple.grb
../wgrib2/wgrib2 junk_jpeg2simple.grb -v2 -s > junk_jpeg2simple.txt
touch junk_jpeg2simple.txt
diff -w junk_jpeg2simple.txt data/ref_jpeg2simple.txt

echo "*** SUCCESS!"
exit 0
exit 0
13 changes: 13 additions & 0 deletions tests/run_wgrib2_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,18 @@ echo "*** Testing write/read section"
touch secs.txt
diff -w secs.txt simple.txt


echo "*** test pdt 48 ***"
n=`../wgrib2/wgrib2 ./data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -d 1 -set_pdt +48 -set_byte 4 12 00:12:0 | grep -c "aerosol_size"`
if [ "$n" -ne 1 ] ; then
exit 1
fi
set -x
echo "*** test pdt 49 ***"
n=`../wgrib2/wgrib2 ./data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -d 1 -set_pdt +49 -set_byte 4 12 00:12:0 | grep -c "aerosol_size"`
if [ "$n" -ne 1 ] ; then
exit 1
fi

echo "*** SUCCESS!"
exit 0
15 changes: 15 additions & 0 deletions tests/test_ftn_api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
#
# script to see if ftn_api compiled
#

echo "see if ftn_api compiled"
set -xe

if [ ! -f ../wgrib2/ftn_api/include/wgrib2api.mod ] ; then
echo "failed: did not find wgrib2api.mod"
exit 1
fi

echo "*** SUCCESS!"
exit 0
15 changes: 15 additions & 0 deletions tests/test_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
#
# script to see if shared lib was made
#

echo "see if shared library made"
set -xe

if [ ! -f ../wgrib2/libwgrib2.so -a ! -f ../wgrib2/libwgrib2.a ] ; then
echo "failed: did not find libwgrib2"
exit 1
fi

echo "*** SUCCESS!"
exit 0
15 changes: 15 additions & 0 deletions tests/test_shared_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
#
# script to see if shared lib was made
#

echo "see if shared library made"
set -xe

if [ ! -f ../wgrib2/libwgrib2.so ] ; then
echo "failed: did not find libwgrib2.so"
exit 1
fi

echo "*** SUCCESS!"
exit 0
Loading

0 comments on commit 16f3c3c

Please sign in to comment.