Utilities
This module contains functions, objects, and constants used by various modules in the coupler.
Utilities API
ClimaCoupler.Utilities.get_comms_context — Functionget_comms_context(config_dict)Sets up the appropriate ClimaComms context for the device the model is to be run on, choosing from the following options: - CPU single threaded - CPU with MPI - GPU
If no device is passed to ClimaComms.context() then ClimaComms automatically selects the device from which this code is called.
Arguments
config_dict: dictionary containing a "device" flag which decides which device context is needed
ClimaCoupler.Utilities.get_device — Functionget_device(config_dict)Returns the device on which the model is being run
Arguments
config_dict: dictionary containing a "device" flag which decides which device to run on
ClimaCoupler.Utilities.show_memory_usage — Functionshow_memory_usage()Display and return the maximum resident set size (RSS) memory footprint on the CPU of this process since it began.
ClimaCoupler.Utilities.setup_output_dirs — Functionsetup_output_dirs(output_dir_root = pwd(),
    artifacts_dir = joinpath(output_dir, "artifacts"),
    checkpoints_dir = joinpath(output_dir, "checkpoints"),
    regrid_dir = nothing,
    comms_ctx,
)Create output directories for the experiment. If comms_ctx is provided, only the root process will create the directories. By default, the artifacts and checkpoints directories are created inside the root output directory with the names artifacts/ and checkpoints/. The regrid directory is by default created as a temporary directory inside the root output directory and is automatically deleted when the process exits.
ClimaUtilities.OutputPathGenerator is used so that simulations can be re-run and re-started. The output path looks like:
coupler_output_dir_amip/
├── checkpoints
│       └── checkpoints for the various models
├── artifacts
│       └── plots produced by the postporcessing step
├── regrid_tmp_<random_tempdir>/
│       └── temporary files used for regridding
├── output_0000/
│   ├── atmos/
│   │   └── output of the atmos model
│   └── ocean/
│       └── output of the ocean model
├── output_0001/
│   └── ... component model outputs in their folders ...
├── output_0002/
│   └── ... component model outputs in their folders ...
└── output_active -> output_0002/Arguments
output_dir::String: The directory where the output files will be stored. Default is the current directory.artifacts_dir::String: The directory where plots (from postprocessing and conservation checks) will be stored. Default isoutput_dir/artifacts/.checkpoint_dir::String: The directory where the checkpoint files will be stored. Default isoutput_dir/checkpoints/.regrid_dir::String: The directory where the regridded files will be stored. Default isoutput_dir/regrid_tmp_<random_tempdir>/.comms_ctx::Union{Nothing, ClimaComms.AbstractCommsContext}: The communicator context. If provided, only the root process will create the directories.
Returns
- A NamedTuple with the paths to output directories for each component and the coupler,
 
as well as paths toartifacts, regrid, and checkpoints directories.
ClimaCoupler.Utilities.time_to_seconds — Functiontime_to_seconds(s::String)Convert a string to seconds. The string should be in the format numberunit, where unit is one of secs, mins, hours, or days.
Arguments
s::String: The string to convert to seconds.
Returns
- The number of seconds represented by the string.