Skip to content

Commit ad02d81

Browse files
Merge branch 'MFlowCode:master' into master
2 parents 05fbe8f + a21bfbf commit ad02d81

233 files changed

Lines changed: 10765 additions & 9815 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/rules/common-pitfalls.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Before submitting a PR:
5959
- [ ] `./mfc.sh precheck -j 8` (5 CI lint checks)
6060
- [ ] `./mfc.sh build -j 8` (compiles)
6161
- [ ] `./mfc.sh test --only <relevant> -j 8` (tests pass)
62-
- [ ] If adding parameters: all 4 locations updated
62+
- [ ] If adding parameters: definitions.py (_r + _nv) updated; cmake reconfigured; case_validator.py if constraints
6363
- [ ] If modifying `src/common/`: all three targets tested
6464
- [ ] If changing output: golden files regenerated for affected tests
6565
- [ ] One logical change per commit

.claude/rules/parameter-system.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@ MFC has ~3,400 simulation parameters defined in Python and read by Fortran via n
2323
- Reads `&user_inputs` namelist
2424
- Each parameter must be declared in the namelist statement
2525

26-
## Adding a New Parameter (4-location checklist)
26+
## Adding a New Parameter (2-location checklist)
2727

28-
YOU MUST update the first 3 locations. Missing any causes silent failures or compile errors.
29-
Location 4 is required only if the parameter has physics constraints.
28+
Fortran declarations and namelist bindings are now auto-generated from definitions.py
29+
at CMake configure time — no manual Fortran edits needed for simple scalar parameters.
3030

31-
1. **`toolchain/mfc/params/definitions.py`**: Add parameter with type, default, constraints
32-
2. **`src/*/m_global_parameters.fpp`**: Declare the Fortran variable in the relevant
33-
target(s). If the param is used by simulation only, add it there. If shared, add to
34-
all three targets' m_global_parameters.fpp.
35-
3. **`src/*/m_start_up.fpp`**: Add to the Fortran `namelist` declaration in the relevant
36-
target(s).
37-
4. **`toolchain/mfc/case_validator.py`**: Add validation rules if the parameter has
31+
1. **`toolchain/mfc/params/definitions.py`**: Add parameter with `_r()` (type, default,
32+
constraints) AND add it to `NAMELIST_VARS` via `_nv()` for the relevant target(s).
33+
After editing, re-run cmake (or `./mfc.sh build`) to regenerate the Fortran includes.
34+
2. **`toolchain/mfc/case_validator.py`**: Add validation rules if the parameter has
3835
physics constraints. Include `PHYSICS_DOCS` entry with title, category, explanation.
3936

37+
**Exceptions — still require manual Fortran edits:**
38+
- Array variables (e.g. `logical, dimension(num_fluids_max)`) → declare in `src/*/m_global_parameters.fpp`
39+
- Derived-type members (`fluid_pp%attr`, `patch_icpp(i)%attr`) → declare in the relevant derived type
40+
- Case-optimization parameters → add to `CASE_OPT_PARAMS` and the `#:else` block in `src/simulation/m_global_parameters.fpp`
41+
4042
## Case Files
4143
- Case files are Python scripts (`.py`) that define a dict of parameters
4244
- Validated with `./mfc.sh validate case.py`

.coderabbit.yaml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/CODEOWNERS

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
# Spencer H. Bryngelson (sbryngelson) is the
22
# default owner of all files in the repository.
33
* @sbryngelson
4-
5-
# @core-devs
6-
src/ @MFlowCode/core-devs
7-
docs/ @MFlowCode/core-devs
8-
toolchain/ @MFlowCode/core-devs
9-
tests/ @MFlowCode/core-devs
10-
benchmarks/ @MFlowCode/core-devs
11-
mfc.sh @MFlowCode/core-devs
12-
CMakeLists.txt @MFlowCode/core-devs
13-
14-
# @physics-devs
15-
src/ @MFlowCode/physics-devs

.github/Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@ ARG FC_COMPILER
88
ARG COMPILER_PATH
99
ARG COMPILER_LD_LIBRARY_PATH
1010

11+
ENV DEBIAN_FRONTEND=noninteractive
12+
ENV TZ=UTC
13+
1114
RUN apt-get update -y && \
12-
apt-get install -y software-properties-common ca-certificates gnupg && \
15+
apt-get install -y software-properties-common ca-certificates gnupg wget && \
1316
add-apt-repository ppa:deadsnakes/ppa && \
1417
apt-get update -y && \
15-
if [ "$TARGET" != "gpu" ]; then \
18+
if [ "$TARGET" = "cpu" ]; then \
1619
apt-get install -y \
1720
build-essential git make cmake gcc g++ gfortran bc \
1821
python3.12 python3.12-venv python3-pip \
1922
openmpi-bin libopenmpi-dev libfftw3-dev \
2023
mpich libmpich-dev; \
21-
else \
24+
elif [ "$TARGET" = "gpu" ]; then \
2225
apt-get install -y \
2326
build-essential git make cmake bc \
2427
python3.12 python3.12-venv python3-pip \
@@ -30,15 +33,16 @@ RUN apt-get update -y && \
3033

