Skip to content

Commit

Permalink
csf extrema
Browse files Browse the repository at this point in the history
  • Loading branch information
LenkaNovak committed Apr 9, 2024
1 parent 1359d55 commit 479954c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/model_configs/gpu_slabplanet_albedo_function.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ moist: "equil"
mono_surface: true
precip_model: "0M"
run_name: "gpu_slabplanet_albedo_function"
t_end: "10days"
t_end: "2000secs"
vert_diff: "true"
2 changes: 1 addition & 1 deletion config/model_configs/slabplanet_albedo_function.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ moist: "equil"
mono_surface: true
precip_model: "0M"
run_name: "slabplanet_albedo_function"
t_end: "10days"
t_end: "2000secs"
vert_diff: "true"
21 changes: 21 additions & 0 deletions experiments/AMIP/coupler_driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ import ClimaCoupler.Utilities: get_comms_context

pkg_dir = pkgdir(ClimaCoupler)

function print_extrema(fields, names; ct = 0)
@info("Printing extrema at $(ct)")
for (field, name) in zip(fields, names)
println("$(name) min: $(minimum(field)) max: $(maximum(field))")
end
return ct + 1
end

#=
### Helper Functions
These will be eventually moved to their respective component model and diagnostics packages, and so they should not
Expand Down Expand Up @@ -589,6 +597,8 @@ cs = CoupledSimulation{FT}(
thermo_params,
);

ct = print_extrema(cs.fields, coupler_field_names, ct = 0)

#=
## Restart component model states if specified
If a restart directory is specified and contains output files from the `checkpoint_cb` callback, the component model states are restarted from those files. The restart directory
Expand Down Expand Up @@ -620,12 +630,16 @@ import_combined_surface_fields!(cs.fields, cs.model_sims, cs.boundary_space, cs.
import_atmos_fields!(cs.fields, cs.model_sims, cs.boundary_space, cs.turbulent_fluxes)
update_model_sims!(cs.model_sims, cs.fields, cs.turbulent_fluxes)

ct = print_extrema(cs.fields, coupler_field_names, ct = 1)

# 3.surface vapor specific humidity (`q_sfc`): step surface models with the new surface density to calculate their respective `q_sfc` internally
## TODO: the q_sfc calculation follows the design of the bucket q_sfc, but it would be neater to abstract this from step! (#331)
step!(land_sim, Δt_cpl)
step!(ocean_sim, Δt_cpl)
step!(ice_sim, Δt_cpl)

ct = print_extrema(cs.fields, coupler_field_names, ct = 2)

# 4.turbulent fluxes: now we have all information needed for calculating the initial turbulent surface fluxes using the combined state
# or the partitioned state method
if cs.turbulent_fluxes isa CombinedStateFluxes
Expand All @@ -644,6 +658,8 @@ elseif cs.turbulent_fluxes isa PartitionedStateFluxes
atmos_sim.integrator.p.precomputed.sfc_conditions .= new_p.precomputed.sfc_conditions
end

ct = print_extrema(cs.fields, coupler_field_names, ct = 3)

# 5.reinitialize models + radiative flux: prognostic states and time are set to their initial conditions. For atmos, this also triggers the callbacks and sets a nonzero radiation flux (given the new sfc_conditions)
reinit_model_sims!(cs.model_sims)

Expand All @@ -654,6 +670,8 @@ reinit_model_sims!(cs.model_sims)
import_atmos_fields!(cs.fields, cs.model_sims, cs.boundary_space, cs.turbulent_fluxes)
update_model_sims!(cs.model_sims, cs.fields, cs.turbulent_fluxes)

ct = print_extrema(cs.fields, coupler_field_names, ct = 4)

#=
## Coupling Loop
Expand Down Expand Up @@ -710,6 +728,9 @@ function solve_coupler!(cs)

end

ct = print_extrema(cs.fields, coupler_field_names, ct = 6)


## compute global energy
!isnothing(cs.conservation_checks) ? check_conservation!(cs) : nothing
ClimaComms.barrier(comms_ctx)
Expand Down

0 comments on commit 479954c

Please sign in to comment.