def scanPOWER(initial, limit, restart, loadpath, key, subkey, increment): global i, loadfrom inputfiles = os.listdir(loadfrom) for runfiles in inputfiles: filepath = os.path.join(loadfrom, runfiles) if os.path.isfile(filepath): shutil.copy(filepath, directory) # fixes headings back into the control files so the BOUT can understand them returnHeadings(directory + '/BOUT.inp') #npro = raw_input('N.o of processors to use: ') cmd = exe + ' -d ' + directory + '/' print("Command = '%s'" % cmd) th, temp = mkstemp() with open(temp,'w') as g: with open(loadpath, 'r') as f: for line in f: if line.startswith(key): g.write(line) for line in f: if line.startswith(subkey): string = line.split() a = string[string.index('=') + 1] if i < 2: final = initial # this determines whether raw or percentage increase elif incrementType == '+': final = initial + increment initial = final else: final = initial * increment initial = final b = str(final) new = line.replace(a, b) initial = final g.write(new) break else: g.write(line) else: g.write(line) g.close() remove(loadpath) move(temp, loadpath) # runs the simulation, adds restart command if necessary if restart == 'y': launch(cmd + ' restart', nproc = proc, nice = nicelvl) else: launch(cmd, nproc = proc, nice = nicelvl, pipe=False) return initial
# Split exe into path and file path, exe = os.path.split(exe) print ("Path = '%s', exe = '%s'" % (path, exe)) # Change directory old_dir = os.getcwd() os.chdir(path) cmd = "./" + exe + " -d " + os.path.join(old_dir, directory) + "/" print ("Current dir = '%s', running '%s'" % (os.getcwd(), cmd)) # print("Command = '%s'" % cmd) if restart == "y": launch(cmd + " restart", nproc=proc, nice=nicelvl) else: launch(cmd, nproc=proc, nice=nicelvl, pipe=False) # Change back to old directory os.chdir(old_dir) # Save files from tmp into the loaded archive file and allows for addition of notes inputfiles = os.listdir(directory) for runfiles in inputfiles: filepath = os.path.join(directory, runfiles) if os.path.isfile(filepath): shutil.copy(filepath, runid) shutil.rmtree("tmp")
# Split exe into path and file path, exe = os.path.split(exe) print("Path = '%s', exe = '%s'" % (path, exe)) # Change directory old_dir = os.getcwd() os.chdir(path) cmd = "./" + exe + ' -d ' + os.path.join(old_dir, directory) + '/' print("Current dir = '%s', running '%s'" % (os.getcwd(), cmd)) #print("Command = '%s'" % cmd) if restart == 'y': launch(cmd + ' restart', nproc=proc, nice=nicelvl) else: launch(cmd, nproc=proc, nice=nicelvl, pipe=False) # Change back to old directory os.chdir(old_dir) # Save files from tmp into the loaded archive file and allows for addition of notes inputfiles = os.listdir(directory) for runfiles in inputfiles: filepath = os.path.join(directory, runfiles) if os.path.isfile(filepath): shutil.copy(filepath, runid) shutil.rmtree('tmp')