Skip to content

Commit

Permalink
Make XML type-aware and fix all the bugs this exposed.
Browse files Browse the repository at this point in the history
All the entries in enx*.xml files have a <type> that was being
ignored. This commit changes that. This should help reduce mistakes
on the client side by checking that they are using the right types.
  • Loading branch information
jgfouca committed Mar 11, 2016
1 parent 6446700 commit baaedfd
Show file tree
Hide file tree
Showing 26 changed files with 219 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</entry>

<entry id="DATM_CPLHIST_CASE">
<type>char*256</type>
<type>char</type>
<valid_values></valid_values>
<default_value>UNSET</default_value>
<values>
Expand Down
4 changes: 2 additions & 2 deletions components/data_comps/dlnd/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</entry>

<entry id="DLND_CPLHIST_DIR">
<type>char*256</type>
<type>char</type>
<default_value>UNSET</default_value>
<values>
<value compset="2000.*_DLND%SCPL.*_CISM" grid="a%0.9x1.25_l%0.9x1.25_oi%gx1v6">$DIN_LOC_ROOT/lnd/dlnd7/CPLHIST_SNO/b.e10.BG20TRCN.f09_g16.002_c121001</value>
Expand All @@ -45,7 +45,7 @@
</entry>

<entry id="DLND_CPLHIST_CASE">
<type>char*256</type>
<type>char</type>
<default_value>UNSET</default_value>
<values>
<value compset="2000.*_DLND%SCPL.*_CISM" grid="a%0.9x1.25_l%0.9x1.25_oi%gx1v6">b.e10.BG20TRCN.f09_g16.002</value>
Expand Down
4 changes: 2 additions & 2 deletions components/data_comps/drof/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</entry>

<entry id="DROF_CPLHIST_DIR">
<type>char*256</type>
<type>char</type>
<valid_values></valid_values>
<default_value>UNSET</default_value>
<group>run_component_drof</group>
Expand All @@ -45,7 +45,7 @@
</entry>

<entry id="DROF_CPLHIST_CASE">
<type>char*256</type>
<type>char</type>
<valid_values></valid_values>
<default_value>UNSET</default_value>
<group>run_component_drof</group>
Expand Down
28 changes: 14 additions & 14 deletions driver_cpl/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<!-- ===================================================================== -->

<entry id="CASE">
<type>char*256</type>
<type>char</type>
<default_value>UNSET</default_value>
<group>case_def</group>
<file>env_case.xml</file>
Expand Down Expand Up @@ -228,7 +228,7 @@
</entry>

<entry id="RUN_REFDIR">
<type>char*256</type>
<type>char</type>
<default_value>ccsm4_init</default_value>
<group>run_begin_stop_restart</group>
<file>env_run.xml</file>
Expand All @@ -238,7 +238,7 @@
</entry>

<entry id="RUN_REFCASE">
<type>char*256</type>
<type>char</type>
<default_value>case.std</default_value>
<group>run_begin_stop_restart</group>
<file>env_run.xml</file>
Expand All @@ -248,7 +248,7 @@
</entry>

<entry id="RUN_REFDATE">
<type>char*10</type>
<type>char</type>
<default_value>0001-01-01</default_value>
<group>run_begin_stop_restart</group>
<file>env_run.xml</file>
Expand Down Expand Up @@ -675,7 +675,7 @@
</entry>

<entry id="USE_ESMF_LIB">
<type>char</type>
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>build_def</group>
Expand Down Expand Up @@ -769,7 +769,7 @@
</entry>

<entry id="BUILD_COMPLETE">
<type>int</type>
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>build_status</group>
Expand Down Expand Up @@ -1156,15 +1156,15 @@
</entry>

<entry id="PTS_LAT">
<type>real(1)</type>
<type>real</type>
<default_value>-999.99</default_value>
<group>run_domain</group>
<file>env_run.xml</file>
<desc>Latitude to find nearest points for points mode (only used if PTS_MODE is TRUE)</desc>
</entry>

<entry id="PTS_LON">
<type>real(1)</type>
<type>real</type>
<default_value>-999.99</default_value>
<group>run_domain</group>
<file>env_run.xml</file>
Expand Down Expand Up @@ -1962,7 +1962,7 @@
</entry>

