Skip to content

Commit

Permalink
- Convert logging level to command-line argument
Browse files Browse the repository at this point in the history
     - Fix calls to logging.critical() with no argument
  • Loading branch information
mkavulich committed Aug 9, 2024
1 parent 6fe54a5 commit 18883a7
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions scm/etc/scripts/dephy_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
parser = argparse.ArgumentParser()
parser.add_argument('-n', '--case_name', help='name of case', required=True)
parser.add_argument('-a', '--use_area', help='use column_area namelist attribute as forcing_scale', action='store_true')
parser.add_argument('-d', '--debug', help='enable debugging output', action='store_true')


########################################################################################
Expand All @@ -41,18 +42,18 @@
def parse_arguments():
"""Parse command line arguments"""
args = parser.parse_args()
case_name = args.case_name
use_area = args.use_area


return (case_name, use_area)
return (args.case_name, args.use_area, args.debug)

########################################################################################
#
########################################################################################
def setup_logging():
def setup_logging(debug):
"""Sets up the logging module."""
logging.basicConfig(format='%(levelname)s: %(message)s', level=LOGLEVEL)
if debug:
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
else:
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)

class Case_Data(object):
def __init__(self, name, missing_value, time, levels, soil_depth, lat, lon, slmsk, vegsrc, vegtyp, soiltyp, \
Expand Down Expand Up @@ -2282,7 +2283,7 @@ def write_SCM_case_file(case_nml, case_data, use_area):

if (nc_file.adv_ta == forcing_on):
message = 'adv_ta is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.'
logging.critical()
logging.critical(message)
raise Exception(message)
# tnta_adv_var = nc_file.createVariable('tnta_adv', wp, ('time','lev'))
# tnta_adv_var.units = 'K s-1'
Expand All @@ -2291,7 +2292,7 @@ def write_SCM_case_file(case_nml, case_data, use_area):

if (nc_file.adv_qv == forcing_on):
message = 'adv_qv is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.'
logging.critical()
logging.critical(message)
raise Exception(message)
# tnqv_adv_var = nc_file.createVariable('tnqv_adv', wp, ('time','lev'))
# tnqv_adv_var.units = 'kg kg-1 s-1'
Expand All @@ -2300,7 +2301,7 @@ def write_SCM_case_file(case_nml, case_data, use_area):

if (nc_file.adv_ua == forcing_on):
message = 'adv_ua is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.'
logging.critical()
logging.critical(message)
raise Exception(message)
# tnua_adv_var = nc_file.createVariable('tnua_adv', wp, ('time','lev'))
# tnua_adv_var.units = 'm s-2'
Expand All @@ -2309,7 +2310,7 @@ def write_SCM_case_file(case_nml, case_data, use_area):

if (nc_file.adv_va == forcing_on):
message = 'adv_va is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.'
logging.critical()
logging.critical(message)
raise Exception(message)
# tnva_adv_var = nc_file.createVariable('tnva_adv', wp, ('time','lev'))
# tnva_adv_var.units = 'm s-2'
Expand All @@ -2318,7 +2319,7 @@ def write_SCM_case_file(case_nml, case_data, use_area):

if (nc_file.adv_theta == forcing_on):
message = 'adv_theta is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.'
logging.critical()
logging.critical(message)
raise Exception(message)
# tntheta_adv_var = nc_file.createVariable('tntheta_adv', wp, ('time','lev'))
# tntheta_adv_var.units = 'K s-1'
Expand All @@ -2345,7 +2346,7 @@ def write_SCM_case_file(case_nml, case_data, use_area):

if (nc_file.adv_rv == forcing_on):
message = 'adv_rv is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.'
logging.critical()
logging.critical(message)
raise Exception(message)
# tnrv_adv_var = nc_file.createVariable('tnrv_adv', wp, ('time','lev'))
# tnrv_adv_var.units = 'kg kg-1 s-1'
Expand All @@ -2354,7 +2355,7 @@ def write_SCM_case_file(case_nml, case_data, use_area):

if (nc_file.adv_rt == forcing_on):
message = 'adv_rt is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.'
logging.critical()
logging.critical(message)
raise Exception(message)
# tnrt_adv_var = nc_file.createVariable('tnrt_adv', wp, ('time','lev'))
# tnrt_adv_var.units = 'kg kg-1 s-1'
Expand Down

0 comments on commit 18883a7

Please sign in to comment.