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