Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2Execution of turbomole binaries and scripts: 

3define, dscf, grad, ridft, rdgrad, aoforce, jobex, NumForce 

4""" 

5import os 

6from subprocess import Popen, PIPE 

7 

8 

9def get_output_filename(basename): 

10 """return the output file name from the basename of the executable""" 

11 return 'ASE.TM.' + basename + '.out' 

12 

13 

14def check_bad_output(stderr): 

15 """check status written in stderr by turbomole executables""" 

16 if 'abnormally' in stderr or 'ended normally' not in stderr: 

17 raise OSError(f'Turbomole error: {stderr}') 

18 

19 

20def execute(args, input_str=''): 

21 """executes a turbomole executable and process the outputs""" 

22 

23 stdout_file = get_output_filename(os.path.basename(args[0])) 

24 with open(stdout_file, 'w') as stdout: 

25 proc = Popen(args, stdin=PIPE, stderr=PIPE, stdout=stdout, 

26 encoding='ASCII') 

27 stdout_txt, stderr_txt = proc.communicate(input=input_str) 

28 check_bad_output(stderr_txt) 

29 return stdout_file