CheMPAS-A (Chemistry for MPAS - Atmosphere) is a standalone project derived from NCAR/MPAS-Model-ACOM-dev, itself a fork of MPAS-Dev/MPAS-Model. It extends the Model for Prediction Across Scales (MPAS) with integrated MUSICA/MICM atmospheric chemistry, enabling coupled atmospheric-chemistry modeling on MPAS's unstructured mesh. CheMPAS-A is an independent project and is not intended to sync with the upstream repositories.
docs/architecture/ARCHITECTURE.md- High-level system architectureBUILD.md- Build system documentation (includes LLVM/macOS instructions)RUN.md- Test case execution instructionsdocs/guides/VISUALIZE.md- Chemistry visualization tools and workflowsdocs/architecture/COMPONENTS.md- Detailed component descriptionsdocs/musica/MUSICA_INTEGRATION.md- MUSICA/MICM coupling detailsdocs/musica/MUSICA_API.md- MUSICA Fortran API referenceAGENTS.md- Agent roles, workflow, and operational detailsdocs/results/BENCHMARKS.md- Agent model benchmark comparisonPURPOSE.md- Project motivation and goalsdocs/results/TEST_RUNS.md- Test run documentationdocs/project/TODO.md- Development task list
~/EarthSystem/DAVINCI-MPAS/- Sister project with prior lightning-NOx/O3 implementation work.- Start with:
PLAN.md(Phase 6 LNOx-O3 details)SCIENCE.md(physics assumptions and validation framing)DC3.md(observational context and targets)
CheMPAS-A builds on two platforms. The preflight script auto-detects the compiler toolchain (flang or gfortran) and sets paths accordingly:
scripts/check_build_env.sh # report mode — shows what it found
eval "$(scripts/check_build_env.sh --export)" # export mode — sets env varsPKG_CONFIG_PATH must be present in the same shell invocation as make.
The Makefile uses $(shell pkg-config ...) during parse, so exporting it
in a separate shell and then invoking make later is not sufficient.
Resolved environment:
NETCDF=/opt/homebrewPNETCDF=/Users/fillmore/softwarePIO=/Users/fillmore/softwarePKG_CONFIG_PATH=/Users/fillmore/software/lib/pkgconfig- Make target:
llvm
eval "$(scripts/check_build_env.sh --export)" && make -j8 llvm \
CORE=atmosphere PIO="$PIO" NETCDF="$NETCDF" PNETCDF="$PNETCDF" \
PRECISION=double MUSICA=true
eval "$(scripts/check_build_env.sh --export)" && make -j8 llvm \
CORE=init_atmosphere PIO="$PIO" NETCDF="$NETCDF" PNETCDF="$PNETCDF" \
PRECISION=doubleRequires the mpas conda environment (conda activate mpas).
Resolved environment:
NETCDF=$CONDA_PREFIX(miniconda3/envs/mpas)PNETCDF=$CONDA_PREFIXPIO=$HOME/softwarePKG_CONFIG_PATH=$HOME/software/lib/pkgconfig- Make target:
gfortran
eval "$(scripts/check_build_env.sh --export)" && make -j8 gfortran \
CORE=atmosphere PIO="$PIO" NETCDF="$NETCDF" PNETCDF="$PNETCDF" \
PRECISION=double MUSICA=true
eval "$(scripts/check_build_env.sh --export)" && make -j8 gfortran \
CORE=init_atmosphere PIO="$PIO" NETCDF="$NETCDF" PNETCDF="$PNETCDF" \
PRECISION=doubleDependencies installed via conda-forge: gcc gxx gfortran cmake openmpi libnetcdf netcdf-fortran libpnetcdf libblas liblapack pkg-config make.
PIO and MUSICA built from source into ~/software.
- Always use
-j8for parallel compilation. - MUSICA-Fortran must be built with the same Fortran compiler as CheMPAS-A.
Mixing flang and gfortran
.modfiles causes link failures. PNETCDFis required for the normal top-level build.- A full atmosphere build may still stop later if
src/core_atmosphere/physics/physics_mmmtries togit fetchMMM-physicsand network access is unavailable.
| Component | Path |
|---|---|
| Framework | src/framework/ |
| Operators | src/operators/ |
| Atmosphere Core | src/core_atmosphere/ |
| Init Atmosphere | src/core_init_atmosphere/ |
| Dynamics | src/core_atmosphere/dynamics/ |
| Physics | src/core_atmosphere/physics/ |
| Chemistry | src/core_atmosphere/chemistry/ |
| MUSICA Integration | src/core_atmosphere/chemistry/musica/ |
| Registry (metadata) | src/core_atmosphere/Registry.xml |
| File | Purpose |
|---|---|
mpas_atm_chemistry.F |
Generic chemistry interface |
mpas_musica.F |
MUSICA/MICM coupler implementation |
| File | Description |
|---|---|
atmosphere_model |
Main atmosphere executable |
init_atmosphere_model |
Initialization/preprocessing tool |
build_tables |
Physics lookup table generator |
Skills are defined in .claude/commands/ and can be invoked with /skillname:
| Skill | Command | Description |
|---|---|---|
| Build MPAS | /build-mpas |
Build atmosphere or init_atmosphere |
| Test MPAS | /test-mpas |
Run a test case and verify output |
| Plot Chemistry | /plot-chemistry |
Generate and open chemistry visualization plots |
| MUSICA Dev | /musica-dev |
Work on MUSICA/MICM chemistry integration |
CheMPAS-A uses a coding-agent-assisted development model. Agents are used for implementation, review support, and verification, while humans retain responsibility for scientific judgment and final technical direction. See AGENTS.md for the full workflow, agent roles, and human review gates.
CheMPAS-A uses three agents from three vendors (see AGENTS.md). Codex 5.4 reviews Claude's work and may push doc edits or review findings directly to the repo, but that review remains part of a human-directed workflow rather than a fully automated merge path.
Convention for cross-agent communication:
- Codex writes review findings to
CODEX_REVIEW.mdand pushes todevelop - When the user says "check the review", pull and read
CODEX_REVIEW.md - Implement fixes, then remove
CODEX_REVIEW.md(it's a transient artifact, not a permanent doc) - Codex may also edit
.mddocumentation files directly — alwaysgit pullbefore committing if Codex has been active - Before merging to main, ensure no concurrent Codex edits are in flight
- Fortran Standards: This is a Fortran 2008 codebase using MPI for parallelism
- Build System: Uses legacy Makefile (not CMake) with
make llvm(macOS) ormake gfortran(Ubuntu) - Module Files: flang and gfortran
.modfiles are incompatible - don't mix compilers - MPI: macOS/LLVM uses
include 'mpif.h'viaNOMPIMODflag; Ubuntu/gfortran usesmpi_f08module natively - Registry System: Most variable definitions are in
Registry.xml(build-time), but MUSICA chemistry tracers are injected at runtime from the MICM config - Physics: Many physics schemes from WRF, NoahMP, and other sources
- MUSICA: Use
scripts/check_build_env.shbefore MUSICA builds. The working pkg-config file is~/software/lib/pkgconfig/musica-fortran.pcon both platforms. - Build Environment:
PKG_CONFIG_PATHmust be present in the same shell invocation asmake; otherwise the Makefile's parse-timepkg-configchecks fail. - Testing: Always run with 8 MPI ranks (
mpiexec -n 8). A mismatched rank count with no matching partition file causes segfaults in the dynamics solver. SeeRUN.mdfor details.
The preflight script auto-detects the make target (llvm or gfortran):
make clean CORE=atmosphere
find . -name "*.mod" -delete
find . -name "*.o" -delete
eval "$(scripts/check_build_env.sh --export)" && make -j8 TARGET CORE=atmosphere PIO="$PIO" NETCDF="$NETCDF" PNETCDF="$PNETCDF" PRECISION=doubleReplace TARGET with llvm (macOS) or gfortran (Ubuntu), or read it from
the preflight output.
eval "$(scripts/check_build_env.sh --export)" && make -j8 TARGET \
CORE=atmosphere \
PIO="$PIO" \
NETCDF="$NETCDF" \
PNETCDF="$PNETCDF" \
PRECISION=double \
MUSICA=trueNotes:
- Keep the
eval ... && make ...in a single shell command. - If the build fails after chemistry compiles, check whether
physics_mmmattempted a network fetch.
ls -la atmosphere_model init_atmosphere_model build_tablesA conda environment mpas is available for visualization and analysis:
~/miniconda3/envs/mpas/bin/python # Direct path
# Or activate: conda activate mpasPackages: numpy, matplotlib, netcdf4
| Script | Purpose |
|---|---|
plot_chemistry.py |
Visualize chemistry tracer output (qA, qB, qAB) |
init_tracer_sine.py |
Initialize tracers with sine wave patterns |
plot_chemistry.py usage:
cd ~/Data/CheMPAS/supercell
~/miniconda3/envs/mpas/bin/python plot_chemistry.py -o output.png
~/miniconda3/envs/mpas/bin/python plot_chemistry.py --time-series # Spatial evolution
~/miniconda3/envs/mpas/bin/python plot_chemistry.py --diff # Difference from t=0init_tracer_sine.py usage:
# Apply horizontal sine wave to qAB (for advection studies)
python init_tracer_sine.py -i supercell_init.nc -t qAB --waves-x 2 --amplitude 0.4 --offset 0.6Idealized test cases are in ~/Data/CheMPAS/:
| Case | Directory | Duration | Mesh |
|---|---|---|---|
| Supercell | ~/Data/CheMPAS/supercell/ |
2 hours | 60 stretched levels to 50 km (~300 m surface → ~1 km top) |
| Mountain wave | ~/Data/CheMPAS/mountain_wave/ |
5 hours | ~577 m, 70 levels |
| Baroclinic wave | ~/Data/CheMPAS/jw_baroclinic_wave/ |
16 days | 120 km, 26 levels |
Reference namelists and streams files are tracked in test_cases/ in the repo.
See RUN.md for execution instructions and test_cases/README.md for data
download and setup.
Important: All streams files use io_type="netcdf" to avoid PnetCDF
compatibility issues.