Skip to content

Commit

Permalink
Require g2c for build and remove duplicate C code (#752)
Browse files Browse the repository at this point in the history
* update workflows to use g2c

* require g2c

* Update memcheck.yml

* Update CMakeLists.txt

* debug memcheck

* debug

* debug

* debugging

* more debug

* Update CMakeLists.txt

* debug png

* Update g2png.F90

* more debug png

* Update g2png.F90

* update dec_png

* Update g2png.F90

* debug

* undo change

* Update g2png.F90

* Update g2png.F90

* Update g2png.F90

* debug

* debug seg fault

* Update CMakeLists.txt

* debug segfault

* more debugging

* restore changes

* Update g2png.F90

* Update g2png.F90

* use g2c for jpeg

* debug

* debugging

* Update Linux_versions.yml

* undo changes

* debug jpeg

* more debug

* Update CMakeLists.txt

* debug

* undo

* debug jasper

* reinclude g2cjpeg2000

* reverting some changes

* debug

* renew changes

* Update Linux_shared.yml

* Update Linux_shared.yml

* Update CMakeLists.txt

* typo

* update library path

* Update Linux_shared.yml

* update ld_library_path for jasper

* added some print statements to debug mem issue

* remove print statements

* Update test_addfield.F90

* debugging failing check

* undo

* deleting unnecessary files

* update jasper max mem

* debug test

* more debugging

* turn off utils in intel workflow

* cleanup
  • Loading branch information
AlysonStahl-NOAA authored Sep 4, 2024
1 parent fae775d commit 5418ace
Show file tree
Hide file tree
Showing 17 changed files with 153 additions and 995 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/Intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
w3emc-version: develop
w3emc-cmake-args: -DBUILD_WITH_BUFR=OFF
ip-version: develop
g2c-version: develop
key-prefix: Intel-

- name: checkout
Expand All @@ -52,7 +53,7 @@ jobs:
cd g2
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip" -DBUILD_UTILS=ON ..
cmake -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DBUILD_UTILS=OFF ..
make -j2
- name: test
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/Linux_options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
env:
FC: gfortran
CC: gcc
LD_LIBRARY_PATH: /home/runner/jasper/lib
LD_LIBRARY_PATH: /home/runner/work/NCEPLIBS-g2/NCEPLIBS-g2/nceplibs/jasper/lib/
strategy:
# fail-fast: true
matrix:
Expand Down Expand Up @@ -55,11 +55,13 @@ jobs:
with:
bacio-version: v${{ matrix.bacio-version }}
g2c-version: develop
g2c-cmake-args: -DBUILD_G2C=ON
jasper-version: version-4.0.0
w3emc-version: v${{ matrix.w3emc-version }}
w3emc-cmake-args: -DBUILD_WITH_BUFR=OFF -DBUILD_WITH_EXTRA_DEPS=ON
ip-version: develop


- name: checkout
uses: actions/checkout@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/Linux_shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
env:
FC: gfortran
CC: gcc
LD_LIBRARY_PATH: /home/runner/jasper/lib
LD_LIBRARY_PATH: /home/runner/work/NCEPLIBS-g2/NCEPLIBS-g2/nceplibs/jasper/lib/
strategy:
fail-fast: true
matrix:
Expand Down Expand Up @@ -53,11 +53,11 @@ jobs:
bacio-version: v${{ matrix.bacio-version }}
bacio-cmake-args: -DBUILD_SHARED_LIBS=ON
g2c-version: develop
g2c-cmake-args: -DENABLE_SHARED=ON
g2c-cmake-args: -DBUILD_SHARED_LIBS=ON
jasper-version: version-4.0.0
jasper-cmake-args: -DENABLE_SHARED=ON
w3emc-version: v${{ matrix.w3emc-version }}
w3emc-cmake-args: -DBUILD_WITH_BUFR=OFF -DENABLE_SHARED=ON -DBUILD_WITH_EXTRA_DEPS=OFF
w3emc-cmake-args: -DBUILD_WITH_BUFR=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_WITH_EXTRA_DEPS=OFF
ip-version: develop

- name: checkout
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/Linux_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
env:
FC: gfortran
CC: gcc
LD_LIBRARY_PATH: /home/runner/jasper/lib
LD_LIBRARY_PATH: /home/runner/work/NCEPLIBS-g2/NCEPLIBS-g2/nceplibs/jasper/lib/
strategy:
fail-fast: true
matrix:
Expand All @@ -44,6 +44,7 @@ jobs:
with:
bacio-version: v${{ matrix.bacio-version }}
g2c-version: develop
g2c-cmake-args: -DENABLE_SHARED=ON
jasper-version: version-${{ matrix.jasper-version }}
w3emc-version: v${{ matrix.w3emc-version }}
w3emc-cmake-args: -DBUILD_WITH_BUFR=OFF
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
with:
bacio-version: v${{ matrix.bacio-version }}
g2c-version: develop
g2c-cmake-args: -DENABLE_SHARED=ON
jasper-version: version-${{ matrix.jasper-version }}
w3emc-version: v2.10.0
w3emc-cmake-args: -DBUILD_WITH_BUFR=OFF
Expand Down
22 changes: 4 additions & 18 deletions .github/workflows/memcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
env:
FC: gfortran
CC: gcc

LD_LIBRARY_PATH: /home/runner/work/NCEPLIBS-g2/NCEPLIBS-g2/nceplibs/jasper/lib/
steps:

- name: install-dependencies
Expand All @@ -38,22 +38,8 @@ jobs:
w3emc-version: develop
jasper-version: version-4.0.0
w3emc-cmake-args: -DBUILD_WITH_BUFR=OFF

- name: checkout-ip
uses: actions/checkout@v3
with:
repository: NOAA-EMC/NCEPLIBS-ip
path: ip
ref: develop

- name: build-ip
run: |
cd ip
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=~/ip ..
make -j2
make install
ip-version: develop
g2c-version: develop

- name: checkout
uses: actions/checkout@v4
Expand All @@ -72,7 +58,7 @@ jobs:
cd g2
mkdir build
cd build
cmake -DJasper_ROOT=~/Jasper -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip" -DCMAKE_Fortran_FLAGS="-g -O0" -DCMAKE_C_FLAGS="-g -O0" -DFTP_TEST_FILES=ON -DTEST_FILE_DIR=/home/runner/data -DCMAKE_BUILD_TYPE=Debug ..
cmake -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DCMAKE_Fortran_FLAGS="-g -O0" -DCMAKE_C_FLAGS="-g -O0" -DFTP_TEST_FILES=ON -DTEST_FILE_DIR=/home/runner/data -DCMAKE_BUILD_TYPE=Debug ..
make -j2 VERBOSE=1
- name: test_memcheck
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ endif()
# There was a bug in jasper for the intel compiler that was fixed in
# 2.0.25.
find_package(Jasper 2.0.25 REQUIRED)
find_package(g2c REQUIRED)
find_package(PNG REQUIRED)
find_package(bacio REQUIRED)
if(bacio_VERSION LESS 2.5.0)
Expand Down
1 change: 1 addition & 0 deletions spack/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class G2(CMakePackage):

depends_on("jasper@:2.0.32", when="@:3.4.7")
depends_on("jasper")
depends_on("g2c", when="@develop")
depends_on("libpng")
depends_on("zlib-api")
depends_on("bacio", when="@3.4.6:")
Expand Down
26 changes: 10 additions & 16 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (BUILD_WITH_W3EMC)
endif()

# These are the C source files.
set(c_src g2cpng.c mova2i.c)
set(c_src mova2i.c)

# Create this fortran file, which has the contents of the VERSION file
# substituted in.
Expand Down Expand Up @@ -45,7 +45,8 @@ foreach(kind ${kinds})
# Build the C code.
add_library(${lib_name}_c OBJECT ${c_src})
target_include_directories(${lib_name}_c PRIVATE ${JASPER_INCLUDE_DIR})
target_link_libraries(${lib_name}_c PRIVATE PNG::PNG)
target_link_libraries(${lib_name}_c PRIVATE PNG::PNG g2c::g2c)

if(BUILD_SHARED_LIBS)
set_property(TARGET ${lib_name}_c PROPERTY POSITION_INDEPENDENT_CODE 1)
endif()
Expand All @@ -54,7 +55,7 @@ foreach(kind ${kinds})
add_library(${lib_name} $<TARGET_OBJECTS:${lib_name}_f> $<TARGET_OBJECTS:${lib_name}_c>)

# Link to bacio, and jasper always.
target_link_libraries(${lib_name} PUBLIC bacio::bacio ${PNG_LIBRARIES} ${JASPER_LIBRARIES})
target_link_libraries(${lib_name} PUBLIC bacio::bacio ${PNG_LIBRARIES} ${JASPER_LIBRARIES} g2c::g2c)
# Link to w3emc if necessary.
if (BUILD_WITH_W3EMC)
target_link_libraries(${lib_name} PUBLIC w3emc::w3emc_${kind})
Expand All @@ -73,20 +74,13 @@ foreach(kind ${kinds})
list(APPEND LIB_TARGETS ${lib_name})

# Build with Jasper.
if(JASPER_FOUND)
message(STATUS "Found JASPER:")
message(STATUS " JASPER include directories ${JASPER_INCLUDE_DIR}")
message(STATUS " JASPER libraries ${JASPER_LIBRARIES} version ${JASPER_VERSION}")
target_sources(${lib_name} PRIVATE g2cjpeg2000.c)
target_compile_definitions(${lib_name} PRIVATE USE_JPEG2000)
target_include_directories(${lib_name} PRIVATE "${JASPER_INCLUDE_DIR}")
set(G2_JPEG2000_ENABLED ON)
if(JASPER_VERSION_STRING VERSION_GREATER_EQUAL "3")
message(STATUS " JASPER is version 3.0 or greater")
add_definitions(-DJASPER3)
endif()
add_definitions(-DJPEG)
message(STATUS "Found JASPER:")
message(STATUS " JASPER include directories ${JASPER_INCLUDE_DIR}")
message(STATUS " JASPER libraries ${JASPER_LIBRARIES} version ${JASPER_VERSION}")
if(JASPER_VERSION_STRING VERSION_GREATER_EQUAL "3")
message(STATUS " JASPER is version 3.0 or greater")
endif()
target_include_directories(${lib_name} PRIVATE ${JASPER_INCLUDE_DIR})

install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})

Expand Down
Loading

0 comments on commit 5418ace

Please sign in to comment.