Skip to content

Commit

Permalink
Smp workflows (#6)
Browse files Browse the repository at this point in the history
* add workflow in standalone mode

* Add ngen_integration

* Change branch name from master to main

* Revise workflow code and realization file

* Correct a cat-id error in realization file

* Use SFT realization file

* Remove the re-checkout codes in ngen_integration.yaml

* Reformatting realization json

* Revision with reviewer comments

* Fix data path error

* Move topmodel data into proper directory

* Update realization file

* Add SMP integration test

* Remove SFT build

* Remove some unnecessary codes
  • Loading branch information
stcui007 authored Jan 8, 2024
1 parent 832d5a7 commit 235cdf9
Show file tree
Hide file tree
Showing 5 changed files with 352 additions and 4 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/build_and_run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Test changes that have been pushed to the master 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: check gcc version
# run: gcc --version

- name: Build and Run Unittest
run: |
cd test
if [ ${{ runner.os }} == 'macOS' ]
then
brew install gnu-sed
#PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
fi
sed -i 's/\${CXX}/g++/' run_unittest.sh
./run_unittest.sh
- name: Build and Run Standalone
run: |
mkdir build && cd build
cmake ../ -DSTANDALONE=ON
make && cd ..
./run_smp.sh STANDALONE
- name: Build and Run with Topmodel
run: |
git clone https://github.com/NOAA-OWP/topmodel extern/topmodel
if [ -d build ]; then
rm -rf build
fi
mkdir build && cd build
cmake ../ -DWITHTOPMODEL=ON
make && cd ..
./run_smp.sh WITHTOPMODEL
101 changes: 101 additions & 0 deletions .github/workflows/ngen_integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Test ngen-smp 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_smp:
# 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 SoilMoistureProfiles
- name: Checkout the commit
uses: actions/checkout@v4

- name: Build the SMP Library
run: |
cmake -B cmake_build -S . -DNGEN=ON
make -C cmake_build
- name: Save SoilMoistureProfiles to a Temp Directory
run: |
# Move files to a temporary directory
mkdir ${{runner.temp}}/smp
mv ./* ${{runner.temp}}/smp
# 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 Topmodel
id: submod_build_4
uses: ./.github/actions/ngen-submod-build
with:
mod-dir: "extern/topmodel/"
targets: "topmodelbmi"

- 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'
timeout-minutes: 15

- name: Move SMP Files Including cmake_build to Appropriate Directory
run: |
rm -rf extern/SoilMoistureProfiles/SoilMoistureProfiles/*
mv ${{runner.temp}}/smp/* extern/SoilMoistureProfiles/SoilMoistureProfiles
- name: Run Ngen Test for SMP
run: |
mv ${{ steps.ngen_id1.outputs.build-dir }} ./ngen-build/
inputfile='extern/SoilMoistureProfiles/SoilMoistureProfiles/config/realization_config_smp_ngenCI.json'
./ngen-build/ngen ./data/catchment_data.geojson "cat-27" ./data/nexus_data.geojson "nex-26" $inputfile
- name: Run Ngen Test with Topmodel
run: |
cp extern/topmodel/topmodel/data/*.dat data
inputfile='extern/SoilMoistureProfiles/SoilMoistureProfiles/config/realization_config_smp_topmodel_ngenCI.json'
./ngen-build/ngen ./data/catchment_data.geojson "cat-27" ./data/nexus_data.geojson "nex-26" $inputfile
7 changes: 3 additions & 4 deletions config/realization_config_smp.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"allow_exceed_end_time": true,
"main_output_variable": "soil_storage",
"output_variables" : [
"soil_storage",
"water_table"
"soil_water_table"
],
"modules": [
{
Expand All @@ -34,7 +33,7 @@
"sloth_SOIL_STORAGE_CHANGE(1,double,m,node)": -0.000472,
"soil_moisture_wetting_fronts(1,double,1,node)": 0.0,
"soil_depth_wetting_fronts(1,double,1,node)": 0.0,
"num_wetting_fronts(1,double,1,node)": 0.0,
"num_wetting_fronts(1,int,1,node)": 1,
"Qb_topmodel(1,double,1,node)": 0.0,
"Qv_topmodel(1,double,1,node)": 0.0,
"global_deficit(1,double,1,node)": 0.0
Expand All @@ -46,7 +45,7 @@
"params": {
"model_type_name": "bmi_smp",
"library_file": "./extern/SoilMoistureProfiles/cmake_build/libsmpbmi",
"init_config": "./extern/SoilMoistureProfiles/SoilMoistureProfiles/config/config_conceptual.txt",
"init_config": "./extern/SoilMoistureProfiles/SoilMoistureProfiles/configs/config_conceptual.txt",
"allow_exceed_end_time": true,
"main_output_variable": "soil_storage",
"variables_names_map" : {
Expand Down
73 changes: 73 additions & 0 deletions config/realization_config_smp_ngenCI.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"time": {
"start_time": "2015-12-01 00:00:00",
"end_time": "2015-12-01 03:00:00",
"output_interval": 3600
},
"catchments": {
"cat-27": {
"formulations": [
{
"name": "bmi_multi",
"params": {
"model_type_name": "bmi_multi_sloth_smp",
"forcing_file": "",
"init_config": "",
"allow_exceed_end_time": true,
"main_output_variable": "soil_storage",
"output_variables" : [
"soil_water_table"
],
"modules": [
{
"name": "bmi_c++",
"params": {
"model_type_name": "bmi_c++_sloth",
"library_file": "./extern/sloth/cmake_build/libslothmodel",
"init_config": "/dev/null",
"allow_exceed_end_time": true,
"main_output_variable": "z",
"uses_forcing_file": false,
"model_params": {
"sloth_SOIL_STORAGE(1,double,m,node)": 0.8,
"sloth_SOIL_STORAGE_CHANGE(1,double,m,node)": -0.000472,
"soil_moisture_wetting_fronts(1,double,1,node)": 0.0,
"soil_depth_wetting_fronts(1,double,1,node)": 0.0,
"num_wetting_fronts(1,int,1,node)": 1,
"Qb_topmodel(1,double,1,node)": 0.0,
"Qv_topmodel(1,double,1,node)": 0.0,
"global_deficit(1,double,1,node)": 0.0
}
}
},
{
"name": "bmi_c++",
"params": {
"model_type_name": "bmi_smp",
"library_file": "./extern/SoilMoistureProfiles/SoilMoistureProfiles/cmake_build/libsmpbmi",
"init_config": "./extern/SoilMoistureProfiles/SoilMoistureProfiles/config/config_conceptual.txt",
"allow_exceed_end_time": true,
"main_output_variable": "soil_storage",
"variables_names_map" : {
"soil_storage" : "sloth_SOIL_STORAGE",
"soil_storage_change" : "sloth_SOIL_STORAGE_CHANGE"
},
"output_variables" : [
"soil_storage",
"soil_water_table"
],
"uses_forcing_file": false
}
}
],
"uses_forcing_file": false
}
}
],
"forcing": {
"path": "./extern/cfe/cfe/forcings/cat87_01Dec2015-.csv",
"provider": "CsvPerFeature"
}
}
}
}
109 changes: 109 additions & 0 deletions config/realization_config_smp_topmodel_ngenCI.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"time": {
"start_time": "2015-12-01 00:00:00",
"end_time": "2015-12-01 03:00:00",
"output_interval": 3600
},
"catchments": {
"cat-27": {
"formulations": [
{
"name": "bmi_multi",
"params": {
"model_type_name": "bmi_multi_sloth_smp",
"forcing_file": "",
"init_config": "",
"allow_exceed_end_time": true,
"main_output_variable": "soil_storage",
"output_variables" : [
"soil_water_table"
],
"modules": [
{
"name": "bmi_c++",
"params": {
"model_type_name": "bmi_c++_sloth",
"library_file": "./extern/sloth/cmake_build/libslothmodel",
"init_config": "/dev/null",
"allow_exceed_end_time": true,
"main_output_variable": "z",
"uses_forcing_file": false,
"model_params": {
"sloth_SOIL_STORAGE(1,double,m,node)": 0.8,
"sloth_SOIL_STORAGE_CHANGE(1,double,m,node)": -0.000472,
"soil_moisture_wetting_fronts(1,double,1,node)": 0.0,
"soil_depth_wetting_fronts(1,double,1,node)": 0.0,
"num_wetting_fronts(1,int,1,node)": 1
}
}
},
{
"name": "bmi_c",
"params": {
"model_type_name": "bmi_c_pet",
"library_file": "./extern/evapotranspiration/evapotranspiration/cmake_build/libpetbmi",
"forcing_file": "",
"init_config": "./extern/cfe/cfe/configs/cat_87_bmi_config_pet_pass.txt",
"allow_exceed_end_time": true,
"main_output_variable": "water_potential_evaporation_flux",
"registration_function":"register_bmi_pet",
"uses_forcing_file": false
}
},
{
"name": "bmi_c",
"params": {
"model_type_name": "bmi_c_topmodel",
"library_file": "./extern/topmodel/cmake_build/libtopmodelbmi",
"init_config": "./extern/topmodel/topmodel/data/topmod.run",
"allow_exceed_end_time": true,
"main_output_variable": "Qout",
"registration_function": "register_bmi_topmodel",
"variables_names_map" : {
"water_potential_evaporation_flux" : "water_potential_evaporation_flux",
"atmosphere_water__liquid_equivalent_precipitation_rate" : "APCP_surface",
"atmosphere_air_water~vapor__relative_saturation" : "SPFH_2maboveground",
"land_surface_air__temperature" : "TMP_2maboveground",
"land_surface_wind__x_component_of_velocity" : "UGRD_10maboveground",
"land_surface_wind__y_component_of_velocity" : "VGRD_10maboveground",
"land_surface_radiation~incoming~longwave__energy_flux" : "DLWRF_surface",
"land_surface_radiation~incoming~shortwave__energy_flux" : "DSWRF_surface",
"land_surface_air__pressure" : "PRES_surface"
},
"uses_forcing_file": false
}
},
{
"name": "bmi_c++",
"params": {
"model_type_name": "bmi_smp",
"library_file": "./extern/SoilMoistureProfiles/SoilMoistureProfiles/cmake_build/libsmpbmi",
"init_config": "./extern/SoilMoistureProfiles/SoilMoistureProfiles/config/config_topmodel.txt",
"allow_exceed_end_time": true,
"main_output_variable": "soil_storage",
"variables_names_map" : {
"soil_storage" : "sloth_SOIL_STORAGE",
"soil_storage_change" : "sloth_SOIL_STORAGE_CHANGE",
"Qb_topmodel" : "land_surface_water__baseflow_volume_flux",
"Qv_topmodel" : "soil_water_root-zone_unsat-zone_top__recharge_volume_flux",
"global_deficit" : "soil_water__domain_volume_deficit"
},
"output_variables" : [
"soil_storage",
"soil_water_table"
],
"uses_forcing_file": false
}
}
],
"uses_forcing_file": false
}
}
],
"forcing": {
"path": "./extern/cfe/cfe/forcings/cat87_01Dec2015-.csv",
"provider": "CsvPerFeature"
}
}
}
}

0 comments on commit 235cdf9

Please sign in to comment.