# wrf-model/wrf architecture

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

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

## Overview

1. This repository is the full WRF-ARW modeling system: a large Fortran-centered atmospheric model with optional chemistry, hydrology, data assimilation, and adjoint/tangent-linear capabilities. The codebase is organized as a set of cooperating model subsystems rather than a single application.

2. The main runtime entry points are in `main/`. The key drivers are `wrf.F`, `real_em.F`, `ideal_em.F`, `ndown_em.F`, `convert_em.F`, and the NMM variants. These launch different model workflows: real-data forecasts, idealized tests, nested-domain transfer, and conversion/preprocessing paths.

3. The core forecast execution path flows through `frame/`, `share/`, `dyn_em/`, and `phys/`. `frame/` provides model infrastructure such as time stepping, domain management, comms, I/O plumbing, and error handling; `share/` holds common utilities and mediation layers; `dyn_em/` implements the ARW dynamical core; `phys/` contains the physics parameterizations that are called each timestep.

4. The model state and many compile-time interfaces are generated from the `Registry/` definitions. This is a major architectural boundary: the Registry drives structure layout, I/O metadata, and many generated headers and interfaces under `inc/`, `share/`, and related build outputs. This means a lot of the data model is code-generated rather than hand-written.

5. Build and configuration are handled by both legacy and modern systems. Top-level `Makefile`, `configure`, `compile`, and `clean` coexist with `CMakeLists.txt` and `cmake/`. Platform-specific compiler settings live in `arch/`, while `.ci/` and `.github/workflows/` define automated build/test matrices.

6. I/O is abstracted into pluggable backend implementations under `external/`. There are backends for NetCDF, parallel NetCDF, ADIOS2, PIO, ESMF, HDF5/PHDF5, GRIB1/2, and IOAPI-related support. This lets the same model state be written to restart, boundary, and diagnostic files through different storage stacks without changing the core model logic.

7. The `run/` directory is not code; it is the runtime data bundle. It contains lookup tables, aerosol/radiation coefficients, land-surface tables, ozone and greenhouse gas data, and other static inputs required by physics and chemistry packages. These files are read by the model at startup and during physics calculations.

8. The physics subsystem in `phys/` is broad and modular. It includes boundary layer, microphysics, cumulus, radiation, surface layer, land surface, fire, aerosol, lightning, and diagnostics packages. The model selects among these at runtime based on namelist configuration, so the physics layer is a set of interchangeable components attached to the dynamical core.

9. Chemistry is a substantial subsystem in `chem/`. It contains chemistry drivers, aerosol and gas-phase modules, photolysis, deposition, emissions, and many mechanism-specific implementations. `chem/KPP/` is especially important: it holds the KPP mechanism generator, mechanism definitions, and generated include files for dozens of chemical schemes. Chemistry data flow is driven by mechanism selection and couples into the physics/dynamics timestep.

10. WRF-Hydro is integrated as a separate but coupled model family under `hydro/`. It includes routing, groundwater, reservoir, nudging, I/O, orchestration, and coupling layers. This subsystem has its own configuration and templates, but it exchanges forcing and state with the atmospheric model through coupling interfaces.

11. Data assimilation lives under `var/` and is effectively a second major application inside the repository. It contains WRFDA components for observation processing, forward operators, background-error generation, minimization, radiance handling, analysis increments, verification, and VARBC. The flow is typically observations + background + error statistics in, analysis increments / updated initial conditions out, with separate tooling for running and generating background-error fields.

12. The adjoint and tangent-linear model is isolated in `wrftladj/`. It mirrors key forecast modules with `_tl` and `_ad` variants, plus adjoint-specific infrastructure. This boundary exists because the adjoint workflow needs a differentiable version of the forecast physics/dynamics for sensitivity and optimization tasks.

13. Testing and examples are split across several layers. `test/` contains named model cases with namelists and inputs; `tools/` contains validation, registry/code-generation utilities, and regression helpers; `.sane/` and `.ci/` define scripted build and HPC regression workflows. This makes the repo support both developer-level unit/regression checks and full model-case integration runs.

14. The repository’s main integration boundaries are therefore: configuration/build system; generated state definition via Registry; forecast runtime core; pluggable I/O backends; optional physics/chemistry/hydro modules; and separate DA/adjoin/validation toolchains. An architecture diagram should show the core forecast model in the center, with these optional subsystems attaching through well-defined interfaces and shared state.

Main entry points: [`Registry`](https://github.com/wrf-model/wrf/tree/master/Registry) (Registry), [`share`](https://github.com/wrf-model/wrf/tree/master/share) (Shared mediation), [`main`](https://github.com/wrf-model/wrf/tree/master/main) (Main drivers), [`phys`](https://github.com/wrf-model/wrf/tree/master/phys) (Physics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build & config"]
  node_build_make["Makefile<br/>build system"]
  node_build_cmake["CMake<br/>build system<br/>[CMakeLists.txt]"]
  node_build_arch["Arch config<br/>platform settings"]
  node_build_ci["CI scripts<br/>automation<br/>[workflows]"]
end

subgraph group_core["Forecast core"]
  node_main_drivers["Main drivers<br/>runtime entrypoints"]
  node_share_frame["Shared mediation<br/>shared runtime"]
  node_frame["Frame core<br/>model infrastructure"]
  node_dyn_em["ARW dynamics<br/>dynamical core"]
end

subgraph group_io["I/O backends"]
  node_io_ext["I/O backends<br/>backend adapters"]
end

subgraph group_opt["Optional subsystems"]
  node_phys["Physics<br/>parameterizations"]
  node_chem["Chemistry"]
  node_hydro["WRF-Hydro<br/>coupled hydrology"]
end

subgraph group_analysis["Analysis tools"]
  node_registry["Registry<br/>code generation"]
  node_var_da["WRFDA<br/>data assimilation"]
  node_wrftladj["TL/Adjoint<br/>sensitivity model"]
  node_tools["Tools<br/>developer utilities"]
  node_tests["Test cases<br/>model cases"]
end

subgraph group_data["Runtime data"]
  node_runtime_data[("Run data<br/>static inputs")]
end

node_build_make -->|"builds"| node_main_drivers
node_build_cmake -->|"builds"| node_main_drivers
node_build_arch -->|"configures"| node_build_make
node_build_arch -->|"configures"| node_build_cmake
node_build_ci -.->|"checks"| node_build_make
node_build_ci -.->|"checks"| node_build_cmake
node_main_drivers -->|"boots"| node_share_frame
node_share_frame -->|"uses"| node_frame
node_frame -->|"steps"| node_dyn_em
node_dyn_em -->|"calls"| node_phys
node_phys -->|"reads"| node_runtime_data
node_chem -->|"reads"| node_runtime_data
node_main_drivers -->|"generated from"| node_registry
node_registry -->|"generates"| node_share_frame
node_registry -.->|"defines state"| node_phys
node_registry -.->|"defines state"| node_chem
node_io_ext -->|"implements I/O"| node_share_frame
node_io_ext -->|"supports"| node_frame
node_var_da -->|"reuses"| node_registry
node_var_da -->|"couples to"| node_share_frame
node_wrftladj -->|"mirrors"| node_dyn_em
node_wrftladj -->|"mirrors"| node_phys
node_hydro -->|"couples to"| node_share_frame
node_tools -->|"generates"| node_registry
node_tests -.->|"exercise"| node_main_drivers

click node_build_make "https://github.com/wrf-model/wrf/tree/master/Makefile"
click node_build_cmake "https://github.com/wrf-model/wrf/blob/master/CMakeLists.txt"
click node_build_arch "https://github.com/wrf-model/wrf/tree/master/arch"
click node_build_ci "https://github.com/wrf-model/wrf/blob/master/.github/workflows"
click node_main_drivers "https://github.com/wrf-model/wrf/tree/master/main"
click node_share_frame "https://github.com/wrf-model/wrf/tree/master/share"
click node_frame "https://github.com/wrf-model/wrf/tree/master/frame"
click node_dyn_em "https://github.com/wrf-model/wrf/tree/master/dyn_em"
click node_phys "https://github.com/wrf-model/wrf/tree/master/phys"
click node_chem "https://github.com/wrf-model/wrf/tree/master/chem"
click node_hydro "https://github.com/wrf-model/wrf/tree/master/hydro"
click node_registry "https://github.com/wrf-model/wrf/tree/master/Registry"
click node_io_ext "https://github.com/wrf-model/wrf/tree/master/external"
click node_runtime_data "https://github.com/wrf-model/wrf/tree/master/run"
click node_var_da "https://github.com/wrf-model/wrf/tree/master/var"
click node_wrftladj "https://github.com/wrf-model/wrf/tree/master/wrftladj"
click node_tools "https://github.com/wrf-model/wrf/tree/master/tools"
click node_tests "https://github.com/wrf-model/wrf/tree/master/test"

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_build_make,node_build_cmake,node_build_arch,node_build_ci toneBlue
class node_main_drivers,node_share_frame,node_frame,node_dyn_em toneAmber
class node_io_ext toneMint
class node_phys,node_chem,node_hydro toneRose
class node_registry,node_var_da,node_wrftladj,node_tools,node_tests toneIndigo
class node_runtime_data toneTeal
```

## Components

### Build & config

Build systems, platform settings, and CI automation.

- [Makefile](https://github.com/wrf-model/wrf/tree/master/Makefile): build system · Legacy build entry point for compiling the model stack. · `Makefile`
- [CMake](https://github.com/wrf-model/wrf/blob/master/CMakeLists.txt): build system · Modern build configuration and platform detection. · `CMakeLists.txt`
- [Arch config](https://github.com/wrf-model/wrf/tree/master/arch): platform settings · Compiler and machine-specific build settings. · `arch`
- [CI scripts](https://github.com/wrf-model/wrf/blob/master/.github/workflows): automation · Repository automation for builds, tests, and workflows. · `.github/workflows`

### Forecast core

Main atmospheric model runtime and shared infrastructure.

- [Main drivers](https://github.com/wrf-model/wrf/tree/master/main): runtime entrypoints · Top-level executables for real, idealized, nesting, and conversion workflows. · `main`
- [Shared mediation](https://github.com/wrf-model/wrf/tree/master/share): shared runtime · Common startup, domain mediation, namelist, and restart plumbing. · `share`
- [Frame core](https://github.com/wrf-model/wrf/tree/master/frame): model infrastructure · Time stepping, domain management, comms, I/O plumbing, and error handling. · `frame`
- [ARW dynamics](https://github.com/wrf-model/wrf/tree/master/dyn_em): dynamical core · The atmospheric dynamical core and integration routines. · `dyn_em`

### I/O backends

Pluggable file-format and parallel I/O implementations.

- [I/O backends](https://github.com/wrf-model/wrf/tree/master/external): backend adapters · NetCDF, PNetCDF, ADIOS2, PIO, ESMF, HDF5, GRIB, and related adapters. · `external`

### Optional subsystems

Physics, chemistry, hydrology, and specialized model families.

- [Physics](https://github.com/wrf-model/wrf/tree/master/phys): parameterizations · Interchangeable timestep physics packages attached to the dynamical core. · `phys`
- [Chemistry](https://github.com/wrf-model/wrf/tree/master/chem): chemistry system · Gas-phase, aerosol, photolysis, emissions, and mechanism drivers. · `chem`
- [WRF-Hydro](https://github.com/wrf-model/wrf/tree/master/hydro): coupled hydrology · Integrated hydrology, routing, reservoirs, and coupling layers. · `hydro`

### Analysis tools

Data assimilation, adjoint/tangent-linear, and validation tooling.

- [Registry](https://github.com/wrf-model/wrf/tree/master/Registry): code generation · Model state definitions and generated interfaces that shape the data model. · `Registry`
- [WRFDA](https://github.com/wrf-model/wrf/tree/master/var): data assimilation · Observation processing, minimization, background-error, radiance, and analysis tools. · `var`
- [TL/Adjoint](https://github.com/wrf-model/wrf/tree/master/wrftladj): sensitivity model · Tangent-linear and adjoint forecast components for sensitivity and optimization. · `wrftladj`
- [Tools](https://github.com/wrf-model/wrf/tree/master/tools): developer utilities · Registry/code-generation, regression, and repository helper utilities. · `tools`
- [Test cases](https://github.com/wrf-model/wrf/tree/master/test): model cases · Named integration cases and namelist/input bundles for exercising the model. · `test`

### Runtime data

Static tables and lookup files used at run time.

- [Run data](https://github.com/wrf-model/wrf/tree/master/run): static inputs · Lookup tables, coefficients, and other runtime files consumed by physics and chemistry. · `run`

## Connections

- Makefile → Main drivers: builds · Legacy build compiles the executables and shared objects.
- CMake → Main drivers: builds · CMake builds the same runtime entry points.
- Arch config → Makefile: configures · Platform-specific compiler settings feed legacy builds.
- Arch config → CMake: configures · Architecture settings also inform the CMake path.
- CI scripts → Makefile: checks · CI runs make-based compilation and regression workflows.
- CI scripts → CMake: checks · CI runs CMake-based build and test matrices.
- Main drivers → Shared mediation: boots · Drivers initialize the shared mediation layer and runtime state.
- Shared mediation → Frame core: uses · Shared routines delegate to the frame infrastructure.
- Frame core → ARW dynamics: steps · Frame integration calls into the dynamical core each timestep.
- ARW dynamics → Physics: calls · Dynamics invokes selected physics packages during integration.
- Physics → Run data: reads · Physics packages consume static tables and coefficient files.
- Chemistry → Run data: reads · Chemistry mechanisms and photolysis use external lookup data.
- Main drivers → Registry: generated from · Executables depend on generated state, I/O metadata, and interfaces.
- Registry → Shared mediation: generates · Registry definitions feed shared headers and interfaces.
- Registry → Physics: defines state · Physics accesses state layout and metadata derived from Registry.
- Registry → Chemistry: defines state · Chemical species and interfaces are driven by Registry definitions.
- I/O backends → Shared mediation: implements I/O · Backend adapters provide the storage layer used by shared I/O code.
- I/O backends → Frame core: supports · Frame I/O plumbing routes through selectable backend implementations.
- WRFDA → Registry: reuses · Assimilation state and generated interfaces track the model data model.
- WRFDA → Shared mediation: couples to · DA workflows use shared model mediation, I/O, and state transfer.
- TL/Adjoint → ARW dynamics: mirrors · Adjoint/TL modules mirror key forecast dynamics.
- TL/Adjoint → Physics: mirrors · Adjoint/TL physics modules mirror selected parameterizations.
- WRF-Hydro → Shared mediation: couples to · Hydrology exchanges forcing and state through shared coupling interfaces.
- Tools → Registry: generates · Developer tools generate allocs, args, streams, and state descriptors.
- Test cases → Main drivers: exercise · Integration cases run the main model entry points.