<entry id="NINST_LND_LAYOUT">
<type>integer</type>
<type>char</type>
<valid_values>sequential,concurrent</valid_values>
<default_value>concurrent</default_value>
<group>mach_pes_lnd</group>
Expand Down Expand Up @@ -2003,7 +2003,7 @@
</entry>

<entry id="NINST_ICE_LAYOUT">
<type>integer</type>
<type>char</type>
<valid_values>equential,concurrent</valid_values>
<default_value>concurrent</default_value>
<group>mach_pes_ice</group>
Expand Down Expand Up @@ -2301,7 +2301,7 @@
<!-- ===================================================================== -->

<entry id="PIO_VERSION">
<type>int</type>
<type>integer</type>
<default_value>1</default_value>
<valid_values>1,2</valid_values>
<group>build_macros</group>
Expand Down Expand Up @@ -3318,7 +3318,7 @@
</entry>

<entry id="SCIENCE_SUPPORT">
<type>char*256</type>
<type>char</type>
<valid_values>on, off</valid_values>
<default_value>off</default_value>
<group>case_def</group>
Expand Down Expand Up @@ -3549,15 +3549,15 @@

<!-- Job Submission stuff -->
<entry id="JOB_QUEUE">
<type>character</type>
<type>char</type>
<valid_values></valid_values>
<default_value></default_value>
<group>job_submission</group>
<file>env_batch.xml</file>
<desc>The machine queue in which to submit the job. Default determined in config_machines.xml can be overwritten by testing</desc>
</entry>
<entry id="JOB_WALLCLOCK_TIME">
<type>character</type>
<type>char</type>
<valid_values></valid_values>
<default_value></default_value>
<group>job_submission</group>
Expand Down
2 changes: 1 addition & 1 deletion scripts/Testing/Testcases/config_tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<INFO_DBUG>1</INFO_DBUG>
<STOP_OPTION>ndays</STOP_OPTION>
<STOP_N>22</STOP_N>
<CCSM_TCOST></CCSM_TCOST>
<CCSM_TCOST>0</CCSM_TCOST>
<DOUT_S>FALSE</DOUT_S>
</test>

Expand Down
8 changes: 4 additions & 4 deletions scripts/Tools/check_lockedfiles
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,22 @@ def check_lockedfiles(caseroot):
logging.warn("File %s has been modified"%lfile)
for key in diffs.keys():
print(" found difference in %s : case %s locked %s" %
(key, diffs[key][0], diffs[key][1]))
(key, repr(diffs[key][0]), repr(diffs[key][1])))
if objname == "env_mach_pes":
expect(False, "Invoke case.setup -clean followed by case.setup")
if objname == "env_case":
expect(False, "Cannot change file env_case.xml, please"
" recover the original copy from LockedFiles")
if objname == "env_build":
logging.warn("Setting build complete to False")
f1obj.set_value("BUILD_COMPLETE", "FALSE")
f1obj.set_value("BUILD_COMPLETE", False)
if "PIO_VERSION" in diffs.keys():
f1obj.set_value("BUILD_STATUS", "2")
f1obj.set_value("BUILD_STATUS", 2)
f1obj.write()
logging.critical("Changing PIO_VERSION requires running "
"case.clean_build all and rebuilding")
else:
f1obj.set_value("BUILD_STATUS", "1")
f1obj.set_value("BUILD_STATUS", 1)
f1obj.write()


Expand Down
8 changes: 5 additions & 3 deletions scripts/Tools/xmlchange
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from standard_script_setup import *

from CIME.utils import expect, run_cmd
from CIME.utils import expect, run_cmd, convert_to_type
from CIME.case import Case

import argparse, doctest, shutil, glob
Expand Down Expand Up @@ -85,15 +85,17 @@ def xmlchange(caseroot, listofsettings=None, xmlfile=None, xmlid=None, xmlval=No
if(listofsettings ):
for setting in listofsettings:
(xmlid, xmlval) = setting.split('=', 1)
type_str = case.get_type_info(xmlid)
if(append is True):
value = case.get_value(xmlid, resolved=False, subgroup=subgroup)
xmlval = "%s %s" %(xmlval, value)
case.set_value(xmlid, xmlval, subgroup)
case.set_value(xmlid, convert_to_type(xmlval, type_str, xmlid), subgroup)
else:
if(append is True):
value = case.get_value(xmlid, resolved=False, subgroup=subgroup)
xmlval = "%s %s" %(xmlval, value)
case.set_value(xmlid, xmlval, subgroup)
type_str = case.get_type_info(xmlid)
case.set_value(xmlid, convert_to_type(xmlval, type_str, xmlid), subgroup)
case.flush()

if(noecho is False):
Expand Down
2 changes: 1 addition & 1 deletion utils/python/CIME/SystemTests/eri.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, caseroot, case):
SystemTestsCommon.__init__(self, caseroot, case)

