diff --git a/.gitmodules b/.gitmodules index c0b72575..f968ba5c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,7 +7,7 @@ [submodule "history"] path = src/history/buffers url = https://github.com/peverwhee/history_output - fxtag = sima-history + fxtag = 44099b18b2dcbb80c1ed1755b6ef1cc7be028033 fxrequired = AlwaysRequired fxDONOTUSEurl = https://github.com/peverwhee/history_output [submodule "mpas"] @@ -20,7 +20,7 @@ [submodule "ncar-physics"] path = src/physics/ncar_ccpp url = https://github.com/peverwhee/atmospheric_physics - fxtag = diagnostics + fxtag = 61bd9d3dac2abb11bb1e44a2ca34b401da0f44b1 fxrequired = AlwaysRequired fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics [submodule "ccs_config"] diff --git a/cime_config/buildnml b/cime_config/buildnml index ddff8621..8989f291 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -307,26 +307,6 @@ def buildnml(case, caseroot, compname): user_nl_fname = "user_nl_cam" + inst_string user_nl_file = os.path.join(caseroot, user_nl_fname) - # Temporary user_nl file with history config stripped - user_nl_temp = os.path.join(confdir, "user_nl_temp") - if os.path.exists(user_nl_temp): - os.remove(user_nl_temp) - # end if - - # Remove history configuration from the normal user_nl content - with open(user_nl_file, 'r') as infile: - clines = infile.readlines() - # end with - with open(user_nl_temp, 'w') as outfile: - for line in clines: - sline = line.strip() - if ((not sline) or (sline[0] == '!') or - (_USER_NL_LINE.match(sline) is not None)): - outfile.write(line) - # end if - # end or - # end with - # Check that file actually exists. If not then throw an error: if not os.path.exists(user_nl_file): emsg = "The file 'user_nl_cam' is missing. Please run 'case.setup' first." diff --git a/cime_config/hist_config.py b/cime_config/hist_config.py index f00b53c0..65097be2 100644 --- a/cime_config/hist_config.py +++ b/cime_config/hist_config.py @@ -11,12 +11,12 @@ import sys # Find and include the ccpp-framework scripts directory -# Assume we are in /src/data and SPIN is in /ccpp_framework +# Assume we are in /src/data and CCPP is in /ccpp_framework __CURRDIR = os.path.abspath(os.path.dirname(__file__)) __CAMROOT = os.path.abspath(os.path.join(__CURRDIR, os.pardir)) -__SPINSCRIPTS = os.path.join(__CAMROOT, "ccpp_framework", 'scripts') -if __SPINSCRIPTS not in sys.path: - sys.path.append(__SPINSCRIPTS) +__CCPPSCRIPTS = os.path.join(__CAMROOT, "ccpp_framework", 'scripts') +if __CCPPSCRIPTS not in sys.path: + sys.path.append(__CCPPSCRIPTS) # end if # CCPP framework imports @@ -30,10 +30,10 @@ # %y = year, # %m = month, # %d = day, -# %s = seconds in day, +# %s = seconds since midnight GMT in current day, # %u = unit number (e.g., h0, i) # -# rhfilename_spec is the templdate for history restart files +# rhfilename_spec is the template for history restart files _DEFAULT_RESTART_HIST_SPEC = '%c.cam.r%u.%y-%m-%d-%s.nc' # hfilename_spec is the template for each history file _DEFAULT_HISTORY_SPEC = '%c.cam.%u.%y-%m-%d-%s.nc' @@ -41,11 +41,12 @@ # Note, these lists should match the corresponding lists in # cam_hist_config_file.F90 _TIME_PERIODS = ['nsteps', 'nstep', 'nseconds', 'nsecond', - 'nminutes', 'nminute', 'nhours', 'nhour', 'ndays', 'nday', - 'monthly', 'nmonths', 'nmonth', 'nyears', 'nyear', + 'nminutes', 'nminute', 'nhours', 'nhour', 'ndays', + 'nday', 'nmonths', 'nmonth', 'nyears', 'nyear', 'steps', 'seconds', 'minutes', 'hours', 'days', 'months', 'years'] _OUT_PRECS = ['REAL32', 'REAL64'] +_NETCDF_ID_RE = re.compile(r"^[a-z][a-z0-9_]{0,62}$", re.IGNORECASE) ############################################################################## ### @@ -64,12 +65,23 @@ def __init__(self, message): super().__init__(message) ############################################################################## -def blank_config_line(line): +def _blank_config_line(line): ############################################################################## """Return True if is a valid history config blank or comment line. Also return True if we have reached the end of the file - (no line)""" - return (not line) or (line.strip()[0] == '!') + (no line) + >>> _blank_config_line(" ! hist_add_avg_field") + True + >>> _blank_config_line(" ") + True + >>> _blank_config_line("") + True + >>> _blank_config_line("hist_add_avg_fields;h0: U") + False + >>> _blank_config_line("this is a ! weird line but is not blank") + False + """ + return (not line.strip()) or (line.strip()[0] == '!') ############################################################################## def _is_integer(entry): @@ -118,12 +130,16 @@ def _list_of_idents(entry, sep=','): (None, "'foo.3bar' is not a valid identifier") >>> _list_of_idents("foo3bariendnaadfasdfbasdlkfap983rasdfvalsda938qjnasdasd98adfasxd") (None, "'foo3bariendnaadfasdfbasdlkfap983rasdfvalsda938qjnasdasd98adfasxd' is not a valid identifier") - >>> _list_of_idents("") + >>> _list_of_idents("foo.3bar, foo3bariendnaadfasdfbasdlkfap983rasdfvalsda938qjnasdasd98adfasxd") + (None, "'foo.3bar' is not a valid identifier\\n 'foo3bariendnaadfasdfbasdlkfap983rasdfvalsda938qjnasdasd98adfasxd' is not a valid identifier") + >>> _list_of_idents("foo.3bar; foo", sep=';') + (None, "'foo.3bar' is not a valid identifier") + >>> _list_of_idents(" ") (None, 'No identifiers found') """ errmsg = None - if entry: - good_list = [x.strip() for x in str(entry).split(sep)] + if entry.strip(): + good_list = [x.strip() for x in entry.split(sep)] for sample in good_list: if _NETCDF_ID_RE.match(sample) is None: if errmsg: @@ -151,27 +167,34 @@ def _is_mult_period(entry): A time-period entry is of the form: [ *] where is an optional integer and is one of the recognized - time period (e.g., steps, days, months). + time periods (e.g., steps, days, months). Also, return an error string or None if no error is found. >>> _is_mult_period("nsteps") ((1, 'nsteps'), None) >>> _is_mult_period("3 * nmonths") ((3, 'nmonths'), None) >>> _is_mult_period("2*fortnights") - (None, 'period must be one of nsteps, nstep, nseconds, nsecond, nminutes, nminute, nhours, nhour, ndays, nday, monthly, nmonths, nmonth, nyears, nyear, steps, seconds, minutes, hours, days, months, years') - >>> _is_mult_period("") - (None, 'no entry for frequency') + (None, 'period must be one of nsteps, nstep, nseconds, nsecond, nminutes, nminute, nhours, nhour, ndays, nday, nmonths, nmonth, nyears, nyear, steps, seconds, minutes, hours, days, months, years') + >>> _is_mult_period("7*nhours of day") + (None, 'period must be one of nsteps, nstep, nseconds, nsecond, nminutes, nminute, nhours, nhour, ndays, nday, nmonths, nmonth, nyears, nyear, steps, seconds, minutes, hours, days, months, years') + >>> _is_mult_period(" ") + (None, 'a frequency ([*]period) is required') >>> _is_mult_period("1*nyear") ((1, 'nyear'), None) >>> _is_mult_period("-6*nhours") (None, 'multiplier must be a positive integer') + >>> _is_mult_period("7h*nhours") + (None, 'multiplier must be a positive integer') + >>> _is_mult_period("5*nhours*ndays") + (None, "Bad formatting of frequency, must be in the form of '*