Skip to content

Commit

Permalink
diag_table updates: (#225)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alperaltuntas authored Jan 25, 2025
1 parent 70a0af7 commit 615266c
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 65 deletions.
69 changes: 29 additions & 40 deletions cime_config/MOM_RPS/FType_diag_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,55 +159,44 @@ def expand_func(varname):
packing = field_block["packing"]
field_list_1d = get_all_fields(field_block)

# seperate field_name and output_name:
# seperate field_name, alias, and reduction method
# (the latter two are optional)
field_list_1d_seperated = []
for field in field_list_1d:
field_split = field.split(":")
if len(field_split) == 2:
field = field_split[0], field_split[1]
elif len(field_split) == 1:
field = field_split[0], field_split[0]
else:
raise RuntimeError(
"Cannot infer field name and output name for " + field
)
field_list_1d_seperated.append(field)
field_name = field_split[0]
alias = field_name
reduction = file_block["reduction_method"]
assert 1 <= len(field_split) <= 3, (
"Invalid field format: " + field
)
if len(field_split) >= 2:
alias = field_split[1]
if len(field_split) >= 3:
reduction = field_split[2]

field_list_1d_seperated.append((field_name, alias, reduction))

# check if there are any duplicate fields in the same file:
for field_name, output_name in field_list_1d_seperated:
assert field_name not in all_fields, (
'Field "'
+ field_name
+ '" is listed more than once'
+ " in file: "
+ file_block["suffix"]
)
all_fields.append(field_name)
field_set = set()
for field_name, alias, reduction in field_list_1d_seperated:
if alias in field_set:
raise ValueError(
'Field "'
+ alias
+ '" is listed more than once'
+ " in file: "
+ file_block["suffix"]
)
field_set.add(alias)

mfnl = max([len(field) for field in field_list_1d]) + 3
mfnl = min(16, mfnl) # limit to 16
for field_name, output_name in field_list_1d_seperated:
w = lambda s: f'"{s}",' # wrap string in quotes and add comma
for field_name, alias, reduction in field_list_1d_seperated:
diag_table.write(
(
"{module_name:14s} {field_name:"
+ str(mfnl)
+ "}{output_name:"
+ str(mfnl)
+ "}"
'{fname} "all", {reduction_method} {regional_section} {packing}\n'
).format(
module_name='"' + module + '",',
field_name='"' + field_name + '",',
output_name='"' + output_name + '",',
fname=fname + ",",
reduction_method='"'
+ str(file_block["reduction_method"])
+ '",',
regional_section='"'
+ str(file_block["regional_section"])
+ '",',
packing=str(packing),
)
f'{w(module)} {w(field_name):{mfnl}}{w(alias):{mfnl}}{fname}, "all", '
f'{w(reduction)} {w(file_block["regional_section"])} {packing}\n'
)

diag_table.write("\n")
29 changes: 21 additions & 8 deletions param_templates/diag_table.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@
###############################################################################
---
FieldLists:
- &prognostic ["uo", "vo", "h", "e", "thetao", "so", "KE", "rhopot0"]
- &prognostic ["uo", "vo", "h", "e", "thetao", "so", "KE", "MEKE", "rhopot0"]

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

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

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

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

- &surface_flds ["SSH", "tos", "sos", "SSU", "SSV", "mass_wt", "opottempmint",
"somint", "Rd_dx", "speed", "mlotst"]
- &surface_flds_common ["tos", "tos:tos_min:min", "tos:tos_max:max",
"sos", "sos:sos_min:min", "sos:sos_max:max",
"SSU", "SSV", "opottempmint", "somint", "Rd_dx", "speed",
"mlotst", "mlotst:mlots_min:min", "mlotst:mlots_max:max"]

- &surface_flds_daily ["zos", "zossq"]

- &kpp_diags ["KPP_OBLdepth:oml"]
- &surface_flds_monthly ["sst_global", "sss_global", "SSH", "mass_wt"]

- &kpp_diags ["KPP_OBLdepth:oml", "KPP_OBLdepth:oml_min:min", "KPP_OBLdepth:oml_max:max"]

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

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

Expand All @@ -53,6 +59,8 @@ FieldLists:

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

- &geothermal ["Geo_heat"]

###############################################################################
# Section 2: File lists:
# List of files to be added in diag_table
Expand Down Expand Up @@ -115,7 +123,8 @@ Files:
*kpp_diags,
*forcing_flds,
*enthalpy_flds,
*surface_flds]
*surface_flds_common,
*surface_flds_monthly]
lists3:
$USE_CFC_CAP == "True":
[ *cfc_2d ]
Expand Down Expand Up @@ -166,7 +175,8 @@ Files:
$OCN_DIAG_MODE != "none" and $TEST is not True :
module: "ocean_model" # native
packing: = 1 if $TEST else 2
lists: [ *surface_flds,
lists: [ *surface_flds_common,
*surface_flds_daily,
*kpp_diags ]
forcing_avg:
suffix:
Expand Down Expand Up @@ -222,6 +232,9 @@ Files:
module: "ocean_model" # native
packing: = 1 if $TEST else 2
lists: [ *static_flds ]
lists2:
$DO_GEOTHERMAL == "True":
[ *geothermal ]


# Sections ------------------------------------
Expand Down
90 changes: 73 additions & 17 deletions param_templates/json/diag_table.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"thetao",
"so",
"KE",
"MEKE",
"rhopot0"
],
[
Expand All @@ -31,7 +32,8 @@
"uh",
"vh",
"vhbt",
"uhbt"
"uhbt",
"rsdo"
],
[
"agessc",
Expand All @@ -43,20 +45,36 @@
"T_hbd_diffy_2d"
],
[
"SSH",
"tos",
"tos:tos_min:min",
"tos:tos_max:max",
"sos",
"sos:sos_min:min",
"sos:sos_max:max",
"SSU",
"SSV",
"mass_wt",
"opottempmint",
"somint",
"Rd_dx",
"speed",
"mlotst"
"mlotst",
"mlotst:mlots_min:min",
"mlotst:mlots_max:max"
],
[
"KPP_OBLdepth:oml"
"zos",
"zossq"
],
[
"sst_global",
"sss_global",
"SSH",
"mass_wt"
],
[
"KPP_OBLdepth:oml",
"KPP_OBLdepth:oml_min:min",
"KPP_OBLdepth:oml_max:max"
],
[
"tauuo",
Expand Down Expand Up @@ -135,7 +153,9 @@
"areacello_cv",
"areacello_bu",
"sin_rot",
"cos_rot"
"cos_rot",
"C_P",
"Rho_0"
],
[
"volcello",
Expand Down Expand Up @@ -169,6 +189,9 @@
"cfc12_flux",
"ice_fraction",
"u10_sqr"
],
[
"Geo_heat"
]
],
"Files": {
Expand Down Expand Up @@ -250,7 +273,8 @@
"uh",
"vh",
"vhbt",
"uhbt"
"uhbt",
"rsdo"
],
[
"agessc",
Expand Down Expand Up @@ -287,10 +311,13 @@
"thetao",
"so",
"KE",
"MEKE",
"rhopot0"
],
[
"KPP_OBLdepth:oml"
"KPP_OBLdepth:oml",
"KPP_OBLdepth:oml_min:min",
"KPP_OBLdepth:oml_max:max"
],
[
"tauuo",
Expand Down Expand Up @@ -327,17 +354,27 @@
"heat_content_evap"
],
[
"SSH",
"tos",
"tos:tos_min:min",
"tos:tos_max:max",
"sos",
"sos:sos_min:min",
"sos:sos_max:max",
"SSU",
"SSV",
"mass_wt",
"opottempmint",
"somint",
"Rd_dx",
"speed",
"mlotst"
"mlotst",
"mlotst:mlots_min:min",
"mlotst:mlots_max:max"
],
[
"sst_global",
"sss_global",
"SSH",
"mass_wt"
]
]
},
Expand Down Expand Up @@ -432,20 +469,30 @@
"packing": "= 1 if $TEST else 2",
"lists": [
[
"SSH",
"tos",
"tos:tos_min:min",
"tos:tos_max:max",
"sos",
"sos:sos_min:min",
"sos:sos_max:max",
"SSU",
"SSV",
"mass_wt",
"opottempmint",
"somint",
"Rd_dx",
"speed",
"mlotst"
"mlotst",
"mlotst:mlots_min:min",
"mlotst:mlots_max:max"
],
[
"zos",
"zossq"
],
[
"KPP_OBLdepth:oml"
"KPP_OBLdepth:oml",
"KPP_OBLdepth:oml_min:min",
"KPP_OBLdepth:oml_max:max"
]
]
}
Expand Down Expand Up @@ -584,9 +631,18 @@
"areacello_cv",
"areacello_bu",
"sin_rot",
"cos_rot"
"cos_rot",
"C_P",
"Rho_0"
]
]
],
"lists2": {
"$DO_GEOTHERMAL == \"True\"": [
[
"Geo_heat"
]
]
}
}
},
"Agulhas": {
Expand Down

0 comments on commit 615266c

Please sign in to comment.