def run(self):
self._case.set_value("CONTINUE_RUN","FALSE")
self._case.set_value("CONTINUE_RUN", False)
self._case.set_value("REST_OPTION","none")
self._case.set_value("HIST_OPTION","$STOP_OPTION")
self._case.set_value("HIST_N","$STOP_N")
Expand Down
14 changes: 7 additions & 7 deletions utils/python/CIME/SystemTests/erp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ def build(self, sharedlib_only=False, model_only=False):
if(bld == 2):
# halve the number of tasks and threads
for comp in ['ATM','CPL','OCN','WAV','GLC','ICE','ROF','LND']:
ntasks = int(self._case.get_value("NTASKS_%s"%comp))
nthreads = int(self._case.get_value("NTHRDS_%s"%comp))
rootpe = int(self._case.get_value("ROOTPE_%s"%comp))
ntasks = self._case.get_value("NTASKS_%s"%comp)
nthreads = self._case.get_value("NTHRDS_%s"%comp)
rootpe = self._case.get_value("ROOTPE_%s"%comp)
if ( nthreads > 1 ):
self._case.set_value("BUILD_THREADED","TRUE")
self._case.set_value("BUILD_THREADED", True)
if ( ntasks > 1 ):
self._case.set_value("NTASKS_%s"%comp, "%s"%int(ntasks/2))
self._case.set_value("ROOTPE_%s"%comp, "%s"%int(rootpe/2))
self._case.set_value("NTASKS_%s"%comp, ntasks/2)
self._case.set_value("ROOTPE_%s"%comp, rootpe/2)
if ( nthreads > 1 ):
self._case.set_value("NTHRDS_%s"%comp, "%s"%int(nthreads/2))
self._case.set_value("NTHRDS_%s"%comp, nthreads/2)
self._case.set_value("SMP_BUILD","0")
self._case.flush()
run_cmd("./case.setup -clean -testmode")
Expand Down
2 changes: 1 addition & 1 deletion utils/python/CIME/SystemTests/err.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, caseroot, case):
SystemTestsCommon.__init__(self, caseroot, case)

def run(self):
self._case.set_value("CONTINUE_RUN","FALSE")
self._case.set_value("CONTINUE_RUN",False)
self._case.set_value("REST_OPTION","none")
self._case.set_value("HIST_OPTION","$STOP_OPTION")
self._case.set_value("HIST_N","$STOP_N")
Expand Down
2 changes: 1 addition & 1 deletion utils/python/CIME/SystemTests/ers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, caseroot, case):
SystemTestsCommon.__init__(self, caseroot, case)

def run(self):
self._case.set_value("CONTINUE_RUN","FALSE")
self._case.set_value("CONTINUE_RUN",False)
self._case.set_value("REST_OPTION","none")
self._case.set_value("HIST_OPTION","$STOP_OPTION")
self._case.set_value("HIST_N","$STOP_N")
Expand Down
2 changes: 1 addition & 1 deletion utils/python/CIME/SystemTests/icp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def build(self, sharedlib_only=False, model_only=False):
self._case.set_value("CICE_AUTO_DECOMP","false")

def run(self):
self._case.set_value("CONTINUE_RUN","FALSE")
self._case.set_value("CONTINUE_RUN",False)
self._case.set_value("REST_OPTION","none")
self._case.set_value("HIST_OPTION","$STOP_OPTION")
self._case.set_value("HIST_N","$STOP_N")
Expand Down
11 changes: 6 additions & 5 deletions utils/python/CIME/SystemTests/nck.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from system_tests_common import SystemTestsCommon

class NCK(SystemTestsCommon):

