$ cat CalcFoldTemp/Jobs.history
Generation 1 Step 1 of Structure 1 at Calcfold1 : JOBID 0 Submitted Feb11-01:36:18
Generation 1 Step 1 of Structure 2 at Calcfold2 : JOBID 0 Submitted Feb11-01:36:18
Generation 1 Step 1 of Structure 3 at Calcfold3 : JOBID 0 Submitted Feb11-01:36:18
Generation 1 Step 1 of Structure 4 at Calcfold4 : JOBID 0 Submitted Feb11-01:36:18
Generation 1 Step 1 of Structure 5 at Calcfold5 : JOBID 0 Submitted Feb11-01:36:19
Generation 1 Step 1 of Structure 6 at Calcfold6 : JOBID 0 Submitted Feb11-01:36:19
Generation 1 Step 1 of Structure 7 at Calcfold7 : JOBID 0 Submitted Feb11-01:36:19
Generation 1 Step 1 of Structure 8 at Calcfold8 : JOBID 0 Submitted Feb11-01:36:19
Generation 1 Step 1 of Structure 9 at Calcfold9 : JOBID 0 Submitted Feb11-01:36:19
Generation 1 Step 1 of Structure 10 at Calcfold10 : JOBID 0 Submitted Feb11-01:36:19
Generation 1 Step 1 of Structure 1 at Calcfold1 : JOBID 0 Submitted Feb11-01:36:56
Generation 1 Step 1 of Structure 2 at Calcfold2 : JOBID 0 Submitted Feb11-01:36:56
Generation 1 Step 1 of Structure 3 at Calcfold3 : JOBID 0 Submitted Feb11-01:36:56
Generation 1 Step 1 of Structure 4 at Calcfold4 : JOBID 0 Submitted Feb11-01:36:56
Generation 1 Step 1 of Structure 5 at Calcfold5 : JOBID 0 Submitted Feb11-01:36:56
Generation 1 Step 1 of Structure 6 at Calcfold6 : JOBID 0 Submitted Feb11-01:36:56
......
$ cat Submission/submitJob_local.py
from subprocess import check_output
import re
def submitJob_local():
"""
This routine is to submit job
One needs to do a little edit based on your own case.
Step 1: to prepare the job script which is required by your supercomputer
Step 2: to submit the job with the command like qsub, bsub, llsubmit, .etc.
Step 3: to get the jobID from the screen message
:return:
"""
# Step 1
myrun_content = ''
myrun_content += '#!/bin/sh\n'
#myrun_content += '#SBATCH -o out\n'
#myrun_content += '#SBATCH -p cpu\n'
#myrun_content += '#SBATCH -J USPEX\n'
#myrun_content += '#SBATCH -t 06:00:00\n'
#myrun_content += '#SBATCH -N 1\n'
#myrun_content += '#SBATCH -n 8\n'
myrun_content += '#PBS -l nodes=1:ppn=1,walltime=2:30:00 -q batch\n'
myrun_content += '#PBS -N USPEX\n'
myrun_content += '#PBS -j oe\n'
myrun_content += '#PBS -V \n'
myrun_content += 'cd ${PBS_O_WORKDIR}\n'
# myrun_content += 'cd ${PBS_O_WORKDIR}\n' check this, must have /cephfs suffix with SBATCH in my case
myrun_content += 'mpirun -np 1 vasp > log\n'
with open('myrun', 'w') as fp:
fp.write(myrun_content)
# Step 2-3
# It will output some message on the screen like '2350873.nano.cfn.bnl.local'
#output = str(check_output('sbatch myrun', shell=True))
output = str(check_output('qsub myrun', shell=True))
jobNumber = int(re.findall(r'\d+', output)[0])
return jobNumber
if __name__ == '__main__':
with open('TEMPORARY_FILE', 'w') as fp:
fp.write('I HAVE BEEN HERE')
print('CALLBACK ')
N = submitJob_local()
print(str(N))
######### checkStatus_local.py #############
$ cat Submission/checkStatus_local.py
import os
from subprocess import check_output
import glob
_author_ = 'etikhonov'
def checkStatus_local(jobID):
"""
This function is to check if the submitted job is done or not
One needs to do a little edit based on your own case.
1 : whichCluster (0: no-job-script, 1: local submission, 2: remote submission)
Step1: the command to check job by ID.
Step2: to find the keywords from screen message to determine if the job is done
Below is just a sample:
-------------------------------------------------------------------------------
Job id Name User Time Use S Queue
------------------------- ---------------- --------------- -------- - -----
2455453.nano USPEX qzhu 02:28:42 R cfn_gen04
-------------------------------------------------------------------------------
If the job is still running, it will show as above.
If there is no key words like 'R/Q Cfn_gen04', it indicates the job is done.
:param jobID:
:return: doneOr
"""
# Step 1
output = str(check_output('qstat {}'.format(jobID), shell=True))
# Step 2
doneOr = True
if ' R ' in output or ' Q ' in output:
doneOr = False
if doneOr:
for file in glob.glob('USPEX*'):
os.remove(file) # to remove the log file
return doneOr