@@ -3,6 +3,7 @@ using ClimaCorePlots
3
3
using Printf
4
4
using ClimaCoupler. Interfacer: ComponentModelSimulation, SurfaceModelSimulation
5
5
using ClimaCore
6
+ using Adapt
6
7
7
8
# plotting functions for the coupled simulation
8
9
"""
@@ -42,15 +43,21 @@ function debug(cs_fields::NamedTuple, dir, cs_fields_ref = nothing)
42
43
:z0m_S ,
43
44
)
44
45
all_plots = []
46
+ cpu_comms_ctx = ClimaComms. SingletonCommsContext ()
47
+
48
+
45
49
for field_name in field_names
46
50
field = getproperty (cs_fields, field_name)
47
- push! (all_plots, Plots. plot (field, title = string (field_name) * print_extrema (field)))
51
+ # Convert field from GPU to CPU if necessary
52
+ cpu_field = Adapt. adapt (Array, field)
53
+
54
+ push! (all_plots, Plots. plot (cpu_field, title = string (field_name) * print_extrema (cpu_field)))
48
55
if (field_name == :T_S ) && (@isdefined debug_csf0)
49
56
push! (
50
57
all_plots,
51
58
Plots. plot (
52
- field .- debug_csf0. T_S,
53
- title = string (field_name) * " _anom" * print_extrema (field ),
59
+ cpu_field .- debug_csf0. T_S,
60
+ title = string (field_name) * " _anom" * print_extrema (cpu_field ),
54
61
color = :viridis ,
55
62
),
56
63
)
@@ -64,11 +71,14 @@ function debug(cs_fields::NamedTuple, dir, cs_fields_ref = nothing)
64
71
all_plots = []
65
72
for field_name in field_names
66
73
field = getproperty (cs_fields, field_name)
74
+ # Convert field from GPU to CPU if necessary
75
+ cpu_field = Adapt. adapt (Array, field)
76
+
67
77
push! (
68
78
all_plots,
69
79
Plots. plot (
70
- field .- getproperty (cs_fields_ref, field_name),
71
- title = string (field_name) * print_extrema (field ),
80
+ cpu_field .- getproperty (cs_fields_ref, field_name),
81
+ title = string (field_name) * print_extrema (cpu_field ),
72
82
),
73
83
)
74
84
end
@@ -89,7 +99,10 @@ function debug(sim::ComponentModelSimulation, dir)
89
99
all_plots = []
90
100
for field_name in field_names
91
101
field = get_field (sim, Val (field_name))
92
- push! (all_plots, Plots. plot (field, title = string (field_name) * print_extrema (field)))
102
+ # Convert field from GPU to CPU if necessary
103
+ cpu_field = Adapt. adapt (Array, field)
104
+
105
+ push! (all_plots, Plots. plot (cpu_field, title = string (field_name) * print_extrema (cpu_field)))
93
106
end
94
107
fig = Plots. plot (all_plots... , size = (1500 , 800 ))
95
108
Plots. png (joinpath (dir, " debug_$(name (sim)) " ))
0 commit comments