Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock env_mach.xml file #1039

Merged
merged 2 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions cime_config/acme/machines/config_batch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
<batch_directive></batch_directive>
<jobid_pattern>(\d+)</jobid_pattern>
<depend_string> --dependencies</depend_string>
<walltime_format>%H:%M:%S</walltime_format>
<walltime_format>%H:%M:%s</walltime_format>
<submit_args>
<arg flag="--cwd" name="CASEROOT"/>
<arg flag="-A" name="PROJECT"/>
<arg flag="-t" name="JOB_WALLCLOCK_TIME"/>
<!-- space is required here so that variable is resolved correctly -->
<arg flag="-n" name=" $TOTALPES/$PES_PER_NODE"/>
<arg flag="-n" name=" $TOTALPES / $PES_PER_NODE"/>
<arg flag="-q" name="JOB_QUEUE"/>
<arg flag="--mode script"/>
</submit_args>
Expand All @@ -72,43 +72,43 @@
<batch_redirect>&lt;</batch_redirect>
<batch_directive>#BSUB</batch_directive>
<jobid_pattern>&lt;(\d+)&gt;</jobid_pattern>
<depend_string> -w "done(jobid)"</depend_string>
<depend_string> -w 'done(jobid)'</depend_string>
<walltime_format>%H:%M</walltime_format>
<submit_args>
<arg flag="-q" name="$JOB_QUEUE"/>
<arg flag="-W" name="$JOB_WALLCLOCK_TIME"/>
<arg flag="-P" name="$PROJECT"/>
</submit_args>
<directives>
<directive > -n {{ totaltasks }} </directive>
<directive > -R "span[ptile={{ ptile }}]"</directive>
<directive > -q {{ job_queue }} </directive>
<directive > -n {{ total_tasks }} </directive>
<directive > -R "span[ptile={{ tasks_per_node }}]"</directive>
<directive > -N </directive>
<directive default="poe" > -a {{ poe }} </directive>
<directive > -x {{ queue_exclusive }} </directive>
<directive default="acme.stdout" > -o {{ acme_stdout }}.%J </directive>
<directive default="acme.stderr" > -e {{ acme_stderr }}.%J </directive>
<directive default="acme.stdout" > -o {{ output_error_path }}.%J </directive>
<directive default="acme.stderr" > -e {{ output_error_path }}.%J </directive>
<directive > -J {{ job_id }} </directive>
<directive > -W {{ job_wallclock_time }} </directive>
<directive > -P {{ account }} </directive>
</directives>
</batch_system>

<batch_system type="pbs" >
<batch_query args="-u $USER" >qselect</batch_query>
<batch_query args="-f" >qstat</batch_query>
<batch_submit>qsub </batch_submit>
<batch_directive>#PBS</batch_directive>
<jobid_pattern>^(\d+)</jobid_pattern>
<jobid_pattern>^(\S+)$</jobid_pattern>
<depend_string> -W depend=afterok:jobid</depend_string>
<walltime_format>%H:%M:%S</walltime_format>
<submit_args>
<arg flag="-q" name="JOB_QUEUE"/>
<arg flag="-l walltime=" name="JOB_WALLCLOCK_TIME"/>
<arg flag="-A" name="PROJECT"/>
<arg flag="-q" name="$JOB_QUEUE"/>
<arg flag="-l walltime=" name="$JOB_WALLCLOCK_TIME"/>
<arg flag="-A" name="$PROJECT"/>
</submit_args>
<directives>
<directive> -V </directive>
<directive> -N {{ job_id }}</directive>
<directive default="n"> -r {{ rerunnable }} </directive>
<!-- <directive> -j oe {{ output_error_path }} </directive> -->
<directive> -j oe </directive>
<directive default="ae" > -m {{ mail_options }} </directive>
<directive default="/bin/bash" > -S {{ shell }} </directive>
<directive> -V </directive>
</directives>
</batch_system>

