Skip to content

Commit

Permalink
now support USE_IPOLATES=1 build, and test with new Linux_options wor…
Browse files Browse the repository at this point in the history
…kflow (#93)

* trying ip build

* trying ip build

* trying ip build

* trying ip build

* trying ip build

* more ip work

* added -DGFORTRAN to build, didn't work

* got build to succeed!

* reverted change
  • Loading branch information
edwardhartnett authored Mar 29, 2024
1 parent e3faa1c commit b3ef3ca
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 247 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/Linux_options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# This is the Linux_options workflow for the wgrib2 project. This
# tests different wgrib2 build options.
#
# Ed Hartnett, 3/27/24
name: Linux_options
on:
push:
branches:
- develop
pull_request:
branches:
- develop

# Cancel in-progress workflows when pushing to a branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

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

strategy:
# fail-fast: true
matrix:
config:
- {
options: "-DUSE_IPOLATES=1"
}

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
- name: checkout-jasper
uses: actions/checkout@v2
with:
repository: jasper-software/jasper
path: jasper
ref: version-1.900.1

- name: build-jasper
if: steps.cache-jasper.outputs.cache-hit != 'true'
run: |
cd jasper
./configure --prefix=$HOME/Jasper
make
make install
- name: checkout-sp
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-sp
path: sp
ref: v2.3.3

- name: build-sp
run: |
cd sp
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=~/sp -DBUILD_8=ON ..
make -j2
make install
- name: cache-ip
id: cache-ip
uses: actions/cache@v3
with:
path: ~/ip
key: ip-${{ runner.os }}-${{ matrix.ip-version }}

- name: checkout-ip
if: steps.cache-ip.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: NOAA-EMC/NCEPLIBS-ip
path: ip
ref: v3.3.3

- name: build-ip
if: steps.cache-ip.outputs.cache-hit != 'true'
run: |
cd ip
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/ip -DCMAKE_PREFIX_PATH=~/sp
make -j2
make install
- name: checkout-ip2
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-ip2
path: ip2
ref: develop

- name: build-ip2
run: |
cd ip2
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/ip2 -DCMAKE_PREFIX_PATH=~
make -j2
make install
- name: checkout
uses: actions/checkout@v2
with:
path: wgrib2

- name: build
run: |
cd wgrib2
mkdir b
cd b
cmake ${{ matrix.config.options }} -DCMAKE_PREFIX_PATH="~/sp;~/ip;~/ip2" ..
make VERBOSE=1
39 changes: 23 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# This is the main CMake build file for the wgrib2 project.
#
# Kyle Gerheiser, Edward Hartnett, Wesley Ebisuzaki

cmake_minimum_required(VERSION 3.12)
project(wgrib2 VERSION 3.1.4 LANGUAGES Fortran C)


option(USE_NETCDF3 "Use NetCDF-3?" off)
option(USE_NETCDF4 "Use NetCDF-4?" off)
option(USE_HDF5 "Use HDF5?" off)
option(USE_REGEX "Use Regex?" on)
option(USE_TIGGE "Use tigge?" on)
option(USE_MYSQL "Use MySQL?" off)
# option(USE_IPOLATES "iplib=0,1,3?" 3)
set(USE_IPOLATES 0)
option(USE_IPOLATES "iplib=0,1,3?" 3)
option(USE_UDF "Use UDF?" off)
option(USE_OPENMP "Use OpenMP?" on)
option(USE_PROJ4 "Use Proj4?" off)
Expand Down Expand Up @@ -43,11 +45,12 @@ endif()

include(GNUInstallDirs)

message(STATUS "Setting compiler flags...")
if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_C_FLAGS "-g -traceback ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "-g -traceback ${CMAKE_C_FLAGS} -DIFORT")
set(CMAKE_C_FLAGS_DEBUG "-O0")
elseif(CMAKE_C_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_C_FLAGS "-g ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "-g ${CMAKE_C_FLAGS} -DGFORTRAN")
set(CMAKE_C_FLAGS_DEBUG "-O0")
endif()

Expand All @@ -60,6 +63,7 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
endif()


message(STATUS "Checking if user wants to use NCEPLIBS-g2c...")
if(USE_G2CLIB)
if(USE_PNG)
message(FATAL_ERROR "If USE_G2CLIB is on, USE_PNG must be off")
Expand All @@ -74,19 +78,27 @@ if(USE_NETCDF3 AND USE_NETCDF4)
message(FATAL_ERROR "USE_NETCDF3 OR USE_NetCDF4, not both")
endif()


# If user wants to use NCEPLIBS-ip, find it and the sp library.
message(STATUS "Checking if the user want to use NCEPLIBS-ip...")
if(USE_IPOLATES EQUAL 1)
find_package(ip CONFIG REQUIRED)
find_package(sp CONFIG REQUIRED)
elseif(USE_IPOLATES EQUAL 3)
find_package(ip2 CONFIG REQUIRED)
endif()

if(NOT USE_IPOLATES EQUAL 0)
list(APPEND definitions_list -DIPOLATES_LIB="ipolates_lib")
endif()
list(APPEND definitions_list -DUSE_IPOLATES=${USE_IPOLATES})

message(STATUS "Checking if the user want to use NetCDF...")
if(USE_NETCDF4)
find_package(NetCDF MODULE REQUIRED COMPONENTS C)
list(APPEND definitions_list -DUSE_NETCDF4 -DUSE_HDF5 -DHDF5="hdf5")
endif()

message(STATUS "Checking if the user wants to use Jasper...")
if(USE_JASPER)
list(APPEND definitions_list -DUSE_JASPER)
find_package(Jasper REQUIRED)
Expand All @@ -95,6 +107,7 @@ if(USE_JASPER)
endif()
endif()

message(STATUS "Checking if the user want to use OpenMP...")
if(USE_OPENMP)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
Expand All @@ -105,13 +118,14 @@ if(USE_OPENMP)
# endif()
endif()

message(STATUS "Checking of the user wants to use PNG...")
if(USE_PNG)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
endif()


# write config.h
message(STATUS "Writing config.h...")
FILE(WRITE "wgrib2/config.h" "/* config.h generated by cmake */\n")
FILE(APPEND "wgrib2/config.h" "#ifndef _CONFIG_H\n")
FILE(APPEND "wgrib2/config.h" "#define _CONFIG_H\n")
Expand All @@ -136,21 +150,14 @@ FILE(APPEND "wgrib2/config.h" "#define CC \"${CMAKE_C_COMPILER} ${CMAKE_C_COMPIL
FILE(APPEND "wgrib2/config.h" "#define FORTRAN \"${CMAKE_Fortran_COMPILER} ${CMAKE_Fortran_COMPILER_ID}\"\n")
FILE(APPEND "wgrib2/config.h" "#define CPPFLAGS \"${CMAKE_C_FLAGS}\"\n")
FILE(APPEND "wgrib2/config.h" "#define FFLAGS \"${CMAKE_Fortran_FLAGS}\"\n")



FILE(APPEND "wgrib2/config.h" "#endif\n")





message(STATUS "Adding wgrib2, aux_probs subdirectories...")
add_subdirectory(wgrib2)
add_subdirectory(aux_progs)


if(BUILD_LIB)

message(STATUS "Adding wgrib2 library build...")
### Package config
include(CMakePackageConfigHelpers)
set(CONFIG_INSTALL_DESTINATION lib/cmake/${PROJECT_NAME})
Expand Down
Loading

0 comments on commit b3ef3ca

Please sign in to comment.