1 | #include "xmlioserver.hpp" |
---|
2 | #include "attribute_template.hpp" |
---|
3 | #include "buffer_out.hpp" |
---|
4 | #include "buffer_in.hpp" |
---|
5 | #include "type.hpp" |
---|
6 | #include "cxios.hpp" |
---|
7 | #include "client.hpp" |
---|
8 | #include "event_client.hpp" |
---|
9 | #include "context.hpp" |
---|
10 | #include "context_client.hpp" |
---|
11 | #include "context_server.hpp" |
---|
12 | #include "object_template.hpp" |
---|
13 | #include "array_new.hpp" |
---|
14 | #include "mpi.hpp" |
---|
15 | |
---|
16 | |
---|
17 | using namespace std ; |
---|
18 | |
---|
19 | int main (int argc, char ** argv, char ** UNUSED (env)) |
---|
20 | { |
---|
21 | |
---|
22 | int a=3 ; |
---|
23 | int b=2 ; |
---|
24 | int c=1 ; |
---|
25 | int buff[100] ; |
---|
26 | string str("titi") ; |
---|
27 | CBufferOut bufferOut(&buff,sizeof(buff)) ; |
---|
28 | CBufferIn bufferIn(&buff,sizeof(buff)) ; |
---|
29 | CMessage msg ; |
---|
30 | |
---|
31 | CAttributeArray<double,1> tabIn("in") ; |
---|
32 | CAttributeArray<double,1> tabOut("out") ; |
---|
33 | |
---|
34 | CArray<double,1> tab(5) |
---|
35 | tab=0,1,2,3,4 ; |
---|
36 | tabIn=tab ; |
---|
37 | tab= 4,3,2,1,0 |
---|
38 | tabOut=tab ; |
---|
39 | // tabOut=1 ; |
---|
40 | tabIn.toBuffer(bufferOut) ; |
---|
41 | tabOut.fromBuffer(bufferIn) ; |
---|
42 | |
---|
43 | cout<<"attribut<Arraydouble,5>>="<<tabOut.toString()<<endl ; |
---|
44 | |
---|
45 | MPI_Init(&argc,&argv) ; |
---|
46 | int rank ; |
---|
47 | int size ; |
---|
48 | char buffer[128] ; |
---|
49 | |
---|
50 | MPI_Comm_rank(MPI_COMM_WORLD,&rank) ; |
---|
51 | if (rank>=0 && rank<=1) |
---|
52 | { |
---|
53 | CXios::initClientSide("test1") ; |
---|
54 | CClient::registerContext("toto",CClient::intraComm) ; |
---|
55 | // CClient::registerContext("tata",CClient::intraComm) ; |
---|
56 | CClient::registerContext("tutu",CClient::intraComm) ; |
---|
57 | CContext::setCurrent("tutu") ; |
---|
58 | CContext* tutu=CContext::get("tutu").get() ; |
---|
59 | |
---|
60 | |
---|
61 | CContext::setCurrent("toto") ; |
---|
62 | CContext* toto=(CContext::get("toto").get() ; |
---|
63 | toto->calendar_type.setValue("NoLeap") ; |
---|
64 | toto->sendAttributToServer("calendar_type" ); |
---|
65 | |
---|
66 | |
---|
67 | for(int i=0;i<0;i++) |
---|
68 | { |
---|
69 | CMessage msg ; |
---|
70 | int count ; |
---|
71 | int msgSize; |
---|
72 | CEventClient event(1,1) ; |
---|
73 | count=rand()%32 ; |
---|
74 | msg<<string("toto")<<string(buffer,count)<<rank<<msgSize; |
---|
75 | msgSize=msg.size() ; |
---|
76 | event.push(0,2,msg) ; |
---|
77 | event.push(1,2,msg) ; |
---|
78 | toto->client->sendEvent(event) ; |
---|
79 | cout<<"Send Event from toto : size "<<msgSize<<endl ; |
---|
80 | } |
---|
81 | toto->client->finalize() ; |
---|
82 | tutu->client->finalize() ; |
---|
83 | CXios::clientFinalize() ; |
---|
84 | } |
---|
85 | else if (rank>=2 && rank<=3) CXios::initServerSide(); |
---|
86 | else if (rank>=4 && rank<=6) |
---|
87 | { |
---|
88 | CXios::initClientSide("test2") ; |
---|
89 | CClient::registerContext("tito",CClient::intraComm) ; |
---|
90 | CContext::setCurrent("tito") ; |
---|
91 | CContext* tito=CContext::get("tito").get() ; |
---|
92 | |
---|
93 | CClient::registerContext("tete",CClient::intraComm) ; |
---|
94 | CContext::setCurrent("tete") ; |
---|
95 | CContext* tete=CContext::get("tete").get() ; |
---|
96 | |
---|
97 | tito->client->finalize() ; |
---|
98 | tete->client->finalize() ; |
---|
99 | CXios::clientFinalize() ; |
---|
100 | } |
---|
101 | else if (rank>=7 && rank<=7) |
---|
102 | { |
---|
103 | CXios::initClientSide("test3") ; |
---|
104 | CClient::registerContext("turlututu",CClient::intraComm) ; |
---|
105 | CContext::setCurrent("turlututu") ; |
---|
106 | CContext* turlututu=CContext::get("turlututu").get() ; |
---|
107 | turlututu->client->finalize() ; |
---|
108 | CXios::clientFinalize() ; |
---|
109 | } |
---|
110 | |
---|
111 | |
---|
112 | |
---|
113 | MPI_Barrier(MPI_COMM_WORLD); |
---|
114 | MPI_Finalize() ; |
---|
115 | |
---|
116 | return EXIT_SUCCESS ; |
---|
117 | |
---|
118 | } |
---|