Expand All @@ -119,32 +119,37 @@
<jobid_pattern>(\d+)$</jobid_pattern>
<depend_string> -W depend=afterok:jobid</depend_string>
<walltime_format>%H:%M:%S</walltime_format>
<submit_args>
<arg flag="-l walltime=" name="$JOB_WALLCLOCK_TIME"/>
<arg flag="-A" name="$PROJECT"/>
</submit_args>
<directives>
<directive> -N {{ job_id }}</directive>
<directive> -l walltime={{ job_wallclock_time }}</directive>
<directive> -j oe </directive>
<directive> -A {{ project }} </directive>
<directive default="n"> -r {{ rerunnable }} </directive>
<directive default="ae" > -m {{ mail_options }} </directive>
<directive default="/bin/bash" > -S {{ shell }}</directive>
</directives>
</batch_system>

<batch_system type="slurm" >
<batch_query args="-o '%i' -h -u $USER">squeue </batch_query>
<batch_query>squeue</batch_query>
<batch_submit>sbatch</batch_submit>
<batch_directive>#SBATCH</batch_directive>
<jobid_pattern>(\d+)$</jobid_pattern>
<depend_string> --dependency=afterok:jobid</depend_string>
<walltime_format>%H:%M:%S</walltime_format>
<submit_args>
<arg flag="--time" name="$JOB_WALLCLOCK_TIME"/>
<arg flag="-p" name="$JOB_QUEUE"/>
<arg flag="--account" name="$PROJECT"/>
</submit_args>
<directives>
<directive> --job-name={{ job_id }}</directive>
<directive> --nodes={{ num_nodes }}</directive>
<directive> --ntasks-per-node={{ tasks_per_node }}</directive>
<directive> --output={{ output_error_path }} </directive>
<directive> --exclusive </directive>
<directive> --time={{ job_wallclock_time }}</directive>
<directive> --partition={{ job_queue }}</directive>
<directive> --account={{ project }}</directive>
</directives>
</batch_system>

Expand Down
7 changes: 3 additions & 4 deletions scripts/create_newcase
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python

from Tools.standard_script_setup import *
from shutil import copyfile
from CIME.utils import expect, get_model
from CIME.case import Case
from CIME.check_lockedfiles import lock_file

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -191,9 +191,8 @@ def _main_func(description):
user_mods_dir = os.path.abspath(user_mods_dir)
case.apply_user_mods(user_mods_dir)

# Copy env_case.xml into LockedFiles
copyfile(os.path.join(caseroot,"env_case.xml"),
os.path.join(caseroot,"LockedFiles","env_case.xml"))
# Lock env_case.xml
lock_file("env_case.xml", caseroot)

###############################################################################

Expand Down
31 changes: 14 additions & 17 deletions utils/python/CIME/SystemTests/erp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from CIME.case_setup import case_setup
import CIME.utils
from CIME.SystemTests.system_tests_common import SystemTestsCommon
from CIME.check_lockedfiles import *

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -40,15 +41,15 @@ def build_phase(self, sharedlib_only=False, model_only=False):
# env_build.xml in LockedFiles if they are not there. If there
# are already copies there then simply copy them back to
# have the starting env_mach_pes.xml and env_build.xml
machpes1 = os.path.join("LockedFiles","env_mach_pes.ERP1.xml")
envbuild1 = os.path.join("LockedFiles","env_build.ERP1.xml")
if ( os.path.isfile(machpes1) ):
shutil.copy(machpes1,"env_mach_pes.xml")
machpes1 = "env_mach_pes.ERP1.xml"
envbuild1 = "env_build.ERP1.xml"
if is_locked(machpes1):
restore(machpes1, newname="env_mach_pes.xml")
else:
shutil.copy("env_mach_pes.xml","env_mach_pes.ERP1.xml")
lock_file("env_mach_pes.xml", newname=machpes1)

if ( os.path.isfile(envbuild1) ):
shutil.copy(envbuild1,"env_build.xml")
if is_locked(envbuild1):
restore(envbuild1, newname="env_build.xml")

