forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
411 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
set(_sundials_components nvecserial;cvode;arkode) | ||
|
||
if (ENABLE_OMP) | ||
list(APPEND _sundials_components nvecopenmp) | ||
endif () | ||
|
||
if (ENABLE_CUDA) | ||
list(APPEND _sundials_components nveccuda) | ||
endif () | ||
|
||
if (ENABLE_FORTRAN_INTERFACES) | ||
add_sources(fnvector_serial.f90 fnvector_serial_fprefix.f90) | ||
add_sources(fsunlinsol_dense.f90 fsunmat_dense.f90) | ||
|
||
# Arkcode interfaces | ||
add_sources(arkode_interface.f90 farkode.f90) | ||
|
||
# CVODe interfaces | ||
add_sources(cvode_interface.f90 fcvode.f90 ) | ||
endif () | ||
|
||
# | ||
# We link to libraries and always include nvecserial (in case app code needs it) | ||
# | ||
find_package(SUNDIALS REQUIRED COMPONENTS ${_sundials_components}) | ||
foreach(_comp ${_sundials_components}) | ||
target_link_libraries(amrex PUBLIC SUNDIALS::${_comp}) | ||
endforeach () | ||
target_compile_definitions(amrex PUBLIC AMREX_USE_SUNDIALS_3x4x) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#[=======================================================================[: | ||
FindSUNDIALS | ||
------- | ||
Finds the SUNDIALS libraries. | ||
Imported Targets | ||
^^^^^^^^^^^^^^^^ | ||
This module provides the following imported targets, if found: | ||
``SUNDIALS::<comp>`` | ||
The <comp> library | ||
where <comp> is the selected component. | ||
If no component is specified, this module will search for ``nvecserial`` only. | ||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
This will define the following variables: | ||
``SUNDIALS_FOUND`` | ||
True if all the selected components have been found. | ||
``SUNDIALS_VERSION`` | ||
The version of the SUNDIALS library which was found. | ||
``SUNDIALS_<COMP>_INCLUDE_DIRS`` | ||
Include directories needed to use component <COMP>. | ||
``SUNDIALS_<COMP>_LIBRARY`` | ||
Libraries needed to link to component <COMP>. | ||
#]=======================================================================] | ||
|
||
# | ||
# Find package version | ||
# | ||
set(_version_file_name sundials_config.h) | ||
|
||
find_path(_version_file_path | ||
NAMES "${_version_file_name}" | ||
PATH_SUFFIXES include;sundials ) | ||
|
||
if (_version_file_path) | ||
file(STRINGS "${_version_file_path}/${_version_file_name}" | ||
_strings_with_version_regex REGEX "SUNDIALS_VERSION") | ||
list(GET _strings_with_version_regex 0 _version_string) | ||
string(REGEX MATCHALL "[0-9]" _version "${_version_string}") | ||
string(REPLACE ";" "." SUNDIALS_VERSION "${_version}") | ||
endif () | ||
|
||
# | ||
# Include directory is only the top level one, i.e. "include" | ||
# Find path by using directory "sundials" as reference | ||
# | ||
find_path(_sundials_include_path NAMES sundials PATH_SUFFIXES include) | ||
|
||
# | ||
# | ||
# | ||
include(FindPackageHandleStandardArgs) | ||
|
||
# | ||
# Valid components | ||
# | ||
set(_valid_components | ||
nvecserial | ||
nvecparallel | ||
nvecopenmp | ||
nvecopenmpdev | ||
nveccuda | ||
cvode | ||
arkode | ||
) | ||
|
||
# | ||
# Search for a default library (nvecserial) or for all the | ||
# required components | ||
# | ||
if (NOT SUNDIALS_FIND_COMPONENTS) | ||
set(_sundials_findlist nvecserial ) | ||
else () | ||
set(_sundials_findlist ${SUNDIALS_FIND_COMPONENTS}) | ||
endif () | ||
|
||
list(REMOVE_DUPLICATES _sundials_findlist) | ||
|
||
# | ||
# Setup one imported target per component | ||
# | ||
set(_SUNDIALS_REQUIRED_VARS) | ||
foreach(_comp IN LISTS _sundials_findlist) | ||
|
||
string( TOLOWER "${_comp}" _comp_lower ) | ||
string( TOUPPER "${_comp}" _comp_upper ) | ||
|
||
# Check whether component is in valid list | ||
if (NOT (${_comp_lower} IN_LIST _valid_components)) | ||
message(FATAL_ERROR "Invalid component ${_comp_lower}") | ||
endif () | ||
|
||
# Include path is always the path to the top-level "include" directory in the install tree | ||
# App codes should include headers by using relative paths | ||
set(SUNDIALS_${_comp_upper}_INCLUDE_DIRS ${_sundials_include_path}) | ||
find_library(SUNDIALS_${_comp_upper}_LIBRARY NAMES sundials_${_comp_lower} PATH_SUFFIXES lib) | ||
|
||
find_package_handle_standard_args(SUNDIALS_${_comp_upper} | ||
REQUIRED_VARS | ||
SUNDIALS_${_comp_upper}_LIBRARY | ||
SUNDIALS_${_comp_upper}_INCLUDE_DIRS | ||
VERSION_VAR SUNDIALS_VERSION | ||
) | ||
|
||
mark_as_advanced(SUNDIALS_${_comp_upper}_LIBRARY SUNDIALS_${_comp_upper}_INCLUDE_DIRS) | ||
|
||
list(APPEND _SUNDIALS_REQUIRED_VARS "SUNDIALS_${_comp_upper}_FOUND") | ||
|
||
# Create imported target | ||
set(_target SUNDIALS::${_comp_lower}) | ||
if (SUNDIALS_${_comp_upper}_FOUND AND NOT TARGET ${_target}) | ||
add_library(${_target} UNKNOWN IMPORTED) | ||
set_target_properties(${_target} PROPERTIES | ||
IMPORTED_LOCATION "${SUNDIALS_${_comp_upper}_LIBRARY}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${SUNDIALS_${_comp_upper}_INCLUDE_DIRS}" | ||
) | ||
endif () | ||
|
||
endforeach() | ||
|
||
# | ||
# Set | ||
# | ||
find_package_handle_standard_args(SUNDIALS | ||
REQUIRED_VARS ${_SUNDIALS_REQUIRED_VARS} | ||
VERSION_VAR SUNDIALS_VERSION | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Tutorials/CVODE/SUNDIALS3_cppversion/EX1_SERIAL_NVEC/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Does not work if amrex is built in shared mode | ||
# | ||
if (NOT (ENABLE_SUNDIALS) ) | ||
return() | ||
endif () | ||
|
||
set( EXENAME "sundials3_cvode_cpp_ex1_serial.exe" ) | ||
|
||
add_executable( ${EXENAME} EXCLUDE_FROM_ALL "" ) | ||
|
||
target_sources( ${EXENAME} PRIVATE | ||
SetIC.f90 | ||
main.cpp | ||
myfunc_F.H | ||
) | ||
|
||
set_target_properties( ${EXENAME} PROPERTIES | ||
INCLUDE_DIRECTORIES | ||
"${CMAKE_CURRENT_LIST_DIR};${CMAKE_CURRENT_BINARY_DIR}/mod_files" | ||
Fortran_MODULE_DIRECTORY | ||
${CMAKE_CURRENT_BINARY_DIR}/mod_files | ||
RUNTIME_OUTPUT_DIRECTORY | ||
${CMAKE_CURRENT_BINARY_DIR} ) | ||
|
||
target_link_libraries( ${EXENAME} amrex ) | ||
|
||
# | ||
# Find input files | ||
# | ||
file( GLOB_RECURSE inputs LIST_DIRECTORIES false ${CMAKE_CURRENT_LIST_DIR}/input* ) | ||
|
||
# | ||
# Copy input files to corresponding build dir | ||
# | ||
file( COPY ${inputs} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) | ||
|
||
# | ||
# Add to the "tutorial" target | ||
# | ||
add_tutorial(${EXENAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Does not work if amrex is built in shared mode | ||
# | ||
if (NOT (ENABLE_SUNDIALS AND ENABLE_SUNDIALS_CVODE) ) | ||
return() | ||
endif () | ||
|
||
set( EXENAME "sundials3_cvode_finterface_ex1.exe" ) | ||
|
||
add_executable( ${EXENAME} EXCLUDE_FROM_ALL "" ) | ||
|
||
target_sources( ${EXENAME} PRIVATE | ||
integrate_ode.f90 | ||
main.cpp | ||
myfunc_F.H | ||
ode_mod.f90 | ||
) | ||
|
||
set_target_properties( ${EXENAME} PROPERTIES | ||
INCLUDE_DIRECTORIES | ||
"${CMAKE_CURRENT_LIST_DIR};${CMAKE_CURRENT_BINARY_DIR}/mod_files" | ||
Fortran_MODULE_DIRECTORY | ||
${CMAKE_CURRENT_BINARY_DIR}/mod_files | ||
RUNTIME_OUTPUT_DIRECTORY | ||
${CMAKE_CURRENT_BINARY_DIR} ) | ||
|
||
target_link_libraries( ${EXENAME} amrex ) | ||
|
||
# | ||
# Find input files | ||
# | ||
file( GLOB_RECURSE inputs LIST_DIRECTORIES false ${CMAKE_CURRENT_LIST_DIR}/input* ) | ||
|
||
# | ||
# Copy input files to corresponding build dir | ||
# | ||
file( COPY ${inputs} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) | ||
|
||
# | ||
# Add to the "tutorial" target | ||
# | ||
add_tutorial(${EXENAME}) | ||
|
Oops, something went wrong.