Skip to content

Commit d9f65ad

Browse files
committed
Restructure output directory
And don't use `atmos.p.output_dir` The output structure looks like this: ``` coupler_output_dir_amip/ ├── checkpoints │ └── checkpoints for the various models ├── 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/ ```
1 parent f66d5df commit d9f65ad

File tree

11 files changed

+130
-79
lines changed

11 files changed

+130
-79
lines changed

NEWS.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,33 @@ As a part of the post processing pipeline, bias plots for variables at the
2727
pressure levels of 850.0, 500.0, 250.0 hPa and bias plots over latitude and
2828
pressure levels are being created.
2929

30+
### Code cleanup
3031

32+
#### Output path updates - PRs [#1106](https://github.com/CliMA/ClimaCoupler.jl/pull/1058),
33+
[#1106](https://github.com/CliMA/ClimaCoupler.jl/pull/1106)
3134

32-
### Code cleanup
33-
#### Output path update - PR [#1058](https://github.com/CliMA/ClimaCoupler.jl/pull/1058)
3435
Previously, ClimaEarth simulation outputs were saved in a path
35-
`experiments/ClimaEarth/output/$mode_name/$job_id/artifacts/`.
36-
This PR removes `mode_name` has from this pattern, so output will now be in
37-
`experiments/ClimaEarth/output/$job_id/artifacts/`.
36+
`experiments/ClimaEarth/output/$mode_name/$job_id/artifacts/`. Now, `ClimaEarth`
37+
creates output folders with an increment (increasing the counter every time the
38+
simulation is run). This is in preparation to restarts. The output now looks
39+
like
40+
```
41+
coupler_output_dir_amip/
42+
├── checkpoints
43+
│ └── checkpoints for the various models
44+
├── artifacts
45+
│ └── plots produced by the postporcessing step
46+
├── output_0000/
47+
│ ├── atmos/
48+
│ │ └── output of the atmos model
49+
│ └── ocean/
50+
│ └── output of the ocean model
51+
├── output_0001/
52+
│ └── ... component model outputs in their folders ...
53+
├── output_0002/
54+
│ └── ... component model outputs in their folders ...
55+
└── output_active -> output_0002/
56+
``
3857
Note that any external scripts that assume an output path will need to be updated.
3958
4059
#### Remove ClimaCoupler.Diagnostics module - PR [#953](https://github.com/CliMA/ClimaCoupler.jl/pull/953)

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.1.1"
77
ClimaComms = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
88
ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
99
ClimaCoreTempestRemap = "d934ef94-cdd4-4710-83d6-720549644b70"
10+
ClimaUtilities = "b3f4f4ca-9299-4f7f-bd9b-81e1242a7513"
1011
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1112
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
1213
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
@@ -20,6 +21,7 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
2021
ClimaComms = "0.5.6, 0.6"
2122
ClimaCore = "0.14.19"
2223
ClimaCoreTempestRemap = "0.3"
24+
ClimaUtilities = "0.1.14"
2325
Dates = "1"
2426
JLD2 = "0.4, 0.5"
2527
Logging = "1"

experiments/ClimaEarth/components/atmosphere/climaatmos.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ FluxCalculator.get_surface_params(sim::ClimaAtmosSimulation) = CAP.surface_fluxe
293293
### ClimaAtmos.jl model-specific functions (not explicitly required by ClimaCoupler.jl)
294294
###
295295
"""
296-
get_atmos_config_dict(coupler_dict::Dict, job_id::String)
296+
get_atmos_config_dict(coupler_dict::Dict, job_id::String, atmos_output_dir)
297297
298298
Returns the specified atmospheric configuration (`atmos_config`) overwitten by arguments
299299
in the coupler dictionary (`config_dict`).
@@ -313,7 +313,7 @@ The TOML parameter file to use is chosen using the following priority:
313313
If a coupler TOML file is provided, it is used. Otherwise we use an atmos TOML
314314
file if it's provided. If neither is provided, we use a default coupler TOML file.
315315
"""
316-
function get_atmos_config_dict(coupler_dict::Dict, job_id::String)
316+
function get_atmos_config_dict(coupler_dict::Dict, job_id::String, atmos_output_dir)
317317
atmos_config_file = coupler_dict["atmos_config_file"]
318318
atmos_config_repo = coupler_dict["atmos_config_repo"]
319319
# override default or specified configs with coupler arguments, and set the correct atmos config_file
@@ -357,7 +357,7 @@ function get_atmos_config_dict(coupler_dict::Dict, job_id::String)
357357
end
358358

359359
# Specify atmos output directory to be inside the coupler output directory
360-
atmos_output_dir = joinpath(coupler_dict["coupler_output_dir"], job_id, "clima_atmos")
360+
atmos_config["output_dir_style"] = "RemovePreexisting"
361361
atmos_config["output_dir"] = atmos_output_dir
362362

363363
# Access extra atmosphere diagnostics from coupler so we can rename for atmos code

experiments/ClimaEarth/hierarchy/climate_plots.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ for job_id in ["dry_held_suarez", "moist_held_suarez"]
1414
DATA_DIR = "experiments/ClimaEarth/$job_id/$job_id/clima_atmos/output_active/"
1515
else
1616
build = ENV["BUILDKITE_BUILD_NUMBER"]
17-
DATA_DIR = "/central/scratch/esm/slurm-buildkite/climacoupler-ci/$build/climacoupler-ci/$job_id/$job_id/clima_atmos/output_active/"
17+
DATA_DIR = "/central/scratch/esm/slurm-buildkite/climacoupler-ci/$build/climacoupler-ci/$job_id/output_active/clima_atmos/"
1818
end
1919

2020
reduction = "6h_inst"

experiments/ClimaEarth/run_amip.jl

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,25 @@ add_extra_diagnostics!(config_dict)
125125
plot_diagnostics,
126126
) = get_coupler_args(config_dict)
127127

128+
#=
129+
### I/O Directory Setup `setup_output_dirs` returns `dir_paths.output =
130+
COUPLER_OUTPUT_DIR`, which is the directory where the output of the simulation
131+
will be saved, `dir_paths.artifacts` is the directory where the plots (from
132+
postprocessing and the conservation checks) of the simulation will be saved,
133+
#and `dir_paths.checkpoints`, where restart files are saved.
134+
=#
135+
136+
COUPLER_OUTPUT_DIR = joinpath(output_dir_root, job_id)
137+
dir_paths = Utilities.setup_output_dirs(output_dir = COUPLER_OUTPUT_DIR, comms_ctx = comms_ctx)
138+
@info "Coupler output directory $(dir_paths.output)"
139+
@info "Coupler artifacts directory $(dir_paths.artifacts)"
140+
@info "Coupler checkpoint directory $(dir_paths.checkpoints)"
141+
128142
## get component model dictionaries (if applicable)
129143
## Note this step must come after parsing the coupler config dictionary, since
130144
## some parameters are passed from the coupler config to the component model configs
131-
atmos_config_dict = get_atmos_config_dict(config_dict, job_id)
145+
atmos_output_dir = joinpath(dir_paths.output, "clima_atmos")
146+
atmos_config_dict = get_atmos_config_dict(config_dict, job_id, atmos_output_dir)
132147
(; dt_rad, output_default_diagnostics) = get_atmos_args(atmos_config_dict)
133148

134149
## set unique random seed if desired, otherwise use default
@@ -137,18 +152,6 @@ Random.seed!(random_seed)
137152

138153
tspan = (t_start, t_end)
139154

140-
#=
141-
### I/O Directory Setup
142-
`Utilities.setup_output_dirs` returns `dir_paths.output = COUPLER_OUTPUT_DIR`, which is the directory where the output of the simulation will be saved, and `dir_paths.artifacts` is the directory where
143-
the plots (from postprocessing and the conservation checks) of the simulation will be saved. `dir_paths.regrid` is the directory where the regridding
144-
temporary files will be saved.
145-
=#
146-
147-
COUPLER_OUTPUT_DIR = joinpath(output_dir_root, job_id)
148-
dir_paths = Utilities.setup_output_dirs(output_dir = COUPLER_OUTPUT_DIR, comms_ctx = comms_ctx)
149-
@info "Coupler output directory $(dir_paths.output)"
150-
@info "Coupler artifacts directory $(dir_paths.artifacts)"
151-
152155
#=
153156
## Data File Paths
154157
=#
@@ -848,13 +851,12 @@ if ClimaComms.iamroot(comms_ctx)
848851

849852
# define variable names and output directories for each diagnostic
850853
amip_short_names_atmos = ["ta", "ua", "hus", "clw", "pr", "ts", "toa_fluxes_net"]
851-
output_dir_atmos = atmos_sim.integrator.p.output_dir
852854
amip_short_names_coupler = ["F_turb_energy"]
853855
output_dir_coupler = dir_paths.output
854856

855857
# Check if all output variables are available in the specified directories
856858
make_diagnostics_plots(
857-
output_dir_atmos,
859+
atmos_output_dir,
858860
dir_paths.artifacts,
859861
short_names = amip_short_names_atmos,
860862
output_prefix = "atmos_",
@@ -870,17 +872,16 @@ if ClimaComms.iamroot(comms_ctx)
870872
# Check this because we only want monthly data for making plots
871873
if t_end > 84600 * 31 * 3 && output_default_diagnostics
872874
include("leaderboard/leaderboard.jl")
873-
diagnostics_folder_path = atmos_sim.integrator.p.output_dir
874875
leaderboard_base_path = dir_paths.artifacts
875-
compute_leaderboard(leaderboard_base_path, diagnostics_folder_path)
876-
compute_pfull_leaderboard(leaderboard_base_path, diagnostics_folder_path)
876+
compute_leaderboard(leaderboard_base_path, atmos_output_dir)
877+
compute_pfull_leaderboard(leaderboard_base_path, atmos_output_dir)
877878
end
878879
end
879880
## plot extra atmosphere diagnostics if specified
880881
if plot_diagnostics
881882
@info "Plotting diagnostics"
882883
include("user_io/diagnostics_plots.jl")
883-
make_diagnostics_plots(atmos_sim.integrator.p.output_dir, dir_paths.artifacts)
884+
make_diagnostics_plots(atmos_output_dir, dir_paths.artifacts)
884885
end
885886

886887
## plot all model states and coupler fields (useful for debugging)

experiments/ClimaEarth/run_cloudless_aquaplanet.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ start_date = "19790301"
5555
hourly_checkpoint = true
5656
dt_rad = "6hours"
5757

58+
#=
59+
### I/O Directory Setup
60+
=#
61+
62+
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = ClimaComms.context())
63+
@info(config_dict)
64+
5865
## namelist
5966
config_dict = Dict(
6067
# general
@@ -109,7 +116,8 @@ config_dict = Dict(
109116
)
110117

111118
## merge dictionaries of command line arguments, coupler dictionary and component model dictionaries
112-
atmos_config_dict = get_atmos_config_dict(config_dict, job_id)
119+
atmos_output_dir = joinpath(dir_paths.output, "clima_atmos")
120+
atmos_config_dict = get_atmos_config_dict(config_dict, job_id, atmos_output_dir)
113121
atmos_config_object = CA.AtmosConfig(atmos_config_dict)
114122

115123
#=
@@ -118,13 +126,6 @@ atmos_config_object = CA.AtmosConfig(atmos_config_dict)
118126

119127
comms_ctx = Utilities.get_comms_context(Dict("device" => "auto"))
120128

121-
#=
122-
### I/O Directory Setup
123-
=#
124-
125-
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = comms_ctx)
126-
@info(config_dict)
127-
128129
#=
129130
## Component Model Initialization
130131
=#

experiments/ClimaEarth/run_cloudy_aquaplanet.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ start_date = "19790301"
5555
hourly_checkpoint = true
5656
dt_rad = "6hours"
5757

58+
#=
59+
### I/O Directory Setup
60+
=#
61+
62+
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = ClimaComms.context())
63+
@info(config_dict)
64+
5865
## namelist
5966
config_dict = Dict(
6067
# general
@@ -122,7 +129,8 @@ config_dict = Dict(
122129
)
123130

124131
## merge dictionaries of command line arguments, coupler dictionary and component model dictionaries
125-
atmos_config_dict = get_atmos_config_dict(config_dict, job_id)
132+
atmos_output_dir = joinpath(dir_paths.output, "clima_atmos")
133+
atmos_config_dict = get_atmos_config_dict(config_dict, job_id, atmos_output_dir)
126134
atmos_config_object = CA.AtmosConfig(atmos_config_dict)
127135

128136
## override default toml parameters
@@ -143,13 +151,6 @@ comms_ctx = Utilities.get_comms_context(Dict("device" => "auto"))
143151
ClimaComms.init(comms_ctx)
144152

145153

146-
#=
147-
### I/O Directory Setup
148-
=#
149-
150-
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = comms_ctx)
151-
@info(config_dict)
152-
153154
#=
154155
## Component Model Initialization
155156
=#

experiments/ClimaEarth/run_cloudy_slabplanet.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ start_date = "19790321"
6060
hourly_checkpoint = true
6161
dt_rad = "6hours"
6262

63+
#=
64+
### I/O Directory Setup
65+
=#
66+
67+
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = ClimaComms.context())
68+
@info(config_dict)
69+
70+
6371
## namelist
6472
config_dict = Dict(
6573
# general
@@ -126,7 +134,8 @@ config_dict = Dict(
126134
)
127135

128136
## merge dictionaries of command line arguments, coupler dictionary and component model dictionaries
129-
atmos_config_dict = get_atmos_config_dict(config_dict, job_id)
137+
atmos_output_dir = joinpath(dir_paths.output, "clima_atmos")
138+
atmos_config_dict = get_atmos_config_dict(config_dict, job_id, atmos_output_dir)
130139
atmos_config_object = CA.AtmosConfig(atmos_config_dict)
131140

132141
# override default toml parameters
@@ -145,13 +154,6 @@ atmos_config_object.toml_dict["max_area_limiter_scale"]["value"] = 0
145154

146155
comms_ctx = Utilities.get_comms_context(Dict("device" => "auto"))
147156

148-
#=
149-
### I/O Directory Setup
150-
=#
151-
152-
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = comms_ctx)
153-
@info(config_dict)
154-
155157
#=
156158
## Data File Paths
157159
=#

experiments/ClimaEarth/run_dry_held_suarez.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ tspan = (Float64(0.0), Float64(Utilities.time_to_seconds(t_end)))
5555
start_date = "19790301"
5656
hourly_checkpoint = true
5757

58+
#=
59+
### I/O Directory Setup
60+
=#
61+
62+
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = ClimaComms.context())
63+
@info(config_dict)
64+
5865
## namelist
5966
config_dict = Dict(
6067
# general
@@ -101,7 +108,8 @@ config_dict = Dict(
101108
)
102109

103110
## merge dictionaries of command line arguments, coupler dictionary and component model dictionaries
104-
atmos_config_dict = get_atmos_config_dict(config_dict, job_id)
111+
atmos_output_dir = joinpath(dir_paths.output, "clima_atmos")
112+
atmos_config_dict = get_atmos_config_dict(config_dict, job_id, atmos_output_dir)
105113
atmos_config_object = CA.AtmosConfig(atmos_config_dict)
106114

107115
#=
@@ -110,13 +118,6 @@ atmos_config_object = CA.AtmosConfig(atmos_config_dict)
110118

111119
comms_ctx = Utilities.get_comms_context(Dict("device" => "auto"))
112120

113-
#=
114-
### I/O Directory Setup
115-
=#
116-
117-
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = comms_ctx)
118-
@info(config_dict)
119-
120121
#=
121122
## Component Model Initialization
122123
=#

experiments/ClimaEarth/run_moist_held_suarez.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ tspan = (Float64(0.0), Float64(Utilities.time_to_seconds(t_end)))
5757
start_date = "19790301"
5858
hourly_checkpoint = true
5959

60+
#=
61+
### I/O Directory Setup
62+
=#
63+
64+
65+
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = ClimaComms.context())
66+
@info(config_dict)
67+
6068
## namelist
6169
config_dict = Dict(
6270
# general
@@ -109,7 +117,8 @@ config_dict = Dict(
109117
# TODO: may need to switch to Bulk fluxes
110118

111119
## merge dictionaries of command line arguments, coupler dictionary and component model dictionaries
112-
atmos_config_dict = get_atmos_config_dict(config_dict, job_id)
120+
atmos_output_dir = joinpath(dir_paths.output, "clima_atmos")
121+
atmos_config_dict = get_atmos_config_dict(config_dict, job_id, atmos_output_dir)
113122
atmos_config_object = CA.AtmosConfig(atmos_config_dict)
114123

115124
#=
@@ -118,13 +127,6 @@ atmos_config_object = CA.AtmosConfig(atmos_config_dict)
118127

119128
comms_ctx = Utilities.get_comms_context(Dict("device" => "auto"))
120129

121-
#=
122-
### I/O Directory Setup
123-
=#
124-
125-
dir_paths = Utilities.setup_output_dirs(output_dir = coupler_output_dir, comms_ctx = comms_ctx)
126-
@info(config_dict)
127-
128130
#=
129131
## Component Model Initialization
130132
=#

0 commit comments

Comments
 (0)