Skip to content

Commit 83a16fe

Browse files
authored
Merge branch 'main' into contributor-agreement
2 parents d22c891 + c5261f0 commit 83a16fe

File tree

90 files changed

+4870
-2254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4870
-2254
lines changed

.github/workflows/testing.yml

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- name: Harden Runner
1919
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
2020
with:
21+
disable-sudo: false
2122
egress-policy: block
2223
allowed-endpoints: >
2324
azure.archive.ubuntu.com:80
@@ -30,6 +31,8 @@ jobs:
3031
3132
- name: Checkout Repository
3233
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
34+
with:
35+
persist-credentials: false
3336

3437
- name: Install linters
3538
run: |
@@ -47,16 +50,17 @@ jobs:
4750
build-netcdf:
4851
name: Build (${{ matrix.build_type }}; ${{ matrix.os }}; NetCDF=True)
4952
needs: lint
50-
runs-on: ubuntu-latest
53+
runs-on: ${{ matrix.os }}
5154
strategy:
55+
fail-fast: false
5256
matrix:
53-
os: [ ubuntu-latest, macos-latest ]
54-
build_type: [ Debug, Release ]
57+
os: [ "ubuntu-latest", "macos-latest" ]
58+
build_type: [ "Debug", "Release" ]
5559
steps:
5660
- name: Harden Runner
5761
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
5862
with:
59-
disable-sudo: true
63+
disable-sudo: false
6064
egress-policy: block
6165
allowed-endpoints: >
6266
azure.archive.ubuntu.com:80
@@ -68,29 +72,45 @@ jobs:
6872
6973
- name: Checkout Repository
7074
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
75+
with:
76+
persist-credentials: false
77+
78+
- name: Install NetCDF (Ubuntu/apt)
79+
if: matrix.os == 'ubuntu-latest'
80+
run: |
81+
sudo apt-get update
82+
sudo apt-get install -y libnetcdf-dev
83+
- name: Install NetCDF4 (macOS/homebrew)
84+
if: (matrix.os == 'macos-latest') && (!matrix.conda)
85+
uses: tecolicom/actions-use-homebrew-tools@b9c066b79607fa3d71e0be05d7003bb75fd9ff34 # v1.3.0
86+
with:
87+
tools: netcdf
88+
cache: "yes"
7189

7290
- name: Fetch NetCDF CMake script
7391
run: |
7492
wget https://raw.githubusercontent.com/Kitware/VTK/master/CMake/FindNetCDF.cmake -P cmake
7593
7694
- name: Build
7795
id: build
78-
continue-on-error: true
7996
run: |
80-
cmake .
81-
cmake --build . --config ${{ matrix.build_type }} -j 3
97+
mkdir build
98+
cd build
99+
cmake ..
100+
cmake --build . --config ${{ matrix.build_type }} -j 3 --verbose
82101
83102
- name: Run tests
84103
if: steps.build.outcome == 'success'
85104
run: |
86-
./Raven
87-
./Raven -v
105+
./build/Raven
106+
./build/Raven -v
88107
89108
build:
90109
name: Build (${{ matrix.build_type }}; ${{ matrix.os }}; NetCDF=False)
91110
needs: lint
92-
runs-on: ubuntu-latest
111+
runs-on: ${{ matrix.os }}
93112
strategy:
113+
fail-fast: false
94114
matrix:
95115
os: [ ubuntu-latest, macos-latest, windows-latest ]
96116
build_type: [ Debug, Release ]
@@ -113,19 +133,28 @@ jobs:
113133
114134
- name: Checkout Repository
115135
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
136+
with:
137+
persist-credentials: false
116138

117139
- name: Install dependencies (Windows)
118140
if: matrix.os == 'windows-latest'
119141
uses: lukka/get-cmake@2bcb1a4c14ab154443cc740dced0f9b6a8fb2b59 # v3.29.6
120142

121143
- name: Build
122144
id: build
123-
continue-on-error: true
124145
run: |
125-
cmake .
126-
cmake --build . --config ${{ matrix.build_type }} -j 3
146+
mkdir build
147+
cd build
148+
cmake ..
149+
cmake --build . --config ${{ matrix.build_type }} -j 3 --verbose
127150
128-
- name: Run tests
151+
- name: Run tests (Windows)
152+
if: ${{ matrix.os == 'windows-latest' && steps.build.outcome == 'success' }}
153+
run: |
154+
./build/${{ matrix.build_type }}/Raven.exe
155+
./build/${{ matrix.build_type }}/Raven.exe -v
156+
- name: Run tests (Ubuntu/macOS)
157+
if: ${{ matrix.os != 'windows-latest' && steps.build.outcome == 'success' }}
129158
run: |
130-
./Raven
131-
./Raven -v
159+
./build/Raven
160+
./build/Raven -v

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ Makefile
4141
# Runtime artifacts
4242
Raven
4343
Raven_errors.txt
44+
45+
# JetBrains
46+
.idea

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ default_language_version:
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.6.0
6+
rev: v5.0.0
77
hooks:
88
- id: check-json
99
- id: pretty-format-json
@@ -26,7 +26,7 @@ repos:
2626
# - id: include-what-you-use
2727

