NOAA-CEFI-Regional-Ocean-Modeling / ocean_BGC

3 stars 8 forks source link

Unregistered diagnostics #90

Open andrew-c-ross opened 3 months ago

andrew-c-ross commented 3 months ago

Not a big issue, but I happened to notice that there are a few diagnostics, including rho_dzt_bot_diag, that are allocated and sent data to in cobalt_send_diag, but never registered in cobalt_reg_diag.

https://github.com/NOAA-CEFI-Regional-Ocean-Modeling/ocean_BGC/blob/dba3aeba6b8bfcfc8b2eb83178d089ee94cab84c/generic_tracers/cobalt_send_diag.F90#L750

charliestock commented 3 months ago

Got it Andrew - let's leave this open as an issue and I'll tackle it in the diagnostic cleanup in the coming weeks.

andrew-c-ross commented 1 month ago

Something like this:

import re

with open('cobalt_send_diag.F90', 'r+') as f:
    send_matches = set(re.findall(r'g_send_data\(\S+\%(id\_[a-zA-Z0-9_]+),', f.read()))

with open('cobalt_reg_diag.F90', 'r+') as f:
    reg_matches = set(re.findall(r'\%(id\_[a-zA-Z0-9_]+) = register_diag_field', f.read()))

# In send_diag but not in reg_diag:
send_matches.difference(reg_matches)
""" >
{'id_co2_alpha',
 'id_co2_csurf',
 'id_f_alk_int_100',
 'id_f_dic_int_100',
 'id_f_din_int_100',
 'id_f_fed_int_100',
 'id_f_po4_int_100',
 'id_f_sio4_int_100',
 'id_grid_kmt_diag',
 'id_irr_aclm',
 'id_irr_aclm_z',
 'id_jalk_100',
 'id_jdic_100',
 'id_jdin_100',
 'id_jfed_100',
 'id_jpo4_100',
 'id_jsio4_100',
 'id_k_bot_diag',
 'id_nh3_alpha',
 'id_nh3_csurf',
 'id_pco2_csurf',
 'id_rho_dzt_bot_diag',
 'id_rho_dzt_kmt_diag'}

"""

# In reg_diag but not in send_diag:
reg_matches.difference(send_matches)
""" >
{'id_det_jhploss_n',
 'id_det_jzloss_n',
 'id_jdiss_cadet_arag_plus_btm',
 'id_jdiss_cadet_calc_plus_btm'}
"""