Skip to content

Commit

Permalink
fix argument errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaganKing committed Feb 13, 2024
1 parent 68f6957 commit f48bb75
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
42 changes: 24 additions & 18 deletions python/ctsm/site_and_regional/neon_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
"""

# Import libraries
import glob
import logging
import os
import re
import shutil
import sys
import time

# Get the ctsm util tools and then the cime tools.
_CTSM_PYTHON = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "python"))
Expand All @@ -36,21 +32,28 @@ class NeonSite(TowerSite):
A class for encapsulating neon sites.
"""

def __init__(self, name, start_year, end_year, start_month, end_month, finidat):
super().__init__(name, start_year, end_year, start_month, end_month, finidat)

def build_base_case(
self, cesmroot, output_root, res, compset, overwrite=False, setup_only=False
self,
cesmroot,
output_root,
res,
compset,
user_mods_dirs=None,
overwrite=False,
setup_only=False,
):
user_mods_dirs = [
os.path.join(self.cesmroot, "cime_config", "usermods_dirs", "NEON", self.name)
]
if user_mods_dirs is None:
user_mods_dirs = [
os.path.join(self.cesmroot, "cime_config", "usermods_dirs", "NEON", self.name)
]
print("in neonsite adding usermodsdirs")
print("usermodsdirs: {}".format(user_mods_dirs))
case_path = super().build_base_case(cesmroot, output_root, res, compset, user_mods_dirs)

return case_path

def get_batch_query(self, case):
return super().get_batch_query(case)
# def get_batch_query(self, case):
# return super().get_batch_query(case)

# pylint: disable=too-many-statements
def run_case(
Expand All @@ -60,6 +63,8 @@ def run_case(
prism,
run_length,
user_version,
tower_type=None,
user_mods_dirs=None,
overwrite=False,
setup_only=False,
no_batch=False,
Expand Down Expand Up @@ -97,17 +102,18 @@ def run_case(
]
tower_type = "NEON"
super().run_case(
base_case_root, run_type, prism, run_length, tower_type, user_mods_dirs, user_version
base_case_root, run_type, prism, run_length, user_version, tower_type, user_mods_dirs
)

def set_ref_case(self, case):
super().set_ref_case(case)
return True ### Check if super returns false, if this will still return True?

def modify_user_nl(self, case_root, run_type, rundir):
def modify_user_nl(self, case_root, run_type, rundir, site_lines=None):
# TODO: include neon-specific user namelist lines, using this as just an example currently
site_lines = [
"""hist_fincl1 = 'TOTECOSYSC', 'TOTECOSYSN', 'TOTSOMC', 'TOTSOMN', 'TOTVEGC',
if site_lines is None:
site_lines = [
"""hist_fincl1 = 'TOTECOSYSC', 'TOTECOSYSN', 'TOTSOMC', 'TOTSOMN', 'TOTVEGC',
'TOTVEGN', 'TLAI', 'GPP', 'CPOOL', 'NPP', 'TWS', 'H2OSNO',"""
]
]
super().modify_user_nl(case_root, run_type, rundir, site_lines)
3 changes: 2 additions & 1 deletion python/ctsm/site_and_regional/run_neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ def main(description):
if run_from_postad:
neon_site.finidat = None
if not base_case_root:
user_mods_dirs = None
base_case_root = neon_site.build_base_case(
cesmroot, output_root, res, compset, overwrite, setup_only
cesmroot, output_root, res, compset, user_mods_dirs, overwrite, setup_only
)
logger.info("-----------------------------------")
logger.info("Running CTSM for neon site : %s", neon_site.name)
Expand Down
6 changes: 3 additions & 3 deletions python/ctsm/site_and_regional/tower_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def get_batch_query(self, case):
return "none"
return case.get_value("batch_query")

def modify_user_nl(self, case_root, run_type, rundir, site_lines):
def modify_user_nl(self, case_root, run_type, rundir, site_lines=None):
"""
Modify user namelist. If transient, include finidat in user_nl;
Otherwise, adjust user_nl to include different mfilt, nhtfrq, and variables in hist_fincl1.
Expand Down Expand Up @@ -249,9 +249,9 @@ def run_case(
run_type,
prism,
run_length,
user_version,
tower_type,
user_mods_dirs,
user_version,
overwrite=False,
setup_only=False,
no_batch=False,
Expand Down Expand Up @@ -399,7 +399,7 @@ def run_case(
if not rundir:
rundir = case.get_value("RUNDIR")

self.modify_user_nl(case_root, run_type, rundir)
self.modify_user_nl(case_root, run_type, rundir) # TODO: add site_lines argument?

case.create_namelists()
# explicitly run check_input_data
Expand Down

0 comments on commit f48bb75

Please sign in to comment.