Ignore:
Timestamp:
02/13/12 19:35:25 (12 years ago)
Author:
ymipsl
Message:

nouvelle version de developpement de xios

  • nouvelle interface fortran
  • recodage complet de la couche de communication
  • et bien d'autres choses...

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/common/src/node/field.hpp

    r286 r300  
    1111#include "declare_group.hpp" 
    1212#include "calendar_util.hpp" 
     13//#include "context.hpp" 
     14 
    1315 
    1416namespace xmlioserver { 
     
    2325   class CFile; 
    2426   class CGrid; 
    25  
     27   class CContext ; 
    2628   ///-------------------------------------------------------------- 
    2729 
     
    4850         typedef CFieldGroup      RelGroup; 
    4951 
     52         enum EEventId 
     53         { 
     54           EVENT_ID_UPDATE_DATA 
     55         } ; 
     56          
    5057         /// Constructeurs /// 
    5158         CField(void); 
     
    8289         void incrementNStep(void); 
    8390 
    84          template <StdSize N> 
    85             inline bool updateData 
    86                (const date::CDate      & currDate, 
    87                 const date::CDuration  & timestep, 
    88                 const ARRAY(double, N)   data); 
    89  
     91         template <StdSize N> bool updateData(const ARRAY(double, N)   data); 
     92          
    9093         bool updateDataServer 
    9194               (const date::CDate & currDate, 
    9295                const std::deque<ARRAY(double, 1)> storedClient); 
    93  
    94       public : 
     96  
     97       public : 
    9598 
    9699         /// Test /// 
     
    112115          
    113116         static ENodeType GetType(void); 
    114  
    115       private : 
     117          
     118        template <StdSize N> void setData(const ARRAY(double, N) _data) ; 
     119        static bool dispatchEvent(CEventServer& event) ; 
     120        void sendUpdateData(void) ; 
     121        static void recvUpdateData(CEventServer& event) ; 
     122        void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ; 
     123        void writeField(void) ; 
     124        void outputField(ARRAY(double,3) fieldOut) ; 
     125        void outputField(ARRAY(double,2) fieldOut) ; 
     126         
     127      public : 
    116128 
    117129         /// Propriétés privées /// 
     
    123135 
    124136         date::CDuration freq_operation, freq_write; 
     137         date::CDuration freq_operation_srv, freq_write_srv; 
    125138 
    126139         StdSize nstep; 
    127140         boost::shared_ptr<date::CDate>    last_Write, last_operation; 
     141         boost::shared_ptr<date::CDate>    last_Write_srv, last_operation_srv; 
     142          
    128143         boost::shared_ptr<func::CFunctor> foperation; 
     144         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv; 
    129145          
    130146         ARRAY(double, 1) data; 
     147         map<int,ARRAY(double,1)> data_srv ; 
    131148 
    132149   }; // class CField 
     
    153170 
    154171   template <StdSize N> 
    155       bool CField::updateData(const date::CDate & currDate, const date::CDuration & timestep, const ARRAY(double, N) _data) 
     172   void CField::setData(const ARRAY(double, N) _data) 
     173   { 
     174     const std::vector<boost::shared_ptr<CField> > & refField=getAllReference(); 
     175     std::vector<boost::shared_ptr<CField> >::const_iterator  it = refField.begin(), end = refField.end(); 
     176      
     177     for (; it != end; it++) (*it)->updateData(_data) ; 
     178    } 
     179     
     180   template <StdSize N> 
     181      bool CField::updateData(const ARRAY(double, N) _data) 
    156182   {         
     183      shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 
     184      const date::CDate & currDate = context->getCalendar()->getCurrentDate(); 
    157185      const date::CDate opeDate      = *last_operation + freq_operation; 
    158186      const date::CDate writeDate    = *last_Write     + freq_write;        
    159187 
    160 //      std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; 
    161 //      std::cout << "Champ : "     << this->getBaseFieldId() << std::endl; 
    162 //      std::cout << "CurrDate : "  << currDate  << std::endl; 
    163 //      std::cout << "opeDate : "   << opeDate   << " = " << *last_operation << " + " << freq_operation << std::endl; 
    164 //      std::cout       << "writeDate : " << writeDate << " = " << *last_Write     << " + " << freq_write     << std::endl; 
    165 //      std::cout << "(opeDate <= currDate)   = " << std::boolalpha << (opeDate <= currDate)   << std::endl; 
    166 //      std::cout       << "(writeDate <= currDate) = " << std::boolalpha << (writeDate <= currDate) << std::endl;    
    167188    
    168       std::cout << ">> " << currDate <<  " : Envoi de données " << this->getBaseFieldId() << std::endl; 
    169       std::cout << ">> next operation "  << opeDate<<std::endl; 
     189      info(50) << "CField::updateData " << currDate <<  " : send data to " << this->getBaseFieldId() << std::endl; 
     190      info(50) << "Next operation "  << opeDate<<std::endl; 
     191 
    170192      if (opeDate <= currDate) 
    171193      { 
    172          //std::cout << "> " << currDate << ": Operation du champs" << this->getBaseFieldId() << std::endl; 
    173          if (this->data->num_elements() != this->grid->storeIndex[0]->num_elements()) 
     194         if (this->data->num_elements() != this->grid->storeIndex_client->num_elements()) 
    174195         { 
    175             this->data->resize(boost::extents[this->grid->storeIndex[0] ->num_elements()]); 
     196            this->data->resize(boost::extents[this->grid->storeIndex_client ->num_elements()]); 
    176197         } 
    177198             
     
    181202          
    182203         *last_operation = currDate; 
    183          std::cout << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl;  
     204         info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl;  
    184205      } 
    185206       
     
    187208      { 
    188209         this->foperation->final(); 
    189          this->incrementNStep(); 
    190210         *last_Write = writeDate; 
    191          std::cout << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 
     211         info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate  << std::endl; 
     212         sendUpdateData() ; 
    192213         return (true);         
    193214      } 
    194 //      std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; 
     215 
    195216      return (false); 
    196    }; 
     217   } 
    197218 
    198219} // namespace tree 
Note: See TracChangeset for help on using the changeset viewer.