Skip to content

Commit

Permalink
Merge pull request #2 from samsrabin/zerothtstep-fix-RXCROPMATURITY
Browse files Browse the repository at this point in the history
Fix RXCROPMATURITY test in zerothtstep branch
  • Loading branch information
olyson authored Nov 2, 2023
2 parents d5b007f + fa843e5 commit 11b6042
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions python/ctsm/crop_calendars/generate_gdds_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def log(logger, string):


def error(logger, string):
print(string)
logger.error(string)
raise RuntimeError(string)

Expand Down Expand Up @@ -217,7 +218,7 @@ def import_and_process_1yr(
else:
chunks = None

# Get h2 file (list)
# Get h1 file (list)
h1_pattern = os.path.join(indir, "*h1.*.nc")
h1_filelist = glob.glob(h1_pattern)
if not h1_filelist:
Expand Down Expand Up @@ -477,13 +478,14 @@ def import_and_process_1yr(
log(logger, f" Importing accumulated GDDs...")
clm_gdd_var = "GDDACCUM"
myVars = [clm_gdd_var, "GDDHARV"]
pattern = os.path.join(indir, f"*h2.{thisYear-1}-01-01*.nc")
h2_files = glob.glob(pattern)
if not h2_files:
pattern = os.path.join(indir, f"*h2.{thisYear-1}-01-01*.nc.base")
patterns = [f"*h2.{thisYear-1}-01*.nc", f"*h2.{thisYear-1}-01*.nc.base"]
for p in patterns:
pattern = os.path.join(indir, p)
h2_files = glob.glob(pattern)
if not h2_files:
error(logger, f"No files found matching pattern '*h2.{thisYear-1}-01-01*.nc(.base)'")
if h2_files:
break
if not h2_files:
error(logger, f"No files found matching patterns: {patterns}")
h2_ds = utils.import_ds(
h2_files,
myVars=myVars,
Expand Down

0 comments on commit 11b6042

Please sign in to comment.