Changeset 1587 for XIOS/trunk/src/server.cpp
- Timestamp:
- 10/15/18 16:42:33 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/server.cpp
r1542 r1587 14 14 #include "timer.hpp" 15 15 #include "event_scheduler.hpp" 16 #include "string_tools.hpp" 16 17 17 18 namespace xios … … 343 344 344 345 string codesId=CXios::getin<string>("oasis_codes_id") ; 345 vector<string> splitted;346 boost::split( splitted, codesId, boost::is_any_of(","), boost::token_compress_on ) ;346 vector<string> oasisCodeId=splitRegex(codesId,"\\s*,\\s*") ; 347 347 348 vector<string>::iterator it ; 348 349 … … 352 353 353 354 // (2) Create interComms with models 354 for(it= splitted.begin();it!=splitted.end();it++)355 for(it=oasisCodeId.begin();it!=oasisCodeId.end();it++) 355 356 { 356 357 oasis_get_intercomm(newComm,*it) ; … … 386 387 } 387 388 if (CXios::usingServer2) delete [] srvGlobalRanks ; 388 oasis_enddef() ; 389 390 bool oasisEnddef=CXios::getin<bool>("call_oasis_enddef",true) ; 391 if (!oasisEnddef) oasis_enddef() ; 389 392 } 390 393 … … 442 445 listenContext(); 443 446 listenRootContext(); 447 listenOasisEnddef() ; 448 listenRootOasisEnddef() ; 444 449 if (!finished) listenFinalize() ; 445 450 } … … 447 452 { 448 453 listenRootContext(); 454 listenRootOasisEnddef() ; 449 455 if (!finished) listenRootFinalize() ; 450 456 } … … 516 522 } 517 523 } 524 525 526 /*! 527 * Root process is listening for an order sent by client to call "oasis_enddef". 528 * The root client of a compound send the order (tag 5). It is probed and received. 529 * When the order has been received from each coumpound, the server root process ping the order to the root processes of the secondary levels of servers (if any). 530 * After, it also inform (asynchronous call) other processes of the communicator that the oasis_enddef call must be done 531 */ 532 533 void CServer::listenOasisEnddef(void) 534 { 535 int flag ; 536 MPI_Status status ; 537 list<MPI_Comm>::iterator it; 538 int msg ; 539 static int nbCompound=0 ; 540 int size ; 541 static bool sent=false ; 542 static MPI_Request* allRequests ; 543 static MPI_Status* allStatus ; 544 545 546 if (sent) 547 { 548 MPI_Comm_size(intraComm,&size) ; 549 MPI_Testall(size,allRequests, &flag, allStatus) ; 550 if (flag==true) 551 { 552 delete [] allRequests ; 553 delete [] allStatus ; 554 sent=false ; 555 } 556 } 557 558 559 for(it=interCommLeft.begin();it!=interCommLeft.end();it++) 560 { 561 MPI_Status status ; 562 traceOff() ; 563 MPI_Iprobe(0,5,*it,&flag,&status) ; // tags oasis_endded = 5 564 traceOn() ; 565 if (flag==true) 566 { 567 MPI_Recv(&msg,1,MPI_INT,0,5,*it,&status) ; // tags oasis_endded = 5 568 nbCompound++ ; 569 if (nbCompound==interCommLeft.size()) 570 { 571 for (std::list<MPI_Comm>::iterator it = interCommRight.begin(); it != interCommRight.end(); it++) 572 { 573 MPI_Send(&msg,1,MPI_INT,0,5,*it) ; // tags oasis_endded = 5 574 } 575 MPI_Comm_size(intraComm,&size) ; 576 allRequests= new MPI_Request[size] ; 577 allStatus= new MPI_Status[size] ; 578 for(int i=0;i<size;i++) MPI_Isend(&msg,1,MPI_INT,i,5,intraComm,&allRequests[i]) ; // tags oasis_endded = 5 579 sent=true ; 580 } 581 } 582 } 583 } 584 585 /*! 586 * Processes probes message from root process if oasis_enddef call must be done. 587 * When the order is received it is scheduled to be treated in a synchronized way by all server processes of the communicator 588 */ 589 void CServer::listenRootOasisEnddef(void) 590 { 591 int flag ; 592 MPI_Status status ; 593 const int root=0 ; 594 int msg ; 595 static bool eventSent=false ; 596 597 if (eventSent) 598 { 599 boost::hash<string> hashString; 600 size_t hashId = hashString("oasis_enddef"); 601 if (eventScheduler->queryEvent(0,hashId)) 602 { 603 oasis_enddef() ; 604 eventSent=false ; 605 } 606 } 607 608 traceOff() ; 609 MPI_Iprobe(root,5,intraComm, &flag, &status) ; 610 traceOn() ; 611 if (flag==true) 612 { 613 MPI_Recv(&msg,1,MPI_INT,root,5,intraComm,&status) ; // tags oasis_endded = 5 614 boost::hash<string> hashString; 615 size_t hashId = hashString("oasis_enddef"); 616 eventScheduler->registerEvent(0,hashId); 617 eventSent=true ; 618 } 619 } 620 621 622 623 518 624 519 625 void CServer::listenContext(void)
Note: See TracChangeset
for help on using the changeset viewer.