@@ -98,8 +98,9 @@ include("cli_options.jl")
98
98
parsed_args = parse_commandline (argparse_settings ())
99
99
100
100
# # modify parsed args for fast testing from REPL #hide
101
+ include (" user_io/debug_plots.jl" )
102
+ pkg_dir = pkgdir (ClimaCoupler)
101
103
if isinteractive ()
102
- include (" user_io/debug_plots.jl" )
103
104
parsed_args[" config_file" ] =
104
105
isnothing (parsed_args[" config_file" ]) ? joinpath (pkg_dir, " config/model_configs/interactive_debug.yml" ) :
105
106
parsed_args[" config_file" ]
@@ -122,10 +123,11 @@ run_name = config_dict["run_name"]
122
123
energy_check = config_dict[" energy_check" ]
123
124
const FT = config_dict[" FLOAT_TYPE" ] == " Float64" ? Float64 : Float32
124
125
land_sim_name = " bucket"
125
- t_end = Float64 (time_to_seconds (config_dict[" t_end" ]))
126
+ # t_end = Float64(time_to_seconds(config_dict["t_end"]))
126
127
t_start = 0.0
127
- tspan = (t_start, t_end)
128
128
Δt_cpl = Float64 (config_dict[" dt_cpl" ])
129
+ t_end = Δt_cpl
130
+ tspan = (t_start, t_end)
129
131
saveat = Float64 (time_to_seconds (config_dict[" dt_save_to_sol" ]))
130
132
date0 = date = DateTime (config_dict[" start_date" ], dateformat " yyyymmdd" )
131
133
mono_surface = config_dict[" mono_surface" ]
@@ -173,6 +175,10 @@ The data files are downloaded from the `ClimaCoupler` artifacts directory. If th
173
175
original sources.
174
176
=#
175
177
178
+ debug_dir = joinpath (COUPLER_ARTIFACTS_DIR, " debug_output/" )
179
+ isdir (debug_dir) ? nothing : mkpath (debug_dir)
180
+
181
+ # get the paths to the necessary data files: land-sea mask, sst map, sea ice concentration
176
182
include (joinpath (pkgdir (ClimaCoupler), " artifacts" , " artifact_funcs.jl" ))
177
183
sst_data = joinpath (sst_dataset_path (), " sst.nc" )
178
184
sic_data = joinpath (sic_dataset_path (), " sic.nc" )
@@ -551,6 +557,8 @@ cs = CoupledSimulation{FT}(
551
557
dir_paths,
552
558
);
553
559
560
+ debug (cs, debug_dir * " 0_initialized_cs" )
561
+
554
562
#=
555
563
## Restart component model states if specified
556
564
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
@@ -585,18 +593,21 @@ end
585
593
586
594
# 2.coupler updates surface model area fractions
587
595
update_surface_fractions! (cs)
596
+ debug (cs, " debug_output/2_surface_fraction_update" )
588
597
589
598
# 3.surface density (`ρ_sfc`): calculated by the coupler by adiabatically extrapolating atmospheric thermal state to the surface.
590
599
# For this, we need to import surface and atmospheric fields. The model sims are then updated with the new surface density.
591
600
import_combined_surface_fields! (cs. fields, cs. model_sims, cs. boundary_space, turbulent_fluxes)
592
601
import_atmos_fields! (cs. fields, cs. model_sims, cs. boundary_space, turbulent_fluxes)
593
602
update_model_sims! (cs. model_sims, cs. fields, turbulent_fluxes)
603
+ debug (cs, " debug_output/3_update_sims" )
594
604
595
605
# 4.surface vapor specific humidity (`q_sfc`): step surface models with the new surface density to calculate their respective `q_sfc` internally
596
606
# # TODO : the q_sfc calculation follows the design of the bucket q_sfc, but it would be neater to abstract this from step! (#331)
597
607
step! (land_sim, Δt_cpl)
598
608
step! (ocean_sim, Δt_cpl)
599
609
step! (ice_sim, Δt_cpl)
610
+ debug (cs, " debug_output/4_step_surface_models" )
600
611
601
612
# 5.turbulent fluxes: now we have all information needed for calculating the initial turbulent surface fluxes using the combined state
602
613
# or the partitioned state method
@@ -615,9 +626,11 @@ elseif turbulent_fluxes isa PartitionedStateFluxes
615
626
CA. SurfaceConditions. update_surface_conditions! (atmos_sim. integrator. u, new_p, atmos_sim. integrator. t) # # sets T_sfc (but SF calculation not necessary - requires split functionality in CA)
616
627
atmos_sim. integrator. p. precomputed. sfc_conditions .= new_p. precomputed. sfc_conditions
617
628
end
629
+ debug (cs, " debug_output/5_after_turb_fluxes" )
618
630
619
631
# 6.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)
620
632
reinit_model_sims! (cs. model_sims)
633
+ debug (cs, " debug_output/6_after_reinit" )
621
634
622
635
# 7.update all fluxes: coupler re-imports updated atmos fluxes (radiative fluxes for both `turbulent_fluxes` types
623
636
# and also turbulent fluxes if `turbulent_fluxes isa CombinedStateFluxes`,
@@ -626,6 +639,8 @@ reinit_model_sims!(cs.model_sims)
626
639
import_atmos_fields! (cs. fields, cs. model_sims, cs. boundary_space, turbulent_fluxes)
627
640
update_model_sims! (cs. model_sims, cs. fields, turbulent_fluxes)
628
641
642
+ debug (cs, " debug_output/7_import_atmos_fluxes" )
643
+
629
644
#=
630
645
## Coupling Loop
631
646
@@ -755,6 +770,7 @@ end #hide
755
770
# # run the coupled simulation
756
771
solve_coupler! (cs);
757
772
773
+ debug (cs, " debug_output/6_after_solve" )
758
774
#=
759
775
## Postprocessing
760
776
Currently all postprocessing is performed using the root process only.
0 commit comments