Changeset 1194 for XIOS/dev/dev_olga/src/node/context.cpp
- Timestamp:
- 07/04/17 14:28:50 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/node/context.cpp
r1193 r1194 413 413 // (1) blocking send context finalize to its server 414 414 // (2) blocking receive context finalize from its server 415 // (3) s end post finalize to its server415 // (3) some memory deallocations 416 416 if (CXios::isClient) 417 417 { … … 428 428 server->eventLoop(); 429 429 430 if (CXios::isServer) // Mode attache 431 postFinalize(); 432 else // Mode server 433 client->postFinalize(); 434 435 } 436 } 437 // Server: non-blocking send context finalize 430 if (hasServer) // Mode attache 431 { 432 closeAllFile(); 433 registryOut->hierarchicalGatherRegistry() ; 434 if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 435 } 436 437 //! Deallocate client buffers 438 client->releaseBuffers(); 439 440 //! Free internally allocated communicators 441 for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 442 MPI_Comm_free(&(*it)); 443 comms.clear(); 444 445 info(20)<<"CContext: Context <"<<getId()<<"> is finalized."<<endl; 446 } 447 } 438 448 else if (CXios::isServer) 439 449 { 440 // First context finalize message received from a model => send context finalize to its child contexts (if any) 450 // First context finalize message received from a model 451 // Send context finalize to its child contexts (if any) 441 452 if (countChildCtx_ == 0) 442 453 for (int i = 0; i < clientPrimServer.size(); ++i) … … 445 456 // (Last) context finalized message received 446 457 if (countChildCtx_ == clientPrimServer.size()) 458 { 459 // Blocking send of context finalize message to its client (e.g. primary server or model) 447 460 client->finalize(); 461 bool bufferReleased; 462 do 463 { 464 client->checkBuffers(); 465 bufferReleased = !client->havePendingRequests(); 466 } while (!bufferReleased); 467 finalized = true; 468 469 if (hasServer && !hasClient) 470 { 471 closeAllFile(); 472 registryOut->hierarchicalGatherRegistry() ; 473 if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 474 } 475 476 //! Deallocate client buffers 477 client->releaseBuffers(); 478 for (int i = 0; i < clientPrimServer.size(); ++i) 479 clientPrimServer[i]->releaseBuffers(); 480 481 //! Free internally allocated communicators 482 for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 483 MPI_Comm_free(&(*it)); 484 comms.clear(); 485 486 info(20)<<"CContext: Context <"<<getId()<<"> is finalized."<<endl; 487 } 448 488 449 489 ++countChildCtx_; 450 490 } 451 }452 453 /*!454 * \fn void CContext::postFinalize(void)455 * Close files, gather registries, and make deallocations.456 * Function is called when a context is finalized.457 */458 void CContext::postFinalize(void)459 {460 finalized = true;461 462 // Primary server: blocking send post finalize to secondary servers463 for (int i = 0; i < clientPrimServer.size(); ++i)464 clientPrimServer[i]->postFinalize();465 bool buffersReleased;466 do467 {468 buffersReleased = true;469 for (int i = 0; i < clientPrimServer.size(); ++i)470 {471 clientPrimServer[i]->checkBuffers();472 buffersReleased *= !clientPrimServer[i]->havePendingRequests();473 }474 } while (!buffersReleased);475 476 // Primary or classical server: block until all messages are sent to model477 // Client (model): block until all messages are sent to server478 if ( CServer::serverLevel==0 || CServer::serverLevel==1 || !hasServer)479 do480 {481 client->checkBuffers();482 buffersReleased = !client->havePendingRequests();483 } while (!buffersReleased);484 485 if (hasServer && !hasClient)486 {487 closeAllFile();488 registryOut->hierarchicalGatherRegistry() ;489 if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ;490 }491 492 //! Deallocate client buffers493 client->releaseBuffers();494 for (int i = 0; i < clientPrimServer.size(); ++i)495 clientPrimServer[i]->releaseBuffers();496 497 //! Free internally allocated communicators498 for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it)499 MPI_Comm_free(&(*it));500 comms.clear();501 502 info(20)<<"CContext: Context <"<<getId()<<"> is finalized."<<endl;503 504 491 } 505 492 … … 530 517 checkGridEnabledFields(); 531 518 532 setClientServerBuffer(client); 519 // Buffer for primary server for connection to client will be allocated by default (to min size) 520 if (CServer::serverLevel != 1) 521 setClientServerBuffer(client); 533 522 if (hasServer) 534 523 for (int i = 0; i < clientPrimServer.size(); ++i)
Note: See TracChangeset
for help on using the changeset viewer.