33that CTSM does not fail using the just-generated input files
44"""
55
6- import os
7- import sys
8- import logging
9- from CIME .SystemTests .system_tests_common import SystemTestsCommon
10- from CIME .user_mod_support import apply_user_mods
11- from CIME .XML .standard_module_setup import *
6+ from subsetdata import SUBSETDATASHARED
127
13- # In case we need to import subset_data later
14- _CTSM_PYTHON = os .path .join (
15- os .path .dirname (os .path .realpath (__file__ )), os .pardir , os .pardir , "python"
16- )
17- sys .path .insert (1 , _CTSM_PYTHON )
188
19- logger = logging .getLogger (__name__ )
20-
21-
22- class SUBSETDATAPOINT (SystemTestsCommon ):
9+ class SUBSETDATAPOINT (SUBSETDATASHARED ):
2310 def __init__ (self , case ):
2411 """
2512 initialize an object interface to the SMS system test
2613 """
27- SystemTestsCommon .__init__ (self , case )
28-
29- # Check the test setup
30- if not self ._case .get_value ("LND_GRID" ) == "CLM_USRDAT" :
31- raise RuntimeError ("SUBSETDATAPOINT tests require resolution CLM_USRDAT" )
32- if "serial" not in self ._case .get_value ("MPILIB" ):
33- raise RuntimeError ("SUBSETDATAPOINT tests require a serial MPILIB" )
34- if "BGC-CROP" not in self ._case .get_value ("COMPSET" ):
35- raise RuntimeError ("SUBSETDATAPOINT tests require a BGC-CROP compset" )
36-
37- def build_phase (self , sharedlib_only = False , model_only = False ):
38-
39- # Where the output files will be saved
40- out_dir = os .path .join (self ._get_caseroot (), "subset_data_output" )
41- usermods_dir = os .path .join (out_dir , "user_mods" )
4214
43- # Import subset_data. Do it here rather than at top because otherwise the import will
44- # be attempted even during RUN phase.
45- # pylint: disable=wrong-import-position,import-outside-toplevel
46- from ctsm .subset_data import main as subset_data
47-
48- # Run the tool
4915 lat = 45.402252
5016 lon = - 92.798085
51- sys .argv = [
17+
18+ # Don't need to include things that are added during SUBSETDATASHARED.__init__()
19+ subset_data_cmd = [
5220 "tools/site_and_regional/subset_data" ,
5321 "point" ,
5422 "--lat" ,
@@ -65,24 +33,6 @@ def build_phase(self, sharedlib_only=False, model_only=False):
6533 "1901" ,
6634 "--datm-eyr" ,
6735 "1901" ,
68- "--create-user-mods" ,
69- "--outdir" ,
70- out_dir ,
71- "--user-mods-dir" ,
72- usermods_dir ,
73- "--overwrite" ,
7436 ]
75- subset_data ()
76-
77- # Required so that CTSM doesn't fail
78- user_nl_clm_path = os .path .join (usermods_dir , "user_nl_clm" )
79- with open (user_nl_clm_path , "a" , encoding = "utf-8" ) as user_nl_clm :
80- user_nl_clm .write ("\n check_dynpft_consistency = .false." )
81-
82- # Apply the user mods
83- self ._case .flush (flushall = True )
84- apply_user_mods (self ._get_caseroot (), usermods_dir )
85- self ._case .read_xml ()
8637
87- # Do the build
88- super ().build_phase (sharedlib_only , model_only )
38+ super ().__init__ (case , subset_data_cmd )
0 commit comments