# noaa-gsl/mpas_app architecture

> Architecture diagram of the GitHub repository noaa-gsl/mpas_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/noaa-gsl/mpas_app
- Repository: https://github.com/noaa-gsl/mpas_app

## Overview

##### Core System Components
- MPAS-Model (Main computation engine)
- Build System
- Workflow Management
- Data Processing Pipeline
- Platform-Specific Configurations

##### Main Architectural Layers

a) Infrastructure Layer:
- Conda environment management
- Module system integration

b) Configuration Layer:
- Default configuration system
- User configuration override system
- Machine-specific configurations
- YAML-based configuration management

c) Workflow Layer:
- Rocoto workflow management
- Task scheduling and dependencies
- Data retrieval system
- Model initialization
- Boundary conditions processing

d) Processing Components:
- Ungrib data processing
- Initial conditions creation
- Lateral boundary conditions
- MPAS atmosphere executable
- Output conversion system

##### Use a top-down approach with clear separation of concerns
- Top: User Interface (Scripts and Configuration)
- Middle: Workflow Management and Task Orchestration
- Bottom: Computation and Data Processing

##### Component Grouping
- Build System (build.sh and related components)
- Configuration Management (YAML files and config processing)
- Workflow Management (Rocoto integration)
- Data Processing Pipeline
- Platform-Specific Modules

##### Configuration Flow
default_config.yaml → user_config.yaml → experiment.yaml

##### Build Process
build.sh → platform-specific modules → MPAS-Model

##### Workflow Pipeline
Data Retrieval → Ungrib → Initial Conditions → Boundary Conditions → Forecast

##### Output Processing
MPAS Output → convert_mpas → Lat/Lon Grid

- Component types
- Platform-specific elements
- Configuration hierarchy
- Task dependencies

Level of Detail:
- Keep high-level workflow visible
- Abstract internal MPAS-Model details
- Clear interfaces between components
- Configuration and platform flexibility
- File locations and naming conventions

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Infrastructure
        Platform["Platform Support"]
        Hera["Hera"]:::platform
        Jet["Jet"]:::platform
        Hercules["Hercules"]:::platform
        Platform --> Hera & Jet & Hercules
        
        CondaEnv["Conda Environment"]:::env
        ModuleSystem["Module System"]:::env
    end

    subgraph ConfigurationSystem
        DefaultConfig["Default Config"]:::config
        UserConfig["User Config"]:::config
        MachineConfig["Machine Configs"]:::config
        DataLocations["Data Locations"]:::config
        
        DefaultConfig --> UserConfig
        UserConfig --> MachineConfig
        MachineConfig --> DataLocations
    end

    subgraph WorkflowManagement
        RocotoWF["Rocoto Workflow"]:::workflow
        TaskScheduler["Task Scheduler"]:::workflow
        WFModules["Workflow Modules"]:::workflow
        
        RocotoWF --> TaskScheduler
        TaskScheduler --> WFModules
    end

    subgraph ProcessingPipeline
        DataRetrieval["Data Retrieval"]:::process
        Ungrib["Ungrib Processing"]:::process
        InitCond["Initial Conditions"]:::process
        BoundaryCond["Boundary Conditions"]:::process
        MPASExec["MPAS Atmosphere"]:::core
        OutputConv["Output Conversion"]:::process
        
        DataRetrieval --> Ungrib
        Ungrib --> InitCond
        InitCond --> BoundaryCond
        BoundaryCond --> MPASExec
        MPASExec --> OutputConv
    end

    subgraph BuildSystem
        BuildScript["Build Script"]:::build
        MPASCore["MPAS Core Model"]:::core
        BuildModules["Build Modules"]:::build
        
        BuildScript --> BuildModules
        BuildModules --> MPASCore
    end

    ConfigurationSystem --> WorkflowManagement
    Infrastructure --> BuildSystem
    WorkflowManagement --> ProcessingPipeline

    %% Click Events
    click MPASCore "https://github.com/NOAA-GSL/mpas_app/tree/main/src/MPAS-Model"
    click BuildScript "https://github.com/NOAA-GSL/mpas_app/blob/main/build.sh"
    click Hera "https://github.com/NOAA-GSL/mpas_app/blob/main/modulefiles/build_hera_intel.lua"
    click Hercules "https://github.com/NOAA-GSL/mpas_app/blob/main/modulefiles/build_hercules_intel.lua"
    click Jet "https://github.com/NOAA-GSL/mpas_app/blob/main/modulefiles/build_jet_intel.lua"
    click DefaultConfig "https://github.com/NOAA-GSL/mpas_app/blob/main/ush/default_config.yaml"
    click MachineConfig "https://github.com/NOAA-GSL/mpas_app/tree/main/parm/machines"
    click DataLocations "https://github.com/NOAA-GSL/mpas_app/blob/main/parm/data_locations.yml"
    click RocotoWF "https://github.com/NOAA-GSL/mpas_app/blob/main/parm/wflow/cold_start.yaml"
    click WFModules "https://github.com/NOAA-GSL/mpas_app/blob/main/load_wflow_modules.sh"
    click Ungrib "https://github.com/NOAA-GSL/mpas_app/blob/main/scripts/ungrib.py"
    click InitCond "https://github.com/NOAA-GSL/mpas_app/blob/main/scripts/mpas_init.py"
    click MPASExec "https://github.com/NOAA-GSL/mpas_app/blob/main/scripts/mpas.py"
    click DataRetrieval "https://github.com/NOAA-GSL/mpas_app/blob/main/scripts/get_external_data.sh"
    click CondaEnv "https://github.com/NOAA-GSL/mpas_app/blob/main/environment.yml"
    click ModuleSystem "https://github.com/NOAA-GSL/mpas_app/blob/main/modulefiles/conda.lua"

    %% Styling
    classDef platform fill:#9370DB
    classDef env fill:#87CEEB
    classDef config fill:#FFA500
    classDef workflow fill:#98FB98
    classDef process fill:#20B2AA
    classDef core fill:#4169E1
    classDef build fill:#CD853F

    %% Legend
    subgraph Legend
        L1["Platform Component"]:::platform
        L2["Environment Component"]:::env
        L3["Configuration Component"]:::config
        L4["Workflow Component"]:::workflow
        L5["Processing Component"]:::process
        L6["Core Component"]:::core
        L7["Build Component"]:::build
    end
```
