Skip to content

Commit 2d1bdf2

Browse files
committed
rename date1 -> first_day_of_month
The previous name was unclear; now it's more apparent that this variable represents the first day of the month, which gets updated monthly as the simulation progresses.
1 parent 880eba7 commit 2d1bdf2

9 files changed

+23
-23
lines changed

experiments/ClimaEarth/run_amip.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ Utilities.show_memory_usage(comms_ctx)
453453
model_sims = (atmos_sim = atmos_sim, ice_sim = ice_sim, land_sim = land_sim, ocean_sim = ocean_sim);
454454

455455
## dates
456-
dates = (; date = [date], date0 = [date0], date1 = [Dates.firstdayofmonth(date0)], new_month = [false])
456+
dates = (; date = [date], date0 = [date0], first_day_of_month = [Dates.firstdayofmonth(date0)], new_month = [false])
457457

458458
#=
459459
### Online Diagnostics
@@ -533,7 +533,7 @@ checkpoint_cb = CallbackManager.HourlyCallback(
533533
update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback(
534534
dt = FT(1),
535535
func = CallbackManager.update_firstdayofmonth!,
536-
ref_date = [dates.date1[1]],
536+
ref_date = [dates.first_day_of_month[1]],
537537
active = true,
538538
)
539539
dt_water_albedo = parse(FT, filter(x -> !occursin(x, "hours"), dt_rad))
@@ -680,7 +680,7 @@ function solve_coupler!(cs)
680680
cs.dates.date[1] = Interfacer.current_date(cs, t)
681681

682682
## print date on the first of month
683-
if cs.dates.date[1] >= cs.dates.date1[1]
683+
if cs.dates.date[1] >= cs.dates.first_day_of_month[1]
684684
ClimaComms.iamroot(comms_ctx) && @show(cs.dates.date[1])
685685
end
686686

experiments/ClimaEarth/run_cloudless_aquaplanet.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ model_sims = (atmos_sim = atmos_sim, ocean_sim = ocean_sim);
211211

212212
## dates
213213
date0 = date = Dates.DateTime(start_date, Dates.dateformat"yyyymmdd")
214-
dates = (; date = [date], date0 = [date0], date1 = [Dates.firstdayofmonth(date0)], new_month = [false])
214+
dates = (; date = [date], date0 = [date0], first_day_of_month = [Dates.firstdayofmonth(date0)], new_month = [false])
215215

216216
#=
217217
## Initialize Callbacks
@@ -226,7 +226,7 @@ checkpoint_cb = CallbackManager.HourlyCallback(
226226
update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback(
227227
dt = FT(1),
228228
func = CallbackManager.update_firstdayofmonth!,
229-
ref_date = [dates.date1[1]],
229+
ref_date = [dates.first_day_of_month[1]],
230230
active = true,
231231
)
232232
dt_water_albedo = parse(FT, filter(x -> !occursin(x, "hours"), dt_rad))
@@ -328,7 +328,7 @@ function solve_coupler!(cs)
328328
cs.dates.date[1] = Interfacer.current_date(cs, t)
329329

330330
## print date on the first of month
331-
if cs.dates.date[1] >= cs.dates.date1[1]
331+
if cs.dates.date[1] >= cs.dates.first_day_of_month[1]
332332
ClimaComms.iamroot(comms_ctx) && @show(cs.dates.date[1])
333333
end
334334

experiments/ClimaEarth/run_cloudy_aquaplanet.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ model_sims = (atmos_sim = atmos_sim, ocean_sim = ocean_sim);
232232

233233
## dates
234234
date0 = date = Dates.DateTime(start_date, Dates.dateformat"yyyymmdd")
235-
dates = (; date = [date], date0 = [date0], date1 = [Dates.firstdayofmonth(date0)], new_month = [false])
235+
dates = (; date = [date], date0 = [date0], first_day_of_month = [Dates.firstdayofmonth(date0)], new_month = [false])
236236

237237
#=
238238
## Initialize Callbacks
@@ -247,7 +247,7 @@ checkpoint_cb = CallbackManager.HourlyCallback(
247247
update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback(
248248
dt = FT(1),
249249
func = CallbackManager.update_firstdayofmonth!,
250-
ref_date = [dates.date1[1]],
250+
ref_date = [dates.first_day_of_month[1]],
251251
active = true,
252252
)
253253
callbacks = (; checkpoint = checkpoint_cb, update_firstdayofmonth! = update_firstdayofmonth!_cb)
@@ -340,7 +340,7 @@ function solve_coupler!(cs)
340340
cs.dates.date[1] = Interfacer.current_date(cs, t)
341341

342342
## print date on the first of month
343-
if cs.dates.date[1] >= cs.dates.date1[1]
343+
if cs.dates.date[1] >= cs.dates.first_day_of_month[1]
344344
ClimaComms.iamroot(comms_ctx) && @show(cs.dates.date[1])
345345
end
346346

experiments/ClimaEarth/run_cloudy_slabplanet.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ land_mask_data = artifact_data(mask_dataset_path(), "seamask")
175175

176176
## dates
177177
date0 = date = Dates.DateTime(start_date, Dates.dateformat"yyyymmdd")
178-
dates = (; date = [date], date0 = [date0], date1 = [Dates.firstdayofmonth(date0)], new_month = [false])
178+
dates = (; date = [date], date0 = [date0], first_day_of_month = [Dates.firstdayofmonth(date0)], new_month = [false])
179179

180180

181181
#=
@@ -293,7 +293,7 @@ checkpoint_cb = CallbackManager.HourlyCallback(
293293
update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback(
294294
dt = FT(1),
295295
func = CallbackManager.update_firstdayofmonth!,
296-
ref_date = [dates.date1[1]],
296+
ref_date = [dates.first_day_of_month[1]],
297297
active = true,
298298
)
299299
dt_water_albedo = parse(FT, filter(x -> !occursin(x, "hours"), dt_rad))
@@ -392,7 +392,7 @@ function solve_coupler!(cs)
392392
cs.dates.date[1] = Interfacer.current_date(cs, t)
393393

394394
## print date on the first of month
395-
if cs.dates.date[1] >= cs.dates.date1[1]
395+
if cs.dates.date[1] >= cs.dates.first_day_of_month[1]
396396
ClimaComms.iamroot(comms_ctx) && @show(cs.dates.date[1])
397397
end
398398

experiments/ClimaEarth/run_dry_held_suarez.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ model_sims = (atmos_sim = atmos_sim,);
174174

175175
## dates
176176
date0 = date = Dates.DateTime(start_date, Dates.dateformat"yyyymmdd")
177-
dates = (; date = [date], date0 = [date0], date1 = [Dates.firstdayofmonth(date0)], new_month = [false])
177+
dates = (; date = [date], date0 = [date0], first_day_of_month = [Dates.firstdayofmonth(date0)], new_month = [false])
178178

179179
#=
180180
## Initialize Callbacks
@@ -188,7 +188,7 @@ checkpoint_cb = CallbackManager.HourlyCallback(
188188
update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback(
189189
dt = FT(1),
190190
func = CallbackManager.update_firstdayofmonth!,
191-
ref_date = [dates.date1[1]],
191+
ref_date = [dates.first_day_of_month[1]],
192192
active = true,
193193
)
194194
callbacks = (; checkpoint = checkpoint_cb, update_firstdayofmonth! = update_firstdayofmonth!_cb)
@@ -240,7 +240,7 @@ function solve_coupler!(cs)
240240
cs.dates.date[1] = Interfacer.current_date(cs, t)
241241

242242
## print date on the first of month
243-
if cs.dates.date[1] >= cs.dates.date1[1]
243+
if cs.dates.date[1] >= cs.dates.first_day_of_month[1]
244244
ClimaComms.iamroot(comms_ctx) ? @show(cs.dates.date[1]) : nothing
245245
end
246246

experiments/ClimaEarth/run_moist_held_suarez.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ model_sims = (atmos_sim = atmos_sim, ocean_sim = ocean_sim);
218218

219219
## dates
220220
date0 = date = Dates.DateTime(start_date, Dates.dateformat"yyyymmdd")
221-
dates = (; date = [date], date0 = [date0], date1 = [Dates.firstdayofmonth(date0)], new_month = [false])
221+
dates = (; date = [date], date0 = [date0], first_day_of_month = [Dates.firstdayofmonth(date0)], new_month = [false])
222222

223223
#=
224224
## Initialize Callbacks
@@ -233,7 +233,7 @@ checkpoint_cb = CallbackManager.HourlyCallback(
233233
update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback(
234234
dt = FT(1),
235235
func = CallbackManager.update_firstdayofmonth!,
236-
ref_date = [dates.date1[1]],
236+
ref_date = [dates.first_day_of_month[1]],
237237
active = true,
238238
)
239239
callbacks = (; checkpoint = checkpoint_cb, update_firstdayofmonth! = update_firstdayofmonth!_cb)
@@ -324,7 +324,7 @@ function solve_coupler!(cs)
324324
cs.dates.date[1] = Interfacer.current_date(cs, t)
325325

326326
## print date on the first of month
327-
if cs.dates.date[1] >= cs.dates.date1[1]
327+
if cs.dates.date[1] >= cs.dates.first_day_of_month[1]
328328
ClimaComms.iamroot(comms_ctx) && @show(cs.dates.date[1])
329329
end
330330
ClimaComms.barrier(comms_ctx)

src/Diagnostics.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ Saves all entries in `dg` in separate HDF5 files per variable in `output_dir`.
165165
function save_diagnostics(cs::Interfacer.CoupledSimulation)
166166
for dg in cs.diagnostics
167167

168-
# Check if the date is greater than the next date to save
169-
if cs.dates.date[1] >= cs.dates.date1[1]
168+
# Check if the date has crossed to the next month
169+
if cs.dates.date[1] >= cs.dates.first_day_of_month[1]
170170
pre_save(dg.operations.accumulate, cs, dg)
171171
save_diagnostics(cs, dg)
172172
post_save(dg.operations.accumulate, cs, dg)

test/diagnostics_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ for FT in (Float32, Float64)
7777
) # or use accumulate = nothing for snapshop save
7878
cs = Interfacer.CoupledSimulation{FT}(
7979
ClimaComms.SingletonCommsContext(), # comms_ctx
80-
(date = [Dates.DateTime(0, 2)], date1 = [Dates.DateTime(0, 1)]), # dates
80+
(date = [Dates.DateTime(0, 2)], first_day_of_month = [Dates.DateTime(0, 1)]), # dates
8181
nothing, # boundary_space
8282
nothing, # fields
8383
nothing, # parsed_args

test/regridder_tests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ for FT in (Float32, Float64)
289289
)
290290

291291
# read in data on CGLL grid from the last saved date
292-
date1 = CallbackManager.strdate_to_datetime.(string(Int(time[end])))
293-
cgll_path = joinpath(REGRID_DIR, "$(hd_outfile_root)_$date1.hdf5")
292+
date_end = CallbackManager.strdate_to_datetime.(string(Int(time[end])))
293+
cgll_path = joinpath(REGRID_DIR, "$(hd_outfile_root)_$date_end.hdf5")
294294
hdfreader = CC.InputOutput.HDF5Reader(cgll_path, comms_ctx)
295295
T_cgll = CC.InputOutput.read_field(hdfreader, varname)
296296
Base.close(hdfreader)

0 commit comments

Comments
 (0)