-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from boutproject/v2.2.1
V2.2.1
- Loading branch information
Showing
14 changed files
with
697 additions
and
278 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Change log | ||
========== | ||
|
||
This file records 'breaking' changes that might require alterations to input files, etc. | ||
|
||
|
||
v2.2.1 (5/4/2022) | ||
----------------- | ||
|
||
* `nu_parallel0` input setting renamed to `nu_parallel0_scalar`. (!153) |
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,49 @@ | ||
cmake_minimum_required(VERSION 3.18) | ||
cmake_policy(VERSION 3.18) | ||
|
||
project(storm | ||
LANGUAGES CXX) | ||
|
||
find_package(bout++ | ||
REQUIRED) | ||
|
||
add_executable(storm | ||
storm3d/storm.cxx storm3d/boundaries.cxx storm3d/initialise.cxx storm3d/monitors.cxx storm3d/operators.cxx storm3d/utilities.cxx shared/fast_output.cxx shared/BoutEquation/equation.cxx storm3d/neutral-rates.cxx storm3d/D-vpar.cxx storm3d/neutral-model.cxx) | ||
|
||
target_link_libraries(storm | ||
PRIVATE bout++::bout++) | ||
|
||
|
||
# Write git hash and diff to ${CMAKE_CURRENT_BINARY_DIR}/include/storm_version.hxx at every build | ||
# Original version inspired by https://stackoverflow.com/a/39960540. | ||
# Modified because original version did not always regenerate storm_version.hxx. Problem | ||
# seems to be fixed by putting the COMMAND directly into add_custom_target() instead of | ||
# using add_custom_command(), and explicitly adding 'GitVersion' as a dependency of | ||
# 'storm', rather than having | ||
# '${CMAKE_CURRENT_BINARY_DIR}/include/storm_version.hxx' as a dependency. Modifications | ||
# inspired by https://stackoverflow.com/a/51881170/13577592. | ||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include) | ||
target_include_directories(storm PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>) | ||
# Remove storm_version.hxx from the source directory (if it exists). It may have been | ||
# generated by a configure/make in-source build, but should not be used here. There does | ||
# not seem to be a way to prevent the source-directory version from taking precedence | ||
# except deleting it (changing `#include "storm_version.hxx"` to `#include | ||
# <storm_version.hxx>` should work, but would break the configure/make build). | ||
file(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/storm3d/storm_version.hxx) | ||
|
||
add_custom_target(GitVersion | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/save_git_version.py ${PROJECT_BINARY_DIR}/include ${PROJECT_BINARY_DIR} > /dev/null | ||
COMMENT "Generating include/storm_version.hxx") | ||
add_dependencies(storm GitVersion) | ||
|
||
|
||
# Copy useful scripts, etc. into build directory | ||
add_custom_command(TARGET storm POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/storm3d/create_bg_1d $<TARGET_FILE_DIR:storm>) | ||
|
||
|
||
# Copy tests into build directory so that we can run them locally | ||
# See https://newbedev.com/how-to-copy-contents-of-a-directory-into-build-directory-after-make-with-cmake | ||
add_custom_command(TARGET storm POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/tests3d $<TARGET_FILE_DIR:storm>/tests3d) |
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 |
---|---|---|
@@ -1,42 +1,131 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
from boututils.run_wrapper import shell_safe | ||
from pathlib import Path | ||
from string import ascii_uppercase | ||
|
||
try: | ||
from git import Repo | ||
from git import Repo, InvalidGitRepositoryError | ||
except ImportError: | ||
# print a return code to stdout so we can capture and test it in the makefile | ||
print(11) | ||
raise | ||
raise ImportError( | ||
"gitpython not installed. You can install with 'conda install gitpython' or " | ||
"'pip3 install --user gitpython'" | ||
) | ||
|
||
scriptdir = Path(__file__).resolve().parent | ||
|
||
scriptdir = Path(__file__).parent | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"output_directory", | ||
type=str, | ||
nargs="?", | ||
default=scriptdir.parent.joinpath("storm3d"), | ||
) | ||
parser.add_argument("cmake_directory", type=str, nargs="?", default=None) | ||
args = parser.parse_args() | ||
output_directory = Path(args.output_directory) | ||
cmake_directory = None if args.cmake_directory is None else Path(args.cmake_directory) | ||
|
||
repo = Repo(scriptdir.parent) | ||
|
||
diff = repo.git.diff() | ||
|
||
# Get version info for storm-configs, if it is being used | ||
try: | ||
storm_configs_repo = Repo(scriptdir.resolve().parent.parent) | ||
except InvalidGitRepositoryError: | ||
storm_configs_repo = None | ||
|
||
if storm_configs_repo is not None: | ||
# Check that storm_configs_repo is really storm-configs | ||
*_, first_commit = storm_configs_repo.iter_commits() | ||
if str(first_commit) != "f45792f72fb401014459987d1064113fa572c625": | ||
storm_configs_repo = None | ||
else: | ||
storm_configs_diff = storm_configs_repo.git.diff() | ||
bout_configs_repo = Repo( | ||
scriptdir.resolve().parent.parent.joinpath("BOUT-configs") | ||
) | ||
bout_configs_diff = bout_configs_repo.git.diff() | ||
|
||
# Get contents of CMakeCache.txt, if CMake is being used | ||
if cmake_directory is not None: | ||
with open(cmake_directory.joinpath("CMakeCache.txt"), "r") as f: | ||
storm_cmake_cache = f.read() | ||
|
||
# Get modules, if the system has a 'module' command | ||
try: | ||
_, module_list = shell_safe("module list", pipe=True) | ||
except RuntimeError: | ||
module_list = None | ||
|
||
# Find a string to use for the delimiter | ||
if storm_configs_repo is not None: | ||
combined_diff = diff + "\n" + storm_configs_diff + "\n" + bout_configs_diff | ||
else: | ||
combined_diff = diff | ||
if cmake_directory is not None: | ||
combined_diff += "\n" + storm_cmake_cache | ||
if module_list is not None: | ||
combined_diff += "\n" + module_list | ||
delimiter = "_STORM_DIFF_" | ||
for letter in ascii_uppercase: | ||
if ")" + delimiter not in diff: | ||
delimiter_success = True | ||
if ")" + delimiter not in combined_diff: | ||
break | ||
delimiter = "_STORM_DIFF_" + letter + "_" | ||
if ")" + delimiter in diff: | ||
if ")" + delimiter in combined_diff: | ||
# print a return code to stdout so we can capture and test it in the makefile | ||
print(12) | ||
raise ValueError( | ||
"save_git_version.py failed to find a delimiter that is not in the git diff" | ||
) | ||
|
||
with open("storm_version.hxx", "w") as f: | ||
f.write("constexpr auto storm_git_hash = \"") | ||
f.write(repo.git.describe(abbrev=40, dirty=True, always=True, tags=True)) | ||
f.write("\";\n") | ||
f.write("constexpr auto storm_git_diff = R\"" + delimiter + "(") | ||
with open(output_directory.joinpath("storm_version.hxx"), "w") as f: | ||
f.write('constexpr auto storm_git_hash = "') | ||
f.write(repo.git.describe(abbrev=40, dirty=True, always=True, tags=True, long=True)) | ||
f.write('";\n') | ||
f.write('constexpr auto storm_git_diff = R"' + delimiter + "(") | ||
f.write(diff) | ||
f.write(")" + delimiter + "\";\n") | ||
f.write(")" + delimiter + '";\n') | ||
|
||
if storm_configs_repo is None: | ||
f.write('constexpr auto storm_configs_git_hash = "";\n') | ||
f.write('constexpr auto storm_configs_git_diff = "";\n') | ||
f.write('constexpr auto bout_configs_git_diff = "";\n') | ||
else: | ||
f.write('constexpr auto storm_configs_git_hash = "') | ||
f.write( | ||
storm_configs_repo.git.describe( | ||
abbrev=40, | ||
dirty=True, | ||
always=True, | ||
tags=True, | ||
), | ||
) | ||
f.write('";\n') | ||
f.write('constexpr auto storm_configs_git_diff = R"' + delimiter + "(") | ||
f.write(storm_configs_diff) | ||
f.write(")" + delimiter + '";\n') | ||
f.write('constexpr auto bout_configs_git_diff = R"' + delimiter + "(") | ||
f.write(bout_configs_diff) | ||
f.write(")" + delimiter + '";\n') | ||
|
||
if cmake_directory is None: | ||
f.write('std::string storm_cmake_cache = "";\n') | ||
else: | ||
f.write('std::string storm_cmake_cache = R"' + delimiter + "(") | ||
f.write(storm_cmake_cache) | ||
f.write(")" + delimiter + '";\n') | ||
|
||
if module_list is None: | ||
f.write('std::string module_list = "";\n') | ||
else: | ||
f.write('std::string module_list = R"' + delimiter + "(") | ||
f.write(module_list) | ||
f.write(")" + delimiter + '";\n') | ||
|
||
# print a return code to stdout so we can capture and test it in the makefile | ||
print(0) |
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
Oops, something went wrong.