1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
|
# ---------------------------------------------------------------
# Programmer(s): Radu Serban @ LLNL
# David J. Gardner @ LLNL
# ---------------------------------------------------------------
# SUNDIALS Copyright Start
# Copyright (c) 2002-2024, Lawrence Livermore National Security
# and Southern Methodist University.
# All rights reserved.
#
# See the top-level LICENSE and NOTICE files for details.
#
# SPDX-License-Identifier: BSD-3-Clause
# SUNDIALS Copyright End
# ---------------------------------------------------------------
# CMakeLists.txt file for CVODES serial examples
# ---------------------------------------------------------------
# Example lists are tuples "name\;args\;type" where the type is
# 'develop' for examples excluded from 'make test' in releases
# Examples using SUNDIALS linear solvers
set(CVODES_examples
"cvsAdvDiff_ASAi_bnd\;\;develop"
"cvsAdvDiff_FSA_non\;-sensi sim t\;exclude-single"
"cvsAdvDiff_FSA_non\;-sensi stg t\;exclude-single"
"cvsAdvDiff_bnd\;\;develop"
"cvsAnalytic_mels\;\;develop"
"cvsDirectDemo_ls\;\;develop"
"cvsDiurnal_FSA_kry\;-sensi sim t\;exclude-single"
"cvsDiurnal_FSA_kry\;-sensi stg t\;exclude-single"
"cvsDiurnal_kry\;\;develop"
"cvsDiurnal_kry_bp\;\;develop"
"cvsFoodWeb_ASAi_kry\;\;develop"
# "cvsFoodWeb_ASAp_kry\;\;develop"
"cvsHessian_ASA_FSA\;\;exclude-single"
"cvsKrylovDemo_ls\;\;develop"
"cvsKrylovDemo_ls\;1\;develop"
"cvsKrylovDemo_ls\;2\;develop"
"cvsKrylovDemo_prec\;\;develop"
"cvsParticle_dns\;\;develop"
"cvsPendulum_dns\;\;exclude-single"
"cvsRoberts_ASAi_dns\;\;exclude-single"
# "cvsRoberts_ASAi_dns_constraints\;\;develop"
"cvsRoberts_FSA_dns\;-sensi sim t\;exclude-single"
"cvsRoberts_FSA_dns\;-sensi stg1 t\;exclude-single"
"cvsRoberts_FSA_dns_Switch\;\;exclude-single"
"cvsRoberts_FSA_dns_constraints\;-sensi stg1 t\;exclude-single"
"cvsRoberts_dns\;\;"
"cvsRoberts_dns_constraints\;\;develop"
"cvsRoberts_dns_uw\;\;develop"
)
if(SUNDIALS_BUILD_WITH_MONITORING)
list(APPEND CVODE_examples "cvsKrylovDemo_ls\;0 1\;develop")
endif()
# Examples using LAPACK linear solvers
set(CVODES_examples_BL
"cvsAdvDiff_bndL\;\;exclude-single"
"cvsRoberts_dnsL\;\;exclude-single"
)
# Examples using KLU linear solver
set(CVODES_examples_KLU
"cvsRoberts_ASAi_klu\;\;develop"
"cvsRoberts_FSA_klu\;-sensi stg1 t\;develop"
"cvsRoberts_klu\;\;develop"
)
# Examples using SuperLU_MT linear solver
set(CVODES_examples_SUPERLUMT
"cvsRoberts_ASAi_sps\;\;exclude-single"
"cvsRoberts_FSA_sps\;-sensi stg1 t\;exclude-single"
"cvsRoberts_sps\;\;develop"
)
# Auxiliary files to install
set(CVODES_extras
plot_cvsParticle.py
plot_cvsPendulum.py
cvsRoberts_ASAi_dns_bkw1_stats.csv
cvsRoberts_ASAi_dns_bkw2_stats.csv
cvsRoberts_ASAi_dns_fwd_stats.csv
cvsRoberts_dns_stats.csv
cvsRoberts_FSA_dns_stats_-sensi_sim_t.csv
cvsRoberts_FSA_dns_stats_-sensi_stg1_t.csv
)
# Specify libraries to link against
set(CVODES_LIB sundials_cvodes)
set(NVECS_LIB sundials_nvecserial)
# Set-up linker flags and link libraries
set(SUNDIALS_LIBS ${CVODES_LIB} ${NVECS_LIB} ${EXE_EXTRA_LINK_LIBS})
# Add the build and install targets for each example
foreach(example_tuple ${CVODES_examples})
# parse the example tuple
list(GET example_tuple 0 example)
list(GET example_tuple 1 example_args)
list(GET example_tuple 2 example_type)
# check if this example has already been added, only need to add
# example source files once for testing with different inputs
if(NOT TARGET ${example})
# example source files
add_executable(${example} ${example}.c)
# folder to organize targets in an IDE
set_target_properties(${example} PROPERTIES FOLDER "Examples")
# libraries to link against
target_link_libraries(${example} ${SUNDIALS_LIBS})
endif()
# check if example args are provided and set the test name
if("${example_args}" STREQUAL "")
set(test_name ${example})
else()
string(REGEX REPLACE " " "_" test_name ${example}_${example_args})
endif()
# add example to regression tests
sundials_add_test(${test_name} ${example}
TEST_ARGS ${example_args}
ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR}
ANSWER_FILE ${test_name}.out
EXAMPLE_TYPE ${example_type})
# find all .out files for this example
file(GLOB example_out ${example}*.out)
# install example source and .out files
if(EXAMPLES_INSTALL)
install(FILES ${example}.c ${example_out}
DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial)
endif()
endforeach(example_tuple ${CVODES_examples})
# Add the build and install targets for each LAPACK example (if needed)
if(BUILD_SUNLINSOL_LAPACKBAND AND BUILD_SUNLINSOL_LAPACKDENSE)
# Sundials LAPACK linear solver modules
set(SUNLINSOLLAPACK_LIBS
sundials_sunlinsollapackband
sundials_sunlinsollapackdense)
# LAPACK libraries
list(APPEND SUNLINSOLLAPACK_LIBS ${LAPACK_LIBRARIES})
foreach(example_tuple ${CVODES_examples_BL})
# parse the example tuple
list(GET example_tuple 0 example)
list(GET example_tuple 1 example_args)
list(GET example_tuple 2 example_type)
# check if this example has already been added, only need to add
# example source files once for testing with different inputs
if(NOT TARGET ${example})
# example source files
add_executable(${example} ${example}.c)
# folder to organize targets in an IDE
set_target_properties(${example} PROPERTIES FOLDER "Examples")
# libraries to link against
target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLLAPACK_LIBS})
endif()
# check if example args are provided and set the test name
if("${example_args}" STREQUAL "")
set(test_name ${example})
else()
string(REGEX REPLACE " " "_" test_name ${example}_${example_args})
endif()
# add example to regression tests
sundials_add_test(${test_name} ${example}
TEST_ARGS ${example_args}
ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR}
ANSWER_FILE ${test_name}.out
EXAMPLE_TYPE ${example_type})
# find all .out files for this example
file(GLOB example_out ${example}*.out)
# install example source and .out files
if(EXAMPLES_INSTALL)
install(FILES ${example}.c ${example_out}
DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial)
endif()
endforeach(example_tuple ${CVODES_examples_BL})
endif()
# Add the build and install targets for each KLU example (if needed)
if(BUILD_SUNLINSOL_KLU)
# Sundials KLU linear solver module
set(SUNLINSOLKLU_LIBS sundials_sunlinsolklu)
# KLU libraries
list(APPEND SUNLINSOLKLU_LIBS)
foreach(example_tuple ${CVODES_examples_KLU})
# parse the example tuple
list(GET example_tuple 0 example)
list(GET example_tuple 1 example_args)
list(GET example_tuple 2 example_type)
# check if this example has already been added, only need to add
# example source files once for testing with different inputs
if(NOT TARGET ${example})
# add example source files
add_executable(${example} ${example}.c)
# folder to organize targets in an IDE
set_target_properties(${example} PROPERTIES FOLDER "Examples")
# libraries to link against
target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLKLU_LIBS})
endif()
# check if example args are provided and set the test name
if("${example_args}" STREQUAL "")
set(test_name ${example})
else()
string(REGEX REPLACE " " "_" test_name ${example}_${example_args})
endif()
# add example to regression tests
sundials_add_test(${test_name} ${example}
TEST_ARGS ${example_args}
ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR}
ANSWER_FILE ${test_name}.out
EXAMPLE_TYPE ${example_type})
# find all .out files for this example
file(GLOB example_out ${example}*.out)
# install example source and .out files
if(EXAMPLES_INSTALL)
install(FILES ${example}.c ${example_out}
DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial)
endif()
endforeach(example_tuple ${CVODES_examples_KLU})
endif()
# Add the build and install targets for each SuperLU_MT example (if needed)
if(BUILD_SUNLINSOL_SUPERLUMT)
# Sundials SuperLU_MT linear solver module
set(SUNLINSOLSLUMT_LIBS sundials_sunlinsolsuperlumt)
# SuperLU_MT libraries
list(APPEND SUNLINSOLSLUMT_LIBS ${SUPERLUMT_LIBRARIES})
foreach(example_tuple ${CVODES_examples_SUPERLUMT})
# parse the example tuple
list(GET example_tuple 0 example)
list(GET example_tuple 1 example_args)
list(GET example_tuple 2 example_type)
# check if this example has already been added, only need to add
# example source files once for testing with different inputs
if(NOT TARGET ${example})
# add example source files
add_executable(${example} ${example}.c)
# folder to organize targets in an IDE
set_target_properties(${example} PROPERTIES FOLDER "Examples")
# libraries to link against
target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLSLUMT_LIBS})
endif()
# check if example args are provided and set the test name
if("${example_args}" STREQUAL "")
set(test_name ${example})
else()
string(REGEX REPLACE " " "_" test_name ${example}_${example_args})
endif()
# Do not include SuperLUMT examples in testing when the indextype is int32_t.
# Answer files were generated with int64_t and minor differences in output
# occur causing a false positive when testing. These tests can be re-enabled
# when type specific answer files are added.
if(SUNDIALS_INDEX_SIZE MATCHES "64")
# add example to regression tests
sundials_add_test(${test_name} ${example}
TEST_ARGS ${example_args}
ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR}
ANSWER_FILE ${test_name}.out
EXAMPLE_TYPE ${example_type})
endif()
# find all .out files for this example
file(GLOB example_out ${example}*.out)
# install example source and .out files
if(EXAMPLES_INSTALL)
install(FILES ${example}.c ${example_out}
DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial)
endif()
endforeach(example_tuple ${CVODES_examples_SUPERLUMT})
endif()
# create Makfile and CMakeLists.txt for examples
if(EXAMPLES_INSTALL)
# Install the README file
install(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial)
# Install the extra files
foreach(extrafile ${CVODES_extras})
install(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial)
endforeach()
# Prepare substitution variables for Makefile and/or CMakeLists templates
set(SOLVER "CVODES")
set(SOLVER_LIB "sundials_cvodes")
examples2string(CVODES_examples EXAMPLES)
if(BUILD_SUNLINSOL_LAPACKBAND AND BUILD_SUNLINSOL_LAPACKDENSE)
examples2string(CVODES_examples_BL EXAMPLES_BL)
else()
set(EXAMPLES_BL "")
endif()
if(BUILD_SUNLINSOL_KLU)
examples2string(CVODES_examples_KLU EXAMPLES_KLU)
else()
set(EXAMPLES_KLU "")
endif()
if(BUILD_SUNLINSOL_SUPERLUMT)
examples2string(CVODES_examples_SUPERLUMT EXAMPLES_SLUMT)
if (SUNDIALS_SUPERLUMT_THREAD_TYPE STREQUAL "PTHREAD")
set(THREAD_LIBRARY_SLUMT ${CMAKE_THREAD_LIBS_INIT})
else()
set(THREAD_LIBRARY_SLUMT "")
endif()
else()
set(EXAMPLES_SLUMT "")
set(THREAD_LIBRARY_SLUMT "")
endif()
# Regardless of the platform we're on, we will generate and install
# CMakeLists.txt file for building the examples. This file can then
# be used as a template for the user's own programs.
# generate CMakelists.txt in the binary directory
configure_file(
${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in
${PROJECT_BINARY_DIR}/examples/cvodes/serial/CMakeLists.txt
@ONLY
)
# install CMakelists.txt
install(
FILES ${PROJECT_BINARY_DIR}/examples/cvodes/serial/CMakeLists.txt
DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial
)
# On UNIX-type platforms, we also generate and install a makefile for
# building the examples. This makefile can then be used as a template
# for the user's own programs.
if(UNIX)
# generate Makefile and place it in the binary dir
configure_file(
${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in
${PROJECT_BINARY_DIR}/examples/cvodes/serial/Makefile_ex
@ONLY
)
# install the configured Makefile_ex as Makefile
install(
FILES ${PROJECT_BINARY_DIR}/examples/cvodes/serial/Makefile_ex
DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial
RENAME Makefile
)
endif()
# add test_install target
sundials_add_test_install(cvodes serial EXECUTABLE cvsRoberts_dns)
endif()
|