diff --git a/parametricJob.py b/parametricJob.py index f351a8a9339c34ae693407f2277d05a4cde4dd8c..1a53becd89fcd9ede554d9efae9fdde8c201bd4e 100644 --- a/parametricJob.py +++ b/parametricJob.py @@ -265,18 +265,34 @@ class ParametricJob(PRMSet): # AT/BATCH SPECIFIC def runBatch(self): # get guess profile - cfgfile = self.guessProfile() + cfgfile = self.guessProfile() + cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile) + import re + m = re.compile(cfgFileName+'([0-9]+)\.'+cfgFileExtension) + launchId = 0 + for fn in os.listdir('.'): + out = m.search(fn) + if out : + outId = int(out.group(1)) + if outId > launchId : + lauchId = outId + launchId +=1 + print ("launchId =", launchId) + os.system("cp %s %s%s%s"%(self.cfgfile, cfgFileName, launchId, cfgFileExtension)) + # build script - scriptname="runbatch.sh" + scriptname="runbatch%d.sh"%launchId file = open(scriptname,"w") file.write("#!/bin/bash\n") # this avoids /bin/sh when sh=dash file.write(". %s\n" % cfgfile) - file.write("echo `atq`\n") - file.write("jobId=`atq | awk '{if ($1>jobId)jobId=$1} END {print jobId}'`\n") - file.write("echo \"at JobId = $jobId\"\n") - file.write('%s -x -i $jobId -d "%s"\n' % (sys.argv[0], os.getcwd()) ) + #file.write("echo `atq`\n") + #file.write("jobId=`atq | awk '{if ($1>jobId)jobId=$1} END {print jobId}'`\n") + #file.write("echo \"at JobId = $jobId\"\n") + #file.write('%s -x -i $jobId -d "%s"\n' % (sys.argv[0], os.getcwd()) ) + file.write('%s -x -i %d -d "%s"\n' % (sys.argv[0], launchId, os.getcwd()) ) file.close() os.chmod(scriptname,0o700) + print("starting script in batch mode: %s" % scriptname) #shcmd="at %s -f %s" % (self.pars['BATCHTIME'].val, scriptname) if self.pars['RUNMETHOD'].val == "at" : @@ -300,8 +316,8 @@ class ParametricJob(PRMSet): batchId = m.group(1) #print m.group if m: - cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile) - os.system("cp %s %s%s%s"%(self.cfgfile, cfgFileName, batchId, cfgFileExtension)) + #cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile) + #os.system("cp %s %s%s%s"%(self.cfgfile, cfgFileName, batchId, cfgFileExtension)) self.atrmScript(batchId) print("\tuse 'atq' and find job number %s to check the status of your job" % batchId) print("\t\t - 'a' means waiting in the queue 'a'")