@@ -479,23 +479,40 @@ Returns the specified atmospheric configuration (`atmos_config`) overwitten by a
479479in the coupler dictionary (`coupler_config`).
480480The returned `atmos_config` dictionary will then be used to set up the atmosphere simulation.
481481
482- In this function, parameters are overwritten in a specific order, from lowest to highest priority:
483- 1. Default atmos config
484- 2. Provided atmos config file (if any)
485- 3. TOML parameter file
486- 5. Output directory and timestep are set explicitly based on the coupler config
482+ The `atmos_config` is mostly a copy of the `coupler_config`, which has already been created
483+ by combining the default and provided atmosphere and coupler configuration files.
484+ Please see the documentation of `get_coupler_config_dict` for more details about how that is done.
485+
486+ This function makes the following changes to `coupler_config` when creating `atmos_config`:
487+ - Renaming for consistency with ClimaAtmos.jl
488+ - TOML parameter file selection (see details below)
489+ - Setting the atmos output directory to the provided `atmos_output_dir`
490+ - Adding extra atmosphere diagnostics
491+ - Manually setting the restart file suffix
487492
488493The TOML parameter file to use is chosen using the following priority:
489- If a coupler TOML file is provided, it is used. Otherwise we use an atmos TOML
490- file if it's provided. If neither is provided, we use a default coupler TOML file.
494+ If a coupler TOML file is provided, it is used.
495+ Otherwise we use an atmos TOML file if it's provided.
496+ If neither file is provided, the default ClimaAtmos parameters are used.
491497"""
492498function get_atmos_config_dict (coupler_config:: Dict , atmos_output_dir)
493499 atmos_config = deepcopy (coupler_config)
494500
501+ # Rename parameters for consistency with ClimaAtmos.jl
495502 # Rename atmosphere config file from ClimaCoupler convention to ClimaAtmos convention
496503 atmos_config[" config_file" ] = coupler_config[" atmos_config_file" ]
497504
498- # use atmos toml if coupler toml is not defined
505+ # Ensure Atmos's own checkpoints are synced up with ClimaCoupler, so that we
506+ # can pick up from where we have left. NOTE: This should not be needed, but
507+ # there is no easy way to initialize ClimaAtmos with a different t_start
508+ atmos_config[" dt_save_state_to_disk" ] = coupler_config[" checkpoint_dt" ]
509+
510+ # The Atmos `get_simulation` function expects the atmos config to contains its timestep size
511+ # in the `dt` field. If there is a `dt_atmos` field in coupler_config, we add it to the atmos config as `dt`
512+ dt_atmos = haskey (coupler_config, " dt_atmos" ) ? coupler_config[" dt_atmos" ] : coupler_config[" dt" ]
513+ atmos_config[" dt" ] = dt_atmos
514+
515+ # Use atmos toml if coupler toml is not defined
499516 # If we can't find the file at the relative path, prepend pkgdir(ClimaAtmos)
500517 atmos_toml = map (atmos_config[" toml" ]) do file
501518 isfile (file) ? file : joinpath (pkgdir (CA), file)
@@ -511,22 +528,12 @@ function get_atmos_config_dict(coupler_config::Dict, atmos_output_dir)
511528 atmos_config[" output_dir_style" ] = " RemovePreexisting"
512529 atmos_config[" output_dir" ] = atmos_output_dir
513530
514- # Ensure Atmos's own checkpoints are synced up with ClimaCoupler, so that we
515- # can pick up from where we have left. NOTE: This should not be needed, but
516- # there is no easy way to initialize ClimaAtmos with a different t_start
517- atmos_config[" dt_save_state_to_disk" ] = coupler_config[" checkpoint_dt" ]
518-
519531 # Add all extra atmos diagnostic entries into the vector of atmos diagnostics
520532 atmos_config[" diagnostics" ] =
521533 haskey (atmos_config, " diagnostics" ) ?
522534 vcat (atmos_config[" diagnostics" ], coupler_config[" extra_atmos_diagnostics" ]) :
523535 coupler_config[" extra_atmos_diagnostics" ]
524536
525- # The Atmos `get_simulation` function expects the atmos config to contains its timestep size
526- # in the `dt` field. If there is a `dt_atmos` field in coupler_config, we add it to the atmos config as `dt`
527- dt_atmos = haskey (coupler_config, " dt_atmos" ) ? coupler_config[" dt_atmos" ] : coupler_config[" dt" ]
528- atmos_config[" dt" ] = dt_atmos
529-
530537 # set restart file to the initial file saved in this location if it is not nothing
531538 # TODO this is hardcoded and should be fixed once we have a better restart system
532539 if ! isnothing (atmos_config[" restart_file" ])
0 commit comments