2828
- repo: https://github.com/python-jsonschema/check-jsonschema
29-
rev: 0.28.6
29+
rev: 0.30.0
3030
hooks:
3131
- id: check-github-workflows
3232
- repo: meta

CMakeLists.txt

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
cmake_minimum_required(VERSION 3.20)
22
# made with help from Zhu Liang-Jun of IGSNRR in Beijing
3-
# modified for GitHub by Trevor James Smith of Ouranos in Montreal
3+
# modified for GitHub and C++11 by Trevor James Smith of Ouranos in Montreal
4+
# modified for lpsolve support by Maxim Krassovski of DFO
5+
6+
# Set the C++ standard to C++11
7+
set(CMAKE_CXX_STANDARD 11)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
SET(CMAKE_CXX_EXTENSIONS OFF)
410

511
# optional cmake command line arguments (e.g, "cmake -D COMPILE_LIB=ON" .)
612
option(COMPILE_LIB "If ON, will create a dynamic lib file (default: OFF)" OFF)
713
option(COMPILE_EXE "If ON, will create a executable file (default: ON)" ON)
814
option(PYTHON, "If ON, will create a share library for python (default: OFF)" OFF)
15+
option(LPSOLVE, "If ON, will link to lp_solve optimization library (default: OFF)" OFF)
916

1017
# Setup Project
1118
PROJECT(Raven CXX)
@@ -14,15 +21,22 @@ PROJECT(Raven CXX)
1421
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
1522

1623
# Find NetCDF
17-
find_package(NetCDF)
24+
find_package(NetCDF) #may also be 'netCDF'
25+
if (NOT NetCDF_FOUND)
26+
message(STATUS "NetCDF not found, trying netCDF")
27+
find_package(netCDF)
28+
endif()
29+
30+
# Find HDF5
31+
find_package(HDF5)
1832

1933
# find header & source
2034
file(GLOB HEADER "src/*.h")
2135
file(GLOB SOURCE "src/*.cpp")
2236

2337
# Create library with Python bindings
2438
# To work, install pybind11, making sure it comes with cmake files (conda install -c conda-forge pybind11)
25-
if (PYTHON)
39+
if(PYTHON)
2640
SET(PYBIND11_NEWPYTHON ON)
2741
find_package(Python COMPONENTS REQUIRED Interpreter Development)
2842
find_package(pybind11 CONFIG REQUIRED)
@@ -43,15 +57,33 @@ if(COMPILE_EXE)
4357
${SOURCE}
4458
${HEADER}
4559
)
46-
target_compile_definitions(Raven PUBLIC STANDALONE)
4760
set_target_properties(Raven PROPERTIES LINKER_LANGUAGE CXX)
61+
62+
# Remove deprecation warnings for GCC
63+
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
64+
target_compile_options(Raven PRIVATE "-Wno-deprecated")
65+
message(STATUS "Modified compile flags with '-Wno-deprecated'")
66+
ENDIF()
67+
68+
if(LPSOLVE)
69+
target_link_directories(Raven PRIVATE lib/lp_solve) # where liblpsolve55.so is located
70+
target_link_libraries(Raven lpsolve55)
71+
add_definitions(-D_LPSOLVE_)
72+
endif()
4873
endif()
4974

50-
IF(NETCDF_FOUND)
75+
if(NETCDF_FOUND)
5176
add_definitions(-Dnetcdf)
5277
include_directories(${NetCDF_INCLUDE_DIRS})
5378
target_link_libraries(Raven NetCDF::NetCDF)
54-
ENDIF()
79+
elseif(netCDF_FOUND)
80+
add_definitions(-Dnetcdf)
81+
include_directories(${NetCDF_INCLUDE_DIRS})
82+
target_link_libraries(Raven netcdf)
83+
endif()
84+
85+
source_group("Header Files" FILES ${HEADER})
86+
source_group("Source Files" FILES ${SOURCE})
5587

5688
source_group("Header Files" FILES ${HEADER})
5789
source_group("Source Files" FILES ${SOURCE})

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
The code repository for the Raven Hydrological Modelling Framework developed at the University of Waterloo.
44

