# ncar/cm1 architecture

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

- Interactive diagram: https://gitdiagram.com/ncar/cm1
- Repository: https://github.com/ncar/cm1

## Overview

CM1 is a cloud-resolving atmospheric simulation model, with a Python package for preparing soundings, retrieving ERA5 data, plotting, and managing runs. The typical user workflow is to choose a testcase configuration, prepare and execute the model, then use its output. Python call relationships are based on shown excerpts; the Fortran tree indicates major model stages, but their internal calls were not sampled, so those links are omitted.

Main entry points: [`src/cm1.F`](https://github.com/ncar/cm1/blob/main/src/cm1.F) (CM1 simulation), [`cm1/run.py`](https://github.com/ncar/cm1/blob/main/cm1/run.py) (Run manager), [`cm1/input/era5.py`](https://github.com/ncar/cm1/blob/main/cm1/input/era5.py) (ERA5 loaders), [`cm1/input/sounding.py`](https://github.com/ncar/cm1/blob/main/cm1/input/sounding.py) (Sounding preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run_setup["Run setup"]
  node_case_config["Case configuration"]
  node_run_manager["Run manager<br/>[run.py]"]
  node_run_directory["Run directory"]
end

subgraph group_model_core["Model core"]
  node_model["CM1 simulation<br/>[cm1.F]"]
  node_initialization["Initialization<br/>[init3d.F]"]
  node_dynamics["Dynamics<br/>[solve1.F]"]
  node_advection["Advection<br/>[adv.F]"]
  node_microphysics["Microphysics<br/>[mp_driver.F]"]
  node_radiation["Radiation<br/>[radiation_driver.F]"]
  node_surface_physics["Surface physics<br/>[sfcphys.F]"]
  node_output["Model output<br/>[writeout.F]"]
end

subgraph group_era5_input["Sounding input"]
  node_era5["ERA5 loaders<br/>[era5.py]"]
  node_sounding["Sounding preparation<br/>[sounding.py]"]
  node_campaign_storage[("Campaign storage")]
  node_aws_storage[("ERA5 AWS")]
end

subgraph group_python_tools["Python tools"]
  node_plotting["Sounding plots<br/>[sounding.py]"]
  node_skewt_cli["Skew-T command<br/>[skewt.py]"]
  node_utilities["Data utilities<br/>[utils.py]"]
end

node_user(("Model user"))

node_user -->|"chooses case"| node_case_config
node_user -->|"configures run"| node_run_manager
node_run_manager -->|"loads namelist"| node_case_config
node_run_manager -->|"prepares files"| node_run_directory
node_run_manager -->|"executes"| node_model
node_model -.-> node_initialization
node_model -.-> node_dynamics
node_model -.-> node_advection
node_model -.-> node_microphysics
node_model -.-> node_radiation
node_model -.-> node_surface_physics
node_model -.-> node_output
node_sounding -->|"loads ERA5"| node_era5
node_era5 -.->|"loads data"| node_campaign_storage
node_era5 -.->|"fetches data"| node_aws_storage
node_user -->|"requests plot"| node_skewt_cli
node_skewt_cli -->|"retrieves sounding"| node_sounding
node_skewt_cli -->|"parses arguments"| node_utilities
node_sounding -.->|"plots sounding"| node_plotting

click node_case_config "https://github.com/ncar/cm1/tree/main/run/config_files"
click node_run_manager "https://github.com/ncar/cm1/blob/main/cm1/run.py"
click node_run_directory "https://github.com/ncar/cm1/tree/main/run"
click node_model "https://github.com/ncar/cm1/blob/main/src/cm1.F"
click node_initialization "https://github.com/ncar/cm1/blob/main/src/init3d.F"
click node_dynamics "https://github.com/ncar/cm1/blob/main/src/solve1.F"
click node_advection "https://github.com/ncar/cm1/blob/main/src/adv.F"
click node_microphysics "https://github.com/ncar/cm1/blob/main/src/mp_driver.F"
click node_radiation "https://github.com/ncar/cm1/blob/main/src/radiation_driver.F"
click node_surface_physics "https://github.com/ncar/cm1/blob/main/src/sfcphys.F"
click node_output "https://github.com/ncar/cm1/blob/main/src/writeout.F"
click node_era5 "https://github.com/ncar/cm1/blob/main/cm1/input/era5.py"
click node_sounding "https://github.com/ncar/cm1/blob/main/cm1/input/sounding.py"
click node_plotting "https://github.com/ncar/cm1/blob/main/cm1/input/sounding.py"
click node_skewt_cli "https://github.com/ncar/cm1/blob/main/cm1/skewt.py"
click node_utilities "https://github.com/ncar/cm1/blob/main/cm1/utils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_case_config,node_run_manager,node_run_directory,node_user toneBlue
class node_model,node_initialization,node_dynamics,node_advection,node_microphysics,node_radiation,node_surface_physics,node_output toneAmber
class node_era5,node_sounding,node_campaign_storage,node_aws_storage toneMint
class node_plotting,node_skewt_cli,node_utilities toneRose
```

## Components

### Run setup

- [Case configuration](https://github.com/ncar/cm1/tree/main/run/config_files): `run/config_files`
- [Run manager](https://github.com/ncar/cm1/blob/main/cm1/run.py): `cm1/run.py`
- [Run directory](https://github.com/ncar/cm1/tree/main/run): `run`

### Model core

- [CM1 simulation](https://github.com/ncar/cm1/blob/main/src/cm1.F): `src/cm1.F`
- [Initialization](https://github.com/ncar/cm1/blob/main/src/init3d.F): `src/init3d.F`
- [Dynamics](https://github.com/ncar/cm1/blob/main/src/solve1.F): `src/solve1.F`
- [Advection](https://github.com/ncar/cm1/blob/main/src/adv.F): `src/adv.F`
- [Microphysics](https://github.com/ncar/cm1/blob/main/src/mp_driver.F): `src/mp_driver.F`
- [Radiation](https://github.com/ncar/cm1/blob/main/src/radiation_driver.F): `src/radiation_driver.F`
- [Surface physics](https://github.com/ncar/cm1/blob/main/src/sfcphys.F): `src/sfcphys.F`
- [Model output](https://github.com/ncar/cm1/blob/main/src/writeout.F): `src/writeout.F`

### Sounding input

- [ERA5 loaders](https://github.com/ncar/cm1/blob/main/cm1/input/era5.py): `cm1/input/era5.py`
- [Sounding preparation](https://github.com/ncar/cm1/blob/main/cm1/input/sounding.py): `cm1/input/sounding.py`
- **Campaign storage**
- **ERA5 AWS**

### Python tools

- [Sounding plots](https://github.com/ncar/cm1/blob/main/cm1/input/sounding.py): `cm1/input/sounding.py`
- [Skew-T command](https://github.com/ncar/cm1/blob/main/cm1/skewt.py): `cm1/skewt.py`
- [Data utilities](https://github.com/ncar/cm1/blob/main/cm1/utils.py): `cm1/utils.py`

### Other components

- **Model user**

## Connections

- Model user → Case configuration: chooses case
- Model user → Run manager: configures run (evidence: `cm1/run.py`)
- Run manager → Case configuration: loads namelist (evidence: `cm1/run.py`)
- Run manager → Run directory: prepares files (evidence: `cm1/run.py`)
- Run manager → CM1 simulation: executes (evidence: `cm1/run.py`)
- CM1 simulation → Initialization
- CM1 simulation → Dynamics
- CM1 simulation → Advection
- CM1 simulation → Microphysics
- CM1 simulation → Radiation
- CM1 simulation → Surface physics
- CM1 simulation → Model output
- Sounding preparation → ERA5 loaders: loads ERA5 (evidence: `cm1/input/sounding.py`)
- ERA5 loaders → Campaign storage: loads data
- ERA5 loaders → ERA5 AWS: fetches data
- Model user → Skew-T command: requests plot (evidence: `cm1/skewt.py`)
- Skew-T command → Sounding preparation: retrieves sounding (evidence: `cm1/skewt.py`)
- Skew-T command → Data utilities: parses arguments (evidence: `cm1/skewt.py`)
- Sounding preparation → Sounding plots: plots sounding (evidence: `cm1/input/sounding.py`)
