Skip to content

Commit

Permalink
Merge branch 'development' into ppm_one_sided_second
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Aug 19, 2024
2 parents c989b5d + 15327db commit 29df0eb
Show file tree
Hide file tree
Showing 801 changed files with 233,957 additions and 87,478 deletions.
16 changes: 12 additions & 4 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@ Checks: >
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-do-while,
-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-*,
misc-*,
-misc-const-correctness,
-misc-include-cleaner,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-modernize-use-using,
performance-*,
-performance-avoid-endl,
-performance-enum-size,
portability-*,
readability-*,
-readability-avoid-const-params-in-decls,
-readability-braces-around-statements,
Expand All @@ -33,9 +39,11 @@ Checks: >
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-named-parameter,
-readability-redundant-inline-specifier,
-readability-redundant-member-init,
-readability-simplify-boolean-expr,
-readability-static-accessed-through-instance,
mpi-*,
openmp-*
HeaderFilterRegex: '(/Source/*/|/Util/model_parser_cxx|^\./|^tmp_build_dir/castro_sources/*/).*\.H$'
HeaderFilterRegex: '(/Source/*/|/Util/model_parser|^\./|^tmp_build_dir/castro_sources/*/).*\.H$'
2 changes: 2 additions & 0 deletions .codespell-ignore-words
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ thi
nd
ue
bion
aas
checkin
49 changes: 49 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# http://EditorConfig.org
#
# precedence of rules is bottom to top

# this is the top-most EditorConfig file
root = true


[*.{c,h,cpp,hpp,H,py}]
# 4 space indentation
indent_style = space
indent_size = 4

# Clean up trailing whitespace
trim_trailing_whitespace = true

# unix-style newlines
end_of_line = lf

# newline ending in files
insert_final_newline = true


[*.md]
# two end of line whitespaces are newlines without a paragraph
trim_trailing_whitespace = false


[*.rst]
# Enforce UTF-8 encoding
charset = utf-8

# Unix-style newlines
end_of_line = lf

# Newline ending in files
insert_final_newline = true

# 3 space indentation
indent_style = space
indent_size = 3

# Clean up trailing whitespace
trim_trailing_whitespace = true

[{Makefile,GNUmakefile,Make.*}]
# TABs are part of its syntax
indent_style = tab
indent_size = unset
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Dependabot configuration
# ref: https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
target-branch: "development"
21 changes: 18 additions & 3 deletions .github/workflows/c-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ name: cpp-linter

on: [pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
cpp-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -24,6 +28,16 @@ jobs:
sudo apt-get update -y -qq
sudo apt-get -qq -y install curl clang-tidy cmake jq clang cppcheck clang-format bear g++>=9.3.0 gfortran>=9.3.0
- name: Install hypre
run: |
wget -q https://github.com/hypre-space/hypre/archive/refs/tags/v2.28.0.tar.gz
tar xfz v2.28.0.tar.gz
cd hypre-2.28.0/src
./configure --with-cxxstandard=17 --without-MPI
make -j 4
make install
cd ../../
- name: Get cpp linter repo
run: |
cd external
Expand All @@ -38,14 +52,15 @@ jobs:
- name: Run cpp linter
run: |
export AMREX_HYPRE_HOME=${PWD}/hypre-2.28.0/src/hypre
python3 external/cpp-linter-action/run_on_changed_files.py ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \
-ignore-files="amrex|Microphysics" \
-config-file="${GITHUB_WORKSPACE}/.clang-tidy" \
-header-filter='/Source/|/Util/model_parser_cxx|^\./' \
-header-filter='/Source/|/Util/model_parser|^\./' \
-run-linter
- name: Archive clang tidy report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: clang-tidy-report
path: clang-tidy-report.txt
15 changes: 3 additions & 12 deletions .github/workflows/check-ifdefs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
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-
python-version: '3.11'

- name: Run check-ifdefs
run: |
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/check-makefiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: check makefiles

on:
push:
branches:
- development
- main
pull_request:
branches:
- development

jobs:
check-ifdefs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Run check-ifdefs
run: |
python .github/workflows/check_makefiles.py
37 changes: 37 additions & 0 deletions .github/workflows/check-params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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@v4
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@v5
with:
python-version: '3.11'

- name: Run check-params
run: |
PYTHONPATH=external/Microphysics/util/build_scripts python .github/workflows/check_params.py .
46 changes: 46 additions & 0 deletions .github/workflows/check_makefiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import re
import sys
from pathlib import Path

correct_params = {
"DEBUG": "FALSE",
"USE_MPI": "TRUE",
"USE_OMP": "FALSE",
"COMP": "gnu",
"USE_CUDA": "FALSE",
"USE_HIP": "FALSE",
"PRECISION": "DOUBLE",
"PROFILE": "FALSE"}


def find_source_files():
p = Path("./Exec")
files = list(p.glob(r"**/GNUmakefile"))
return files

def check_makefile(makefile):

with open(makefile) as mf:
for _line in mf:
if idx := _line.find("#") >= 0:
line = _line[:idx]
else:
line = _line

for key in correct_params:
if key in line:
try:
k, v = re.split(":=|\?=|=", line)
except ValueError:
sys.exit(f"invalid line: {line}")

if not v.strip() == correct_params[key]:
sys.exit(f"invalid param {key} in {makefile}")

if __name__ == "__main__":

for f in find_source_files():
check_makefile(f)



76 changes: 76 additions & 0 deletions .github/workflows/check_params.py
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])


Loading

0 comments on commit 29df0eb

Please sign in to comment.