Skip to content

Commit 2575eb7

Browse files
authored
Merge branch 'master' into readme
2 parents 0a5a0f6 + 0ba6c02 commit 2575eb7

11 files changed

Lines changed: 905 additions & 218 deletions

File tree

.codeant/configuration.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"review_configuration": {
3+
"include": [
4+
"src/**/*.fpp",
5+
"src/**/*.f90",
6+
"toolchain/**/*.py"
7+
],
8+
"exclude": [
9+
"tests/**",
10+
"examples/**",
11+
"docs/**"
12+
]
13+
}
14+
}

.coderabbit.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
2+
language: en-US
3+
4+
reviews:
5+
profile: chill
6+
path_instructions:
7+
- path: "src/**/*.fpp"
8+
instructions: |
9+
Fortran source (Fypp-preprocessed). Follow the coding standards in
10+
docs/documentation/contributing.md and the GPU macro API in
11+
docs/documentation/gpuParallelization.md.
12+
- path: "src/**/*.f90"
13+
instructions: |
14+
Fortran source. Follow the coding standards in
15+
docs/documentation/contributing.md.
16+
- path: "toolchain/**/*.py"
17+
instructions: |
18+
Python toolchain code. Follow PEP 8. Requires Python 3.10+;
19+
do not suggest __future__ imports or backwards-compatibility shims.
20+
21+
knowledge_base:
22+
code_guidelines:
23+
enabled: true
24+
filePatterns:
25+
- "docs/documentation/contributing.md"
26+
- "docs/documentation/gpuParallelization.md"
27+
- ".github/copilot-instructions.md"

.github/CONTRIBUTING.md

Lines changed: 10 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,15 @@
1-
# Contributing to the MFC Codebase (Multi‑Component Flow Code)
1+
# Contributing to MFC
22

3-
**Multi‑Component Flow Code (MFC)** is an open‑source, high‑performance code for simulating compressible multi‑component, multi‑phase flows.
4-
We welcome contributions of all kinds—bug fixes, new features, documentation, tests, and issue triage—from both newcomers and experienced developers.
5-
This guide explains how to set up your environment, follow MFC's coding standards, and navigate the pull-request (PR) process so your work can be merged smoothly.
3+
We welcome contributions of all kinds -- bug fixes, new features, documentation, tests, and issue triage.
64

