@@ -37,15 +37,19 @@ function argparse_settings()
37
37
arg_type = String
38
38
default = nothing
39
39
" --cpu_job_id_atmos"
40
- help = " The name of the CPU atmos-only run we want to compare. User must specify CPU and/or GPU atmos-only run name."
40
+ help = " The name of the CPU atmos-only run without diagnostic EDMF we want to compare. User must specify CPU and/or GPU atmos-only non-EDMF run name."
41
41
arg_type = String
42
42
default = nothing
43
43
" --gpu_job_id_atmos"
44
44
help = " The name of the GPU atmos-only run we want to compare."
45
45
arg_type = String
46
46
default = nothing
47
- " --mode_name"
48
- help = " The mode of the simulations being compared (`slabplanet` or `AMIP`)."
47
+ " --cpu_job_id_atmos_diagedmf"
48
+ help = " The name of the CPU atmos-only run with diagnostic EDMF we want to compare. User must specify CPU and/or GPU atmos-only EDMF run name."
49
+ arg_type = String
50
+ default = nothing
51
+ " --gpu_job_id_atmos_diagedmf"
52
+ help = " The name of the GPU atmos-only run we want to compare."
49
53
arg_type = String
50
54
default = nothing
51
55
" --coupler_output_dir"
@@ -60,62 +64,54 @@ function argparse_settings()
60
64
return s
61
65
end
62
66
63
- # Parse command line arguments
64
- parsed_args = ArgParse . parse_args ( ARGS , argparse_settings () )
67
+ """
68
+ get_run_info(parsed_args, run_type )
65
69
66
- # Access buildkite pipeline ID (from `BUILDKITE_GITHUB_DEPLOYMENT_ID` variable)
67
- build_id = parsed_args[" build_id" ]
68
- if ! isnothing (build_id)
69
- build_id_str = " Build ID: $build_id "
70
- else
71
- build_id_str = " Build ID: N/A"
72
- end
70
+ Use the input `parsed_args` to get the job ID and artifacts directories for
71
+ both the CPU and GPU runs of the given `run_type`.
73
72
74
- # Construct CPU and GPU artifacts directories
75
- output_dir = parsed_args[" coupler_output_dir" ]
73
+ `run_type` must be one of "coupled", "atmos", or "atmos_diagedmf".
74
+ """
75
+ function get_run_info (parsed_args, run_type)
76
+ # Read in CPU and GPU job ID info from command line
77
+ if run_type == " coupled"
78
+ cpu_job_id = parsed_args[" cpu_job_id_coupled" ]
79
+ gpu_job_id = parsed_args[" gpu_job_id_coupled" ]
80
+ mode_name = " amip"
81
+ elseif run_type == " atmos_diagedmf"
82
+ cpu_job_id = parsed_args[" cpu_job_id_atmos_diagedmf" ]
83
+ gpu_job_id = parsed_args[" gpu_job_id_atmos_diagedmf" ]
84
+ mode_name = " climaatmos"
85
+ elseif run_type == " atmos"
86
+ cpu_job_id = parsed_args[" cpu_job_id_atmos" ]
87
+ gpu_job_id = parsed_args[" gpu_job_id_atmos" ]
88
+ mode_name = " climaatmos"
89
+ else
90
+ error (" Invalid run type: $run_type " )
91
+ end
76
92
77
- # Coupled runs
78
- # Read in CPU and GPU run name info from command line
79
- cpu_job_id_coupled = parsed_args[" cpu_job_id_coupled" ]
80
- gpu_job_id_coupled = parsed_args[" gpu_job_id_coupled" ]
81
- if isnothing (cpu_job_id_coupled) && isnothing (gpu_job_id_coupled)
82
- error (" Must pass CPU and/or GPU coupled run name to compare them." )
83
- elseif isnothing (gpu_job_id_coupled)
84
- gpu_job_id_coupled = " gpu_" * cpu_job_id_coupled
85
- elseif isnothing (cpu_job_id_coupled)
86
- cpu_job_id_coupled = gpu_job_id_coupled[5 : end ]
87
- end
93
+ # Verify that the user has provided the necessary job IDs
94
+ # If only one job ID of the CPU/GPU run pair is provided, the other will be inferred
95
+ if isnothing (cpu_job_id) && isnothing (gpu_job_id)
96
+ error (" Must pass CPU and/or GPU coupled run name to compare them." )
97
+ elseif isnothing (gpu_job_id)
98
+ gpu_job_id = " gpu_" * cpu_job_id
99
+ elseif isnothing (cpu_job_id)
100
+ cpu_job_id = gpu_job_id[5 : end ]
101
+ end
88
102
89
- # Read in mode name from command line (or retrieve from run name).
90
- # Note that we expect this to be the same for all 4 simulations being compared.
91
- mode_name = parsed_args[" mode_name" ]
92
- if isnothing (mode_name)
93
- mode_name =
94
- occursin (" amip" , cpu_job_id_coupled) ? " amip" :
95
- (occursin (" slabplanet" , cpu_job_id_coupled) ? " slabplanet" : error (" Please provide a valid `mode_name`." ))
96
- end
103
+ # Construct CPU and GPU artifacts directories
104
+ cpu_artifacts_dir = joinpath (output_dir, mode_name, cpu_job_id) * " _artifacts"
105
+ gpu_artifacts_dir = joinpath (output_dir, mode_name, gpu_job_id) * " _artifacts"
97
106
98
- gpu_artifacts_dir_coupled = joinpath (output_dir, mode_name, gpu_job_id_coupled) * " _artifacts"
99
- cpu_artifacts_dir_coupled = joinpath (output_dir, mode_name, cpu_job_id_coupled) * " _artifacts"
100
-
101
- # Atmos-only runs
102
- # Read in CPU and GPU run name info from command line
103
- cpu_job_id_atmos = parsed_args[" cpu_job_id_atmos" ]
104
- gpu_job_id_atmos = parsed_args[" gpu_job_id_atmos" ]
105
- if isnothing (cpu_job_id_atmos) && isnothing (gpu_job_id_atmos)
106
- error (" Must pass CPU and/or GPU coupled run name to compare them." )
107
- elseif isnothing (gpu_job_id_atmos)
108
- gpu_job_id_atmos = " gpu_" * cpu_job_id_atmos
109
- elseif isnothing (cpu_job_id_atmos)
110
- cpu_job_id_atmos = gpu_job_id_atmos[5 : end ]
111
- cpu_artifacts_dir_atmos = joinpath (output_dir, cpu_job_id_atmos)
107
+ return (cpu_job_id, gpu_job_id, cpu_artifacts_dir, gpu_artifacts_dir)
112
108
end
113
109
114
- mode_name_atmos = " climaatmos"
115
- gpu_artifacts_dir_atmos = joinpath (output_dir, mode_name_atmos, gpu_job_id_atmos) * " _artifacts"
116
- cpu_artifacts_dir_atmos = joinpath (output_dir, mode_name_atmos, cpu_job_id_atmos) * " _artifacts"
110
+ """
111
+ get_sypd_allocs(artifacts_dir)
117
112
118
- # Read in SYPD and allocations info from artifacts directories
113
+ Read in SYPD and allocations info from artifacts directories.
114
+ """
119
115
function get_sypd_allocs (artifacts_dir)
120
116
# Read in SYPD info
121
117
sypd_file = open (joinpath (artifacts_dir, " sypd.txt" ), " r" )
@@ -128,18 +124,6 @@ function get_sypd_allocs(artifacts_dir)
128
124
return (sypd, cpu_allocs)
129
125
end
130
126
131
- cpu_sypd_coupled, cpu_allocs_coupled = get_sypd_allocs (cpu_artifacts_dir_coupled)
132
- gpu_sypd_coupled, gpu_cpu_allocs_coupled = get_sypd_allocs (gpu_artifacts_dir_coupled)
133
- cpu_sypd_atmos, cpu_allocs_atmos = get_sypd_allocs (cpu_artifacts_dir_atmos)
134
- gpu_sypd_atmos, gpu_cpu_allocs_atmos = get_sypd_allocs (gpu_artifacts_dir_atmos)
135
-
136
- # Set up info for PrettyTables.jl
137
- headers = [build_id_str, " Horiz. res.: 30 elems" , " CPU Run [64 processes]" , " GPU Run [4 A100s]" ]
138
- data = [
139
- [" " " Vert. res.: 63 levels" " " " " ]
140
- [" " " dt: 120secs" " " " " ]
141
- ]
142
-
143
127
"""
144
128
append_table_data!(table_data, setup_id, cpu_job_id, gpu_job_id, cpu_artifacts_dir, gpu_artifacts_dir)
145
129
@@ -159,14 +143,42 @@ function append_table_data!(table_data, setup_id, cpu_job_id, gpu_job_id, cpu_ar
159
143
table_data = vcat (table_data, new_table_data)
160
144
end
161
145
162
- append_table_data! (data, " Coupled" , cpu_job_id_coupled, gpu_job_id_coupled, cpu_artifacts_dir_coupled, gpu_artifacts_dir_coupled)
163
- append_table_data! (data, " Atmos with diag. EDMF" , cpu_job_id_atmos, gpu_job_id_atmos, cpu_artifacts_dir_atmos, gpu_artifacts_dir_atmos)
146
+
147
+ # Read in command line arguments
148
+ parsed_args = ArgParse. parse_args (ARGS , argparse_settings ())
149
+ output_dir = parsed_args[" coupler_output_dir" ]
150
+
151
+ # Access buildkite pipeline ID (from `BUILDKITE_GITHUB_DEPLOYMENT_ID` variable)
152
+ build_id = parsed_args[" build_id" ]
153
+ if ! isnothing (build_id)
154
+ build_id_str = " Build ID: $build_id "
155
+ else
156
+ build_id_str = " Build ID: N/A"
157
+ end
158
+
159
+ # Read in run info for each of the cases we want to compare
160
+ run_info_coupled = get_run_info (parsed_args, " coupled" )
161
+ run_info_atmos_diagedmf = get_run_info (parsed_args, " atmos_diagedmf" )
162
+ run_info_atmos = get_run_info (parsed_args, " atmos" )
163
+
164
+ # Set up info for PrettyTables.jl
165
+ headers = [build_id_str, " Horiz. res.: 30 elems" , " CPU Run [64 processes]" , " GPU Run [4 A100s]" ]
166
+ data = [
167
+ [" " " Vert. res.: 63 levels" " " " " ]
168
+ [" " " dt: 120secs" " " " " ]
169
+ ]
170
+
171
+ # Append data to the table for each of the cases we want to compare
172
+ append_table_data! (data, " Coupled" , run_info_coupled... )
173
+ append_table_data! (data, " Atmos with diag. EDMF" , run_info_atmos_diagedmf... )
174
+ append_table_data! (data, " Atmos without diag. EDMF" , run_info_atmos_diagedmf... )
164
175
165
176
# Use the coupled CPU job ID for the output dir
166
- table_output_dir = joinpath (output_dir, " compare_$(mode_name) _$(mode_name_atmos) _$(cpu_job_id_coupled) " )
177
+ cpu_job_id_coupled = run_info_coupled[1 ]
178
+ table_output_dir = joinpath (output_dir, " compare_amip_climaatmos_$(cpu_job_id_coupled) " )
167
179
! isdir (table_output_dir) && mkdir (table_output_dir)
168
180
table_path = joinpath (table_output_dir, " table.txt" )
169
181
open (table_path, " w" ) do f
170
182
# Output the table, including lines before and after the header
171
- PrettyTables. pretty_table (f, data, header = headers, hlines = [0 , 3 , 6 , 9 ]) # TODO don't hardcode hlines
183
+ PrettyTables. pretty_table (f, data, header = headers, hlines = [0 , 3 , 6 , 9 , 12 ]) # TODO don't hardcode hlines
172
184
end
0 commit comments