Skip to content

Commit

Permalink
add noah-owp-modular workflow (#96)
Browse files Browse the repository at this point in the history
* add noah-owp-modular workflow

* change master to main and addressing comments

* Remove LD_LIBRARY_PATH for macOS

* add noah-owp-modular workflow

* change master to main and addressing comments

* Remove LD_LIBRARY_PATH for macOS

* Revise build and run

* Use unified build and run codes for Linux & MacOS

* Add make clean

* Fix a configure issue

* Add revised ngen_integration.yaml

* Clean up commit history
Brew install gcc9

Try Homebrew

Try Linux

Try Linux with brew install

* Try Linux style gfortran

* Add a comment on gfortran in macOS

* Remove the re-checkout

* Delete .github/workflows/tmp.md

* update realization.json to include pet

---------

Co-authored-by: JessicaGarrett-NOAA <[email protected]>
  • Loading branch information
stcui007 and madMatchstick authored Jan 19, 2024
1 parent 04e8ac0 commit 05aec15
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 1 deletion.
78 changes: 78 additions & 0 deletions .github/workflows/Build_and_Run_Standalone_Test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Test changes that have been pushed to the main branch

name: Testing and Validation

# Controls when the action will run.
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

#env:
# Obtained from https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
# TODO: add something later that can check the runners for hyperthreading
#LINUX_NUM_PROC_CORES: 2
#MACOS_NUM_PROC_CORES: 3

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Run general unit tests in linux environment
test_unit:
# The type of runner that the job will run on
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout the commit
uses: actions/checkout@v4

- name: Install NetCDF
run: |
if [ ${{ runner.os }} == 'Linux' ]
then
sudo apt-get update
sudo apt-get install -y --fix-missing libnetcdf-dev libnetcdff-dev libnetcdf-c++4-1 libnetcdf-c++4-dev
echo "NETCDF=/usr" >> $GITHUB_ENV
elif [ ${{ runner.os }} == 'macOS' ]
then
brew install netcdf netcdf-cxx netcdf-fortran
echo "LIBRARY_PATH=/usr/local/lib/:$LIBRARY_PATH" >> $GITHUB_ENV
echo "LDFLAGS=-L/usr/local/lib" >> $GITHUB_ENV
echo "INCLUDE=/usr/local/include" >> $GITHUB_ENV
echo "NETCDF=/usr/local" >> $GITHUB_ENV
fi
# Build and run noah executable
# noah-owp-modular's configure system has 5 options serving the need for different computer
# servers and OS environment. The numbers 5 is for Linux type computing enviroments.
# Using the Linux option for macOS as macOS could not find gfortran in /usr/local/bin/.
- name: Configure
run: |
if [ ${{ runner.os }} == 'Linux' ]
then
./configure 5
elif [ ${{ runner.os }} == 'macOS' ]
then
sudo ln -s $(which gfortran-13) /usr/local/bin/gfortran
./configure 5
fi
- name: Build and Run Standalone
run: |
make clean
make
cd run
./noah_owp_modular.exe namelist.input
- name: Build and Run BMI test
run: |
make clean
make testBMI
cd test
./noahowp_test.exe ../run/namelist.input
107 changes: 107 additions & 0 deletions .github/workflows/ngen_integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Test ngen-cfe integration

name: Ngen Integration Tests

# Controls when the action will run.
on:
push:
branches: [ main, dev, notreal ]
pull_request:
branches: [ main, dev, notreal ]
workflow_dispatch:

env:
# Obtained from https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
# TODO: add something later that can check the runners for hyperthreading
LINUX_NUM_PROC_CORES: 2
MACOS_NUM_PROC_CORES: 3
ASAN_OPTIONS: detect_leaks=false

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Run general unit tests in linux environment
test_surfacebmi_plus_cfe:
# The type of runner that the job will run on
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:

# Checkout and build the noah-owp-modular
- name: Checkout the commit
uses: actions/checkout@v4

- name: Save noah-owp-modular to a Temp Directory
run: |
# Move files to appropriate temporary directory
mkdir ${{runner.temp}}/noah-owp-modular
mv ./* ${{runner.temp}}/noah-owp-modular
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout actions in another repo
uses: actions/checkout@v4
with:
repository: noaa-owp/ngen

- name: Build ISO C Fortran BMI
id: submod_build_2
uses: ./.github/actions/ngen-submod-build
with:
mod-dir: "extern/iso_c_fortran_bmi/"

- name: Build CFE
id: submod_build_3
uses: ./.github/actions/ngen-submod-build
with:
mod-dir: "extern/cfe/"
targets: "cfebmi"

- name: Build PET
id: submod_build_5
uses: ./.github/actions/ngen-submod-build
with:
mod-dir: "extern/evapotranspiration/evapotranspiration"
targets: "petbmi"

- name: Build SLoTH
id: submod_build_6
uses: ./.github/actions/ngen-submod-build
with:
mod-dir: "extern/sloth/"
targets: "slothmodel"

# Build Ngen and save some files
- name: Build Ngen
id: ngen_id1
uses: ./.github/actions/ngen-build
with:
targets: "ngen"
build-cores: ${{ env.LINUX_NUM_PROC_CORES }}
#is this required for this test?
bmi_c: 'ON'
bmi_fortran: 'ON'
timeout-minutes: 15

- name: Prepare to Build noah-owp-modular Library for Ngen
run: |
# Move files to appropriate directory to build noah-owp-modular library
rm -rf extern/noah-owp-modular/noah-owp-modular/*
mv ${{runner.temp}}/noah-owp-modular/* extern/noah-owp-modular/noah-owp-modular
- name: Build Noah-owp-modular Surfacebmi
id: submod_build_1
uses: ./.github/actions/ngen-submod-build
with:
mod-dir: " extern/noah-owp-modular/"
targets: "surfacebmi"

- name: Run Ngen Test
run: |
# Run ngen with NoahOWPModular, CFE & PET
mv ${{ steps.ngen_id1.outputs.build-dir }} ./ngen-build/
inputfile='data/example_bmi_multi_realization_config_w_noah_pet_cfe.json'
./ngen-build/ngen ./data/catchment_data.geojson "cat-27" ./data/nexus_data.geojson "nex-26" $inputfile
1 change: 0 additions & 1 deletion .github/workflows/tmp.md

This file was deleted.

0 comments on commit 05aec15

Please sign in to comment.