Commit 21db2b12 authored by Taddeüs Kroes's avatar Taddeüs Kroes

ModSim ass4 taddeus: some final changes to MPI python scripts.

parent 7f895397
...@@ -7,4 +7,4 @@ seq: seq.o ...@@ -7,4 +7,4 @@ seq: seq.o
par: par.o par: par.o
clean: clean:
rm -vf *.o seq par rm -vf *.o seq par out*.txt
#!/usr/bin/env python
from sys import argv, exit from sys import argv, exit
def combine(numfiles): if len(argv) < 2:
files = range(int(numfiles))
lines = [open('out%d.txt' % i).readlines() for i in files]
return [' '.join([lines[j][i][:-1] for j in files]) for i in
range(len(lines[0]))]
if __name__ == '__main__':
if len(argv) < 2:
print 'Usage: python %s TASKS' % argv[0] print 'Usage: python %s TASKS' % argv[0]
exit() exit()
print '\n'.join(combine(argv[1])) files = range(int(argv[1]))
lines = [open('out%d.txt' % i).readlines() for i in files]
lines = [' '.join([lines[j][i][:-1] for j in files]) for i in
range(len(lines[0]))]
print '\n'.join(lines)
...@@ -2,20 +2,16 @@ ...@@ -2,20 +2,16 @@
from sys import stdin, argv, exit from sys import stdin, argv, exit
from pylab import figure, plot, axis, draw, ion, clf from pylab import figure, plot, axis, draw, ion, clf
from time import sleep from time import sleep
from combine import combine
if len(argv) < 3: if len(argv) < 2:
print 'Usage: python %s TASKS TIME_STEP [ DELAY ]' % argv[0] print 'Usage: python %s TIME_STEP [ DELAY ]' % argv[0]
exit() exit()
# tasks = 0 means sequential, above means parallel and having to combine the stride = int(argv[1])
# different output files delay = .1 if len(argv) < 3 else float(argv[2])
lines = combine(int(argv[1])) if int(argv[1]) else stdin.readlines()
stride = int(argv[2])
delay = .1 if len(argv) < 4 else float(argv[3])
# Collect data # Collect data
lines = stdin.readlines()
y = [] y = []
x = map(float, lines[0].split(' ')) x = map(float, lines[0].split(' '))
for line in lines[1::stride]: for line in lines[1::stride]:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment