# [Greenline] Driver - model setup I
<!-- Add the tag for the current cycle number in the top bar -->
- Shaped by:
- Appetite (FTEs, weeks):
- Developers: <!-- Filled in at the betting table unless someone is specifically required here -->
## Problem
<!-- The raw idea, a use case, or something we’ve seen that motivates us to work on this -->
The current `icon4py_driver.py` that we use to run Jablonowski Williamson still relies on serialized data and is hacky. We should rewrite the driver
- To incorporate a proper setup of the model
- allow a more flexible structure as to the model components used and their coupling.
Model run has the following stages: (TODO add pic)
Model Stages:
### 1) model setup stages
- (1) Configuration (for grid, model components, run, output, … everything )
- (1) Logging
- (2) Read horizontal grid
- (2) Initialize vertical grid (read topography, compute vct_a)
- (3) Initialization of static fields (geometry, interpolation, metrics)
- (4) initialize output monitors
- (4) Initialization of model components (dycore, diffusion, …)
### 2) setup time loop stage
This one is the one that is mostly experiment specific, together with choice of the model components to setup....
- (4) Compute initial conditions (prognostics)
- compute analytical
- (or read in, for us that would currently be for restarts...)
- (5) Set up time-loop, organized model run (interfaces to model components…, additional diagnostic computations for physics, register output)
### 3) run
Run the model
### 4) cleanup
In this project we want to start with the **model setup**.
The main goal of the project is to focus on the run script and configuration handling.
## Appetite
<!-- Explain how much time we want to spend and how that constrains the solution -->
## Solution
<!-- The core elements we came up with, presented in a form that’s easy for people to immediately understand -->
### Driver
- Evaluate whether to use [hydra][hydra] (last release 2022!!?) or something [`typer` cli][typer] and do the administration ourselves?
- Determine `ProcessProperties` (number of nodes)
- Instantiate [Configuration](#configuration):
- for each run: dump the actual configuration (from files, or comandline overwrites) to a directory that is unique to the run (`.icon4py_run_timestamp`) (on single IO node)
- - setup **logging** - there is simple in-code logging [setup function](https://github.com/C2SM/icon4py/blob/6c97904d8bf3363703f1fc4fdfe4b673d79025ef/model/driver/src/icon4py/model/driver/initialization_utils.py#L534) that is use now. And is patched for distributed components to preend rank information.
- run GridManager
- initialize VerticalGrid
- cleanup: can the vertical (`num_levels`) be finally separated from the `Grid`?
### Configuration
#### Requirements:
- Configuration should be read from yml files
- allow for modular configuration (configuration blocks per component)
- allow for hierarchical / partial overwrites
- setup configuration files for our testing experiments and
- from the Configuration get the Configuration Dataclasses (all `XXConfig` should be frozen `dataclass`es)
#### Implementation
- use [OmegaConf][omega-conf] (in case not something higher level like [hydra][hydra] is used, which uses omegaconf under the hood.)
### VerticalGrid
- setup `vct_a`: for now use computation option `vertical.py::get_vct_a_and_vct_b`
- read or compute topography (see [PR-747](https://github.com/C2SM/icon4py/pull/747))
- compute SLEVE coordinate
- setup VerticalGrid
## Rabbit holes
<!-- Details about the solution worth calling out to avoid problems -->
## No-gos
<!-- Anything specifically excluded from the concept: functionality or use cases we intentionally aren’t covering to fit the ## appetite or make the problem tractable -->
## Progress
<!-- Don't fill during shaping. This area is for collecting TODOs during building. As first task during building add a preliminary list of coarse-grained tasks for the project and refine them with finer-grained items when it makes sense as you work on them. -->
[hydra]:https://hydra.cc/
[omega-conf]:https://omegaconf.readthedocs.io/en/2.3_branch/
[typer]:https://typer.tiangolo.com/
- [x] Task 1 ([PR#xxxx](https://github.com/GridTools/gt4py/pulls))
- [x] Subtask A
- [x] Subtask X
- [ ] Task 2
- [x] Subtask H
- [ ] Subtask J
- [ ] Discovered Task 3
- [ ] Subtask L
- [ ] Subtask S
- [ ] Task 4