7-
---
5+
**Full developer guide:** [mflowcode.github.io/documentation/contributing.html](https://mflowcode.github.io/documentation/contributing.html)
86

9-
## 1. Setting Up Your Development Environment
7+
## Quick Reference
108

11-
1. **Fork and clone**
12-
```bash
13-
git clone https://github.com/<your‑user>/MFC.git
14-
cd MFC
15-
git remote add upstream https://github.com/MFlowCode/MFC.git
16-
```
17-
2. **Build MFC** – follow the [documentation](https://mflowcode.github.io/documentation/md_getting-started.html). For example:
18-
```bash
19-
./mfc.sh build -j 8 # parallel build with 8 threads
20-
```
21-
3. **Run the test suite** to verify your environment:
22-
```bash
23-
./mfc.sh test -j 8
24-
```
25-
26-
---
27-
28-
## 2. Development Workflow
29-
30-
| Step | Action | Notes |
31-
|------|--------|-------|
32-
| 1 | **Sync your fork**: `git checkout master && git pull upstream master` | Stay up‑to‑date to avoid merge conflicts. |
33-
| 2 | **Create a branch**: `git checkout -b feature/<short‑name>` | Keep each branch focused on one logical change. |
34-
| 3 | **Code, test, document** | Follow the guidelines in §3. |
35-
| 4 | **Format & lint**: `./mfc.sh format` | CI will re‑check; make it pass locally first. |
36-
| 5 | **Run tests**: `./mfc.sh test` | All existing and new tests must pass. |
37-
| 6 | **Commit** (see *Commit Messages* below) | Write clear, atomic commits. |
38-
| 7 | **Push** & open a **PR** | Be mindful: *every push triggers CI*. Bundle fixes together to avoid dozens of CI runs. |
39-
40-
### Commit Messages
41-
42-
- Start with a concise (≤50 chars) summary in imperative mood: `Fix out‑of‑bounds in EOS module`.
43-
- Add a blank line, then a detailed explanation.
44-
- Reference related issues or PRs, e.g., `Fixes #123`.
45-
46-
### Managing CI Runs
47-
48-
Each push to a branch with an open PR runs the full CI matrix (which can take hours).
49-
Plan your pushes—run tests locally and group changes—so the CI queue is not flooded.
50-
51-
---
52-
53-
## 3. Coding Guidelines and Best Practices
54-
55-
### 3.1 Style, Formatting & Linting
56-
MFC enforces a project‑wide Fortran style:
57-
- **Formatter**: `./mfc.sh format` auto‑formats your changes.
58-
- **Linter**: CI runs several linter checks that spot common Fortran-gotchas (implicit typing, shadowed variables, unused locals, etc.). Fix issues before pushing or the linter will often catch them.
59-
60-
### 3.2 Fypp Metaprogramming
61-
62-
MFC uses [**Fypp**](https://github.com/aradi/fypp), a lightweight Python-based preprocessor, to generate repetitive or accelerator-specific Fortran.
63-
Key points:
64-
- Fypp macros live in `include/` directories nested within `src/`.
65-
- Run `./mfc.sh format` to format the example case files and the source code.
66-
- When editing `.fpp`, maintain readability, prefer simple macros over deeply nested constructs.
67-
68-
### 3.3 Documentation
69-
70-
- Add or update Doxygen comments in source files.
71-
- Update Markdown docs under `docs/` if user‑facing behavior changes.
72-
- Provide a minimal example in `examples/` for each new feature when practical.
73-
74-
### 3.4 Testing
75-
76-
- Add regression tests that fail before your change and pass after.
77-
- Use `./mfc.sh test --generate` to create golden files for new cases.
78-
- Keep tests fast; favor small grids and short runtimes.
79-
80-
### 3.5 GPU & Performance
81-
82-
- Ensure code compiles for CPU *and* GPU targets (NVHPC for NVIDIA, Cray for AMD).
83-
- Profile critical kernels; avoid introducing bottlenecks.
84-
85-
---
86-
87-
## 4. Preparing Your Pull Request
88-
89-
1. **One PR = One logical change**. If you plan a follow‑up change, open an issue describing it and assign yourself for visibility.
90-
2. **Fill out the PR template**. Remove checkboxes that do **not** apply.
91-
3. **Describe testing** – list commands, compilers, and any profiling.
92-
4. **Link issues**`Fixes #<id>` or `Part of #<id>`.
93-
5. **Ensure CI passes** before requesting review.
94-
95-
> **Tip** If your change is large, consider splitting it into smaller PRs. Document the intent in an issue so reviewers understand the overall roadmap.
96-
97-
---
98-
99-
## 5. Code Review & Merge
100-
101-
- Respond promptly to reviewer comments.
102-
- Push focused updates; each push re‑runs CI.
103-
- When all reviews are approved and CI is green, a maintainer will merge your PR.
104-
105-
---
106-
107-
## 6. Issue Triage
108-
109-
If you prefer helping with issue management:
110-
- Comment to clarify reproduction steps.
111-
- Label issues when you have triage rights.
112-
- Close fixed issues and reference the PR.
9+
1. Fork and clone the repository
10+
2. Create a feature branch: `git checkout -b feature/<short-name>`
11+
3. Make your changes and run `./mfc.sh test`
12+
4. Commit (formatting and linting run automatically via pre-commit hook)
13+
5. Push and open a pull request
11314

15+
See the [developer guide](https://mflowcode.github.io/documentation/contributing.html) for coding standards, testing details, and the full PR process.

.github/copilot-instructions.md

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,52 @@
1-
# GitHub Copilot Instructions – Pull-Request Reviews for MFC
1+
# AI Code Review Instructions for MFC
22

3-
These instructions guide **GitHub Copilot Code Review** and **Copilot Chat** when they evaluate pull requests in this repository.
3+
These instructions guide AI code reviewers (GitHub Copilot, CodeRabbit, Qodo, Cubic, CodeAnt, etc.) when evaluating pull requests in this repository.
44

5-
---
6-
7-
## 1 Project Context (always include)
5+
**Coding standards, common pitfalls, and contribution guidelines:** `docs/documentation/contributing.md`
6+
**GPU macro API reference:** `docs/documentation/gpuParallelization.md`
87

9-
* **Project:** MFC (exascale many-physics solver) written in **modern Fortran 2008+**, generated with **Fypp**.
10-
* **Directory layout:**
11-
* Sources in `src/`, tests in `tests/`, examples in `examples/`.
12-
* Most source files are templated `.fpp`; CMake transpiles them to `.f90`.
13-
* **Fypp macros** are in `src/<subprogram>/include/`, where `<subprogram>` is `simulation`, `common`, `pre_process`, or `post_process`. Review these first.
14-
* Only `simulation` (plus its `common` dependencies) is GPU-accelerated with **OpenACC**.
15-
16-
> **Copilot, when reviewing:**
17-
> * Treat the codebase as free-form Fortran 2008+ with `implicit none`, explicit `intent`, and standard intrinsics.
18-
> * Prefer `module … contains … subroutine foo()` over legacy constructs; flag uses of `COMMON`, file-level `include`, or other global state.
8+
Formatting and linting are enforced by pre-commit hooks. Focus review effort on correctness, not style.
199

2010
---
2111

22-
## 2 Incremental-Change Workflow
12+
## 1 Project Context
2313

24-
Copilot, when reviewing:
25-
* Encourage small, buildable commits
14+
* **Project:** MFC (exascale many-physics solver) written in **modern Fortran 2008+**, preprocessed with **Fypp**.
15+
* **Directory layout:**
16+
* Sources in `src/`, tests in `tests/`, examples in `examples/`, Python toolchain in `toolchain/`.
17+
* Most source files are `.fpp` (Fypp templates); CMake transpiles them to `.f90`.
18+
* **Fypp macros** are in `src/<subprogram>/include/`, where `<subprogram>` is `simulation`, `common`, `pre_process`, or `post_process`.
19+
* Only `simulation` (plus its `common` dependencies) is GPU-accelerated via **OpenACC**.
20+
* Code must compile with **GNU gfortran**, **NVIDIA nvfortran**, **Cray ftn**, and **Intel ifx**.
21+
* Precision modes: double (default), single, and mixed (`wp` = working precision, `stp` = storage precision).
22+
* **Python toolchain** requires **Python 3.10+** — do not suggest `from __future__` imports or other backwards-compatibility shims.
2623

2724
---
2825

29-
## 3 Style & Naming Conventions (*.fpp / *.f90)
26+
## 2 What to Review
3027

31-
| Element | Rule |
32-
|---------|------|
33-
| Indentation | 2 spaces; continuation lines align beneath &. |
34-
| Case | Lower-case keywords & intrinsics (do, end subroutine, …). |
35-
| Modules | m_<feature> (e.g. m_transport). |
36-
| Public subroutines | s_<verb>_<noun> (s_compute_flux). |
37-
| Public functions | f_<verb>_<noun>. |
38-
| Routine size | subroutine ≤ 500 lines, helper ≤ 150, function ≤ 100, file ≤ 1000. |
39-
| Arguments | ≤ 6; else use a derived-type params struct. |
40-
| Forbidden | goto (except legacy), COMMON, save globals. |
41-
| Variables | Every arg has explicit intent; use dimension/allocatable/pointer as appropriate. |
42-
| Errors | Call s_mpi_abort(<msg>), never stop or error stop. |
28+
See the **Common Pitfalls** section of `docs/documentation/contributing.md` for the full reference. Key review priorities:
4329

44-
Copilot, when reviewing:
45-
* Flag violations of any cell above.
46-
* Suggest refactors when size or argument limits are exceeded.
47-
* Ensure private helpers stay inside their defining module and avoid nested procedures.
30+
1. **Correctness over style** — logic bugs, numerical issues, array bounds (non-unity lower bounds with ghost cells)
31+
2. **Precision mixing**`stp` vs `wp` conversions, no double-precision intrinsics (`dsqrt`, `dble`, `real(8)`, etc.)
32+
3. **Memory**`@:ALLOCATE`/`@:DEALLOCATE` pairing, GPU pointer setup (`@:ACC_SETUP_VFs`/`@:ACC_SETUP_SFs`)
33+
4. **MPI** — halo exchange pack/unpack offsets, `GPU_UPDATE` around MPI calls, buffer sizing
34+
5. **GPU** — no raw OpenACC/OpenMP pragmas (use Fypp GPU macros), `private(...)` on loop-local variables, no `stop`/`error stop` in device code
35+
6. **Physics** — pressure formula must match `model_eqns`, `case_validator.py` constraints for new parameters
36+
7. **Compiler portability** — all four compilers, Fypp macros for GPU and CPU builds
37+
8. **`src/common/` blast radius** — changes affect all three executables
4838

4939
---
5040

51-
## 4 OpenACC Guidelines (for GPU kernels)
52-
53-
Wrap tight loops:
54-
55-
```fortran
56-
!$acc parallel loop gang vector default(present) reduction(...)
57-
```
58-
59-
* Add collapse(n) when safe.
60-
* Declare loop-local variables with private(...).
61-
* Allocate large arrays with managed or move them into a persistent !$acc enter data region at start-up.
62-
* Avoid stop/error stop inside device code.
63-
* Code must compile with Cray ftn, NVIDIA nvfortran, GNU gfortran, and Intel ifx/ifort.
64-
65-
---
41+
## 3 PR-Pattern Triggers
6642

67-
## 5 Review Checklist (what Copilot should verify)
43+
Flag these patterns when reviewing a pull request:
6844

69-
1. Buildability: PR includes build instructions or CI passes the staged build.
70-
2. Tests: Focused tests are added/updated.
71-
3. Style compliance: All rules in §3 are satisfied.
72-
4. Module hygiene: No new global state; proper namespacing.
73-
5. Performance: GPU code follows §4; no large host/device transfers in hot loops.
74-
6. Documentation: Updated in-code comments and, when needed, README or docs site.
75-
7. Regressions: No changes to outputs of golden tests without clear justification.
45+
* PR adds a parameter in `toolchain/mfc/params/definitions.py` but does not update the `namelist /user_inputs/` in `src/*/m_start_up.fpp` or declare it in `src/*/m_global_parameters.fpp`
46+
* PR adds a parameter with cross-parameter constraints but does not add validation in `toolchain/mfc/case_validator.py`
47+
* PR modifies files in `src/common/` but does not mention testing all three targets (pre_process, simulation, post_process)
48+
* PR adds `@:ALLOCATE` calls without matching `@:DEALLOCATE` in the corresponding finalization subroutine
49+
* PR renames or moves files referenced in `docs/documentation/contributing.md` or `docs/documentation/gpuParallelization.md` without updating those docs
50+
* PR adds a new `.fpp` module missing `implicit none` or missing `private`/`public` declarations
51+
* PR modifies MPI pack/unpack logic in one sweep direction without updating all directions
52+
* PR adds a new physics feature or model without a corresponding regression test

.github/pull_request_template.md

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,32 @@
11
## Description
22

3-
Please include a summary of the changes and the related issue(s) if they exist.
4-
Please also include relevant motivation and context.
3+
Summarize your changes and the motivation behind them.
54

6-
Fixes #(issue) [optional]
5+
Fixes #(issue)
76

87
### Type of change
98

10-
Please delete options that are not relevant.
9+
- [ ] Bug fix
10+
- [ ] New feature
11+
- [ ] Refactor
12+
- [ ] Documentation
13+
- [ ] Other: _describe_
1114

12-
- [ ] Bug fix (non-breaking change which fixes an issue)
13-
- [ ] New feature (non-breaking change which adds functionality)
14-
- [ ] Something else
15+
## Testing
1516

16-
### Scope
17+
How did you test your changes?
1718

18-
- [ ] This PR comprises a set of related changes with a common goal
19-
20-
If you cannot check the above box, please split your PR into multiple PRs that each have a common goal.
21-
22-
## How Has This Been Tested?
23-
24-
Please describe the tests that you ran to verify your changes.
25-
Provide instructions so we can reproduce.
26-
Please also list any relevant details for your test configuration
19+
## Checklist
2720

28-
- [ ] Test A
29-
- [ ] Test B
21+
- [ ] I added or updated tests for new behavior
22+
- [ ] I updated documentation if user-facing behavior changed
3023

31-
**Test Configuration**:
24+
See the [developer guide](https://mflowcode.github.io/documentation/contributing.html) for full coding standards.
3225

33-
* What computers and compilers did you use to test this:
26+
<details>
27+
<summary><strong>GPU changes</strong> (expand if you modified <code>src/simulation/</code>)</summary>
3428

35-
## Checklist
29+
- [ ] GPU results match CPU results
30+
- [ ] Tested on NVIDIA GPU or AMD GPU
3631

37-
- [ ] I have added comments for the new code
38-
- [ ] I added Doxygen docstrings to the new code
39-
- [ ] I have made corresponding changes to the documentation (`docs/`)
40-
- [ ] I have added regression tests to the test suite so that people can verify in the future that the feature is behaving as expected
41-
- [ ] I have added example cases in `examples/` that demonstrate my new feature performing as expected.
42-
They run to completion and demonstrate "interesting physics"
43-
- [ ] I ran `./mfc.sh format` before committing my code
44-
- [ ] New and existing tests pass locally with my changes, including with GPU capability enabled (both NVIDIA hardware with NVHPC compilers and AMD hardware with CRAY compilers) and disabled
45-
- [ ] This PR does not introduce any repeated code (it follows the [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) principle)
46-
- [ ] I cannot think of a way to condense this code and reduce any introduced additional line count
47-
48-
### If your code changes any code source files (anything in `src/simulation`)
49-
50-
To make sure the code is performing as expected on GPU devices, I have:
51-
- [ ] Checked that the code compiles using NVHPC compilers
52-
- [ ] Checked that the code compiles using CRAY compilers
53-
- [ ] Ran the code on either V100, A100, or H100 GPUs and ensured the new feature performed as expected (the GPU results match the CPU results)
54-
- [ ] Ran the code on MI200+ GPUs and ensure the new features performed as expected (the GPU results match the CPU results)
55-
- [ ] Enclosed the new feature via `nvtx` ranges so that they can be identified in profiles
56-
- [ ] Ran a Nsight Systems profile using `./mfc.sh run XXXX --gpu -t simulation --nsys`, and have attached the output file (`.nsys-rep`) and plain text results to this PR
57-
- [ ] Ran a Rocprof Systems profile using `./mfc.sh run XXXX --gpu -t simulation --rsys --hip-trace`, and have attached the output file and plain text results to this PR.
58-
- [ ] Ran my code using various numbers of different GPUs (1, 2, and 8, for example) in parallel and made sure that the results scale similarly to what happens if you run without the new code/feature
32+
</details>

.pr_agent.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,20 @@ pr_commands = ["/describe", "/review", "/improve"]
77
num_max_findings = 10 # how many items to surface
88
require_tests_review = true
99
extra_instructions = """
10-
Focus on duplicate code, the possibility of bugs, and if the PR added appropriate tests if it added a simulation feature.
10+
Project context and review priorities: .github/copilot-instructions.md
11+
Coding standards and common pitfalls: docs/documentation/contributing.md
12+
GPU macro API: docs/documentation/gpuParallelization.md
13+
14+
Prioritize correctness over style (formatting is enforced by pre-commit hooks).
15+
Key areas: logic bugs, numerical issues,
16+
array bounds (non-unity lower bounds with ghost cells), MPI halo exchange
17+
correctness (pack/unpack offsets, GPU data coherence), precision mixing
18+
(stp vs wp), ALLOCATE/DEALLOCATE pairing (GPU memory leaks), physics model
19+
consistency (pressure formula must match model_eqns), missing case_validator.py
20+
constraints for new parameters, and compiler portability across all four
21+
supported compilers.
22+
Python toolchain requires Python 3.10+; do not suggest __future__ imports
23+
or other backwards-compatibility shims.
1124
"""
1225

1326
[pr_code_suggestions]

docs/documentation/case.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ end if
236236

237237
Some patch configurations are not adequately handled with the above analytic variable definitions.
238238
In this case, a hard coded patch can be used.
239-
Hard coded patches can be added by adding additional hard coded patch identifiers to `src/pre_process/include/1[2,3]dHardcodedIC.fpp`.
239+
Hard coded patches can be added by adding additional hard coded patch identifiers to `src/common/include/1[2,3]dHardcodedIC.fpp`.
240240
When using a hard coded patch, the `patch_icpp(patch_id)%%hcid` must be set to the hard-coded patch id.
241-
For example, to add a 2D Hardcoded patch with an id of 200, one would add the following to `src/pre_process/include/2dHardcodedIC.fpp`
241+
For example, to add a 2D Hardcoded patch with an id of 200, one would add the following to `src/common/include/2dHardcodedIC.fpp`
242242

243243
```f90
244244
case(200)
@@ -256,7 +256,7 @@ The code provides three pre-built patches for dimensional extrusion of initial c
256256
- `case(370)`: Extrude 2D data to 3D domain
257257

258258
Setup: Only requires specifying `init_dir` and filename pattern via `zeros_default`. Grid dimensions are automatically detected from the data files.
259-
Implementation: All variables and file handling are managed in `src/pre_process/include/ExtrusionHardcodedIC.fpp` with no manual grid configuration needed.
259+
Implementation: All variables and file handling are managed in `src/common/include/ExtrusionHardcodedIC.fpp` with no manual grid configuration needed.
260260
Usage: Ideal for initializing simulations from lower-dimensional solutions, enabling users to add perturbations or modifications to the base extruded fields for flow instability studies.
261261

262262
#### Parameter Descriptions

0 commit comments

Comments
 (0)