Changeset 640
- Timestamp:
- 07/17/15 13:58:12 (9 years ago)
- Location:
- XIOS/trunk/src/node
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/context.cpp
r639 r640 46 46 47 47 //---------------------------------------------------------------- 48 48 49 /*! 49 50 \brief Get context group (context root) … … 56 57 } 57 58 58 59 59 //---------------------------------------------------------------- 60 60 61 /*! 61 62 \brief Get calendar of a context … … 68 69 69 70 //---------------------------------------------------------------- 71 70 72 /*! 71 73 \brief Set a context with a calendar … … 386 388 if (hasClient) 387 389 { 390 //this->buildAllExpressionOfEnabledFields(); 391 //buildAllExpressionOfFieldsWithReadAccess(); 392 this->buildFilterGraphOfEnabledFields(); 393 buildFilterGraphOfFieldsWithReadAccess(); 388 394 this->solveAllRefOfEnabledFields(true); 389 this->buildAllExpressionOfEnabledFields();390 buildAllExpressionOfFieldsWithReadAccess();391 395 } 392 396 … … 426 430 { 427 431 this->enabledFiles[i]->buildAllExpressionOfEnabledFields(); 432 } 433 } 434 435 void CContext::buildFilterGraphOfEnabledFields() 436 { 437 int size = this->enabledFiles.size(); 438 for (int i = 0; i < size; ++i) 439 { 440 this->enabledFiles[i]->buildFilterGraphOfEnabledFields(garbageCollector); 428 441 } 429 442 } … … 474 487 for (size_t i = 0; i < fieldsWithReadAccess.size(); ++i) 475 488 fieldsWithReadAccess[i]->buildAllExpressionEnabledField(); 489 } 490 491 void CContext::buildFilterGraphOfFieldsWithReadAccess() 492 { 493 for (size_t i = 0; i < fieldsWithReadAccess.size(); ++i) 494 fieldsWithReadAccess[i]->buildFilterGraph(garbageCollector, true); 476 495 } 477 496 -
XIOS/trunk/src/node/context.hpp
r639 r640 112 112 void solveAllRefOfEnabledFields(bool sendToServer); 113 113 void buildAllExpressionOfEnabledFields(); 114 void buildFilterGraphOfEnabledFields(); 114 115 void startPrefetchingOfEnabledReadModeFiles(); 115 116 void checkPrefetchingOfEnabledReadModeFiles(); … … 117 118 void solveAllRefOfFieldsWithReadAccess(); 118 119 void buildAllExpressionOfFieldsWithReadAccess(); 120 void buildFilterGraphOfFieldsWithReadAccess(); 119 121 void postProcessing(); 120 122 -
XIOS/trunk/src/node/field.cpp
r638 r640 14 14 #include "context_server.hpp" 15 15 #include <set> 16 #include "garbage_collector.hpp" 17 #include "source_filter.hpp" 18 #include "store_filter.hpp" 19 #include "file_writer_filter.hpp" 16 20 17 21 namespace xios{ … … 31 35 , isReadDataRequestPending(false) 32 36 , filterSources_() 33 37 { setVirtualVariableGroup(); } 34 38 35 39 CField::CField(const StdString& id) … … 456 460 CContext* context = CContext::getCurrent(); 457 461 StdSize record; 462 std::map<int, CArray<double,1> > data; 463 458 464 for (int i = 0; i < ranks.size(); i++) 465 { 466 int rank = ranks[i]; 467 *buffers[i] >> record; 468 isEOF = (record == size_t(-1)); 469 470 if (!isEOF) 471 *buffers[i] >> data[rank]; 472 else 473 break; 474 } 475 476 if (isEOF) 477 serverSourceFilter->signalEndOfStream(lastDataRequestedFromServer); 478 else 479 serverSourceFilter->streamDataFromServer(lastDataRequestedFromServer, data); 480 481 /*for (int i = 0; i < ranks.size(); i++) 459 482 { 460 483 int rank = ranks[i]; … … 487 510 if (hasFieldOut) updateDataFromExpression(instantData); 488 511 } 489 } 512 }*/ 490 513 491 514 isReadDataRequestPending = false; … … 633 656 using namespace func; 634 657 635 if (!hasOutputFile && !hasFieldOut) return; 658 CContext* context = CContext::getCurrent(); 659 660 if (!context->hasServer || !hasOutputFile) return; 636 661 637 662 StdString id; … … 639 664 else if (!name.isEmpty()) id = name; 640 665 else if (hasDirectFieldReference()) id = baseRefObject->getId(); 641 642 CContext* context = CContext::getCurrent();643 666 644 667 if (freq_op.isEmpty()) freq_op.setValue(TimeStep); … … 722 745 << "The operation is not defined !"); 723 746 // } 747 } 748 749 //---------------------------------------------------------------- 750 751 /*! 752 * Constructs the graph filter for the field, enabling or not the data output. 753 * This method should not be called more than once with enableOutput equal to true. 754 * 755 * \param gc the garbage collector to use when building the filter graph 756 * \param enableOutput must be true when the field data is to be 757 * read by the client or/and written to a file 758 */ 759 void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput) 760 { 761 // Start by building a filter which can provide the field's instant data 762 if (!instantDataFilter) 763 { 764 // Check if the data is to be read from a file 765 if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) 766 instantDataFilter = serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 767 else // The data might be passed from the model 768 instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 769 } 770 771 // If the field data is to be read by the client or/and written to a file 772 if (enableOutput && !storeFilter && !fileWriterFilter) 773 { 774 if (!read_access.isEmpty() && read_access.getValue()) 775 { 776 storeFilter = boost::shared_ptr<CStoreFilter>(new CStoreFilter(gc, CContext::getCurrent(), grid)); 777 instantDataFilter->connectOutput(storeFilter, 0); 778 } 779 780 if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write)) 781 { 782 fileWriterFilter = boost::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this)); 783 instantDataFilter->connectOutput(fileWriterFilter, 0); 784 } 785 } 724 786 } 725 787 -
XIOS/trunk/src/node/field.hpp
r638 r640 28 28 class CFile; 29 29 class CGrid; 30 class CContext 30 class CContext; 31 31 class CGenericFilter; 32 33 class CGarbageCollector; 34 class COutputPin; 35 class CSourceFilter; 36 class CStoreFilter; 37 class CFileWriterFilter; 32 38 33 39 ///-------------------------------------------------------------- … … 124 130 void solveTransformedGrid(); 125 131 CGrid* getGridRefOfBaseReference(); 132 133 void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); 126 134 127 135 // virtual void fromBinary(StdIStream & is); … … 233 241 DECLARE_REF_FUNC(Field,field) 234 242 243 private: 244 //! The output pin of the filter providing the instant data for the field 245 boost::shared_ptr<COutputPin> instantDataFilter; 246 //! The source filter for data provided by the client 247 boost::shared_ptr<CSourceFilter> clientSourceFilter; 248 //! The source filter for data provided by the server 249 boost::shared_ptr<CSourceFilter> serverSourceFilter; 250 //! The terminal filter which stores the instant data 251 boost::shared_ptr<CStoreFilter> storeFilter; 252 //! The terminal filter which writes the data to file 253 boost::shared_ptr<CFileWriterFilter> fileWriterFilter; 235 254 }; // class CField 236 255 -
XIOS/trunk/src/node/field_impl.hpp
r624 r640 9 9 #include "timer.hpp" 10 10 #include "array_new.hpp" 11 #include "source_filter.hpp" 12 #include "store_filter.hpp" 11 13 12 14 … … 16 18 void CField::setData(const CArray<double, N>& _data) 17 19 { 18 if (hasInstantData) 20 if (clientSourceFilter) 21 clientSourceFilter->streamData(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data); 22 else if (!field_ref.isEmpty() || !content.empty()) 23 ERROR("void CField::setData(const CArray<double, N>& _data)", 24 << "Impossible to receive data from the model for a field [ id = " << getId() << " ] with a reference or an arithmetic operation."); 25 26 /*if (hasInstantData) 19 27 { 20 28 grid->inputField(_data, instantData); … … 52 60 } 53 61 if (hasOutputFile || hasFieldOut) updateData(_data); 54 } 62 }*/ 55 63 } 56 64 … … 279 287 void CField::getData(CArray<double, N>& _data) const 280 288 { 281 if (!read_access.isEmpty() && read_access.getValue() && hasInstantData) 282 { 283 CContext* context = CContext::getCurrent(); 289 if (storeFilter) 290 { 291 CDataPacket::StatusCode status = storeFilter->getData(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data); 292 293 if (status == CDataPacket::END_OF_STREAM) 294 ERROR("void CField::getData(CArray<double, N>& _data) const", 295 << "Impossible to access field data, all the records of the field [ id = " << getId() << " ] have been already read."); 296 297 /*CContext* context = CContext::getCurrent(); 284 298 const CDate& currentDate = context->getCalendar()->getCurrentDate(); 285 299 … … 291 305 << "Impossible to access field data, all the records of the field [ id = " << getId() << " ] have been already read."); 292 306 293 grid->outputField(instantData, _data); 307 grid->outputField(instantData, _data);*/ 294 308 } 295 309 else -
XIOS/trunk/src/node/file.cpp
r609 r640 622 622 623 623 /*! 624 * Constructs the filter graph for each active field. 625 * 626 * \param gc the garbage collector to use when building the filter graph 627 */ 628 void CFile::buildFilterGraphOfEnabledFields(CGarbageCollector& gc) 629 { 630 int size = this->enabledFields.size(); 631 for (int i = 0; i < size; ++i) 632 { 633 this->enabledFields[i]->buildFilterGraph(gc, true); 634 } 635 } 636 637 /*! 624 638 Prefetching the data for enabled fields read from file. 625 639 */ -
XIOS/trunk/src/node/file.hpp
r609 r640 22 22 class CFileAttributes; 23 23 class CFile; 24 25 class CGarbageCollector; 24 26 25 27 ///-------------------------------------------------------------- … … 108 110 void solveAllRefOfEnabledFields(bool sendToServer); 109 111 void buildAllExpressionOfEnabledFields(); 112 void buildFilterGraphOfEnabledFields(CGarbageCollector& gc); 110 113 void prefetchEnabledReadModeFields(); 111 114 void prefetchEnabledReadModeFieldsIfNeeded();
Note: See TracChangeset
for help on using the changeset viewer.