0

I am trying to run consecutive jobs with help from python. Below is the detailed problem.

In the parent directory, there are ~1500 subdirectories consisting of two input files in each subdirectory. So total I have to run 3000 separate calculations. This is the first time I am trying to automate the job process one after another using python. For the test run, I am just trying with two input files (1.in and 2.in) put in a rough directory. I am trying to use a script for this purpose as,

import os,glob
path='/home/prasantb/rough/'

inputs=[]
for files in glob.glob('*.in'):
    inputs.append(files)
print(inputs)

import subprocess
for i in inputs:
    subprocess.call(['psi4', i],shell=True)

To run a psi4 job, I just have to use, psi4 abc.in which automatically writes abc.out and related files in the same directory. The output I am getting is,

Traceback (most recent call last):
  File "/home/prasantb/psi4conda/bin/psi4", line 217, in <module>
    raise KeyError("The file %s does not exist." % args["input"])
KeyError: 'The file input.dat does not exist.'
Traceback (most recent call last):
  File "/home/prasantb/psi4conda/bin/psi4", line 217, in <module>
    raise KeyError("The file %s does not exist." % args["input"])
KeyError: 'The file input.dat does not exist.'

Can I have anyones' kind help? Thank you in advance

  • 1
    I don't see a reason why psi4 can't find the file. That said though, you should get rid of that `shell=True` and you should probably use the `path` variable for something. – Aran-Fey May 14 '22 at 16:53
  • I removed `shell=True`, and it is running. But without running the 1.in, it is running 2.in. Could you please tell me more details about the meaning of "you should probably use the path variable for something." – Prasanta Bandyopadhyay May 15 '22 at 04:43
  • 1
    You set `path='/home/prasantb/rough/'`, but then you never read that variable. – Aran-Fey May 15 '22 at 06:38
  • well, actually I thought that setting the path might be of importance later. This is why I set it earlier. – Prasanta Bandyopadhyay May 15 '22 at 07:03

0 Answers0