Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for v4.0.0 release #573

Open
wants to merge 1,628 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1628 commits
Select commit Hold shift + click to select a range
12da1b1
change to snow balance is realMissing if never a snow state in the da…
ashleymedin Apr 18, 2024
2d1dfa7
should have removed these lines for last commit
ashleymedin Apr 18, 2024
31faaa4
change lyr_wght
ashleymedin Apr 18, 2024
065e137
clean up aquiferIni decision
ashleymedin Apr 18, 2024
38c053d
part of last commit
ashleymedin Apr 19, 2024
b3dfc19
utils
ashleymedin Apr 21, 2024
d9fcaee
utils
ashleymedin Apr 22, 2024
5dfabef
utils
ashleymedin Apr 22, 2024
a9e519e
Merge pull request #37 from KyleKlenk/develop
ashleymedin Apr 1, 2024
5c528c9
Merge branch 'ent_state' into develop
ashleymedin Apr 23, 2024
d3bf8c8
clean up cmakelists
ashleymedin Apr 23, 2024
aaed30b
cleanup cmakelist
ashleymedin Apr 23, 2024
6ee8edc
utils
ashleymedin Apr 25, 2024
a7ed31b
utils
ashleymedin Apr 25, 2024
0f075cd
utils
ashleymedin Apr 25, 2024
7507014
utils
ashleymedin Apr 25, 2024
510ada8
utils
ashleymedin Apr 25, 2024
4acf271
Edit cmake lists file to reflect updates to summa-actors, and adjust …
KyleKlenk Apr 25, 2024
28be39a
utils
ashleymedin Apr 26, 2024
d0044eb
utils
ashleymedin Apr 26, 2024
2b8fee5
comment clafication
ashleymedin Apr 29, 2024
00bcd1a
jacobian terms for water enthalpy state vec were incorrect
ashleymedin Apr 29, 2024
08880df
typo
ashleymedin Apr 29, 2024
5b2c3a9
something got screwed up in merge, jacobian enthalpy state now correct
ashleymedin Apr 29, 2024
fdd97ce
Merge pull request #39 from KyleKlenk/develop
ashleymedin Apr 29, 2024
d6ced60
valgrind detected error
ashleymedin Apr 29, 2024
8d4bc05
fix an error message, no code change
ashleymedin Apr 30, 2024
23508f0
have to add canopy values to ida call because even though does not sp…
ashleymedin Apr 30, 2024
5ff8a02
do not need to hold on to liquid or ice because we aren't currently s…
ashleymedin Apr 30, 2024
6de4cca
Adjustments to cmakelists
KyleKlenk Apr 30, 2024
9609fb4
utils for latest paper tag
ashleymedin May 7, 2024
4eb66dc
Merge remote-tracking branch 'ashley/develop' into develop
KyleKlenk May 8, 2024
43fdee0
Updated CMakeLists.txt
KyleKlenk May 8, 2024
6784ca9
Merge pull request #40 from KyleKlenk/develop
ashleymedin May 9, 2024
d8855f6
Fix issue where sundials cannot be found
KyleKlenk May 10, 2024
7f2257c
Fix inclusion of gru actor
KyleKlenk May 10, 2024
08b3049
Merge remote-tracking branch 'ashley/develop' into develop
KyleKlenk May 13, 2024
35e6f13
Renamed summaSolve4numrec.f90 to summaSolve4homegrown.f90.
seantrim May 15, 2024
df3cd12
Added summaSolve4homegrown.f90 to git tracking.
seantrim May 15, 2024
b0cb684
Updates to systemSolv and summaSolv4homegrown to reflect new homegrow…
seantrim May 15, 2024
50c396a
Add extra output variables for sundials functions
KyleKlenk May 15, 2024
905f085
Merge pull request #559 from ashleymedin/develop
wknoben May 16, 2024
05d462a
Applied the homegrown label to class definitions and procedures used …
seantrim May 16, 2024
5f7750d
Updated the comments in multiple routines to clarify references to nu…
seantrim May 16, 2024
e427514
Merge pull request #41 from seantrim/develop_refactor_Newton
ashleymedin May 17, 2024
cdc41c8
get rid of numrec decision and homegrown
ashleymedin May 17, 2024
1c4531d
numrec decision still in there for backwards comp, remove if okay to
ashleymedin May 17, 2024
2755c68
adjusted cmakelist
KyleKlenk May 20, 2024
522db23
remove numrec decision, now use homegrown (or itertive)
ashleymedin May 22, 2024
f71ff46
update builds to StdEnv 2023
ashleymedin May 22, 2024
440e5f7
Set up parameters controled by summa param txt file for sundials solver
KyleKlenk May 22, 2024
cf8b872
Merge remote-tracking branch 'ashley/develop' into develop
KyleKlenk May 23, 2024
6ccaaa4
Reworked CMakeList.txt files to avoid hardcoded paths
KyleKlenk May 23, 2024
e1abf61
Add ability to find path on cluster
KyleKlenk May 23, 2024
ba75a7e
Cleaned up documentation in CMakeLists.txt file
KyleKlenk May 23, 2024
d12956f
Merge pull request #42 from KyleKlenk/develop
ashleymedin May 24, 2024
c8d308b
update make
ashleymedin May 24, 2024
58e8d94
name is NextGen not NexGen
ashleymedin May 24, 2024
54a02d8
capital letter
ashleymedin May 24, 2024
558311c
fixing Cmake
ashleymedin May 24, 2024
ad1a9d7
Merge branch 'develop' of https://github.com/ashleymedin/summa into d…
ashleymedin May 24, 2024
3f0ca58
linking
ashleymedin May 24, 2024
4db8e11
Merge remote-tracking branch 'refs/remotes/origin/develop' into develop
ashleymedin May 24, 2024
eb3ddd1
remove unnecessary module import
KyleKlenk May 24, 2024
8555928
Adjust default value for errTestFailures:
KyleKlenk May 29, 2024
8472fad
fix for if canopyLiq goes negative inside sundials solver, will give …
ashleymedin May 29, 2024
a543572
add comments to last bug fix
ashleymedin May 29, 2024
b65a0ed
utils
ashleymedin May 30, 2024
d1350c2
utils
ashleymedin Jun 1, 2024
f03d596
Fix cmake lists for nextGEN:
KyleKlenk Jun 3, 2024
aa8ef3d
Add file for nextGen compiling:
KyleKlenk Jun 3, 2024
e182fd1
fixed CMake
ashleymedin Jun 4, 2024
8266484
cmake, need non-ngen bit
ashleymedin Jun 6, 2024
d3a243a
quadratic smoother in canopy wetting, may work better?
ashleymedin Jun 6, 2024
3608dc9
logistic smoother on theta instead of function, then do not have to c…
ashleymedin Jun 6, 2024
df52b67
option to use smoother as logistic or quadratic, setting to logistic …
ashleymedin Jun 7, 2024
c7fd3fc
Starting conversion to V1 of CAF
KyleKlenk Jun 7, 2024
fae58e8
Bug fix: with the addition of the Cm term, the solution became more u…
ashleymedin Jun 11, 2024
57f1ba2
Current cmake_lists file represents what has been converted to CAF ve…
KyleKlenk Jun 12, 2024
fedff34
Remove Summa-Actors specific files from cmakelist.txt for summa non-a…
KyleKlenk Jun 17, 2024
d98313b
Merge remote-tracking branch 'ashley/develop' into caf_v1_changes
KyleKlenk Jun 19, 2024
bbd2c25
Merge pull request #44 from KyleKlenk/caf_v1_changes
ashleymedin Jun 20, 2024
0d0953d
cmake example
ashleymedin Jun 20, 2024
6a6f3d2
Merge branch 'develop' of https://github.com/ashleymedin/summa into d…
ashleymedin Jun 20, 2024
da875af
Remove left over actors commands from CMake. Left instructions and li…
KyleKlenk Jun 20, 2024
3d8488e
Merge pull request #45 from KyleKlenk/caf_v1_changes
ashleymedin Jun 21, 2024
e4b226f
just utils
ashleymedin Jun 28, 2024
1d8e2fb
turn on logical(lgt),parameter :: updateCp_closedForm=.tru…
ashleymedin Jun 28, 2024
f77ab88
Merge pull request #567 from ashleymedin/develop
wknoben Jun 28, 2024
56164f4
utils
ashleymedin Jul 1, 2024
5fd0a52
utils
ashleymedin Jul 2, 2024
c463f4c
utils
ashleymedin Jul 4, 2024
a072af1
utils
ashleymedin Jul 4, 2024
49733d9
utils
ashleymedin Jul 8, 2024
2e05f0d
utils
ashleymedin Jul 8, 2024
088943f
utils
ashleymedin Jul 19, 2024
4285fc6
change mass balance to be kg/m3 if possible, so just need to divide b…
ashleymedin Jul 19, 2024
7bdd107
fix error messages
ashleymedin Jul 24, 2024
6ba6c50
conductance error bug
ashleymedin Jul 25, 2024
0365ef1
Merge pull request #570 from ashleymedin/develop
wknoben Jul 25, 2024
f55056a
remove some utils
ashleymedin Jul 29, 2024
3173cda
Got rid of a bunch of stuff we were not using
ashleymedin Jul 29, 2024
1ef08ef
update decisions
ashleymedin Jul 29, 2024
8bfb783
update laugh test notes
ashleymedin Jul 29, 2024
0468a90
add generate cold state to utils, old file, may want to modify
ashleymedin Jul 29, 2024
a70a097
update readme for utils and explain changes to code
ashleymedin Jul 29, 2024
37ba2af
utils, was wrong file
ashleymedin Jul 29, 2024
fc6a2ca
fixing list of changes, no code change
ashleymedin Jul 30, 2024
16c3cdd
utils
ashleymedin Jul 30, 2024
a69bf44
Update CMakeLists.txt
KyleKlenk Aug 8, 2024
e4a33ab
Merge pull request #46 from ashleymedin/KyleKlenk-patch-1
ashleymedin Aug 10, 2024
e7f2b3d
Reorg utils folder to separate dockerfiles from post processing utili…
KyleKlenk Aug 30, 2024
28c5ba6
Created dockerfile to create summa container
KyleKlenk Aug 30, 2024
a2c8279
Got one succesful compile in docker
KyleKlenk Sep 5, 2024
b098ea3
Can run a synthetic test
KyleKlenk Sep 6, 2024
8152903
Can run with sundials and non-sundials builds of summa in debug mode.…
KyleKlenk Sep 6, 2024
9b42243
missed a check in the Jacobian
ashleymedin Sep 11, 2024
6f8731a
Merge remote-tracking branch 'ashley/develop' into openwq
KyleKlenk Sep 12, 2024
946ffff
Testing summa-openwq on older fortran compiler
KyleKlenk Sep 12, 2024
b37b40c
Merge pull request #47 from KyleKlenk/openwq
ashleymedin Sep 12, 2024
8cf1e6f
utils
ashleymedin Sep 18, 2024
a828022
lower lower-bound on temp from enthalpy calculations. move around utils
ashleymedin Sep 18, 2024
74aebf4
fixing enthalpy
ashleymedin Sep 19, 2024
e304a45
enthalpy as state variable fixes
ashleymedin Sep 19, 2024
78f7712
enthalpy state var, make it bail with -1e6 as the temp if can't brack…
ashleymedin Sep 19, 2024
a943ec8
change lower bound to 0
ashleymedin Sep 19, 2024
5c8f5f9
change lower bound error
ashleymedin Sep 20, 2024
48630a5
vapor pressure 0 will give a nan inside stomata
ashleymedin Sep 23, 2024
46bcc66
fix overwrite of cmake prefix path
ashleymedin Sep 23, 2024
5c8128a
lower bound 0, change merge criterion to be just on enthalpy
ashleymedin Sep 24, 2024
503457a
fix nan Jacobian error message
ashleymedin Sep 24, 2024
a0ea6d0
make bracketing smarter
ashleymedin Sep 24, 2024
9f84ec0
fixing brackets
ashleymedin Sep 24, 2024
4e8e9a9
debugging bracket
ashleymedin Sep 25, 2024
6ae495a
debug brackets
ashleymedin Sep 25, 2024
fabb57f
fixing bracketing
ashleymedin Sep 25, 2024
91219ac
build scripts
ashleymedin Sep 26, 2024
500dc66
not working
ashleymedin Sep 26, 2024
f32909a
need to get the -llapack or is slow
ashleymedin Sep 26, 2024
feb89e0
Merge branch 'enth_largeTol' into develop
ashleymedin Sep 26, 2024
cc523d4
comment in CmakeLists
ashleymedin Sep 26, 2024
5de103d
computFlux needs err quitting done after every subroutine
ashleymedin Sep 26, 2024
c55b27d
Merge pull request #574 from ashleymedin/develop
wknoben Sep 27, 2024
75f35b9
fixing mac omp threading
ashleymedin Sep 30, 2024
d2534c5
don't send out error message if negative
ashleymedin Sep 30, 2024
385e77b
make enthalpy progressive variable so can be in restart file
ashleymedin Sep 30, 2024
b40d091
Fix bug with soilRelHumidity going more than 1
ashleymedin Sep 30, 2024
06380e9
fix scalarSoilRelHumidity for cold
ashleymedin Oct 1, 2024
fd4f5b8
utils to include enthalpy form
ashleymedin Oct 1, 2024
ff83e89
utils should be on kg/ m3 /s now
ashleymedin Oct 1, 2024
4dbfea4
need to calculate balances for veg only if computed veg
ashleymedin Oct 1, 2024
bd82132
make balances missing if not compute
ashleymedin Oct 1, 2024
cd8f61e
utils
ashleymedin Oct 2, 2024
04b4939
utils
ashleymedin Oct 2, 2024
ebfe0c2
utils
ashleymedin Oct 3, 2024
7dc924b
Updates to parent CMakeLists.txt and build.pc.bash -- LIBRARY_LINKS e…
seantrim Oct 5, 2024
d8953b3
Build updates -- expanded debug build compiler options.
seantrim Oct 7, 2024
b67a101
Updated soil_utils to avoid division by zero and unintended complex v…
seantrim Oct 8, 2024
819b459
Updates to debug build - optimization level changed for best debugger…
seantrim Oct 8, 2024
540c7d2
Updates to avoid a segmentation fault within stateFilter.
seantrim Oct 8, 2024
cfed33f
Update to soil_utils - parameter used to avoid floating-point excepti…
seantrim Oct 8, 2024
dba01ed
use openBLAS and fix threading to 1
ashleymedin Oct 8, 2024
5cc7151
fixing restart file to have hruId and gruId
ashleymedin Oct 9, 2024
a0a0e1d
Added -DSPECIFY_LAPACK_LINKS build option so that user-specified LAPA…
seantrim Oct 9, 2024
65e6033
Merge branch 'openBlas_threading_fix' into develop
ashleymedin Oct 10, 2024
a834707
a bit more removed for openBLAS default
ashleymedin Oct 10, 2024
b7a3239
Added ifx compoiler flags for release builds -- some derived type def…
seantrim Oct 10, 2024
d9f5e78
Minor change to opSplittin for array assignment.
seantrim Oct 10, 2024
3db9f2e
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 10, 2024
941b4ca
Enabled LIBRARY_LINKS environment variable in link stages for SUMMA o…
seantrim Oct 10, 2024
3a2108f
Update to CMake so that serial OpenBLAS is loaded using find_package …
seantrim Oct 10, 2024
5d0cc50
Merge pull request #48 from seantrim/SUMMA-ROO
ashleymedin Oct 10, 2024
35ce7b5
Removed (or commented out) unused variables detected by gcc 13.2.0.
seantrim Oct 11, 2024
c0c450b
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 11, 2024
c0eba73
Removed non-conforming tab characters - replaced with standard space …
seantrim Oct 11, 2024
83687a8
bug in enthalpy restart
ashleymedin Oct 11, 2024
7cc5025
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 12, 2024
7fd55a1
Added initialize_coupled_em internal subroutine to remedy potential u…
seantrim Oct 12, 2024
d614991
Initialization added for error code.
seantrim Oct 12, 2024
b3d2e77
Initialize derivative value.
seantrim Oct 12, 2024
76d0e10
Removed unused variables from opSplittin.
seantrim Oct 12, 2024
77f7628
fixing build for mac
ashleymedin Oct 15, 2024
01728e0
fixing cmake for mac
ashleymedin Oct 15, 2024
15cd5f6
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 16, 2024
d4ef8c9
spaces
ashleymedin Oct 16, 2024
c3eab85
Added checks for memory allocation and updated syntax to avoid uninte…
seantrim Oct 17, 2024
1e8b44d
Updates to compiler flags: debug checks were expanded, frecursive add…
seantrim Oct 17, 2024
f5cc1e5
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 17, 2024
9044978
Merge pull request #49 from seantrim/SUMMA-ROO
ashleymedin Oct 18, 2024
141b580
remove commented out variables
ashleymedin Oct 18, 2024
724336e
get nSubset
ashleymedin Oct 18, 2024
5e72a98
Added initialize and finalize routines for summa_driver.f90.
seantrim Oct 18, 2024
52fe244
now the user needs to create a file named "openwq_mainJSONFile_fullPa…
Oct 18, 2024
5baeee7
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 19, 2024
a649d90
Added update step for summa_driver.f90.
seantrim Oct 19, 2024
e376278
removing arguments that are unnecessary
ashleymedin Oct 21, 2024
7c840f6
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 22, 2024
22cc168
Merge pull request #50 from ue-hydro/develop
ashleymedin Oct 22, 2024
5c38c01
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 22, 2024
9f5b5c1
name of openWQ module misspelled
ashleymedin Oct 22, 2024
35afb25
Fail-safe to avoid an infinite loop for unforeseen errors in split_se…
seantrim Oct 22, 2024
8b0984a
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 22, 2024
be57e3b
Applied initialize-update-finalize sequence to opSplittin module subr…
seantrim Oct 23, 2024
84a8c64
Added initialize_split, update_split, and finalize_split internal sub…
seantrim Oct 23, 2024
298c9c2
Implementation of initialize_split, update_split, and finalize_split …
seantrim Oct 24, 2024
3e8062f
fixing initialize_coupled_em
ashleymedin Oct 24, 2024
57620ae
Simplified treatment of logical flags for control of main loop in opS…
seantrim Oct 25, 2024
7593c12
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 25, 2024
748f801
Refactoring the main loop in opSplittin using the initialize-update-f…
seantrim Oct 25, 2024
a7ec124
Removed extraneous code and updated comments related to refactoring i…
seantrim Oct 26, 2024
6bfe64c
Updated location of error control for max iterations of split_select_…
seantrim Oct 26, 2024
ecb74c5
Added intent attribute for firstInnerStep dummy variable in opSplittin.
seantrim Oct 26, 2024
1fae3ef
Removed unused module use statements and parameterms in opSplittin.f90.
seantrim Oct 29, 2024
206d600
Cosmetic updates to summa_driver.f90.
seantrim Oct 29, 2024
6b9d1df
Merge pull request #51 from seantrim/SUMMA-ROO
ashleymedin Oct 30, 2024
de21dbf
Updated stateFilter argument list to utilize split_select object.
seantrim Oct 30, 2024
3cf0cb7
Merge branch 'develop' of https://github.com/ashleymedin/summa into S…
seantrim Oct 31, 2024
e6a0e27
Merge pull request #52 from seantrim/SUMMA-ROO
ashleymedin Nov 1, 2024
a8e71d9
Removed nSubset data component from out_stateFilter object -- code us…
seantrim Nov 1, 2024
17ceb25
Removed in_type_stateFilter class and in_stateFilter object -- split_…
seantrim Nov 1, 2024
2da57f1
Merge pull request #53 from seantrim/SUMMA-ROO
ashleymedin Nov 4, 2024
36a08ff
Updated the initialize-update-finalize structure within summaSolve4ho…
seantrim Nov 15, 2024
c0067ee
Merge pull request #54 from seantrim/SUMMA-ROO
ashleymedin Nov 17, 2024
9b2fb7f
Merge pull request #576 from ashleymedin/develop
wknoben Nov 17, 2024
a09eb16
capping functions in canopy energy so negative temps inside solver do…
ashleymedin Dec 5, 2024
e928e4f
possible for dh to be 0 and cause Nan here
ashleymedin Dec 5, 2024
2f740f4
expanded veg table size for Ignacio's Plumber data
ashleymedin Jan 8, 2025
042dc07
Merge pull request #577 from ashleymedin/develop
wknoben Jan 8, 2025
53c79ae
rooting depth > soil depth now makes warning
ashleymedin Jan 10, 2025
0fc37a8
warning message
ashleymedin Jan 10, 2025
8b82d6e
Merge pull request #578 from ashleymedin/develop
wknoben Jan 10, 2025
8b276db
remove unnecessary module
ashleymedin Jan 10, 2025
a8677ad
Change minstep to be read from the parameters file
ijaguirre Jan 19, 2025
fd93127
Merge pull request #1 from ijaguirre/minstep_fix
ijaguirre Jan 19, 2025
ed5b9c0
Merge pull request #55 from ijaguirre/develop
ashleymedin Jan 21, 2025
bcb5f6b
put in check for ground and canopy roughnesses
ashleymedin Jan 22, 2025
829615c
fixing param defs and so be_steps only applies to BE solvers
ashleymedin Jan 22, 2025
794fa4b
prints
ashleymedin Jan 22, 2025
65fa06f
prints
ashleymedin Jan 23, 2025
5d56e40
bug fix for Cm term
ashleymedin Jan 24, 2025
6c0d0a5
these fixes should sort scalar splitting for everything but scalarSoi…
ashleymedin Jan 27, 2025
f23dacb
forcing baseflow to be a value
ashleymedin Jan 27, 2025
1b172f4
flxMapping
ashleymedin Jan 27, 2025
1621b5a
fix typos, deal with baseflow
ashleymedin Jan 27, 2025
4d7e33c
Revert "forcing baseflow to be a value"
ashleymedin Jan 27, 2025
13648e2
reverse all prints
ashleymedin Jan 27, 2025
b5b8d31
fixing the scalar splitting for balance checks
ashleymedin Jan 27, 2025
c01e054
Merge pull request #579 from ashleymedin/develop
wknoben Jan 28, 2025
bcf1488
missed param
ashleymedin Jan 28, 2025
c1f7d1e
Merge pull request #580 from ashleymedin/develop
wknoben Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# summa executable and bin directory
bin
summa.exe
summa_sundials.exe
# temporary files
*~
*.swp
Expand All @@ -27,6 +28,7 @@ summa.exe
*.layout
gmon.out
summa.exe.dSYM*
summa_sundials.exe.dSYM*
summaversion.inc
# makefile
make.out
Expand All @@ -35,3 +37,9 @@ Makefile-*
*.backup
# site directory from mkdocs
site/
Laugh-Tests/
# cmake_build containing cmake build objects
build/cmake_build
runinfo.txt
# OpenWQ source code
build/source/openwq/openwq
36 changes: 0 additions & 36 deletions Dockerfile

