|
3 | 3 | # Arguments: |
4 | 4 | # -h: help, -v: verbose mode -l testing level, -m mpi-tasks, -d sw4-exe-dir |
5 | 5 |
|
6 | | -import os, sys, argparse |
| 6 | +import os, sys, argparse, subprocess |
7 | 7 |
|
8 | 8 | #----(Currently not used)-------------------------------------------- |
9 | 9 | def run_checks(checks): |
@@ -198,14 +198,28 @@ def main_test(sw4_exe_dir="optimize", testing_level=0, mpi_tasks=0, verbose=Fals |
198 | 198 | #print('local_dir = ', local_dir) |
199 | 199 |
|
200 | 200 | # pipe stdout and stderr to a temporary file |
201 | | - run_cmd = sw4_mpi_run + ' ' + sw4_input_file + ' >& ' + sw4_stdout_file |
| 201 | + run_cmd = mpirun_cmd.split() + [ |
| 202 | + sw4_exe, |
| 203 | + sw4_input_file |
| 204 | + ] |
| 205 | + |
| 206 | + sw4_stdout_file = open(case_dir + '.out', 'wt') |
| 207 | + sw4_stderr_file = open(case_dir + '.err', 'wt') |
202 | 208 |
|
203 | 209 | # run sw4 |
204 | 210 | run_dir = os.getcwd() |
205 | 211 | #print('Running sw4 from directory:', run_dir) |
206 | | - status = os.system(run_cmd) |
207 | | - if status!=0: |
208 | | - print('ERROR: Test', test_case, ': sw4 returned non-zero exit status=', status, 'aborting test') |
| 212 | + status = subprocess.run( |
| 213 | + run_cmd, |
| 214 | + stdout=sw4_stdout_file, |
| 215 | + stderr=sw4_stderr_file, |
| 216 | + ) |
| 217 | + |
| 218 | + sw4_stdout_file.close() |
| 219 | + sw4_stderr_file.close() |
| 220 | + |
| 221 | + if status.returncode!=0: |
| 222 | + print('ERROR: Test', test_case, ': sw4 returned non-zero exit status=', status.returncode, 'aborting test') |
209 | 223 | print('run_cmd=', run_cmd) |
210 | 224 | print("DID YOU USE THE CORRECT SW4 EXECUTABLE? (SPECIFY DIRECTORY WITH -d OPTION)") |
211 | 225 | return False # bail out |
|
0 commit comments