source: XIOS/trunk/src/node/field_impl.hpp @ 369

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

Major Update

  • redesign Type and attribute manipulation
  • add enumerate type and attribute
  • use blitz class array instead of boost class array

YM

File size: 2.0 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#include "timer.hpp"
10#include "array_new.hpp"
11
12
13namespace xios {
14
15   template <int N>
16   void CField::setData(const CArray<double, N>& _data)
17   {
18     const std::vector<CField*>& refField=getAllReference();
19     std::vector<CField*>::const_iterator  it = refField.begin(), end = refField.end();
20     
21     for (; it != end; it++) (*it)->updateData(_data) ;
22    }
23   
24   template <int N>
25      bool CField::updateData(const CArray<double, N>& _data)
26   {       
27      CContext* context=CContext::getCurrent();
28      const CDate & currDate = context->getCalendar()->getCurrentDate();
29      const CDate opeDate      = *last_operation + freq_operation;
30      const CDate writeDate    = *last_Write     + freq_write;       
31
32   
33      info(50) << "CField::updateData " << currDate <<  " : send data to " << this->getBaseFieldId() << std::endl;
34      info(50) << "Next operation "  << opeDate<<std::endl;
35
36      if (opeDate <= currDate)
37      {
38         if (this->data.numElements() != this->grid->storeIndex_client.numElements())
39         {
40            this->data.resize(this->grid->storeIndex_client.numElements());
41         }
42           
43         CArray<double,1> input(data.numElements()) ;
44         this->grid->inputField(_data, input);         
45         (*this->foperation)(input);
46         
47         *last_operation = currDate;
48         info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 
49      }
50     
51      if (writeDate < (currDate + freq_operation))
52      {
53         this->foperation->final();
54         *last_Write = writeDate;
55         info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate  << std::endl;
56         CTimer::get("XIOS Send Data").resume() ;
57         sendUpdateData() ;
58         CTimer::get("XIOS Send Data").suspend() ;
59         return (true);       
60      }
61
62      return (false);
63   }
64
65} // namespace xios
66
67#endif
Note: See TracBrowser for help on using the repository browser.