Skip to content

Commit 615266c

Browse files
diag_table updates: (#225)
* diag_table updates: - introduce feature to specify field-specific reduction method. - changes in field list: -min/max mlotst and oml in both daily (sfc) and monthly (native) -sst_global, sss_global in monthly -zos and zossq in daily (sfc) -Drop SSH in daily (sfc) and keep it in the monthly (native) -Drop mass_wt in daily and keep it in the monthly (native) -Add tos and sos min/max in daily (sfc) and monthly (native) -Add MEKE in monthly (native) -C_P and Rho_0 add to static -Geo_heat (when turned on) add to static -Add penetrating solar flux (3D. Diag variable) rsdo Comment end * add geo_head to static diag file when available
1 parent 70a0af7 commit 615266c

3 files changed

Lines changed: 123 additions & 65 deletions

File tree

cime_config/MOM_RPS/FType_diag_table.py

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -159,55 +159,44 @@ def expand_func(varname):
159159
packing = field_block["packing"]
160160
field_list_1d = get_all_fields(field_block)
161161

162-
# seperate field_name and output_name:
162+
# seperate field_name, alias, and reduction method
163+
# (the latter two are optional)
163164
field_list_1d_seperated = []
164165
for field in field_list_1d:
165166
field_split = field.split(":")
166-
if len(field_split) == 2:
167-
field = field_split[0], field_split[1]
168-
elif len(field_split) == 1:
169-
field = field_split[0], field_split[0]
170-
else:
171-
raise RuntimeError(
172-
"Cannot infer field name and output name for " + field
173-
)
174-
field_list_1d_seperated.append(field)
167+
field_name = field_split[0]
168+
alias = field_name
169+
reduction = file_block["reduction_method"]
170+
assert 1 <= len(field_split) <= 3, (
171+
"Invalid field format: " + field
172+
)
173+
if len(field_split) >= 2:
174+
alias = field_split[1]
175+
if len(field_split) >= 3:
176+
reduction = field_split[2]
177+
178+
field_list_1d_seperated.append((field_name, alias, reduction))
175179

176180
# check if there are any duplicate fields in the same file:
177-
for field_name, output_name in field_list_1d_seperated:
178-
assert field_name not in all_fields, (
179-
'Field "'
180-
+ field_name
181-
+ '" is listed more than once'
182-
+ " in file: "
183-
+ file_block["suffix"]
184-
)
185-
all_fields.append(field_name)
181+
field_set = set()
182+
for field_name, alias, reduction in field_list_1d_seperated:
183+
if alias in field_set:
184+
raise ValueError(
185+
'Field "'
186+
+ alias
187+
+ '" is listed more than once'
188+
+ " in file: "
189+
+ file_block["suffix"]
190+
)
191+
field_set.add(alias)
186192

187193
mfnl = max([len(field) for field in field_list_1d]) + 3
188194
mfnl = min(16, mfnl) # limit to 16
189-
for field_name, output_name in field_list_1d_seperated:
195+
w = lambda s: f'"{s}",' # wrap string in quotes and add comma
196+
for field_name, alias, reduction in field_list_1d_seperated:
190197
diag_table.write(
191-
(
192-
"{module_name:14s} {field_name:"
193-
+ str(mfnl)
194-
+ "}{output_name:"
195-
+ str(mfnl)
196-
+ "}"
197-
'{fname} "all", {reduction_method} {regional_section} {packing}\n'
198-
).format(
199-
module_name='"' + module + '",',
200-
field_name='"' + field_name + '",',
201-
output_name='"' + output_name + '",',
202-
fname=fname + ",",
203-
reduction_method='"'
204-
+ str(file_block["reduction_method"])
205-
+ '",',
206-
regional_section='"'
207-
+ str(file_block["regional_section"])
208-
+ '",',
209-
packing=str(packing),
210-
)
198+
f'{w(module)} {w(field_name):{mfnl}}{w(alias):{mfnl}}{fname}, "all", '
199+
f'{w(reduction)} {w(file_block["regional_section"])} {packing}\n'
211200
)
212201

213202
diag_table.write("\n")

param_templates/diag_table.yaml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@
44
###############################################################################
55
---
66
FieldLists:
7-
- &prognostic ["uo", "vo", "h", "e", "thetao", "so", "KE", "rhopot0"]
7+
- &prognostic ["uo", "vo", "h", "e", "thetao", "so", "KE", "MEKE", "rhopot0"]
88

99
- &prognostic_z ["uo", "vo", "h", "thetao", "so", "agessc", "rhopot0", "N2_int"]
1010

1111
- &prognostic_rho2 ["thetao", "so", "agessc"]
1212

13-
- &hist_additional ["soga", "thetaoga", "uh", "vh", "vhbt", "uhbt"]
13+
- &hist_additional ["soga", "thetaoga", "uh", "vh", "vhbt", "uhbt", "rsdo"]
1414

1515
- &tracers ["agessc", "T_ady_2d", "T_adx_2d", "T_diffy_2d", "T_diffx_2d",
1616
"T_hbd_diffx_2d", 'T_hbd_diffy_2d']
1717

18-
- &surface_flds ["SSH", "tos", "sos", "SSU", "SSV", "mass_wt", "opottempmint",
19-
"somint", "Rd_dx", "speed", "mlotst"]
18+
- &surface_flds_common ["tos", "tos:tos_min:min", "tos:tos_max:max",
19+
"sos", "sos:sos_min:min", "sos:sos_max:max",
20+
"SSU", "SSV", "opottempmint", "somint", "Rd_dx", "speed",
21+
"mlotst", "mlotst:mlots_min:min", "mlotst:mlots_max:max"]
22+
23+
- &surface_flds_daily ["zos", "zossq"]
2024

21-
- &kpp_diags ["KPP_OBLdepth:oml"]
25+
- &surface_flds_monthly ["sst_global", "sss_global", "SSH", "mass_wt"]
26+
27+
- &kpp_diags ["KPP_OBLdepth:oml", "KPP_OBLdepth:oml_min:min", "KPP_OBLdepth:oml_max:max"]
2228

2329
- &forcing_flds ["tauuo", "tauvo", "friver", "prsn", "prlq", "evs", "hfsso", "rlntds",
2430
"hfsnthermds", "sfdsi", "rsntds", "hfds", "ustar",
@@ -41,7 +47,7 @@ FieldLists:
4147
- &static_flds ["geolon", "geolat", "geolon_c", "geolat_c", "geolon_u", "geolat_u",
4248
"geolon_v", "geolat_v", "deptho", "wet", "wet_c", "wet_u",
4349
"wet_v", "Coriolis", "areacello", "areacello_cu", "areacello_cv",
44-
"areacello_bu", "sin_rot", "cos_rot"]
50+
"areacello_bu", "sin_rot", "cos_rot", "C_P", "Rho_0"]
4551

4652
- &transports ["volcello", "vmo", "vhGM", "vhml", "umo", "uhGM", "uhml"]
4753

@@ -53,6 +59,8 @@ FieldLists:
5359

5460
- &cfc_2d ["cfc11_flux", "cfc12_flux", "ice_fraction", "u10_sqr"]
5561

62+
- &geothermal ["Geo_heat"]
63+
5664
###############################################################################
5765
# Section 2: File lists:
5866
# List of files to be added in diag_table
@@ -115,7 +123,8 @@ Files:
115123
*kpp_diags,
116124
*forcing_flds,
117125
*enthalpy_flds,
118-
*surface_flds]
126+
*surface_flds_common,
127+
*surface_flds_monthly]
119128
lists3:
120129
$USE_CFC_CAP == "True":
121130
[ *cfc_2d ]
@@ -166,7 +175,8 @@ Files:
166175
$OCN_DIAG_MODE != "none" and $TEST is not True :
167176
module: "ocean_model" # native
168177
packing: = 1 if $TEST else 2
169-
lists: [ *surface_flds,
178+
lists: [ *surface_flds_common,
179+
*surface_flds_daily,
170180
*kpp_diags ]
171181
forcing_avg:
172182
suffix:
@@ -222,6 +232,9 @@ Files:
222232
module: "ocean_model" # native
223233
packing: = 1 if $TEST else 2
224234
lists: [ *static_flds ]
235+
lists2:
236+
$DO_GEOTHERMAL == "True":
237+
[ *geothermal ]
225238

226239

227240
# Sections ------------------------------------

param_templates/json/diag_table.json

Lines changed: 73 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"thetao",
99
"so",
1010
"KE",
11+
"MEKE",
1112
"rhopot0"
1213
],
1314
[
@@ -31,7 +32,8 @@
3132
"uh",
3233
"vh",
3334
"vhbt",
34-
"uhbt"
35+
"uhbt",
36+
"rsdo"
3537
],
3638
[
3739
"agessc",
@@ -43,20 +45,36 @@
4345
"T_hbd_diffy_2d"
4446
],
4547
[
46-
"SSH",
4748
"tos",
49+
"tos:tos_min:min",
50+
"tos:tos_max:max",
4851
"sos",
52+
"sos:sos_min:min",
53+
"sos:sos_max:max",
4954
"SSU",
5055
"SSV",
51-
"mass_wt",
5256
"opottempmint",
5357
"somint",
5458
"Rd_dx",
5559
"speed",
56-
"mlotst"
60+
"mlotst",
61+
"mlotst:mlots_min:min",
62+
"mlotst:mlots_max:max"
5763
],
5864
[
59-
"KPP_OBLdepth:oml"
65+
"zos",
66+
"zossq"
67+
],
68+
[
69+
"sst_global",
70+
"sss_global",
71+
"SSH",
72+
"mass_wt"
73+
],
74+
[
75+
"KPP_OBLdepth:oml",
76+
"KPP_OBLdepth:oml_min:min",
77+
"KPP_OBLdepth:oml_max:max"
6078
],
6179
[
6280
"tauuo",
@@ -135,7 +153,9 @@
135153
"areacello_cv",
136154
"areacello_bu",
137155
"sin_rot",
138-
"cos_rot"
156+
"cos_rot",
157+
"C_P",
158+
"Rho_0"
139159
],
140160
[
141161
"volcello",
@@ -169,6 +189,9 @@
169189
"cfc12_flux",
170190
"ice_fraction",
171191
"u10_sqr"
192+
],
193+
[
194+
"Geo_heat"
172195
]
173196
],
174197
"Files": {
@@ -250,7 +273,8 @@
250273
"uh",
251274
"vh",
252275
"vhbt",
253-
"uhbt"
276+
"uhbt",
277+
"rsdo"
254278
],
255279
[
256280
"agessc",
@@ -287,10 +311,13 @@
287311
"thetao",
288312
"so",
289313
"KE",
314+
"MEKE",
290315
"rhopot0"
291316
],
292317
[
293-
"KPP_OBLdepth:oml"
318+
"KPP_OBLdepth:oml",
319+
"KPP_OBLdepth:oml_min:min",
320+
"KPP_OBLdepth:oml_max:max"
294321
],
295322
[
296323
"tauuo",
@@ -327,17 +354,27 @@
327354
"heat_content_evap"
328355
],
329356
[
330-
"SSH",
331357
"tos",
358+
"tos:tos_min:min",
359+
"tos:tos_max:max",
332360
"sos",
361+
"sos:sos_min:min",
362+
"sos:sos_max:max",
333363
"SSU",
334364
"SSV",
335-
"mass_wt",
336365
"opottempmint",
337366
"somint",
338367
"Rd_dx",
339368
"speed",
340-
"mlotst"
369+
"mlotst",
370+
"mlotst:mlots_min:min",
371+
"mlotst:mlots_max:max"
372+
],
373+
[
374+
"sst_global",
375+
"sss_global",
376+
"SSH",
377+
"mass_wt"
341378
]
342379
]
343380
},
@@ -432,20 +469,30 @@
432469
"packing": "= 1 if $TEST else 2",
433470
"lists": [
434471
[
435-
"SSH",
436472
"tos",
473+
"tos:tos_min:min",
474+
"tos:tos_max:max",
437475
"sos",
476+
"sos:sos_min:min",
477+
"sos:sos_max:max",
438478
"SSU",
439479
"SSV",
440-
"mass_wt",
441480
"opottempmint",
442481
"somint",
443482
"Rd_dx",
444483
"speed",
445-
"mlotst"
484+
"mlotst",
485+
"mlotst:mlots_min:min",
486+
"mlotst:mlots_max:max"
487+
],
488+
[
489+
"zos",
490+
"zossq"
446491
],
447492
[
448-
"KPP_OBLdepth:oml"
493+
"KPP_OBLdepth:oml",
494+
"KPP_OBLdepth:oml_min:min",
495+
"KPP_OBLdepth:oml_max:max"
449496
]
450497
]
451498
}
@@ -584,9 +631,18 @@
584631
"areacello_cv",
585632
"areacello_bu",
586633
"sin_rot",
587-
"cos_rot"
634+
"cos_rot",
635+
"C_P",
636+
"Rho_0"
588637
]
589-
]
638+
],
639+
"lists2": {
640+
"$DO_GEOTHERMAL == \"True\"": [
641+
[
642+
"Geo_heat"
643+
]
644+
]
645+
}
590646
}
591647
},
592648
"Agulhas": {

0 commit comments

Comments
 (0)