This file was deleted.

237 changes: 237 additions & 0 deletions build/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(summa VERSION 4.0.0 LANGUAGES Fortran C CXX)

if(DEFINED ENV{FC})
set (CMAKE_Fortran_COMPILER $ENV{FC}) #for NextGen need, works for others
else()
set (CMAKE_Fortran_COMPILER gfortran)
endif()

#=========================================================================================
# SUMMA can be compiled with debug flags by specifiying -DCMAKE_BUILD_TYPE=Debug
#
# There are multiple options for building SUMMA, including using the
# Sundials suite of solvers and the NextGen framework.
# The options are set by specifying -DOPTION=ON when running cmake.
# For example to compile SUMMA with Sundials, use
# cmake -B ../cmake_build -S ../. -DUSE_SUNDIALS=ON
# cmake --build ../cmake_build --target all -j
#
# To compile SUMMA with Actors, see the Summa-Actors repo:
# https://github.com/uofs-simlab/Summa-Actors
#=========================================================================================

# Add options for build type
set(CMAKE_CONFIGURATION_TYPES Release Debug)

# Options: Enable each with cmake -DOPTION=ON
option(USE_SUNDIALS "Use IDA solver from SUNDIALS suite" OFF)
option(USE_NEXTGEN "Use NextGen Framework" OFF)
option(USE_OPENWQ "Use OpenWQ Framework" OFF)
set(EXT_TARGETS) # list of external targets to link to

