-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into plot_max_level
- Loading branch information
Showing
572 changed files
with
47,821 additions
and
39,922 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Checks: > | ||
-*, | ||
bugprone-*, | ||
-bugprone-easily-swappable-parameters, | ||
-bugprone-implicit-widening-of-multiplication-result, | ||
clang-analyzer-*, | ||
clang-diagnostic-*, | ||
cppcoreguidelines-*, | ||
-cppcoreguidelines-avoid-c-arrays, | ||
-cppcoreguidelines-avoid-goto, | ||
-cppcoreguidelines-avoid-magic-numbers, | ||
-cppcoreguidelines-avoid-non-const-global-variables, | ||
-cppcoreguidelines-init-variables, | ||
-cppcoreguidelines-interfaces-global-init, | ||
-cppcoreguidelines-macro-usage, | ||
-cppcoreguidelines-no-malloc, | ||
-cppcoreguidelines-non-private-member-variables-in-classes, | ||
-cppcoreguidelines-owning-memory, | ||
-cppcoreguidelines-pro-*, | ||
modernize-*, | ||
-modernize-avoid-c-arrays, | ||
-modernize-use-trailing-return-type, | ||
-modernize-use-using, | ||
performance-*, | ||
readability-*, | ||
-readability-avoid-const-params-in-decls, | ||
-readability-braces-around-statements, | ||
-readability-else-after-return, | ||
-readability-function-cognitive-complexity, | ||
-readability-function-size, | ||
-readability-identifier-length, | ||
-readability-implicit-bool-conversion, | ||
-readability-isolate-declaration, | ||
-readability-magic-numbers, | ||
-readability-named-parameter, | ||
-readability-simplify-boolean-expr, | ||
-readability-static-accessed-through-instance, | ||
mpi-*, | ||
openmp-* | ||
HeaderFilterRegex: '(/Source/*/|/Util/model_parser|^\./|^tmp_build_dir/castro_sources/*/).*\.H$' |
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,14 @@ | ||
blocs | ||
bloc | ||
inout | ||
als | ||
truns | ||
pres | ||
dum | ||
fom | ||
fromm | ||
thi | ||
nd | ||
ue | ||
bion | ||
aas |
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,5 @@ | ||
[codespell] | ||
skip = .git,*.ipynb,*.bib,*.ps | ||
ignore-words = .codespell-ignore-words | ||
|
||
|
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,37 @@ | ||
name: check ifdefs | ||
|
||
on: | ||
push: | ||
branches: | ||
- development | ||
- main | ||
pull_request: | ||
branches: | ||
- development | ||
|
||
jobs: | ||
check-ifdefs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v3 | ||
with: | ||
# this path is specific to Ubuntu | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Run check-ifdefs | ||
run: | | ||
python .github/workflows/check_ifdefs.py .github/workflows/good_defines.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,46 @@ | ||
name: check runtime params | ||
|
||
on: | ||
push: | ||
branches: | ||
- development | ||
- main | ||
pull_request: | ||
branches: | ||
- development | ||
|
||
jobs: | ||
check-runtime-params: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get submodules | ||
run: | | ||
git submodule update --init | ||
cd external/Microphysics | ||
git fetch; git checkout development | ||
cd ../amrex | ||
git fetch; git checkout development | ||
cd ../.. | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v3 | ||
with: | ||
# this path is specific to Ubuntu | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Run check-params | ||
run: | | ||
PYTHONPATH=external/Microphysics/util/build_scripts python .github/workflows/check_params.py . |
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,109 @@ | ||
#!/bin/env python | ||
|
||
import re | ||
import sys | ||
|
||
from pathlib import Path | ||
|
||
|
||
def find_source_files(): | ||
p = Path("./") | ||
files = list(p.glob(r"**/*.cpp")) | ||
files += list(p.glob(r"**/*.H")) | ||
return files | ||
|
||
def check_file(filename): | ||
|
||
# this is a general check to see if we should further examine a line | ||
if_general_re = re.compile(r"^(?:#if|#elif)", re.IGNORECASE|re.DOTALL) | ||
|
||
# this checks something of the form "#ifdef NAME" | ||
ifdef_re = re.compile(r"^#if[n]*def\s+([a-z_0-9]+)", re.IGNORECASE|re.DOTALL) | ||
|
||
# this checks something of the form | ||
# #if (NAME == X) | ||
if_re = re.compile(r"^(?:#if|#elif)\s+[\(]?([a-z_0-9]+)", re.IGNORECASE|re.DOTALL) | ||
|
||
# together these check something of the form | ||
# #if defined(NAME1) || !defined(NAME2) | ||
if_defined_re1 = re.compile(r"^(?:#if|#elif)\s+[!]?(?:defined)", re.IGNORECASE|re.DOTALL) | ||
if_defined_re2 = re.compile(r"[!]?(?:defined)\s*[\(]?([a-z_0-9]+)[\)]?", re.IGNORECASE|re.DOTALL) | ||
|
||
ierr = 0 | ||
defines = [] | ||
|
||
with open(filename) as cf: | ||
for line in cf: | ||
if if_general_re.search(line): | ||
|
||
# check each of the patterns | ||
if if_defined_re1.search(line): | ||
g = if_defined_re2.findall(line) | ||
defines += g | ||
continue | ||
|
||
if g := ifdef_re.search(line): | ||
defines.append(g.group(1)) | ||
continue | ||
|
||
if g := if_re.search(line): | ||
defines.append(g.group(1)) | ||
continue | ||
|
||
|
||
# if we made it here, then we didn't handle things | ||
ierr = 1 | ||
print(f"unhandled, file: {filename} | {line}") | ||
|
||
return ierr, set(defines) | ||
|
||
if __name__ == "__main__": | ||
|
||
good_defines_file = sys.argv[1] | ||
|
||
# read in the list of good defines | ||
|
||
good_defines = [] | ||
with open(good_defines_file) as gd: | ||
for line in gd: | ||
good_defines.append(line.strip()) | ||
|
||
all_defines = [] | ||
total_errors = 0 | ||
for f in find_source_files(): | ||
if "tmp_build_dir" in f.parts: | ||
# skip generated files | ||
continue | ||
ierr, defines = check_file(f) | ||
all_defines += defines | ||
total_errors += ierr | ||
|
||
# remove any header guards | ||
|
||
defines = [] | ||
for d in all_defines: | ||
if d.endswith("_H") or d.endswith("_H_"): | ||
continue | ||
if len(d) == 1 and d.isdigit(): | ||
continue | ||
defines.append(d) | ||
|
||
defines = sorted(set(defines)) | ||
|
||
print("found defines:") | ||
for d in defines: | ||
print(d) | ||
|
||
# now check to make sure that all the defines we found are okay | ||
|
||
invalid = [] | ||
for d in defines: | ||
if d not in good_defines: | ||
invalid.append(d) | ||
|
||
if invalid or total_errors > 0: | ||
if invalid: | ||
print("\ninvalid defines:") | ||
for bad in invalid: | ||
print(bad) | ||
sys.exit(1) |
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,76 @@ | ||
import argparse | ||
import importlib | ||
import os | ||
import re | ||
from pathlib import Path | ||
import sys | ||
|
||
# some parameters that are not defined in _cpp_parameters | ||
|
||
whitelist = ["castro.lo_bc", | ||
"castro.hi_bc", | ||
"gravity.abs_tol", | ||
"gravity.rel_tol"] | ||
|
||
# we don't have all of the radiation parametrs in the _cpp_parameters | ||
# yet, so we won't check these namespaces | ||
|
||
namespace_ignore = ["radiation", "radsolve"] | ||
|
||
def doit(castro_dir): | ||
|
||
castro = Path(os.path.abspath(castro_dir)) | ||
|
||
# import the module that defines the Castro runtime params | ||
sys.path.append(str(castro / "Source" / "driver/")) | ||
import parse_castro_params | ||
|
||
# read in the parameters defined in _cpp_parameters | ||
param_file = castro / "Source" / "driver" / "_cpp_parameters" | ||
params = parse_castro_params.read_param_file(str(param_file)) | ||
|
||
namespaces = set(p.namespace for p in params) | ||
runtime_parameters = [f"{p.namespace}.{p.name}" for p in params] | ||
|
||
pattern = re.compile(r"[A-Za-z0-9_]+\.[A-Za-z0-9_]+", re.IGNORECASE) | ||
|
||
# loop over all the inputs files | ||
exec_path = castro / "Exec" | ||
for f in exec_path.glob("**/inputs*"): | ||
|
||
if os.path.isdir(f): | ||
continue | ||
|
||
# find all the params in each namespace | ||
with open(f) as infile: | ||
print(f"working on {f}") | ||
for line in infile: | ||
# remove comments | ||
idx = line.find("#") | ||
if idx > 0: | ||
line = line[idx:] | ||
|
||
found_param = pattern.match(line) | ||
if not found_param: | ||
continue | ||
|
||
p = found_param.group(0) | ||
nm = p.split(".")[0] | ||
if nm in namespaces and nm not in namespace_ignore: | ||
if not (p in runtime_parameters or p in whitelist): | ||
sys.exit(f"Error: {p} not valid") | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
# we need the top-level Castro directory | ||
|
||
p = argparse.ArgumentParser() | ||
p.add_argument("castro_dir", type=str, nargs=1, | ||
help="top level Castro directory") | ||
|
||
args = p.parse_args() | ||
|
||
doit(args.castro_dir[0]) | ||
|
||
|
Oops, something went wrong.