source: XIOS/trunk/src/field_impl.hpp @ 335

Last change on this file since 335 was 335, checked in by ymipsl, 12 years ago

Change namespace xmlioserver -> xios

YM

File size: 2.1 KB
Line 
1
2#ifndef __FIELD_IMPL_HPP__
3#define __FIELD_IMPL_HPP__
4
5#include "xmlioserver_spl.hpp"
6#include "field.hpp"
7#include "context.hpp"
8#include "grid.hpp"
9
10
11namespace xios {
12namespace tree {
13
14   template <StdSize N>
15   void CField::setData(const ARRAY(double, N) _data)
16   {
17     const std::vector<boost::shared_ptr<CField> > & refField=getAllReference();
18     std::vector<boost::shared_ptr<CField> >::const_iterator  it = refField.begin(), end = refField.end();
19     
20     for (; it != end; it++) (*it)->updateData(_data) ;
21    }
22   
23   template <StdSize N>
24      bool CField::updateData(const ARRAY(double, N) _data)
25   {       
26      shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ;
27      const date::CDate & currDate = context->getCalendar()->getCurrentDate();
28      const date::CDate opeDate      = *last_operation + freq_operation;
29      const date::CDate writeDate    = *last_Write     + freq_write;       
30
31   
32      info(50) << "CField::updateData " << currDate <<  " : send data to " << this->getBaseFieldId() << std::endl;
33      info(50) << "Next operation "  << opeDate<<std::endl;
34
35      if (opeDate <= currDate)
36      {
37         if (this->data->num_elements() != this->grid->storeIndex_client->num_elements())
38         {
39            this->data->resize(boost::extents[this->grid->storeIndex_client ->num_elements()]);
40         }
41           
42         ARRAY_CREATE(input, double, 1, [this->data->num_elements()]);
43         this->grid->inputField(_data, input);         
44         (*this->foperation)(input);
45         
46         *last_operation = currDate;
47         info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 
48      }
49     
50      if (writeDate < (currDate + freq_operation))
51      {
52         this->foperation->final();
53         *last_Write = writeDate;
54         info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate  << std::endl;
55         sendUpdateData() ;
56         return (true);       
57      }
58
59      return (false);
60   }
61
62} // namespace tree
63} // namespace xios
64
65#endif
Note: See TracBrowser for help on using the repository browser.