# Set Default Executable Name
set(EXEC_NAME summa.exe)
# Set top-level directory
if (USE_NEXTGEN)
set(F_MASTER "${CMAKE_CURRENT_SOURCE_DIR}/summa")
else()
set(F_MASTER "${CMAKE_CURRENT_SOURCE_DIR}/..")
endif()

set(PARENT_DIR "${F_MASTER}")
set(EXEC_DIR "${F_MASTER}/bin")

# Handle optional external libraries
if (USE_SUNDIALS)
message("ENABLING SUNDIALS")
find_package(SUNDIALS REQUIRED)
list(APPEND EXT_TARGETS SUNDIALS::fida_mod_shared
SUNDIALS::fkinsol_mod_shared)
add_compile_definitions(SUNDIALS_ACTIVE)
set(EXEC_NAME summa_sundials.exe)
endif()

if (USE_NEXTGEN)
message("ENABLING NEXTGEN")
add_compile_definitions(NGEN_ACTIVE BMI_ACTIVE NGEN_FORCING_ACTIVE
NGEN_OUTPUT_ACTIVE)
add_subdirectory(../iso_c_fortran_bmi ${CMAKE_BINARY_DIR}/iso_c_bmi)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/summa/build/cmake/")
list(INSERT CMAKE_PREFIX_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/summa/build/cmake/")
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/fortran)
set(SUMMA_LIB_NAME_CMAKE summabmi)
set(SUMMA_LIB_DESC_CMAKE "Summa-Sundials BMI Module Shared Library")
else()
LIST(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake/")
LIST(INSERT CMAKE_PREFIX_PATH 0 "${CMAKE_SOURCE_DIR}/cmake/")
endif()

# OpenWQ Framework
if (USE_OPENWQ)
message("ENABLING OPENWQ")
add_compile_definitions(OPENWQ_ACTIVE)
if (USE_SUNDIALS)
set(EXEC_NAME summa_sundials_openwq.exe)
else()
set(EXEC_NAME summa_openwq.exe)
endif()
endif()


get_filename_component(F_MASTER "${F_MASTER}" REALPATH)
get_filename_component(PARENT_DIR "${PARENT_DIR}" REALPATH)
get_filename_component(EXEC_DIR "${EXEC_DIR}" REALPATH)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXEC_DIR})

