Skip to content

Commit dfe691b

Browse files
committed
Add an option for disabling preacc to tests.
1 parent 54cd32e commit dfe691b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

TestCases/TestCase.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def __init__(self,tag_in):
6868
self.su2_exec = "SU2_CFD"
6969
self.timeout = 300
7070
self.tol = 0.001
71+
self.no_preacc = False
7172

7273
# Options for file-comparison tests
7374
self.reference_file = "of_grad.dat.ref"
@@ -95,6 +96,10 @@ def run_test(self):
9596
if self.no_restart:
9697
self.disable_restart()
9798

99+
# Check for disabling preacc
100+
if self.no_preacc:
101+
self.disable_preacc()
102+
98103
# Assemble the shell command to run SU2
99104
if len(self.test_vals) != 0:
100105
logfilename = '%s.log' % os.path.splitext(self.cfg_file)[0]
@@ -232,6 +237,10 @@ def run_filediff(self):
232237
# Adjust the number of iterations in the config file
233238
self.adjust_iter()
234239

240+
# Check for disabling preacc
241+
if self.no_preacc:
242+
self.disable_preacc()
243+
235244
# if root, add flag to mpirun
236245
if os.geteuid()==0:
237246
if self.su2_exec.startswith('mpirun'):
@@ -324,6 +333,10 @@ def run_opt(self):
324333
# Adjust the number of iterations in the config file
325334
self.adjust_opt_iter()
326335

336+
# Check for disabling preacc
337+
if self.no_preacc:
338+
self.disable_preacc()
339+
327340
# Assemble the shell command to run SU2
328341
logfilename = '%s.log' % os.path.splitext(self.cfg_file)[0]
329342
command = "%s %s > %s 2>&1" % (self.su2_exec, self.cfg_file, logfilename)
@@ -760,3 +773,42 @@ def disable_restart(self):
760773
os.chdir(workdir)
761774

762775
return
776+
777+
def disable_preacc(self):
778+
779+
# Read the cfg file
780+
workdir = os.getcwd()
781+
os.chdir(self.cfg_dir)
782+
file_in = open(self.cfg_file, 'r')
783+
lines = file_in.readlines()
784+
file_in.close()
785+
786+
# Rewrite the file with a .autotest extension
787+
extension_added = False
788+
if not self.cfg_file.endswith('.autotest'):
789+
self.cfg_file = "%s.autotest"%self.cfg_file
790+
extension_added = True
791+
file_out = open(self.cfg_file,'w')
792+
lines_to_skip = 0
793+
if extension_added:
794+
file_out.write('%% This file automatically generated by the regression script\n')
795+
file_out.write('%% Preaccumulation disabled\n')
796+
else:
797+
while lines[lines_to_skip].startswith('%%'):
798+
file_out.write(lines[lines_to_skip])
799+
lines_to_skip += 1
800+
file_out.write('%% Preaccumulation disabled\n')
801+
preacc_configured = False
802+
for line in lines[lines_to_skip:]:
803+
if not line.startswith("PREACC"):
804+
file_out.write(line)
805+
else:
806+
preacc_configured = True
807+
file_out.write("PREACC= NO\n")
808+
if not preacc_configured:
809+
file_out.write("PREACC= NO\n")
810+
811+
file_out.close()
812+
os.chdir(workdir)
813+
814+
return

0 commit comments

Comments
 (0)