|
| 1 | +# Input |
| 2 | + |
| 3 | +The `Input` module provides functions for parsing command-line arguments and loading |
| 4 | +configuration files for ClimaCoupler simulations. |
| 5 | + |
| 6 | +## Providing Configuration Options |
| 7 | + |
| 8 | +ClimaCoupler simulations have a variety of configuration options, which are |
| 9 | +described in the section [Available Configuration Options](#available-configuration-options) below. |
| 10 | + |
| 11 | +Users can configure a coupled simulation through 2 main entry points: |
| 12 | +command-line arguments and configuration files. Each method, and the |
| 13 | +priority between them, is explained here. |
| 14 | + |
| 15 | +Note that all of these configuration are optional; a default AMIP simulation |
| 16 | +can be set up with the 0-argument constructor `CoupledSimulation()`. |
| 17 | + |
| 18 | +### Configuration Files |
| 19 | + |
| 20 | +Configuration files are YAML files that specify simulation parameters. They can be |
| 21 | +used to specify a valid setting for any configuration option. |
| 22 | + |
| 23 | +Note that since the atmosphere model has many configuration options on its own, |
| 24 | +we also support providing an atmosphere-specific configuration file. As a result, |
| 25 | +multiple configuration files can be used together: |
| 26 | + |
| 27 | +- **Coupler config file** (`--config_file`): Main configuration file for the coupled simulation |
| 28 | +- **Atmos config file** (`--atmos_config_file`): Optional ClimaAtmos-specific configuration |
| 29 | +- **TOML parameter files** (`--coupler_toml`): One or more TOML files containing model parameters |
| 30 | + |
| 31 | +When multiple config files are specified, values in the coupler config file will take |
| 32 | +precedence over those in the atmosphere config file. This is explained in more detail |
| 33 | +in the [Precendence of Config Files and CLI Arguments](#precendence-of-config-files-and-cli-arguments) |
| 34 | +section below. |
| 35 | + |
| 36 | +### Parameter TOML Files |
| 37 | + |
| 38 | +Analogous to configuration files, which specify simulation options such as component models or |
| 39 | +parameterizations to use, ClimaCoupler also accepts optional TOML files of parameter values. |
| 40 | + |
| 41 | +If a TOML file is provided, the default parameter values will be overwritten by the values |
| 42 | +specified in the TOML. If no TOML file is provided, default parameter values will be used. |
| 43 | + |
| 44 | +Since ClimaCoupler accepts coupler config files _and_ atmosphere config files, we may encounter |
| 45 | +a case where a TOML file is specified in both config files. In this case, the coupler TOML |
| 46 | +file takes highest priority; only if there is no coupler TOML will the atmosphere-specific |
| 47 | +TOML be used. |
| 48 | + |
| 49 | +### Command-Line Input (CLI) Arguments |
| 50 | + |
| 51 | +Command-line arguments can be provided when running a simulation: |
| 52 | + |
| 53 | +```bash |
| 54 | +julia run_amip.jl --config_file="path/to/config.yml" --job_id="amip_default" |
| 55 | +``` |
| 56 | + |
| 57 | +Typically, we rely mostly on configuration files, and provide only the `config_file` |
| 58 | +and `job_id` via CLI arguments, though if desired any input can be specified in the command line. |
| 59 | +All available options and their defaults can be viewed by running with `--help`. |
| 60 | + |
| 61 | +### Precendence of Config Files and CLI Arguments |
| 62 | + |
| 63 | +Users have the ability to specify arguments via both CLI arguments and configuration |
| 64 | +files for any given simulation. If this is done, the options are merged |
| 65 | +with the following precedence (from lowest to highest priority): |
| 66 | + |
| 67 | +1. **ClimaAtmos defaults** - Default values from the ClimaAtmos package |
| 68 | +2. **ClimaCoupler defaults** - Default values defined in [`argparse_settings()`](@ref) |
| 69 | +3. **Command-line arguments** - Arguments passed via the command line |
| 70 | +4. **ClimaAtmos configuration file** - YAML file specified via `--atmos_config_file` or in the coupler config file |
| 71 | +5. **ClimaCoupler configuration file** - YAML file specified via `--config_file` (default: `config/ci_configs/amip_default.yml`) |
| 72 | + |
| 73 | +## Available Configuration Options |
| 74 | + |
| 75 | +The following table lists all available command-line arguments organized by category: |
| 76 | + |
| 77 | +#### Simulation-identifying information |
| 78 | + |
| 79 | +| Argument | Type | Default | Valid Options | Description | |
| 80 | +|----------|------|---------|---------------|-------------| |
| 81 | +| `--config_file` | String | `config/ci_configs/amip_default.yml` | Any valid file path | YAML file used to set the configuration of the coupled model | |
| 82 | +| `--job_id` | String | `nothing` | Any string | A unique identifier for this run, defaults to the config file name | |
| 83 | +| `--print_config_dict` | Bool | `true` | `true`, `false` | Whether to print the final configuration dictionary | |
| 84 | +| `--mode_name` | String | `"amip"` | `cmip`, `amip`, `subseasonal`, `slabplanet`, `slabplanet_aqua`, `slabplanet_terra` | Mode of coupled simulation | |
| 85 | +| `--coupler_toml` | Vector{String} | `[]` | Any list of valid TOML file paths | Optional list of paths to TOML files used to overwrite default model parameters | |
| 86 | + |
| 87 | +#### Computational simulation setup |
| 88 | + |
| 89 | +| Argument | Type | Default | Valid Options | Description | |
| 90 | +|----------|------|---------|---------------|-------------| |
| 91 | +| `--unique_seed` | Bool | `false` | `true`, `false` | Whether to set the random number seed to a unique value | |
| 92 | +| `--FLOAT_TYPE` | String | `"Float64"` | `Float64`, `Float32` | Floating point precision | |
| 93 | +| `--device` | String | `"auto"` | `auto`, `CPUSingleThreaded`, `CPUMultiThreaded`, `CUDADevice` | Device type to control running on CPU or GPU | |
| 94 | + |
| 95 | +#### Time information |
| 96 | + |
| 97 | +| Argument | Type | Default | Valid Options | Description | |
| 98 | +|----------|------|---------|---------------|-------------| |
| 99 | +| `--use_itime` | Bool | `true` | `true`, `false` | Whether to use ClimaUtilities ITime (integer time) or Float64 | |
| 100 | +| `--t_end` | String | `"800secs"` | `"Nsecs"`, `"Nmins"`, `"Nhours"`, `"Ndays"`, `"Inf"` | End time of the simulation, relative to the start date | |
| 101 | +| `--t_start` | String | `"0secs"` | `"Nsecs"`, `"Nmins"`, `"Nhours"`, `"Ndays"`, `"Inf"` | Start time of the simulation, relative to the start date | |
| 102 | +| `--start_date` | String | `"20000101"` | `"YYYYMMDD"` format | Start date of the simulation | |
| 103 | +| `--dt_cpl` | String | `"400secs"` | `"Nsecs"`, `"Nmins"`, `"Nhours"`, `"Ndays"`, `"Inf"` | Coupling time step | |
| 104 | +| `--dt` | String | `"400secs"` | `"Nsecs"`, `"Nmins"`, `"Nhours"`, `"Ndays"`, `"Inf"` | Component model time step (used if individual component dt's not specified) | |
| 105 | +| `--dt_atmos` | String | `nothing` | `"Nsecs"`, `"Nmins"`, `"Nhours"`, `"Ndays"`, `"Inf"` | Atmos simulation time step (alternative to `dt`) | |
| 106 | +| `--dt_land` | String | `nothing` | `"Nsecs"`, `"Nmins"`, `"Nhours"`, `"Ndays"`, `"Inf"` | Land simulation time step (alternative to `dt`) | |
| 107 | +| `--dt_ocean` | String | `nothing` | `"Nsecs"`, `"Nmins"`, `"Nhours"`, `"Ndays"`, `"Inf"` | Ocean simulation time step (alternative to `dt`) | |
| 108 | +| `--dt_seaice` | String | `nothing` | `"Nsecs"`, `"Nmins"`, `"Nhours"`, `"Ndays"`, `"Inf"` | Sea ice simulation time step (alternative to `dt`) | |
| 109 | +| `--checkpoint_dt` | String | `"90days"` | `"Nsecs"`, `"Nmins"`, `"Nhours"`, `"Ndays"`, `"Inf"` | Time interval for checkpointing | |
| 110 | + |
| 111 | +Note: If any component model-specific timestep is specified, _all_ component-model |
| 112 | +specific timesteps should be specified, rather than only `dt`. |
| 113 | + |
| 114 | +#### Space information |
| 115 | + |
| 116 | +| Argument | Type | Default | Valid Options | Description | |
| 117 | +|----------|------|---------|---------------|-------------| |
| 118 | +| `--h_elem` | Int | `16` | Any positive integer | Number of horizontal elements to use for the boundary space | |
| 119 | +| `--share_surface_space` | Bool | `true` | `true`, `false` | Whether to share the surface space between surface models, atmosphere, and boundary | |
| 120 | + |
| 121 | +#### Restart information |
| 122 | + |
| 123 | +| Argument | Type | Default | Valid Options | Description | |
| 124 | +|----------|------|---------|---------------|-------------| |
| 125 | +| `--detect_restart_files` | Bool | `false` | `true`, `false` | Whether to automatically use restart files if available | |
| 126 | +| `--restart_dir` | String | `nothing` | Any valid directory path | Directory containing restart files | |
| 127 | +| `--restart_t` | Int | `nothing` | Any integer (seconds) | Time in seconds rounded to nearest index to use at `t_start` for restarted simulation | |
| 128 | +| `--restart_cache` | Bool | `true` | `true`, `false` | Whether to read the cache from the restart file if available | |
| 129 | +| `--save_cache` | Bool | `true` | `true`, `false` | Whether to save the state and cache or only the state when checkpointing | |
| 130 | + |
| 131 | +#### Diagnostics and output |
| 132 | + |
| 133 | +| Argument | Type | Default | Valid Options | Description | |
| 134 | +|----------|------|---------|---------------|-------------| |
| 135 | +| `--use_coupler_diagnostics` | Bool | `true` | `true`, `false` | Whether to compute and output coupler diagnostics | |
| 136 | +| `--coupler_output_dir` | String | `"experiments/ClimaEarth/output"` | Any valid directory path | Directory to save output files | |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | +#### Conservation and RMSE checks |
| 141 | + |
| 142 | +| Argument | Type | Default | Valid Options | Description | |
| 143 | +|----------|------|---------|---------------|-------------| |
| 144 | +| `--energy_check` | Bool | `false` | `true`, `false` | Whether to check energy conservation | |
| 145 | +| `--conservation_softfail` | Bool | `false` | `true`, `false` | Whether to soft fail on conservation errors | |
| 146 | +| `--rmse_check` | Bool | `false` | `true`, `false` | Whether to check RMSE of some physical fields | |
| 147 | + |
| 148 | +#### ClimaAtmos specific |
| 149 | + |
| 150 | +| Argument | Type | Default | Valid Options | Description | |
| 151 | +|----------|------|---------|---------------|-------------| |
| 152 | +| `--surface_setup` | String | `"PrescribedSurface"` | `PrescribedSurface`, `DefaultMoninObukhov` | Triggers ClimaAtmos into coupled mode | |
| 153 | +| `--atmos_config_file` | String | `nothing` | Any valid file path | Optional YAML file used to overwrite default model parameters | |
| 154 | +| `--atmos_log_progress` | Bool | `false` | `true`, `false` | Use ClimaAtmos walltime logging callback instead of default ClimaCoupler one | |
| 155 | +| `--albedo_model` | String | `"CouplerAlbedo"` | `ConstantAlbedo`, `RegressionFunctionAlbedo`, `CouplerAlbedo` | Type of albedo model | |
| 156 | +| `--extra_atmos_diagnostics` | Vector{Dict{Any, Any}} | `[]` | List of dictionaries | List of dictionaries containing information about additional atmosphere diagnostics to output | |
| 157 | + |
| 158 | +#### ClimaLand specific |
| 159 | + |
| 160 | +| Argument | Type | Default | Valid Options | Description | |
| 161 | +|----------|------|---------|---------------|-------------| |
| 162 | +| `--land_model` | String | `"bucket"` | `bucket`, `integrated` | Land model to use | |
| 163 | +| `--land_temperature_anomaly` | String | `"aquaplanet"` | `amip`, `aquaplanet`, `nothing` | Type of temperature anomaly for land model | |
| 164 | +| `--use_land_diagnostics` | Bool | `true` | `true`, `false` | Whether to compute and output land model diagnostics | |
| 165 | +| `--land_spun_up_ic` | Bool | `true` | `true`, `false` | Whether to use integrated land initial conditions from spun up state | |
| 166 | +| `--bucket_albedo_type` | String | `"map_static"` | `map_static`, `function`, `map_temporal` | Access bucket surface albedo information from data file | |
| 167 | +| `--bucket_initial_condition` | String | `""` | Any valid file path | File path for a NetCDF file (read documentation about requirements) | |
| 168 | +| `--era5_initial_condition_dir` | String | `nothing` | Any valid directory path | Directory containing ERA5 initial condition files (subseasonal mode). Filenames inferred from `start_date`. Generated with `https://github.com/CliMA/WeatherQuest` | |
| 169 | + |
| 170 | +#### Ice model specific |
| 171 | + |
| 172 | +| Argument | Type | Default | Valid Options | Description | |
| 173 | +|----------|------|---------|---------------|-------------| |
| 174 | +| `--ice_model` | String | `"prescribed"` | `prescribed`, `clima_seaice` | Sea ice model to use | |
| 175 | + |
| 176 | + |
| 177 | +#### Ocean model specific |
| 178 | + |
| 179 | +| Argument | Type | Default | Valid Options | Description | |
| 180 | +|----------|------|---------|---------------|-------------| |
| 181 | +| `--evolving_ocean` | Bool | `true` | `true`, `false` | Whether to use a dynamic slab ocean model, as opposed to constant surface temperatures | |
| 182 | + |
| 183 | +## Input API |
| 184 | + |
| 185 | +```@docs |
| 186 | +ClimaCoupler.Input.argparse_settings |
| 187 | +ClimaCoupler.Input.parse_commandline |
| 188 | +ClimaCoupler.Input.get_coupler_config_dict |
| 189 | +ClimaCoupler.Input.get_coupler_args |
| 190 | +``` |
0 commit comments