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