@@ -0,0 +1,93 | |||
|
1 | from mpi4py import MPI | |
|
2 | import datetime | |
|
3 | import os, sys | |
|
4 | #import timeit | |
|
5 | ||
|
6 | path = os.path.split(os.getcwd())[0] | |
|
7 | sys.path.append(path) | |
|
8 | ||
|
9 | from controller import * | |
|
10 | ||
|
11 | def conversion(x1,x2): | |
|
12 | a=[x1,x2] | |
|
13 | for x in a: | |
|
14 | m,s = divmod(x,60) | |
|
15 | h,m = divmod(m,60) | |
|
16 | if x==x1: | |
|
17 | startime= str("%02d:%02d:%02d" % (h, m, s)) | |
|
18 | if x==x2: | |
|
19 | endtime =str("%02d:%02d:%02d" % (h, m, s)) | |
|
20 | return startime,endtime | |
|
21 | ||
|
22 | ||
|
23 | ||
|
24 | def loop(startime,endtime,rank): | |
|
25 | desc = "HF_EXAMPLE"+str(rank) | |
|
26 | path= "/home/alex/Documents/hysell_data/pdata/sp1_f0" | |
|
27 | figpath= "/home/alex/Pictures/pdata_plot"+str(rank) | |
|
28 | ||
|
29 | filename = "hf_test"+str(rank)+".xml" | |
|
30 | ||
|
31 | controllerObj = Project() | |
|
32 | ||
|
33 | controllerObj.setup(id = '191', name='test01'+str(rank), description=desc) | |
|
34 | ||
|
35 | readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader', | |
|
36 | path=path, | |
|
37 | startDate='2015/09/26', | |
|
38 | endDate='2015/09/26', | |
|
39 | startTime=startime, | |
|
40 | endTime=endtime, | |
|
41 | online=0, | |
|
42 | #set=1426485881, | |
|
43 | delay=10, | |
|
44 | walk=1 | |
|
45 | #timezone=-5*3600 | |
|
46 | ) | |
|
47 | ||
|
48 | #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
|
49 | ||
|
50 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=readUnitConfObj.getId()) | |
|
51 | ||
|
52 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
|
53 | opObj11.addParameter(name='id', value='1000', format='int') | |
|
54 | opObj11.addParameter(name='wintitle', value='HF_Jicamarca_Spc', format='str') | |
|
55 | #opObj11.addParameter(name='channelList', value='0', format='intlist') | |
|
56 | opObj11.addParameter(name='zmin', value='-120', format='float') | |
|
57 | opObj11.addParameter(name='zmax', value='-70', format='float') | |
|
58 | opObj11.addParameter(name='save', value='1', format='int') | |
|
59 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |
|
60 | ||
|
61 | ||
|
62 | print "Escribiendo el archivo XML" | |
|
63 | controllerObj.writeXml(filename) | |
|
64 | print "Leyendo el archivo XML" | |
|
65 | controllerObj.readXml(filename) | |
|
66 | ||
|
67 | controllerObj.createObjects() | |
|
68 | controllerObj.connectObjects() | |
|
69 | ||
|
70 | #timeit.timeit('controllerObj.run()', number=2) | |
|
71 | ||
|
72 | controllerObj.run() | |
|
73 | ||
|
74 | ||
|
75 | ||
|
76 | def parallel(): | |
|
77 | ||
|
78 | comm = MPI.COMM_WORLD | |
|
79 | rank = comm.Get_rank() | |
|
80 | size = comm.Get_size() | |
|
81 | totalStartTime = time.time() | |
|
82 | print "Hello world from process %d/%d"%(rank,size) | |
|
83 | # First just for one day :D! | |
|
84 | num_hours = 4/size | |
|
85 | time1,time2 = rank*num_hours*3600,(rank+1)*num_hours*3600-60 | |
|
86 | #print time1,time2 | |
|
87 | startime,endtime =conversion(time1,time2) | |
|
88 | print startime,endtime | |
|
89 | loop(startime,endtime,rank) | |
|
90 | print "Total time %f seconds" %(time.time() -totalStartTime) | |
|
91 | ||
|
92 | if __name__=='__main__': | |
|
93 | parallel() No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now