def __init__(self, caseroot, case):
"""
initialize a test object
Expand All @@ -31,13 +32,13 @@ def build(self, sharedlib_only=False, model_only=False):
logging.warn("Starting bld %s"%bld)
machpes = os.path.join("LockedFiles","env_mach_pes.NCK%s.xml"%bld)
for comp in ['ATM','OCN','WAV','GLC','ICE','ROF','LND']:
self._case.set_value("NINST_%s"%comp,str(bld))
self._case.set_value("NINST_%s"%comp, bld)
if(bld == 2):
ntasks = int(self._case.get_value("NTASKS_%s"%comp))
rootpe = int(self._case.get_value("ROOTPE_%s"%comp))
ntasks = self._case.get_value("NTASKS_%s"%comp)
rootpe = self._case.get_value("ROOTPE_%s"%comp)
if ( ntasks > 1 ):
self._case.set_value("NTASKS_%s"%comp, "%s"%int(ntasks/2))
self._case.set_value("ROOTPE_%s"%comp, "%s"%int(rootpe/2))
self._case.set_value("NTASKS_%s"%comp, ntasks/2)
self._case.set_value("ROOTPE_%s"%comp, rootpe/2)
self._case.flush()

run_cmd("./case.setup -clean -testmode")
Expand Down
13 changes: 6 additions & 7 deletions utils/python/CIME/SystemTests/ncr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import CIME.utils
from system_tests_common import SystemTestsCommon


class NCR(SystemTestsCommon):

def __init__(self, caseroot, case):
"""
initialize a test object
Expand All @@ -34,18 +34,17 @@ def build(self):
ntasks_sum = 0
for comp in ['ATM','OCN','WAV','GLC','ICE','ROF','LND']:
self._case.set_value("NINST_%s"%comp,str(bld))
ntasks = int(self._case.get_value("NTASKS_%s"%comp))
ntasks = self._case.get_value("NTASKS_%s"%comp)
if(bld == 1):
self._case.set_value("ROOTPE_%s"%comp,"0")
self._case.set_value("ROOTPE_%s"%comp, 0)
if ( ntasks > 1 ):
self._case.set_value("NTASKS_%s"%comp, "%s"%int(ntasks/2))
self._case.set_value("NTASKS_%s"%comp, ntasks/2)
else:
self._case.set_value("ROOTPE_%s"%comp, "%s"% ntasks_sum)
self._case.set_value("ROOTPE_%s"%comp, ntasks_sum)
ntasks_sum += ntasks*2
self._case.set_value("NTASKS_%s"%comp, "%s"%int(ntasks*2))
self._case.set_value("NTASKS_%s"%comp, ntasks*2)
self._case.flush()


run_cmd("./case.setup -clean -testmode")
run_cmd("./case.setup")
run_cmd('./case.clean_build')
Expand Down
2 changes: 1 addition & 1 deletion utils/python/CIME/SystemTests/pea.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def build(self, sharedlib_only=False, model_only=False):
exeroot = self._case.get_value("EXEROOT")
cime_model = CIME.utils.get_model()
for comp in ['ATM','CPL','OCN','WAV','GLC','ICE','ROF','LND']:
self._case.set_value("NTASKS_%s"%comp,"1")
self._case.set_value("NTASKS_%s"%comp, 1)

build1 = os.path.join("LockedFiles","env_build.PEA1.xml")
if ( os.path.isfile(build1) ):
Expand Down
11 changes: 5 additions & 6 deletions utils/python/CIME/SystemTests/pem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import CIME.utils
from system_tests_common import SystemTestsCommon


class PEM(SystemTestsCommon):

def __init__(self, caseroot, case):
"""
initialize a test object
Expand Down Expand Up @@ -43,12 +43,11 @@ def build(self, sharedlib_only=False, model_only=False):
shutil.copy("env_mach_pes.xml", machpes)

if bld == 1:
ntasks = int(self._case.get_value("NTASKS_%s"%comp))
rootpe = int(self._case.get_value("ROOTPE_%s"%comp))
ntasks = self._case.get_value("NTASKS_%s"%comp)
rootpe = self._case.get_value("ROOTPE_%s"%comp)
if ntasks > 1:
self._case.set_value("NTASKS_%s"%comp, "%s"%int(ntasks/2))
self._case.set_value("ROOTPE_%s"%comp, "%s"%int(rootpe/2))

self._case.set_value("NTASKS_%s"%comp, ntasks/2)
self._case.set_value("ROOTPE_%s"%comp, rootpe/2)

#
# Because mira/cetus interprets its run script differently than
Expand Down
Loading

0 comments on commit baaedfd

Please sign in to comment.