#=========================================================================================
# SET THE PATHS TO THE LIBRARIES AND INCLUDE FILES
#=========================================================================================

# NetCDF is found with a custom FindNetCDF.cmake file
find_package(NetCDF REQUIRED)
list(APPEND EXT_TARGETS NetCDF::NetCDF)

# Find LAPACK with user-specified links or automatic detection
option(SPECIFY_LAPACK_LINKS "Use specified LAPACK links" OFF)
if(SPECIFY_LAPACK_LINKS)
message("Using LAPACK links from LIBRARY_LINKS environment variable")
if(DEFINED ENV{LIBRARY_LINKS})
set(LIBRARY_LINKS $ENV{LIBRARY_LINKS})
else()
message(FATAL_ERROR "LIBRARY_LINKS environment variable not found. Set this variable or try -DSPECIFY_LAPACK_LINKS=OFF in build file.")
endif()
else()
message("Automatically detect LAPACK links")
set(LIBRARY_LINKS "")

# OpenBLAS
set(BLA_VENDOR OpenBLAS)
find_package(OpenBLAS REQUIRED COMPONENTS serial)
list(APPEND EXT_TARGETS OpenBLAS::OpenBLAS)
endif()

# Set compiler flags
set(FLAGS_OPT $ENV{FLAGS_OPT}) # get optional user-specified flags from environment variables
if(CMAKE_BUILD_TYPE MATCHES Debug)
message("\nSetting SUMMA Debug Options")
add_compile_definitions(DEBUG)
# Notes: - optimization -Og is selected here to maximize information displayed in debugging software (e.g., gdb)
# - however, it may be useful to vary the optimization level to test for optimization related issues
set(FLAGS_NOAH -g -Og -fbacktrace -Wall -fcheck=all,no-array-temps -Wfatal-errors -ffree-line-length-none -fPIC -ffree-form ${FLAGS_OPT})
set(FLAGS_ALL -g -Og -fbacktrace -Wall -fcheck=all,no-array-temps -Wfatal-errors -ffree-line-length-none -fPIC -cpp -frecursive ${FLAGS_OPT})
set(FLAGS_CXX -g -Og -fbacktrace -Wall -fcheck=all,no-array-temps -Wfatal-errors -std=c++17 ${FLAGS_OPT})
else()
message("\nSetting SUMMA Release Options")
if (CMAKE_Fortran_COMPILER MATCHES gfortran)
set(FLAGS_NOAH -O3 -Wfatal-errors -ffree-line-length-none -fPIC -ffree-form ${FLAGS_OPT})
set(FLAGS_ALL -O3 -Wfatal-errors -ffree-line-length-none -fPIC -cpp -frecursive ${FLAGS_OPT})
set(FLAGS_CXX -O3 -Wfatal-errors -std=c++17 ${FLAGS_OPT})
else(CMAKE_Fortran_COMPILER MATCHES ifx) # ifx does not currently compile SUMMA -- derived type modifications needed in source code
set(FLAGS_NOAH -O3 -heap-arrays -fPIC -free ${FLAGS_OPT})
set(FLAGS_ALL -O3 -heap-arrays -fPIC -cxxlib ${FLAGS_OPT})
set(FLAGS_CXX -O3 -std=c++17 ${FLAGS_OPT})
endif()
endif()

