Commit 217b487d authored by Peter-Bernd Otte's avatar Peter-Bernd Otte

included all basic functionality

parent e41483e8
......@@ -31,11 +31,15 @@ if rank == 0:
args = parser.parse_args()
print("Delay: "+str(args.delay)+" ms")
clients = {}
worklist = ['file1.txt', 'file2.txt']
worklist = ['file1.txt', 'file2.txt', 'file3.txt']
worklist = ['file1.txt', 'file2.txt', 'file3.txt', 'file4.txt']
if rank ==0:
print ("Number of files to process: "+str(len(worklist)))
now =
outputdir = os.getcwd() + "output_{:04d}{:02d}{:02d}{:02d}{:02d}{:02d}".format(now.year,now.month,,now.hour,now.minute,now.second)
outputdir = os.getcwd() + "/output_{:04d}{:02d}{:02d}{:02d}{:02d}{:02d}".format(now.year,now.month,,now.hour,now.minute,now.second)
if os.path.isdir("./"+outputdir):
print("Output directory already exists. Exiting.")
......@@ -52,21 +56,34 @@ if rank == 0:
print('Total number of workers ',size-1)
for i in range(1,size):
clients[i] = comm.recv(source=i)
print("All clients active. Printing clients details:")
for i in range(1,size):
comm.send(args.execname, dest=i)
for i in range(len(worklist)):
print("ToDo: "+worklist[i])
print("Wait for process...")
rec = comm.recv(tag=2) # get the rank of free worker
comm.send({"workstr":args.execname,"jobid":i}, dest=rec)
for i in range(1,size): # End all workers
comm.send({"workstr":"","jobid":i}, i)
print ("rank "+str(rank))
nodeinfo = {'machine':platform.machine(), 'hostname': platform.node(), 'Ncores': multiprocessing.cpu_count(), 'os': platform.system(), 'pythonVersion': platform.python_version() }
comm.send(nodeinfo, dest=0)
workstr = comm.recv(source=0)
print("Rank "+str(rank)+" recieved: "+workstr)
bashCommand = workstr + " > output"+str(rank)+".txt"
while True:
comm.send(rank, dest=0, tag=2) # send a data package asking for more work
dic = comm.recv(source=0)
workstr = dic["workstr"]
if len(workstr)==0: #check if no more to do from master
jobid = dic["jobid"]
print("Rank "+str(rank)+" recieved (internal job nr="+str(jobid)+"): "+workstr)
bashCommand = workstr + " > "+outputdir+"/"+str(jobid)+"/std_out.txt 2> "+outputdir+"/"+str(jobid)+"/err_out.txt"
completed =, shell=True)
print('Rank '+str(rank)+' returncode: ',completed.returncode)
......@@ -74,10 +91,4 @@ else:
print('Rank '+str(rank)+' ERROR:', err)
if rank == 0:
# print(clients)
# run commands
#cd into subdirector
# catch exceptions
\ No newline at end of file
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