# Build two executables, one using the original tasks and threads (ERP1) and
# one using the modified tasks and threads (ERP2)
Expand Down Expand Up @@ -86,23 +87,19 @@ def build_phase(self, sharedlib_only=False, model_only=False):

# Make copies of the new env_mach_pes.xml and the new
# env_build.xml to be used in the run phase
shutil.copy("env_mach_pes.xml", os.path.join("LockedFiles","env_mach_pes.ERP%s.xml"%bld ))
shutil.copy("env_build.xml", os.path.join("LockedFiles","env_build.ERP%s.xml"%bld ))
#
#
lock_file("env_mach_pes.xml", newname="env_mach_pes.ERP%s.xml" % bld)
lock_file("env_build.xml", newname="env_build.ERP%s.xml" % bld)

def run_phase(self):
# run will have values 1,2
for run in range(1,3):

expect(os.path.isfile(os.path.join("LockedFiles","env_mach_pes.ERP%d.xml"%run)),
"ERROR: LockedFiles/env_mach_pes.ERP%d.xml does not exist, run case.build"%run )
expect(is_locked("env_mach_pes.ERP%d.xml" % run),
"ERROR: LockedFiles/env_mach_pes.ERP%d.xml does not exist, run case.build" % run )

# Use the second env_mach_pes.xml and env_build.xml files
shutil.copy(os.path.join("LockedFiles","env_mach_pes.ERP%d.xml"%run), "env_mach_pes.xml")
shutil.copy("env_mach_pes.xml", os.path.join("LockedFiles","env_mach_pes.xml"))
shutil.copy(os.path.join("LockedFiles","env_build.ERP%d.xml")%run, "env_build.xml")
shutil.copy("env_build.xml", os.path.join("LockedFiles","env_build.xml"))
restore("env_mach_pes.ERP%d.xml" % run, newname="env_mach_pes.xml")
restore("env_build.ERP%d.xml" % run, newname="env_build.xml")

# update the case to use the new values
self._case.read_xml()
Expand Down
29 changes: 13 additions & 16 deletions utils/python/CIME/SystemTests/ncr.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from CIME.case_setup import case_setup
import CIME.utils
from CIME.SystemTests.system_tests_common import SystemTestsCommon
from CIME.check_lockedfiles import *

logger = logging.getLogger(__name__)

Expand All @@ -25,16 +26,16 @@ def build_phase(self, sharedlib_only=False, model_only=False):
exeroot = self._case.get_value("EXEROOT")
cime_model = CIME.utils.get_model()

machpes1 = os.path.join("LockedFiles","env_mach_pes.NCR1.xml")
if ( os.path.isfile(machpes1) ):
shutil.copy(machpes1,"env_mach_pes.xml")
machpes1 = "env_mach_pes.NCR1.xml"
if is_locked(machpes1):
restore(machpes1, newname="env_mach_pes.xml")

# Build two exectuables for this test, the first is a default build, the
# second halves the number of tasks and runs two instances for each component
# Lay all of the components out concurrently
for bld in range(1,3):
logging.warn("Starting bld %s"%bld)
machpes = os.path.join("LockedFiles","env_mach_pes.NCR%s.xml"%bld)
machpes = "env_mach_pes.NCR%s.xml" % bld
ntasks_sum = 0
for comp in ['ATM','OCN','WAV','GLC','ICE','ROF','LND']:
self._case.set_value("NINST_%s"%comp,str(bld))
Expand All @@ -54,14 +55,12 @@ def build_phase(self, sharedlib_only=False, model_only=False):
self.build_indv(sharedlib_only, model_only)
shutil.move("%s/%s.exe"%(exeroot,cime_model),
"%s/%s.exe.NCR%s"%(exeroot,cime_model,bld))
shutil.copy("env_build.xml",os.path.join("LockedFiles","env_build.NCR%s.xml"%bld))
shutil.copy("env_mach_pes.xml", machpes)
lock_file("env_build.xml", newname="env_build.NCR%s.xml" % bld)
lock_file("env_mach_pes.xml", newname=machpes)

# Because mira/cetus interprets its run script differently than
# other systems we need to copy the original env_mach_pes.xml back
shutil.copy(machpes1,"env_mach_pes.xml")
shutil.copy("env_mach_pes.xml",
os.path.join("LockedFiles","env_mach_pes.xml"))
restore(machpes1, newname="env_mach_pes.xml")

def run_phase(self):
os.chdir(self._caseroot)
Expand All @@ -70,16 +69,15 @@ def run_phase(self):
cime_model = CIME.utils.get_model()

# Reset beginning test settings
expect(os.path.exists("LockedFiles/env_mach_pes.NCR1.xml"),
expect(is_locked("env_mach_pes.NCR1.xml"),
"ERROR: LockedFiles/env_mach_pes.NCR1.xml does not exist\n"
" this would been produced in the build - must run case.test_build")

shutil.copy("LockedFiles/env_mach_pes.NCR1.xml", "env_mach_pes.xml")
shutil.copy("env_mach_pes.xml", "LockedFiles/env_mach_pes.xml")
restore("env_mach_pes.NCR1.xml", newname="env_mach_pes.xml")
restore("env_build.NCR1.xml", newname="env_build.xml")
shutil.copy("%s/%s.exe.NCR1" % (exeroot, cime_model),
"%s/%s.exe" % (exeroot, cime_model))
shutil.copy("LockedFiles/env_build.NCR1.xml", "env_build.xml")
shutil.copy("env_build.xml", "LockedFiles/env_build.xml")


stop_n = self._case.get_value("STOP_N")
stop_option = self._case.get_value("STOP_OPTION")
Expand All @@ -104,8 +102,7 @@ def run_phase(self):
os.remove("%s/%s.exe" % (exeroot, cime_model))
shutil.copy("%s/%s.exe.NCR2" % (exeroot, cime_model),
"%s/%s.exe" % (exeroot, cime_model))
shutil.copy("LockedFiles/env_build.NCR2.xml", "env_build.xml")
shutil.copy("env_build.xml", "LockedFiles/env_build.xml")
restore("env_build.NCR2.xml", "env_build.xml")

logger.info("default: doing a %s %s with NINST2" % (stop_n, stop_option))
self.run_indv(suffix="multiinst")
Expand Down
20 changes: 8 additions & 12 deletions utils/python/CIME/SystemTests/seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from CIME.XML.standard_module_setup import *
from CIME.SystemTests.system_tests_common import SystemTestsCommon
from CIME.case_setup import case_setup
from CIME.check_lockedfiles import *
import shutil

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -31,12 +32,11 @@ def build_phase(self, sharedlib_only=False, model_only=False):
shutil.move("%s/%s.exe"%(exeroot,cime_model),
"%s/%s.exe.SEQ1"%(exeroot,cime_model))
any_changes = False
machpes1 = os.path.join("LockedFiles","env_mach_pes.SEQ1.xml")
if ( os.path.isfile(machpes1) ):
shutil.copy(machpes1,"env_mach_pes.xml")
machpes1 = "env_mach_pes.SEQ1.xml"
if is_locked(machpes1):
restore(machpes1, newname="env_mach_pes.xml")
else:
logging.info("Copying env_mach_pes.xml to %s"%(machpes1))
shutil.copy("env_mach_pes.xml", machpes1)
lock_file("env_mach_pes.xml", newname=machpes1)

comp_classes = self._case.get_values("COMP_CLASSES")
for comp in comp_classes:
Expand All @@ -63,9 +63,7 @@ def build_phase(self, sharedlib_only=False, model_only=False):
self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
shutil.move("%s/%s.exe"%(exeroot,cime_model),
"%s/%s.exe.SEQ2"%(exeroot,cime_model))
machpes2 = os.path.join("LockedFiles","env_mach_pes.SEQ2.xml")
logging.info("Copying env_mach_pes.xml to %s"%(machpes2))
shutil.copy("env_mach_pes.xml", machpes2)
lock_file("env_mach_pes.xml", newname="env_mach_pes.SEQ2.xml")

def run_phase(self):
# Move to config_tests.xml once that's ready.
Expand All @@ -87,12 +85,10 @@ def run_phase(self):

shutil.copy("%s/%s.exe.SEQ1"%(exeroot,cime_model),
"%s/%s.exe"%(exeroot,cime_model))
shutil.copy(os.path.join("LockedFiles", "env_mach_pes.SEQ1.xml"), "env_mach_pes.xml")
shutil.copy("env_mach_pes.xml", os.path.join("LockedFiles", "env_mach_pes.xml"))
restore("env_mach_pes.SEQ1.xml", newname="env_mach_pes.xml")
self.run_indv()

shutil.copy(os.path.join("LockedFiles", "env_mach_pes.SEQ2.xml"), "env_mach_pes.xml")
shutil.copy("env_mach_pes.xml", os.path.join("LockedFiles", "env_mach_pes.xml"))
restore("env_mach_pes.SEQ2.xml", newname="env_mach_pes.xml")

os.remove("%s/%s.exe"%(exeroot,cime_model))
shutil.copy("%s/%s.exe.SEQ1"%(exeroot,cime_model),
Expand Down
20 changes: 8 additions & 12 deletions utils/python/CIME/SystemTests/system_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from CIME.case_run import case_run
from CIME.case_st_archive import case_st_archive
from CIME.test_status import *
from CIME.check_lockedfiles import *
from CIME.hist_utils import *

import CIME.build as build
Expand All @@ -20,7 +21,7 @@ class SystemTestsCommon(object):

def __init__(self, case, expected=None):
"""
initialize a CIME system test object, if the file LockedFiles/env_run.orig.xml
initialize a CIME system test object, if the locked env_run.orig.xml
does not exist copy the current env_run.xml file. If it does exist restore values
changed in a previous run of the test.
"""
Expand All @@ -43,20 +44,14 @@ def _init_environment(self, caseroot):

def _init_locked_files(self, caseroot, expected):
"""
If the file LockedFiles/env_run.orig.xml does not exist, copy the current
If the locked env_run.orig.xml does not exist, copy the current
env_run.xml file. If it does exist, restore values changed in a previous
run of the test.
"""
if os.path.isfile(os.path.join(caseroot, "LockedFiles", "env_run.orig.xml")):
if is_locked("env_run.orig.xml"):
self.compare_env_run(expected=expected)
elif os.path.isfile(os.path.join(caseroot, "env_run.xml")):
lockedfiles = os.path.join(caseroot, "LockedFiles")
try:
os.stat(lockedfiles)
except:
os.mkdir(lockedfiles)
shutil.copy(os.path.join(caseroot,"env_run.xml"),
os.path.join(lockedfiles, "env_run.orig.xml"))
lock_file("env_run.xml", caseroot=caseroot, newname="env_run.orig.xml")

def _resetup_case(self, phase):
"""
Expand Down Expand Up @@ -307,12 +302,13 @@ def _check_for_memleak(self):
self._test_status.set_status(MEMLEAK_PHASE, TEST_FAIL_STATUS, comments=comment)

def compare_env_run(self, expected=None):
# JGF implement in check_lockedfiles?
f1obj = EnvRun(self._caseroot, "env_run.xml")
f2obj = EnvRun(self._caseroot, os.path.join("LockedFiles", "env_run.orig.xml"))
f2obj = EnvRun(self._caseroot, os.path.join(LOCKED_DIR, "env_run.orig.xml"))
diffs = f1obj.compare_xml(f2obj)
for key in diffs.keys():
if expected is not None and key in expected:
logging.warn(" Resetting %s for test"%key)
logging.warn(" Resetting %s for test" % key)
f1obj.set_value(key, f2obj.get_value(key, resolved=False))
else:
print "Found difference in %s: case: %s original value %s" %\
Expand Down
Loading