#=========================================================================================
# COMPILE PART 1: Define directory paths
#=========================================================================================

# Define directories that contains source code
set(DRIVER_DIR ${F_MASTER}/build/source/driver)
set(DSHARE_DIR ${F_MASTER}/build/source/dshare)
set(ENGINE_DIR ${F_MASTER}/build/source/engine)
set(HOOKUP_DIR ${F_MASTER}/build/source/hookup)
set(NETCDF_DIR ${F_MASTER}/build/source/netcdf)
set(NOAHMP_DIR ${F_MASTER}/build/source/noah-mp)

#=========================================================================================
# COMPILE PART 2: Assemble all of the SUMMA sub-routines
#=========================================================================================

# SUMMA Source Files are defined in the CMakeLists.txt file in the subdirectory
add_subdirectory(${F_MASTER}/build/source/)


#=========================================================================================
# COMPILE PART 3: Collect the subroutines into build groups depending on build type
#=========================================================================================

set(COMM_ALL ${NRPROC} ${HOOKUP} ${DATAMS} ${UTILMS})
set(SUMMA_ALL ${NETCDF} ${PRELIM} ${MODRUN} ${SOLVER} ${DRIVER})
set(MAIN_SUMMA ${DRIVER_DIR}/summa_driver.f90)

if (USE_NEXTGEN)
set(SUMMA_ALL ${SUMMA_ALL} ${DRIVER_NEXTGEN})
endif()

