Skip to content

Commit afd7a66

Browse files
committed
add set!(::PrescribedAtmospher, checkopoint_file_path)
1 parent a9be97c commit afd7a66

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/OceanSeaIceModels/PrescribedAtmospheres.jl

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ using Oceananigans.OutputReaders: FieldTimeSeries, update_field_time_series!, ex
77
using Oceananigans.TimeSteppers: Clock, tick!
88

99
using Adapt
10+
using JLD2
1011
using Thermodynamics.Parameters: AbstractThermodynamicsParameters
1112

13+
import Oceananigans.Fields: set!
14+
import Oceananigans.OutputWriters: checkpointer_address
1215
import Oceananigans.TimeSteppers: time_step!
1316

1417
import Thermodynamics.Parameters:
@@ -22,15 +25,15 @@ import Thermodynamics.Parameters:
2225
T_0, # Enthalpy reference temperature
2326
LH_v0, # Vaporization enthalpy at the reference temperature
2427
LH_s0, # Sublimation enthalpy at the reference temperature
25-
LH_f0, # Fusionn enthalpy at the reference temperature
28+
LH_f0, # Fusion enthalpy at the reference temperature
2629
cp_d, # Heat capacity of dry air at constant pressure
2730
cp_v, # Isobaric specific heat capacity of gaseous water vapor
2831
cp_l, # Isobaric specific heat capacity of liquid water
2932
cp_i, # Isobaric specific heat capacity of water ice
3033
cv_v, # Heat capacity of dry air at constant volume
3134
cv_l, # Isobaric specific heat capacity of liquid water
3235
cv_i, # Isobaric specific heat capacity of liquid water
33-
e_int_v0, # what? someting about reference internal energy of water vapor
36+
e_int_v0, # what? something about reference internal energy of water vapor
3437
T_freeze, # Freezing temperature of _pure_ water
3538
T_triple, # Triple point temperature of _pure_ water
3639
press_triple, # Triple point pressure of pure water
@@ -75,7 +78,7 @@ Construct a set of parameters that define the density of moist air,
7578
```
7679
7780
where ``p`` is pressure, ``T`` is temperature, ``q`` defines the partition
78-
of total mass into vapor, liqiud, and ice mass fractions, and
81+
of total mass into vapor, liquid, and ice mass fractions, and
7982
``Rᵐ`` is the effective specific gas constant for the mixture,
8083
8184
```math
@@ -318,6 +321,22 @@ function Base.show(io::IO, pa::PrescribedAtmosphere)
318321
print(io, "└── boundary_layer_height: ", prettysummary(pa.boundary_layer_height))
319322
end
320323

324+
# set the clock to be the same as the ocean model
325+
function set!(model::PrescribedAtmosphere, checkpoint_file_path)
326+
addr = checkpointer_address(model)
327+
328+
jldopen(checkpoint_file_path, "r") do file
329+
checkpointed_clock = file["$addr/clock"]
330+
331+
# Update model clock
332+
set_clock!(model, checkpointed_clock)
333+
end
334+
335+
return nothing
336+
end
337+
338+
checkpointer_address(::PrescribedAtmosphere) = "HydrostaticFreeSurfaceModel"
339+
321340
"""
322341
set_clock!(sim, clock)
323342
@@ -434,7 +453,7 @@ struct TwoBandDownwellingRadiation{SW, LW}
434453
end
435454

436455
"""
437-
TwoBandDownwellingRadiation(shortwave=nothing, longwave=nothing)
456+
TwoBandDownwellingRadiation(; shortwave=nothing, longwave=nothing)
438457
439458
Return a two-band model for downwelling radiation (split in a shortwave band
440459
and a longwave band) that passes through the atmosphere and arrives at the surface of ocean
@@ -448,4 +467,3 @@ Adapt.adapt_structure(to, tsdr::TwoBandDownwellingRadiation) =
448467
adapt(to, tsdr.longwave))
449468

450469
end # module
451-

0 commit comments

Comments
 (0)