Changeset 1962 for XIOS/dev/dev_ym
- Timestamp:
- 10/12/20 17:15:59 (4 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/file_reader_source_filter.cpp
r1934 r1962 57 57 file_->checkReadFile(); 58 58 nStepMax_ = file_->getDataInput()->getFieldNbRecords(field_); 59 nStep_ = 0;59 nStep_ = file_->record_offset.isEmpty() ? 0 : file_->record_offset; ; 60 60 } 61 61 MPI_Allreduce(MPI_IN_PLACE, &nStepMax_, 1, MPI_INT, MPI_MAX, context->getIntraComm()); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/file_writer_store_filter.cpp
r1961 r1962 23 23 else needToWrite_=false; 24 24 lastFileSplit_ = file_->getLastSplit() ; 25 nstep_ = 0 ;25 nstep_ = file_->record_offset.isEmpty() ? 0 : file_->record_offset; // record_offset < 0 ==> no output (debugging) 26 26 if (!field->scale_factor.isEmpty()) { scaleFactor_ = field->scale_factor ; hasScaleFactor_ = true ; } 27 27 if (!field->add_offset.isEmpty()) { addOffset_ = field->add_offset ; hasAddOffset_ = true ; } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/io/nc4_data_output.cpp
r1961 r1962 2101 2101 factorUnit=context->getCalendar()->getDayLengthInSeconds() ; 2102 2102 else factorUnit=1 ; 2103 nstep = getRecordFromTime( field->last_Write_srv,factorUnit) + 1;2103 nstep = getRecordFromTime(currentWrite,factorUnit) + 1; 2104 2104 } 2105 2105 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp
r1961 r1962 33 33 : CObjectTemplate<CField>(), CFieldAttributes() 34 34 , written(false) 35 , nstep(0), nstepMax(0)36 35 , hasOutputFile(false) 37 36 , domAxisScalarIds_(vector<StdString>(3,"")) … … 41 40 , hasTimeInstant(false) 42 41 , hasTimeCentered(false) 43 , wasDataRequestedFromServer(false)44 , wasDataAlreadyReceivedFromServer(false)45 42 , mustAutoTrigger(false) 46 , isEOF(false), nstepMaxRead(false)47 43 { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 48 44 … … 50 46 : CObjectTemplate<CField>(id), CFieldAttributes() 51 47 , written(false) 52 , nstep(0), nstepMax(0)53 48 , hasOutputFile(false) 54 49 , domAxisScalarIds_(vector<StdString>(3,"")) … … 58 53 , hasTimeInstant(false) 59 54 , hasTimeCentered(false) 60 , wasDataRequestedFromServer(false)61 , wasDataAlreadyReceivedFromServer(false)62 55 , mustAutoTrigger(false) 63 , isEOF(false), nstepMaxRead(false) 64 { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 56 { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 65 57 66 58 CField::~CField(void) … … 163 155 CATCH 164 156 165 /*166 void CField::writeUpdateData(const CArray<double,1>& data)167 TRY168 {169 const CDate writeDate = last_Write_srv + freq_write_srv;170 last_Write_srv = writeDate;171 writeField(data);172 lastlast_Write_srv = last_Write_srv;173 }174 CATCH_DUMP_ATTR175 */176 177 /*178 void CField::writeField(const CArray<double,1>& data)179 TRY180 {181 if (!getRelFile()->isEmptyZone())182 {183 if (grid_->doGridHaveDataToWrite() || getRelFile()->type == CFile::type_attr::one_file)184 {185 getRelFile()->checkWriteFile();186 this->incrementNStep();187 getRelFile()->getDataOutput()->writeFieldData(CField::get(this), data);188 }189 }190 }191 CATCH_DUMP_ATTR192 */193 194 157 /* 195 158 Send a request for reading data. … … 265 228 CATCH_DUMP_ATTR 266 229 267 /* old interface to be removed ..*/268 /*269 void CField::recvUpdateDataFromCoupler(std::map<int,CBufferIn*>& rankBuffers)270 TRY271 {272 CContext* context = CContext::getCurrent();273 Time timeStamp ;274 if (wasDataAlreadyReceivedFromServer)275 {276 lastDataReceivedFromServer = lastDataReceivedFromServer + freq_op;277 }278 else279 {280 // unlikely to input from file server where data are received at ts=0281 // for coupling, it would be after the first freq_op, because for now we don't have282 // restart mecanism to send the value at ts=0. It mus be changed in future283 lastDataReceivedFromServer = context->getCalendar()->getInitDate();284 wasDataAlreadyReceivedFromServer = true;285 }286 287 CArray<int,1>& storeClient = grid_->getStoreIndex_client();288 CArray<double,1> recv_data_tmp(storeClient.numElements());289 290 auto& outLocalIndexStoreOnClient = grid_-> getOutLocalIndexStoreOnClient() ;291 for (auto it = outLocalIndexStoreOnClient.begin(); it != outLocalIndexStoreOnClient.end(); ++it)292 {293 CArray<double,1> tmp;294 CArray<size_t,1>& indexTmp = it->second;295 *(rankBuffers[it->first]) >> timeStamp >> tmp;296 for (int idx = 0; idx < indexTmp.numElements(); ++idx) recv_data_tmp(indexTmp(idx)) = tmp(idx);297 }298 299 clientSourceFilter->streamData(lastDataReceivedFromServer, recv_data_tmp);300 301 }302 CATCH_DUMP_ATTR303 */304 305 /*!306 Receive read data from server307 \param [in] ranks Ranks of sending processes308 \param [in] buffers buffers containing read data309 */310 // old interface to remove311 /*312 void CField::recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers)313 TRY314 {315 CContext* context = CContext::getCurrent();316 std::map<int, CArray<double,1> > data;317 const bool wasEOF = isEOF;318 319 for (int i = 0; i < ranks.size(); i++)320 {321 int rank = ranks[i];322 int record;323 *buffers[i] >> record;324 isEOF = (record == int(-1));325 326 if (!isEOF)327 *buffers[i] >> data[rank];328 else329 break;330 }331 332 if (wasDataAlreadyReceivedFromServer)333 lastDataReceivedFromServer = lastDataReceivedFromServer + fileIn_->output_freq;334 else335 {336 lastDataReceivedFromServer = context->getCalendar()->getInitDate();337 wasDataAlreadyReceivedFromServer = true;338 }339 340 if (isEOF)341 {342 if (!wasEOF)343 dateEOF = lastDataReceivedFromServer;344 345 serverSourceFilter->signalEndOfStream(lastDataReceivedFromServer);346 }347 else348 serverSourceFilter->streamDataFromServer(lastDataReceivedFromServer, data);349 }350 CATCH_DUMP_ATTR351 */352 230 353 231 void CField::checkForLateDataFromCoupler(void) … … 423 301 CATCH_DUMP_ATTR 424 302 425 //---------------------------------------------------------------- 426 /* 427 void CField::setRelFile(CFile* _file) 428 TRY 429 { 430 this->file = _file; 431 hasOutputFile = true; 432 } 433 CATCH_DUMP_ATTR 434 */ 303 435 304 //---------------------------------------------------------------- 436 305 … … 459 328 CATCH 460 329 461 int CField::getNStep(void) const462 TRY463 {464 return this->nstep;465 }466 CATCH467 468 330 func::CFunctor::ETimeType CField::getOperationTimeType() const 469 331 TRY … … 473 335 CATCH 474 336 475 //----------------------------------------------------------------476 477 void CField::incrementNStep(void)478 TRY479 {480 this->nstep++;481 }482 CATCH_DUMP_ATTR483 484 void CField::resetNStep(int nstep /*= 0*/)485 TRY486 {487 this->nstep = nstep;488 }489 CATCH_DUMP_ATTR490 491 void CField::resetNStepMax(void)492 TRY493 {494 this->nstepMax = 0;495 nstepMaxRead = false;496 }497 CATCH_DUMP_ATTR498 337 499 338 //---------------------------------------------------------------- … … 868 707 if (freq_offset.isEmpty()) freq_offset.setValue(NoneDu); 869 708 870 freq_operation_srv = fileOut_->output_freq.getValue();871 freq_write_srv = fileOut_->output_freq.getValue();872 873 lastlast_Write_srv = context->getCalendar()->getInitDate();874 last_Write_srv = context->getCalendar()->getInitDate();875 last_operation_srv = context->getCalendar()->getInitDate();876 877 const CDuration toffset = freq_operation_srv - freq_offset.getValue() - context->getCalendar()->getTimeStep();878 last_operation_srv = last_operation_srv - toffset;879 880 709 if (operation.isEmpty()) 881 710 ERROR("void CField::solveServerOperation(void)", … … 1086 915 if (freq_op.isEmpty()) freq_op.setValue(TimeStep); 1087 916 if (freq_offset.isEmpty()) freq_offset.setValue(freq_op.getValue() - TimeStep); 1088 1089 /* old1090 1091 freq_operation_srv = freq_op ;1092 last_operation_srv = context->getCalendar()->getInitDate();1093 const CDuration toffset = freq_operation_srv - freq_offset.getValue() - context->getCalendar()->getTimeStep();1094 last_operation_srv = last_operation_srv - toffset;1095 1096 clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid_, false, false, freq_offset, true)) ;1097 clientSourceFilter -> connectOutput(inputFilter,0) ;1098 1099 */1100 // new1101 1102 917 clientFromClientSourceFilter_ = std::shared_ptr<CClientFromClientSourceFilter>(new CClientFromClientSourceFilter(gc, this)) ; 1103 918 clientFromClientSourceFilter_ -> connectOutput(inputFilter,0) ; … … 1700 1515 CATCH_DUMP_ATTR 1701 1516 1702 void CField::scaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset)1703 TRY1704 {1705 data = (data - addOffset) / scaleFactor;1706 }1707 CATCH_DUMP_ATTR1708 1709 void CField::invertScaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset)1710 TRY1711 {1712 data = data * scaleFactor + addOffset;1713 }1714 CATCH_DUMP_ATTR1715 1716 void CField::outputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut)1717 TRY1718 {1719 CArray<size_t,1>& outIndexClient = grid_->localIndexToWriteOnClient_;1720 CArray<size_t,1>& outIndexServer = grid_->localIndexToWriteOnServer_;1721 for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx)1722 {1723 dataOut(outIndexServer(idx)) = dataIn(outIndexClient(idx));1724 }1725 }1726 CATCH_DUMP_ATTR1727 1728 void CField::inputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut)1729 TRY1730 {1731 CArray<size_t,1>& outIndexClient = grid_->localIndexToWriteOnClient_;1732 CArray<size_t,1>& outIndexServer = grid_->localIndexToWriteOnServer_;1733 for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx)1734 {1735 dataOut(outIndexClient(idx)) = dataIn(outIndexServer(idx));1736 }1737 }1738 CATCH_DUMP_ATTR1739 1740 void CField::outputCompressedField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut)1741 TRY1742 {1743 CArray<size_t,1>& outIndexClient = grid_->localIndexToWriteOnClient_;1744 CArray<size_t,1>& outIndexServer = grid_->localIndexToWriteOnServer_;1745 for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx)1746 {1747 dataOut((idx)) = dataIn(outIndexClient(idx));1748 }1749 }1750 CATCH_DUMP_ATTR1751 1752 1517 ///------------------------------------------------------------------- 1753 1518 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp
r1961 r1962 105 105 106 106 public: 107 int getNStep(void) const;108 109 107 template <int N> void getData(CArray<double, N>& _data) const; 110 108 111 109 std::shared_ptr<COutputPin> getInstantDataFilter(); 112 113 /// Mutateur ///114 void setRelFile(CFile* _file);115 void incrementNStep(void);116 void resetNStep(int nstep = 0);117 void resetNStepMax();118 110 119 111 std::map<int, StdSize> getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting = false); … … 193 185 static bool dispatchEvent(CEventServer& event); 194 186 void sendAllAttributesToServer(CContextClient* client) ; 195 void sendUpdateData(Time timestamp, const CArray<double,1>& data, CContextClient* client); 196 void sendUpdateDataServerToClient(bool isEOF, const CArray<double,1>& data, CContextClient* client) ; 197 187 198 188 static void recvUpdateData(CEventServer& event); 199 189 void receiveUpdateData(CEventServer& event); 200 201 void recvUpdateData(std::map<int,CBufferIn*>& rankBuffers); // old interface to be removed 202 void recvUpdateDataFromClient(std::map<int,CBufferIn*>& rankBuffers); // old interface to be removed 203 void recvUpdateDataFromCoupler(std::map<int,CBufferIn*>& rankBuffers); // old interface to be removed 204 205 // void writeField(const CArray<double,1>& data); 190 206 191 bool sendReadDataRequest(const CDate& tsDataRequested); 207 192 bool sendReadDataRequestIfNeeded(void); 208 193 static void recvReadDataRequest(CEventServer& event); 209 194 void recvReadDataRequest(void); 210 EReadField readField(CArray<double,1>& data);211 195 static void recvReadDataReady(CEventServer& event); 212 196 void receiveReadDataReady(CEventServer& event); … … 220 204 void triggerLateField(void) ; 221 205 222 // void outputField(CArray<double,3>& fieldOut);223 // void outputField(CArray<double,2>& fieldOut);224 void outputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut);225 226 // void inputField(CArray<double,3>& fieldOut);227 // void inputField(CArray<double,2>& fieldOut);228 void inputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut);229 void outputCompressedField(const CArray<double,1>& dataIn, CArray<double, 1>& dataOut);230 void scaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset);231 void invertScaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset);232 206 void parse(xml::CXMLNode& node); 233 207 … … 246 220 void recvAddVariableGroup(CBufferIn& buffer); 247 221 void sendAddAllVariables(CContextClient* client); 248 //void writeUpdateData(const CArray<double,1>& data);249 222 250 223 const std::vector<StdString>& getRefDomainAxisIds(); … … 333 306 void unsetModelOut(void) { modelOut_ = false ;} 334 307 335 CDuration freq_operation_srv, freq_write_srv; 336 308 337 309 bool written; //<! Was the field written at least once 338 int nstep, nstepMax;339 bool isEOF;340 CDate lastlast_Write_srv, last_Write_srv, last_operation_srv;341 CDate lastDataRequestedFromServer, lastDataReceivedFromServer, dateEOF;342 bool wasDataRequestedFromServer, wasDataAlreadyReceivedFromServer;343 310 bool mustAutoTrigger; 344 311 345 map<int,std::shared_ptr<func::CFunctor> > foperation_srv;346 347 // map<int, CArray<double,1> > data_srv;348 // CArray<double,1> recvDataSrv; // not usefull anymore349 350 std::shared_ptr<func::CFunctor> recvFoperationSrv;351 312 string content; 352 313 … … 373 334 bool isReferenceSolvedAndTransformed; 374 335 bool isGridChecked; 375 bool nstepMaxRead;376 336 377 337 private: -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/file.cpp
r1961 r1962 240 240 isOpen = false; 241 241 242 // if (!record_offset.isEmpty() && record_offset < 0)243 // ERROR("void CFile::initFile(void)",244 // "Invalid 'record_offset', this attribute cannot be negative.");245 const int recordOffset = record_offset.isEmpty() ? 0 : record_offset;246 247 242 set<StdString> setAxis; 248 243 set<StdString> setDomains; … … 258 253 for (size_t i = 0; i < vecDomains.size(); ++i) 259 254 setDomains.insert(vecDomains[i]->getDomainOutputName()); 260 261 field->resetNStep(recordOffset);262 255 } 263 256 nbAxis = setAxis.size(); … … 267 260 createSubComFile(); 268 261 269 // if (time_counter.isEmpty()) time_counter.setValue(time_counter_attr::centered);270 262 if (time_counter_name.isEmpty()) time_counter_name = "time_counter"; 271 263 }
Note: See TracChangeset
for help on using the changeset viewer.