if (USE_SUNDIALS)
set(COMM_ALL ${COMM_ALL} ${DATAMS_SUNDIALS} ${UTILMS_SUNDIALS})
set(SUMMA_ALL ${SUMMA_ALL} ${MODRUN_SUNDIALS} ${SOLVER_SUNDIALS})
endif()

if (USE_OPENWQ)
add_subdirectory(${F_MASTER}/build/source/openwq)
if (DEFINED OPENWQ_ERROR)
message(FATAL_ERROR "OpenWQ build failed")
endif()
set(SUMMA_ALL ${SUMMA_ALL} ${OPENWQ_COUPLER})
list(APPEND EXT_TARGETS openWQ)
endif ()


# Define version number, not working correctly
set(VERSIONFILE ${DRIVER_DIR}/summaversion.inc)
execute_process(COMMAND " ${GIT_EXECUTABLE} tag | tail -n 1" OUTPUT_VARIABLE VERSION)
execute_process(COMMAND "date" OUTPUT_VARIABLE BULTTIM)
execute_process(COMMAND " ${GIT_EXECUTABLE} describe --long --all --always | sed -e's/heads\///'" OUTPUT_VARIABLE GITBRCH)
execute_process(COMMAND " ${GIT_EXECUTABLE} rev-parse HEAD" OUTPUT_VARIABLE GITHASH)


