#!/usr/bin/env python import sys, commands from os import path, getcwd from os import chdir, system, mkdir from shutil import copy import numpy as np first = 1 last = 500 # Define calculation parameters ################# # this value will be used in the Job file ####### # JobName ='163v1p' # Just a general lable: "JobName_NumTraj" TimeLimit ='100' # in hours: "TimeLimit:00:00" NCores ='24' # SubmissionSteps ='500' # # ################################################# here=getcwd() #workdir for i in range(first,(last+1)): traj= '%.4d' % i # define working directory newdir=path.join(here, traj) # updating mypath propdir=newdir + '_longpropagation' if not path.exists(newdir): print "folder", newdir, "not found. exiting..." quit() if path.exists(newdir + '_longpropagation'): continue if not path.exists(newdir + '/outcome'): continue outcome = open(newdir + '/outcome').readlines() if not 'REACTION' in outcome[0]: continue system('cp -r {} {}'.format(newdir, propdir) ) chdir(propdir) if path.exists('STOPCAR'): system('rm STOPCAR') runs = -1 # check number of runs while path.exists('XDATCAR_%d' % (runs+1)): runs += 1 # copy('CONTCAR_%d' % runs, 'POSCAR') # copy('%s/INPUTS/Job-restart-propagation' % here , 'Job-restart-propagation') # lable = traj + '_' + JobName modify = 'sed -e \"s|_JOBNAME_|%s|g\" Job-restart-propagation > Job' % lable # modify the Jobfile system(modify) # modify = 'sed -i \"s|_TIMELIMIT_|%s|g\" Job' % TimeLimit # system(modify) # modify = 'sed -i \"s|_NCORES_|%s|g\" Job' % NCores # system(modify) # modify = 'sed -i \"s|_SUBSTEPS_|%s|g\" Job' % SubmissionSteps # system(modify) system('sbatch Job > ID.job') # RUN JOB ####################################### system('cat ID.job')