3134
ENV OMPI_ALLOW_RUN_AS_ROOT=1
3235
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
36+
ENV HYDRA_LAUNCHER=fork
3337
ENV PATH="/opt/MFC:$PATH"
3438

3539
COPY ../ /opt/MFC
3640

3741
ENV CC=${CC_COMPILER}
3842
ENV CXX=${CXX_COMPILER}
3943
ENV FC=${FC_COMPILER}
40-
ENV PATH="${COMPILER_PATH}:$PATH"
41-
ENV LD_LIBRARY_PATH="${COMPILER_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH:-}"
44+
ENV PATH="${COMPILER_PATH}:/opt/mpich/bin:$PATH"
45+
ENV LD_LIBRARY_PATH="${COMPILER_LD_LIBRARY_PATH}:/opt/mpich/lib:${LD_LIBRARY_PATH:-}"
4246

4347
# Pre-install numpy into the venv before mfc.sh runs, as it's required at
4448
# build time by several dependencies (pandas, cantera, matplotlib, etc.) that
@@ -50,14 +54,14 @@ RUN python3.12 -m venv /opt/MFC/build/venv && \
5054
RUN echo "TARGET=$TARGET CC=$CC_COMPILER FC=$FC_COMPILER" && \
5155
cd /opt/MFC && \
5256
if [ "$TARGET" = "gpu" ]; then \
53-
./mfc.sh build --gpu -j $(nproc); \
57+
./mfc.sh build --gpu acc -j $(nproc); \
5458
else \
5559
./mfc.sh build -j $(nproc); \
5660
fi
5761

5862
RUN cd /opt/MFC && \
5963
if [ "$TARGET" = "gpu" ]; then \
60-
./mfc.sh test -a --dry-run --gpu -j $(nproc); \
64+
./mfc.sh test -a --dry-run --gpu acc -j $(nproc); \
6165
else \
6266
./mfc.sh test -a --dry-run -j $(nproc); \
6367
fi

.github/file-filter.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ yml: &yml
3030
- '.github/workflows/bench.yml'
3131
- '.github/workflows/test.yml'
3232
- '.github/workflows/formatting.yml'
33+
- '.github/workflows/fp-stability.yml'
34+
- '.github/workflows/convergence.yml'
3335

3436
checkall: &checkall
3537
- *fortran_src

.github/scripts/prebuild-case-optimization.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22

3-
# Pre-builds all benchmark cases with --case-optimization.
4-
# No GPU hardware needed — compilation only.
3+
# Pre-builds all benchmark cases with --case-optimization using --dry-run so
4+
# binaries are cached before the GPU run job. No simulation is executed.
55
# Can run in two modes:
66
# 1. Direct (Frontier login nodes): pass cluster/device/interface as args
7-
# 2. Inside SLURM (Phoenix): uses $job_device/$job_interface from submit-slurm-job.sh
7+
# 2. Inside SLURM (Phoenix/frontier_amd): uses $job_device/$job_interface
88
# Usage: bash prebuild-case-optimization.sh [<cluster> <device> <interface>]
99

1010
set -e
@@ -22,14 +22,18 @@ case "$cluster" in
2222
*) echo "ERROR: Unknown cluster '$cluster'"; exit 1 ;;
2323
esac
2424

25-
source .github/scripts/clean-build.sh
26-
clean_build
25+
# Phoenix starts fresh (no prior dep build); other clusters pre-build deps via
26+
# build.sh first, so we must preserve them and only clean MFC target staging.
27+
if [ "$cluster" = "phoenix" ]; then
28+
source .github/scripts/clean-build.sh
29+
clean_build
30+
else
31+
find build/staging -maxdepth 1 -regex '.*/[0-9a-f]+' -type d -exec rm -rf {} + 2>/dev/null || true
32+
find build/install -maxdepth 1 -regex '.*/[0-9a-f]+' -type d -exec rm -rf {} + 2>/dev/null || true
33+
fi
2734

2835
. ./mfc.sh load -c "$flag" -m g
2936