#=========================================================================================
# COMPILE PART 4: Do the compilation
#=========================================================================================

# update version information, not working correctly
file(WRITE ${VERSIONFILE} "character(len=64), parameter :: summaVersion = '${VERSION}'\n")
file(APPEND ${VERSIONFILE} "character(len=64), parameter :: buildTime = ''\n")
file(APPEND ${VERSIONFILE} "character(len=64), parameter :: gitBranch = '${GITBRCH}'\n")
file(APPEND ${VERSIONFILE} "character(len=64), parameter :: gitHash = '${GITHASH}'")

# Build SUMMA_NOAHMP Object
add_library(SUMMA_NOAHMP OBJECT ${NOAHMP} ${NRUTIL})
target_compile_options(SUMMA_NOAHMP PRIVATE ${FLAGS_NOAH})

# Build SUMMA_COMM Object
add_library(SUMMA_COMM OBJECT ${COMM_ALL})
target_compile_options(SUMMA_COMM PRIVATE ${FLAGS_ALL})
target_link_libraries(SUMMA_COMM PUBLIC SUMMA_NOAHMP ${EXT_TARGETS} ${LIBRARY_LINKS})

# For NextGen, build SUMMA Shared Library and add the outside BMI libraries
if(USE_NEXTGEN)
if(WIN32)
add_library(summabmi ${SUMMA_ALL})
else()
add_library(summabmi SHARED ${SUMMA_ALL})
endif()
target_compile_options(summabmi PRIVATE ${FLAGS_ALL})
target_link_libraries(summabmi PUBLIC ${EXT_TARGETS} iso_c_bmi SUMMA_NOAHMP SUMMA_COMM)

set_target_properties(summabmi PROPERTIES VERSION ${PROJECT_VERSION})
include(GNUInstallDirs)

install(TARGETS summabmi
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
configure_file(summabmi.pc.in summabmi.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/summabmi.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
else()
add_library(summa SHARED ${SUMMA_ALL})
target_compile_options(summa PRIVATE ${FLAGS_ALL})
target_link_libraries(summa PUBLIC ${EXT_TARGETS} SUMMA_NOAHMP SUMMA_COMM ${LIBRARY_LINKS})
add_executable(${EXEC_NAME} ${MAIN_SUMMA})
target_compile_options(${EXEC_NAME} PRIVATE ${FLAGS_ALL})
set_property(TARGET ${EXEC_NAME} PROPERTY LINKER_LANGUAGE Fortran)
target_link_libraries(${EXEC_NAME} summa ${EXT_TARGETS} ${LIBRARY_LINKS})
endif()
Loading