# mpas-dev/mpas-model architecture

> Architecture diagram of the GitHub repository mpas-dev/mpas-model, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mpas-dev/mpas-model
- Repository: https://github.com/mpas-dev/mpas-model

## Overview

##### Main Components
a. Central “Atmosphere Core” – at the heart of the atmosphere code are files such as mpas_atm_core.F and its corresponding interface routines (e.g., mpas_atm_core_interface.F) that coordinate the simulation.
c. Physics Module – include the parameterizations for physical processes such as convection, radiation, microphysics, boundary layer processes, and surface exchanges. These are maintained in files under “src/core_atmosphere/physics”.
d. Diagnostics Module – represent the diagnostics routines responsible for computing and outputting meteorological and derived fields, which might include assembling diagnostic registries and managing observational output, generally found under “src/core_atmosphere/diagnostics”.
e. Supporting Utilities – highlight any common build options, registry files (like Registry.xml) that provide metadata definitions for variables and field information, and any shared routines (I/O or parallel utilities) that support the atmospheric core.

##### Relationships and Data Flow
a. That the Atmosphere Core is driven by a higher‐level driver that calls the core’s initialization, dynamics update, physics routines, and diagnostics.
c. That there is integration between the dynamics and physics – each module calls subroutines within the other to ensure that the computed tendencies and state updates are consistent.
d. That the registry files serve as a contract between configuration tools (and build scripts) and the runtime code, ensuring that data fields generated by physical parameterizations are clearly defined.

##### Architectural Patterns and Design Principles
a. Modularity – each module (dynamics, physics, diagnostics) is developed as an independent unit but with well-defined interfaces. Represent each unit as a separate block.
b. Separation of Concerns – dynamics and physics modules are conceptually separate (one handles fluid motion; the other manages microphysical and radiative effects) yet collaborate via common data structures.
c. Reusability and Extensibility – show that common routines (shared with the MPAS framework) are invoked as services (for I/O, parallel communications, etc.). These can be represented in a supporting “Utilities” or “Framework Support” block.
d. Build and Configuration – include configuration/build interactions (e.g., CMakeLists.txt and Makefiles within “src/core_atmosphere”) that help compile and link these modules; these influence and enforce dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Atmosphere Core Driver"
        AC1["mpas_atm_core.F"]:::driver
        AC2["mpas_atm_core_interface.F"]:::driver
    end

    D["Dynamics Module"]:::dynamics
    P["Physics Module"]:::physics
    DIAG["Diagnostics Module"]:::diagnostics
    UTIL["Utility/Registry & Build Support"]:::utility

    AC2 -->|"initializes"| D
    D -->|"state_update"| P
    P -->|"parameterization"| DIAG
    P -->|"feedback"| D

    AC1 ---|"uses"| UTIL
    AC2 ---|"uses"| UTIL
    D ---|"logs_to"| UTIL
    P ---|"logs_to"| UTIL
    DIAG ---|"outputs_via"| UTIL

    click AC1 "https://github.com/mpas-dev/mpas-model/blob/master/src/core_atmosphere/mpas_atm_core.F"
    click AC2 "https://github.com/mpas-dev/mpas-model/blob/master/src/core_atmosphere/mpas_atm_core_interface.F"
    click D "https://github.com/mpas-dev/mpas-model/tree/master/src/core_atmosphere/dynamics/"
    click P "https://github.com/mpas-dev/mpas-model/tree/master/src/core_atmosphere/physics/"
    click DIAG "https://github.com/mpas-dev/mpas-model/tree/master/src/core_atmosphere/diagnostics/"
    click UTIL "https://github.com/mpas-dev/mpas-model/blob/master/src/core_atmosphere/Registry.xml"
    click UTIL "https://github.com/mpas-dev/mpas-model/blob/master/src/core_atmosphere/build_options.mk"

    classDef driver fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef dynamics fill:#66ccff,stroke:#333,stroke-width:2px;
    classDef physics fill:#99ff99,stroke:#333,stroke-width:2px;
    classDef diagnostics fill:#ff9999,stroke:#333,stroke-width:2px;
    classDef utility fill:#cccccc,stroke:#333,stroke-width:2px;
```