5-
Release versions, tutorials, documentation, and more distributed at [the Raven website](http://raven.uwaterloo.ca/Main.html).
5+
Release versions, tutorials, documentation, and more distributed at [the Raven website](https://raven.uwaterloo.ca/Main.html).
66

7-
Intended for use with Visual Studio Community Edition 2021, but also provided with Windows/linux/unix/MacOS g++ makefile and CMake configuration file.
7+
Intended for use with Visual Studio Community Edition 2022, but also provided with Windows/linux/unix/MacOS g++ makefile and CMake configuration file.
88

99
Note unconventional two-space tabbing conventions.
1010
If you would like to work with the active development of Raven's core, please do so on a branch and coordinate commits to the trunk with the Raven development team.
@@ -32,3 +32,4 @@ So that the ```cmake``` command to build Raven as solely a dynamic library becom
3232
```bash
3333
cmake -DCOMPILE_LIB=ON -DCOMPILE_EXE=OFF ../
3434
```
35+
Raven can alternately be bullt in unix/MacOS using the makefile provided with the source code (g++ must be installed on the machine). Lastly, it may be compiled within Visual Studio Community Edition 2022.

src/Advection.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ CmvAdvection::CmvAdvection(string constit_name,
2525
_constit_ind=pTransModel->GetConstituentIndex(constit_name);
2626

2727
int nAdvConnections =pTransModel->GetNumAdvConnections();
28+
int nWaterStores =pTransModel->GetNumWaterCompartments();
2829
CHydroProcessABC::DynamicSpecifyConnections(3*nAdvConnections+1);//+2 once GW added
30+
//CHydroProcessABC::DynamicSpecifyConnections(nAdvConnections+nWaterStores+1);//+2 once GW added
2931

3032
for (int q=0;q<nAdvConnections;q++) //for regular advection
3133
{
@@ -42,18 +44,29 @@ CmvAdvection::CmvAdvection(string constit_name,
4244
iFrom[2*nAdvConnections+q]=pModel->GetStateVarIndex(CONSTITUENT_SRC,_constit_ind);
4345
iTo [2*nAdvConnections+q]=iTo[q];
4446
}
47+
//for Dirichlet source corrections
48+
//for (int ii = 0; ii < nWaterStores; ii++) {
49+
// iFrom[nAdvConnections+ii]=pModel->GetStateVarIndex(CONSTITUENT_SRC,_constit_ind);
50+
// iTo [nAdvConnections+ii]=pTransModel->GetStorWaterIndex(ii);
51+
// }
52+
4553
//advection into surface water
4654
int iSW=pModel->GetStateVarIndex(SURFACE_WATER);
4755
int m=pTransModel->GetLayerIndex(_constit_ind,iSW);
4856
iFrom[3*nAdvConnections]=pModel->GetStateVarIndex(CONSTITUENT,m);
4957
iTo [3*nAdvConnections]=pModel->GetStateVarIndex(CONSTITUENT_SW,0);
5058

59+
//iFrom[nAdvConnections+nWaterStores]=pModel->GetStateVarIndex(CONSTITUENT,m);
60+
//iTo [nAdvConnections+nWaterStores]=pModel->GetStateVarIndex(CONSTITUENT_SW,0);
61+
5162
//advection into groundwater
5263
//int iGW=pModel->GetStateVarIndex(GROUNDWATER);
5364
//int m=pTransModel->GetLayerIndex(constit_ind,iGW);
5465
//iFrom[3*nAdvConnections+1]=pModel->GetStateVarIndex(CONSTITUENT,m);
5566
//iTo [3*nAdvConnections+1]=pModel->GetStateVarIndex(CONSTITUENT_GW,0);
5667

68+
//iFrom[nAdvConnections+nWaterStores+1]=pModel->GetStateVarIndex(CONSTITUENT,m);
69+
//iTo [nAdvConnections+nWaterStores+1]=pModel->GetStateVarIndex(CONSTITUENT_SW,0);
5770
}
5871

5972
//////////////////////////////////////////////////////////////////
@@ -223,6 +236,8 @@ void CmvAdvection::GetRatesOfChange(const double *state_vars,
223236
mass =sv[iFrom[q]];
224237
dirichlet_mass=Cs*sv[iFromWater]; //Cs*V
225238
rates[nAdvConnections+q]+=(dirichlet_mass-mass)/Options.timestep; //From CONSTITUENT_SRC
239+
//iiFromWater=pTransModel->GetWaterStorIndexFromSVIndex(iFromWater);
240+
//rates[nAdvConnections+iiFromWater]+=(dirichlet_mass-mass)/Options.timestep; //From CONSTITUENT_SRC //JRC: Reduced memory edit (or _aStorIndex[iFromWater])
226241
sv[iFrom[q]]=dirichlet_mass; //override previous mass/enthalpy
227242
}
228243

@@ -237,6 +252,8 @@ void CmvAdvection::GetRatesOfChange(const double *state_vars,
237252
mass =sv[iTo[q]];
238253
dirichlet_mass=Cs*sv[iToWater]; //C*V
239254
rates[2*nAdvConnections+q]+=(dirichlet_mass-mass)/Options.timestep; //From CONSTITUENT_SRC
255+
//iiToWater=pTransModel->GetWaterStorIndexFromSVIndex(iToWater);
256+
//rates[nAdvConnections+iiToWater]+=(dirichlet_mass-mass)/Options.timestep; //From CONSTITUENT_SRC //JRC: Reduced memory edit (or _aStorIndex[iFromWater] of size _nWaterStores)
240257
sv[iTo[q]]=dirichlet_mass; //override previous mass/enthalpy
241258
}
242259

0 commit comments

Comments
 (0)