30-
# Set GPU build flags from interface — this is always a GPU build.
31-
# Don't use gpu-opts.sh since $job_device may be "cpu" when submitted
32-
# to a CPU SLURM partition (no GPU hardware needed for compilation).
3337
case "$job_interface" in
3438
acc) gpu_opts="--gpu acc" ;;
3539
omp) gpu_opts="--gpu mp" ;;
@@ -38,5 +42,5 @@ esac
3842

3943
for case in benchmarks/*/case.py; do
4044
echo "=== Pre-building: $case ==="
41-
./mfc.sh build -i "$case" --case-optimization $gpu_opts -j 8
45+
./mfc.sh run "$case" --case-optimization $gpu_opts -j 8 --dry-run
4246
done

.github/scripts/run_case_optimization.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ benchmarks=(
2323

2424
# For Frontier/Frontier AMD: deps were fetched on the login node via --deps-only;
2525
# build case-optimized binaries here on the compute node before running.
26-
# For Phoenix: prebuild-case-optimization.sh already built everything in a prior SLURM job.
26+
# For Phoenix and frontier_amd: prebuild-case-optimization.sh already built
27+
# everything in a prior SLURM job (via --dry-run), so skip the build here.
2728
#
2829
# Clean stale MFC target staging before building. On self-hosted CI runners,
2930
# corrupted intermediate files from a prior failed build (e.g. CCE optcg crash)
3031
# can persist and poison subsequent builds. Each case-opt config gets its own
3132
# hash-named staging dir, but install dirs and other artifacts may be stale.
32-
if [ "$job_cluster" != "phoenix" ]; then
33+
if [ "$job_cluster" != "phoenix" ] && [ "$job_cluster" != "frontier_amd" ]; then
3334
# Clean stale MFC target dirs (hash-named) from prior builds, but
3435
# preserve dependency dirs (hipfort, fftw, etc.) since the compute
3536
# node has no internet to re-fetch them.

.github/scripts/submit-slurm-job.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ case "$cluster" in
5151
compiler_flag="f"
5252
account="CFD154"
5353
job_prefix="MFC"
54-
qos="develop"
54+
qos="hackathon"
5555
extra_sbatch=""
5656
test_time="01:59:00"
5757
bench_time="01:59:00"
@@ -61,7 +61,7 @@ case "$cluster" in
6161
compiler_flag="famd"
6262
account="CFD154"
6363
job_prefix="MFC"
64-
qos="develop"
64+
qos="hackathon"
6565
extra_sbatch=""
6666
test_time="01:59:00"
6767
bench_time="01:59:00"
@@ -92,7 +92,7 @@ if [ "$device" = "cpu" ]; then
9292
frontier|frontier_amd)
9393
sbatch_device_opts="\
9494
#SBATCH -n 32
95-
#SBATCH -p service"
95+
#SBATCH -p batch"
9696
;;
9797
esac
9898
elif [ "$device" = "gpu" ]; then
@@ -120,7 +120,7 @@ elif [ "$device" = "gpu" ]; then
120120
frontier|frontier_amd)
121121
sbatch_device_opts="\
122122
#SBATCH -n 8
123-
#SBATCH -p service"
123+
#SBATCH -p batch"
124124
;;
125125
esac
126126
else

.github/workflows/convergence.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Convergence
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
types: [opened, synchronize, reopened, ready_for_review]
8+
workflow_dispatch:
9+
10+
env:
11+
OMPI_MCA_rmaps_base_oversubscribe: 1
12+
13+
jobs:
14+
file-changes:
15+
name: Detect File Changes
16+
runs-on: ubuntu-latest
17+
outputs:
18+
checkall: ${{ steps.changes.outputs.checkall }}
19+
steps:
20+
- name: Clone
21+
uses: actions/checkout@v4
22+
23+
- name: Detect Changes
24+
uses: dorny/paths-filter@v3
25+
id: changes
26+
with:
27+
filters: ".github/file-filter.yml"
28+
29+
convergence:
30+
name: "Convergence"
31+
runs-on: ubuntu-latest
32+
needs: [file-changes]
33+
if: >-
34+
!cancelled() &&
35+
needs.file-changes.result == 'success' &&
36+
(needs.file-changes.outputs.checkall == 'true' || github.event_name == 'workflow_dispatch')
37+
timeout-minutes: 240
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Setup Ubuntu
43+
run: |
44+
sudo apt update -y
45+
sudo apt install -y cmake gcc g++ python3 python3-dev \
46+
openmpi-bin libopenmpi-dev
47+
48+
- name: Setup Python
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: "3.12"
52+
53+
- name: Build MFC
54+
run: ./mfc.sh build -j 4
55+
56+
- name: Run convergence tests
57+
run: ./mfc.sh test --only Convergence --no-build -j 1

0 commit comments

Comments
 (0)