Changeset 1882
- Timestamp:
- 05/18/20 10:11:57 (4 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/data_input.cpp
r775 r1882 19 19 //---------------------------------------------------------------- 20 20 21 void CDataInput::readFieldData(CField* field )21 void CDataInput::readFieldData(CField* field, CArray<double,1>& data) 22 22 { 23 this->readFieldData_(field );23 this->readFieldData_(field,data); 24 24 } 25 25 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/data_input.hpp
r775 r1882 18 18 /// Read methods /// 19 19 StdSize getFieldNbRecords(CField* field); 20 void readFieldData(CField* field );20 void readFieldData(CField* field, CArray<double,1>& data); 21 21 void readFieldAttributesMetaData(CField* field); 22 22 void readFieldAttributesValues(CField* field); … … 27 27 protected: 28 28 virtual StdSize getFieldNbRecords_(CField* field) = 0; 29 virtual void readFieldData_(CField* field ) = 0;29 virtual void readFieldData_(CField* field, CArray<double,1>& data) = 0; 30 30 virtual void readFieldAttributes_(CField* field, bool readAttributeValues) = 0; 31 31 virtual void closeFile_(void) = 0; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/data_output.cpp
r1622 r1882 122 122 //---------------------------------------------------------------- 123 123 124 void CDataOutput::writeFieldData(CField* field )124 void CDataOutput::writeFieldData(CField* field, const CArray<double,1>& data) 125 125 TRY 126 126 { 127 127 // CGrid* grid = CGrid::get(field->grid_ref.getValue()); 128 128 // CDomain* domain = CDomain::get(grid->domain_ref.getValue()); 129 this->writeFieldData_(field );129 this->writeFieldData_(field, data); 130 130 } 131 131 CATCH -
XIOS/dev/dev_ym/XIOS_COUPLING/src/data_output.hpp
r1542 r1882 28 28 void writeFieldGrid(CField* field); 29 29 void writeTimeDimension(void); 30 void writeFieldData(CField* field );30 void writeFieldData(CField* field, const CArray<double,1>& data); 31 31 32 32 virtual void definition_start(void) = 0; … … 52 52 virtual void syncFile_ (void) = 0; 53 53 virtual void writeField_ (CField* field) = 0; 54 virtual void writeFieldData_(CField* field ) = 0;54 virtual void writeFieldData_(CField* field, const CArray<double,1>& data) = 0; 55 55 virtual void writeDomain_ (CDomain* domain) = 0; 56 56 virtual void writeAxis_ (CAxis* axis) = 0; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/io/nc4_data_input.cpp
r1869 r1882 43 43 CATCH 44 44 45 void CNc4DataInput::readFieldData_(CField* field )45 void CNc4DataInput::readFieldData_(CField* field, CArray<double,1>& dataOut) 46 46 TRY 47 47 { … … 113 113 } 114 114 115 field->inputField(fieldData );115 field->inputField(fieldData, dataOut); 116 116 117 117 if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) … … 120 120 if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor; 121 121 if (!field->add_offset.isEmpty()) addOffset = field->add_offset; 122 field->invertScaleFactorAddOffset( scaleFactor, addOffset);122 field->invertScaleFactorAddOffset(dataOut,scaleFactor, addOffset); 123 123 } 124 124 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/io/nc4_data_input.hpp
r1639 r1882 37 37 // Read methods 38 38 virtual StdSize getFieldNbRecords_(CField* field); 39 virtual void readFieldData_(CField* field );39 virtual void readFieldData_(CField* field, CArray<double,1>& data); 40 40 virtual void readFieldAttributes_(CField* field, bool readAttributeValues); 41 41 virtual void closeFile_(void); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/io/nc4_data_output.cpp
r1872 r1882 2343 2343 //--------------------------------------------------------------- 2344 2344 2345 void CNc4DataOutput::writeFieldData_ (CField* field )2345 void CNc4DataOutput::writeFieldData_ (CField* field, const CArray<double,1>& data) 2346 2346 { 2347 2347 CContext* context = CContext::getCurrent(); 2348 2348 CGrid* grid = field->getGrid(); 2349 CArray<double,1> dataIn(data.copy()) ; 2349 2350 2350 2351 if (field->getNStep()<1) … … 2457 2458 if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor; 2458 2459 if (!field->add_offset.isEmpty()) addOffset = field->add_offset; 2459 field->scaleFactorAddOffset( scaleFactor, addOffset);2460 field->scaleFactorAddOffset(dataIn, scaleFactor, addOffset); 2460 2461 } 2461 2462 … … 2472 2473 2473 2474 if (field->getUseCompressedOutput()) 2474 field->outputCompressedField( fieldData);2475 field->outputCompressedField(dataIn, fieldData); 2475 2476 else 2476 field->outputField( fieldData);2477 field->outputField(dataIn, fieldData); 2477 2478 2478 2479 if (!field->prec.isEmpty() && field->prec == 2) fieldData = round(fieldData); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/io/nc4_data_output.hpp
r1639 r1882 56 56 virtual void writeAttribute_(CVariable* var); 57 57 virtual void writeAttribute_(CVariable* var, const string& fieldId); 58 virtual void writeFieldData_(CField* field );58 virtual void writeFieldData_(CField* field, const CArray<double,1>& data); 59 59 virtual void writeFile_ (CFile* file); 60 60 virtual void closeFile_ (void); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp
r1881 r1882 235 235 TRY 236 236 { 237 // ym to remove latter 238 /* 237 239 CContext* context = CContext::getCurrent(); 238 240 Time timeStamp ; … … 257 259 if (opeDate <= currDate) 258 260 { 261 259 262 auto& outLocalIndexStoreOnClient = grid_-> getOutLocalIndexStoreOnClient() ; 260 263 for (auto it = outLocalIndexStoreOnClient.begin(); it != outLocalIndexStoreOnClient.end(); ++it) … … 266 269 } 267 270 } 271 */ 272 Time timeStamp ; 273 CArray<int,1>& storeClient = grid_->getStoreIndex_client(); // replace it with local size 274 CArray<double,1> recv_data_tmp(storeClient.numElements()); 275 auto& outLocalIndexStoreOnClient = grid_-> getOutLocalIndexStoreOnClient() ; 276 for (auto it = outLocalIndexStoreOnClient.begin(); it != outLocalIndexStoreOnClient.end(); ++it) 277 { 278 CArray<double,1> tmp; 279 CArray<size_t,1>& indexTmp = it->second; 280 *(rankBuffers[it->first]) >> timeStamp >> tmp; 281 for (int idx = 0; idx < indexTmp.numElements(); ++idx) recv_data_tmp(indexTmp(idx)) = tmp(idx); 282 } 268 283 269 284 this->setData(recv_data_tmp); 285 /* 270 286 // delete incomming flux for server only 271 287 recvFoperationSrv.reset() ; 272 288 recvDataSrv.reset() ; 273 } 274 CATCH_DUMP_ATTR 275 289 */ 290 } 291 CATCH_DUMP_ATTR 292 293 /* ym : old interface : to be removed... 276 294 void CField::writeUpdateData(const CArray<double,1>& data) 277 295 TRY … … 303 321 } 304 322 CATCH_DUMP_ATTR 305 306 void CField::writeField(void) 323 */ 324 325 void CField::writeUpdateData(const CArray<double,1>& data) 326 TRY 327 { 328 const CDate writeDate = last_Write_srv + freq_write_srv; 329 last_Write_srv = writeDate; 330 grid_->computeWrittenIndex(); 331 /* 332 recvDataSrv.resize(data.numElements()) ; 333 recvDataSrv = data ; 334 */ 335 writeField(data); 336 lastlast_Write_srv = last_Write_srv; 337 } 338 CATCH_DUMP_ATTR 339 340 341 void CField::writeField(const CArray<double,1>& data) 307 342 TRY 308 343 { … … 313 348 getRelFile()->checkWriteFile(); 314 349 this->incrementNStep(); 315 getRelFile()->getDataOutput()->writeFieldData(CField::get(this) );350 getRelFile()->getDataOutput()->writeFieldData(CField::get(this), data); 316 351 } 317 352 } … … 403 438 CEventClient event(getType(), EVENT_ID_READ_DATA_READY); 404 439 std::list<CMessage> msgs; 405 406 EReadField hasData = readField(); 440 441 CArray<double,1> data ; 442 EReadField hasData = readField(data); 407 443 408 444 map<int, CArray<double,1> >::iterator it; … … 411 447 if (client->isServerLeader()) 412 448 { 413 if (0 != recvDataSrv.numElements())449 if (0 != data.numElements()) 414 450 { 415 451 const std::list<int>& ranks = client->getRanksServerLeader(); … … 422 458 { 423 459 case RF_DATA: 424 msg << getNStep() - 1 << recvDataSrv;460 msg << getNStep() - 1 << data; 425 461 break; 426 462 case RF_NODATA: 427 msg << int(-2) << recvDataSrv;463 msg << int(-2) << data; 428 464 break; 429 465 case RF_EOF: … … 452 488 for (int idx = 0; idx < indexTmp.numElements(); ++idx) 453 489 { 454 tmp(idx) = recvDataSrv(indexTmp(idx));490 tmp(idx) = data(indexTmp(idx)); 455 491 } 456 492 … … 484 520 \return State of field can be read from a file 485 521 */ 486 CField::EReadField CField::readField( void)522 CField::EReadField CField::readField(CArray<double,1>& data) 487 523 TRY 488 524 { … … 496 532 if (grid_->doGridHaveDataToWrite() || getRelFile()->type == CFile::type_attr::one_file) 497 533 { 498 if (0 == recvDataSrv.numElements())499 {500 534 CArray<int,1>& storeClient = grid_->getStoreIndex_client(); 501 recvDataSrv.resize(storeClient.numElements()); 502 } 535 data.resize(storeClient.numElements()); 503 536 504 537 getRelFile()->checkReadFile(); … … 515 548 516 549 if (RF_EOF != readState) 517 getRelFile()->getDataInput()->readFieldData(CField::get(this) );550 getRelFile()->getDataInput()->readFieldData(CField::get(this),data); 518 551 } 519 552 } … … 2018 2051 CATCH_DUMP_ATTR 2019 2052 2020 void CField::scaleFactorAddOffset( double scaleFactor, double addOffset)2021 TRY 2022 { 2023 recvDataSrv = (recvDataSrv- addOffset) / scaleFactor;2024 } 2025 CATCH_DUMP_ATTR 2026 2027 void CField::invertScaleFactorAddOffset( double scaleFactor, double addOffset)2028 TRY 2029 { 2030 recvDataSrv = recvDataSrv* scaleFactor + addOffset;2031 } 2032 CATCH_DUMP_ATTR 2033 2034 void CField::outputField( CArray<double,1>& fieldOut)2053 void CField::scaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset) 2054 TRY 2055 { 2056 data = (data - addOffset) / scaleFactor; 2057 } 2058 CATCH_DUMP_ATTR 2059 2060 void CField::invertScaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset) 2061 TRY 2062 { 2063 data = data * scaleFactor + addOffset; 2064 } 2065 CATCH_DUMP_ATTR 2066 2067 void CField::outputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 2035 2068 TRY 2036 2069 { … … 2039 2072 for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx) 2040 2073 { 2041 fieldOut(outIndexServer(idx)) = recvDataSrv(outIndexClient(idx));2042 } 2043 } 2044 CATCH_DUMP_ATTR 2045 2046 void CField::inputField( CArray<double,1>& fieldIn)2074 dataOut(outIndexServer(idx)) = dataIn(outIndexClient(idx)); 2075 } 2076 } 2077 CATCH_DUMP_ATTR 2078 2079 void CField::inputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 2047 2080 TRY 2048 2081 { … … 2051 2084 for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx) 2052 2085 { 2053 recvDataSrv(outIndexClient(idx)) = fieldIn(outIndexServer(idx));2054 } 2055 } 2056 CATCH_DUMP_ATTR 2057 2058 void CField::outputCompressedField( CArray<double,1>& fieldOut)2086 dataOut(outIndexClient(idx)) = dataIn(outIndexServer(idx)); 2087 } 2088 } 2089 CATCH_DUMP_ATTR 2090 2091 void CField::outputCompressedField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 2059 2092 TRY 2060 2093 { … … 2063 2096 for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx) 2064 2097 { 2065 fieldOut((idx)) = recvDataSrv(outIndexClient(idx));2098 dataOut((idx)) = dataIn(outIndexClient(idx)); 2066 2099 } 2067 2100 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp
r1875 r1882 190 190 void recvUpdateDataFromCoupler(std::map<int,CBufferIn*>& rankBuffers); 191 191 192 void writeField( void);192 void writeField(const CArray<double,1>& data); 193 193 bool sendReadDataRequest(const CDate& tsDataRequested, CContextClient* client); 194 194 bool sendReadDataRequestIfNeeded(void); 195 195 static void recvReadDataRequest(CEventServer& event); 196 196 void recvReadDataRequest(CContextServer* server); 197 EReadField readField( void);197 EReadField readField(CArray<double,1>& data); 198 198 static void recvReadDataReady(CEventServer& event); 199 199 void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers); … … 206 206 void triggerLateField(void) ; 207 207 208 void outputField(CArray<double,3>& fieldOut); 209 void outputField(CArray<double,2>& fieldOut); 210 void outputField(CArray<double,1>& fieldOut); 211 void inputField(CArray<double,3>& fieldOut); 212 void inputField(CArray<double,2>& fieldOut); 213 void inputField(CArray<double,1>& fieldOut); 214 void outputCompressedField(CArray<double, 1>& fieldOut); 215 void scaleFactorAddOffset(double scaleFactor, double addOffset); 216 void invertScaleFactorAddOffset(double scaleFactor, double addOffset); 208 // void outputField(CArray<double,3>& fieldOut); 209 // void outputField(CArray<double,2>& fieldOut); 210 void outputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 211 212 // void inputField(CArray<double,3>& fieldOut); 213 // void inputField(CArray<double,2>& fieldOut); 214 void inputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 215 void outputCompressedField(const CArray<double,1>& dataIn, CArray<double, 1>& dataOut); 216 void scaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset); 217 void invertScaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset); 217 218 void parse(xml::CXMLNode& node); 218 219 … … 329 330 330 331 // map<int, CArray<double,1> > data_srv; 331 CArray<double,1> recvDataSrv; 332 // CArray<double,1> recvDataSrv; // not usefull anymore 332 333 333 334 std::shared_ptr<func::CFunctor> recvFoperationSrv;
Note: See TracChangeset
for help on using the changeset viewer.