Skip to content

Commit

Permalink
add CI to check the runtime parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored May 16, 2024
1 parent 9dc8417 commit 57c2302
Show file tree
Hide file tree
Showing 142 changed files with 275 additions and 593 deletions.
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 .
74 changes: 74 additions & 0 deletions .github/workflows/check_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import argparse
import importlib
import os
import re
from pathlib import Path
import sys

# some parameters that are not defined in _cpp_parameters

whitelist = ["maestro.lo_bc",
"maestro.hi_bc"]

# we don't have all of the radiation parametrs in the _cpp_parameters
# yet, so we won't check these namespaces

namespace_ignore = []

def doit(maestroex_dir):

maestroex = Path(os.path.abspath(maestroex_dir))

# import the module that defines the MAESTROeX runtime params
sys.path.append(str(maestroex / "Source" / "param/"))
import parse_maestro_params

# read in the parameters defined in _cpp_parameters
param_file = maestroex / "Source" / "param" / "_cpp_parameters"
params = parse_maestro_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 = maestroex / "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 MAESTROeX directory

p = argparse.ArgumentParser()
p.add_argument("maestroex_dir", type=str, nargs=1,
help="top level MAESTROeX directory")

args = p.parse_args()

doit(args.maestroex_dir[0])


2 changes: 1 addition & 1 deletion Exec/science/code_comp/inputs_3d
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ maestro.hi_bc = 0 0 3
geometry.is_periodic = 1 1 0

# VERBOSITY
maestro.v = 1 # verbosity
maestro.maestro_verbose = 1 # verbosity

# DEBUG FOR NAN
amrex.fpe_trap_invalid = 1 # floating point exception
Expand Down
4 changes: 2 additions & 2 deletions Exec/science/ecsn/input_ecsn
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ maestro.init_iter = 1
maestro.stop_time = 30000

# PLOTFILES
maestro.plot_file = plt # root name of plot file
maestro.plot_base_name = plt # root name of plot file
maestro.plot_int = 10 # number of timesteps between plot files
#maestro.small_plot_int = 50

Expand Down Expand Up @@ -69,7 +69,7 @@ maestro.hi_bc = 2 2 2
geometry.is_periodic = 0 0 0

# VERBOSITY
maestro.v = 1 # verbosity
maestro.maestro_verbose = 1 # verbosity
maestro.mg_verbose = 1
maestro.cg_verbose = 0

Expand Down
4 changes: 1 addition & 3 deletions Exec/science/flame/inputs_2d_smallscale
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ maestro.hi_bc = 0 2 2
geometry.is_periodic = 1 0 0

# VERBOSITY
maestro.v = 1 # verbosity
maestro.maestro_verbose = 1 # verbosity

# DEBUG FOR NAN
amrex.fpe_trap_invalid = 1 # floating point exception
Expand All @@ -30,8 +30,6 @@ amr.ref_ratio = 2 2 2 2 2 2 # refinement ratio
amr.blocking_factor = 8 # block factor in grid generation
amr.refine_grid_layout = 0 # chop grids up into smaller grids if nprocs > ngrids

# TAGGING
maestro.temperr = 6.5e8 6.5e8 6.5e8

# TIME STEPPING
maestro.max_step = 300000
Expand Down
4 changes: 1 addition & 3 deletions Exec/science/flame/inputs_2d_smallscale.2levels
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ maestro.hi_bc = 0 2 2
geometry.is_periodic = 1 0 0

# VERBOSITY
maestro.v = 1 # verbosity
maestro.maestro_verbose = 1 # verbosity

# DEBUG FOR NAN
amrex.fpe_trap_invalid = 1 # floating point exception
Expand All @@ -30,8 +30,6 @@ amr.ref_ratio = 2 2 2 2 2 2 # refinement ratio
amr.blocking_factor = 8 # block factor in grid generation
amr.refine_grid_layout = 0 # chop grids up into smaller grids if nprocs > ngrids

# TAGGING
maestro.temperr = 6.5e8 6.5e8 6.5e8

# TIME STEPPING
maestro.max_step = 30000000
Expand Down
4 changes: 1 addition & 3 deletions Exec/science/flame/inputs_2d_smallscale.testsuite
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ maestro.hi_bc = 0 2 2
geometry.is_periodic = 1 0 0

# VERBOSITY
maestro.v = 1 # verbosity
maestro.maestro_verbose = 1 # verbosity

# DEBUG FOR NAN
amrex.fpe_trap_invalid = 1 # floating point exception
Expand All @@ -30,8 +30,6 @@ amr.ref_ratio = 2 2 2 2 2 2 # refinement ratio
amr.blocking_factor = 8 # block factor in grid generation
amr.refine_grid_layout = 0 # chop grids up into smaller grids if nprocs > ngrids

# TAGGING
maestro.temperr = 6.5e8 6.5e8 6.5e8

# TIME STEPPING
maestro.max_step = 20
Expand Down
109 changes: 0 additions & 109 deletions Exec/science/flame/inputs_2d_smallscale_sdc

This file was deleted.

4 changes: 1 addition & 3 deletions Exec/science/flame/inputs_3d_smallscale
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ maestro.hi_bc = 0 0 2
geometry.is_periodic = 1 1 0

# VERBOSITY
maestro.v = 1 # verbosity
maestro.maestro_verbose = 1 # verbosity

# DEBUG FOR NAN
amrex.fpe_trap_invalid = 1 # floating point exception
Expand All @@ -30,8 +30,6 @@ amr.ref_ratio = 2 2 2 2 2 2 # refinement ratio
amr.blocking_factor = 8 # block factor in grid generation
amr.refine_grid_layout = 0 # chop grids up into smaller grids if nprocs > ngrids

# TAGGING
maestro.temperr = 6.5e8 6.5e8 6.5e8

# TIME STEPPING
maestro.max_step = 200
Expand Down
4 changes: 1 addition & 3 deletions Exec/science/flame/inputs_3d_smallscale.testsuite
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ maestro.hi_bc = 0 0 2
geometry.is_periodic = 1 1 0

# VERBOSITY
maestro.v = 1 # verbosity
maestro.maestro_verbose = 1 # verbosity

# DEBUG FOR NAN
amrex.fpe_trap_invalid = 1 # floating point exception
Expand All @@ -30,8 +30,6 @@ amr.ref_ratio = 2 2 2 2 2 2 # refinement ratio
amr.blocking_factor = 8 # block factor in grid generation
amr.refine_grid_layout = 0 # chop grids up into smaller grids if nprocs > ngrids

# TAGGING
maestro.temperr = 6.5e8 6.5e8 6.5e8

# TIME STEPPING
maestro.max_step = 20
Expand Down
Loading

0 comments on commit 57c2302

Please sign in to comment.