Changeset 1962 for XIOS/dev/dev_ym


Ignore:
Timestamp:
10/12/20 17:15:59 (4 years ago)
Author:
ymipsl
Message:

Xios coupling
some cleaning...
YM

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  
    5757      file_->checkReadFile(); 
    5858      nStepMax_ = file_->getDataInput()->getFieldNbRecords(field_); 
    59       nStep_ = 0 ; 
     59      nStep_ = file_->record_offset.isEmpty() ? 0 : file_->record_offset; ; 
    6060    } 
    6161    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  
    2323    else needToWrite_=false; 
    2424    lastFileSplit_ = file_->getLastSplit() ; 
    25     nstep_ = 0 ; 
     25    nstep_ = file_->record_offset.isEmpty() ? 0 : file_->record_offset; // record_offset < 0 ==> no output (debugging) 
    2626    if (!field->scale_factor.isEmpty()) { scaleFactor_ = field->scale_factor ; hasScaleFactor_ = true ; } 
    2727    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  
    21012101            factorUnit=context->getCalendar()->getDayLengthInSeconds() ; 
    21022102            else factorUnit=1 ; 
    2103             nstep = getRecordFromTime(field->last_Write_srv,factorUnit) + 1; 
     2103            nstep = getRecordFromTime(currentWrite,factorUnit) + 1; 
    21042104          } 
    21052105 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp

    r1961 r1962  
    3333    : CObjectTemplate<CField>(), CFieldAttributes() 
    3434    , written(false) 
    35     , nstep(0), nstepMax(0) 
    3635    , hasOutputFile(false) 
    3736    , domAxisScalarIds_(vector<StdString>(3,"")) 
     
    4140    , hasTimeInstant(false) 
    4241    , hasTimeCentered(false) 
    43     , wasDataRequestedFromServer(false) 
    44     , wasDataAlreadyReceivedFromServer(false) 
    4542    , mustAutoTrigger(false) 
    46     , isEOF(false), nstepMaxRead(false) 
    4743  { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 
    4844 
     
    5046    : CObjectTemplate<CField>(id), CFieldAttributes() 
    5147    , written(false) 
    52     , nstep(0), nstepMax(0) 
    5348    , hasOutputFile(false) 
    5449    , domAxisScalarIds_(vector<StdString>(3,"")) 
     
    5853    , hasTimeInstant(false) 
    5954    , hasTimeCentered(false) 
    60     , wasDataRequestedFromServer(false) 
    61     , wasDataAlreadyReceivedFromServer(false) 
    6255    , mustAutoTrigger(false) 
    63     , isEOF(false), nstepMaxRead(false) 
    64   { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 
     56    { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 
    6557 
    6658  CField::~CField(void) 
     
    163155  CATCH 
    164156 
    165 /*   
    166   void CField::writeUpdateData(const CArray<double,1>& data) 
    167   TRY 
    168   { 
    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_ATTR 
    175 */ 
    176  
    177 /* 
    178   void CField::writeField(const CArray<double,1>& data) 
    179   TRY 
    180   { 
    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_ATTR 
    192 */ 
    193    
    194157  /* 
    195158    Send a request for reading data. 
     
    265228  CATCH_DUMP_ATTR 
    266229 
    267   /* old interface to be removed ..*/ 
    268 /* 
    269   void CField::recvUpdateDataFromCoupler(std::map<int,CBufferIn*>& rankBuffers) 
    270   TRY 
    271   { 
    272     CContext* context = CContext::getCurrent(); 
    273     Time timeStamp ; 
    274     if (wasDataAlreadyReceivedFromServer) 
    275     {   
    276       lastDataReceivedFromServer = lastDataReceivedFromServer + freq_op; 
    277     } 
    278     else 
    279     { 
    280       // unlikely to input from file server where data are received at ts=0 
    281       // for coupling, it would be after the first freq_op, because for now we don't have 
    282       // restart mecanism to send the value at ts=0. It mus be changed in future 
    283       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_ATTR 
    303 */  
    304  
    305   /*! 
    306     Receive read data from server 
    307     \param [in] ranks Ranks of sending processes 
    308     \param [in] buffers buffers containing read data 
    309   */ 
    310   // old interface to remove  
    311 /* 
    312   void CField::recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers) 
    313   TRY 
    314   { 
    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       else 
    329         break; 
    330     } 
    331  
    332     if (wasDataAlreadyReceivedFromServer) 
    333       lastDataReceivedFromServer = lastDataReceivedFromServer + fileIn_->output_freq; 
    334     else 
    335     { 
    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     else 
    348       serverSourceFilter->streamDataFromServer(lastDataReceivedFromServer, data); 
    349   } 
    350   CATCH_DUMP_ATTR 
    351 */ 
    352230 
    353231  void CField::checkForLateDataFromCoupler(void) 
     
    423301  CATCH_DUMP_ATTR 
    424302 
    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 
    435304  //---------------------------------------------------------------- 
    436305 
     
    459328  CATCH 
    460329 
    461   int CField::getNStep(void) const 
    462   TRY 
    463   { 
    464     return this->nstep; 
    465   } 
    466   CATCH 
    467  
    468330  func::CFunctor::ETimeType CField::getOperationTimeType() const 
    469331  TRY 
     
    473335  CATCH 
    474336 
    475    //---------------------------------------------------------------- 
    476  
    477   void CField::incrementNStep(void) 
    478   TRY 
    479   { 
    480     this->nstep++; 
    481   } 
    482   CATCH_DUMP_ATTR 
    483  
    484   void CField::resetNStep(int nstep /*= 0*/) 
    485   TRY 
    486   { 
    487     this->nstep = nstep; 
    488   } 
    489   CATCH_DUMP_ATTR 
    490  
    491   void CField::resetNStepMax(void) 
    492   TRY 
    493   { 
    494     this->nstepMax = 0; 
    495     nstepMaxRead = false; 
    496   } 
    497   CATCH_DUMP_ATTR 
    498337 
    499338  //---------------------------------------------------------------- 
     
    868707    if (freq_offset.isEmpty()) freq_offset.setValue(NoneDu); 
    869708 
    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  
    880709    if (operation.isEmpty()) 
    881710      ERROR("void CField::solveServerOperation(void)", 
     
    1086915    if (freq_op.isEmpty()) freq_op.setValue(TimeStep); 
    1087916    if (freq_offset.isEmpty()) freq_offset.setValue(freq_op.getValue() - TimeStep); 
    1088      
    1089     /* old  
    1090  
    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     // new 
    1101  
    1102917    clientFromClientSourceFilter_ = std::shared_ptr<CClientFromClientSourceFilter>(new CClientFromClientSourceFilter(gc, this)) ; 
    1103918    clientFromClientSourceFilter_ -> connectOutput(inputFilter,0) ; 
     
    17001515  CATCH_DUMP_ATTR 
    17011516 
    1702   void CField::scaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset) 
    1703   TRY 
    1704   { 
    1705     data = (data - addOffset) / scaleFactor; 
    1706   } 
    1707   CATCH_DUMP_ATTR 
    1708  
    1709   void CField::invertScaleFactorAddOffset(CArray<double,1>& data, double scaleFactor, double addOffset) 
    1710   TRY 
    1711   { 
    1712     data = data * scaleFactor + addOffset; 
    1713   } 
    1714   CATCH_DUMP_ATTR 
    1715  
    1716   void CField::outputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 
    1717   TRY 
    1718   {  
    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_ATTR 
    1727  
    1728   void CField::inputField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 
    1729   TRY 
    1730   { 
    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_ATTR 
    1739  
    1740  void CField::outputCompressedField(const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 
    1741  TRY 
    1742  { 
    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_ATTR 
    1751  
    17521517  ///------------------------------------------------------------------- 
    17531518 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp

    r1961 r1962  
    105105 
    106106      public: 
    107          int getNStep(void) const; 
    108  
    109107         template <int N> void getData(CArray<double, N>& _data) const; 
    110108 
    111109         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(); 
    118110 
    119111         std::map<int, StdSize> getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting = false); 
     
    193185        static bool dispatchEvent(CEventServer& event); 
    194186        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         
    198188        static void recvUpdateData(CEventServer& event); 
    199189        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 
    206191        bool sendReadDataRequest(const CDate& tsDataRequested); 
    207192        bool sendReadDataRequestIfNeeded(void); 
    208193        static void recvReadDataRequest(CEventServer& event); 
    209194        void recvReadDataRequest(void); 
    210         EReadField readField(CArray<double,1>& data); 
    211195        static void recvReadDataReady(CEventServer& event); 
    212196        void receiveReadDataReady(CEventServer& event); 
     
    220204        void triggerLateField(void) ; 
    221205 
    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); 
    232206        void parse(xml::CXMLNode& node); 
    233207 
     
    246220        void recvAddVariableGroup(CBufferIn& buffer);         
    247221        void sendAddAllVariables(CContextClient* client); 
    248         //void writeUpdateData(const CArray<double,1>& data); 
    249222 
    250223        const std::vector<StdString>& getRefDomainAxisIds(); 
     
    333306         void unsetModelOut(void) { modelOut_ = false ;} 
    334307 
    335          CDuration freq_operation_srv, freq_write_srv; 
    336  
     308          
    337309         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; 
    343310         bool mustAutoTrigger; 
    344311 
    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 anymore 
    349           
    350          std::shared_ptr<func::CFunctor> recvFoperationSrv; 
    351312         string content; 
    352313 
     
    373334         bool isReferenceSolvedAndTransformed; 
    374335         bool isGridChecked; 
    375          bool nstepMaxRead; 
    376336 
    377337       private:  
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/file.cpp

    r1961 r1962  
    240240      isOpen = false;       
    241241 
    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  
    247242      set<StdString> setAxis; 
    248243      set<StdString> setDomains; 
     
    258253         for (size_t i = 0; i < vecDomains.size(); ++i) 
    259254           setDomains.insert(vecDomains[i]->getDomainOutputName()); 
    260  
    261          field->resetNStep(recordOffset); 
    262255      } 
    263256      nbAxis = setAxis.size(); 
     
    267260      createSubComFile(); 
    268261 
    269       // if (time_counter.isEmpty()) time_counter.setValue(time_counter_attr::centered); 
    270262      if (time_counter_name.isEmpty()) time_counter_name = "time_counter"; 
    271263    } 
Note: See TracChangeset for help on using the changeset viewer.