[352] | 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" |
---|
[369] | 10 | #include "array_new.hpp" |
---|
[352] | 11 | |
---|
[369] | 12 | |
---|
[352] | 13 | namespace xios { |
---|
| 14 | |
---|
[369] | 15 | template <int N> |
---|
| 16 | void CField::setData(const CArray<double, N>& _data) |
---|
[352] | 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 | |
---|
[369] | 24 | template <int N> |
---|
| 25 | bool CField::updateData(const CArray<double, N>& _data) |
---|
[352] | 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 | { |
---|
[369] | 38 | if (this->data.numElements() != this->grid->storeIndex_client.numElements()) |
---|
[352] | 39 | { |
---|
[369] | 40 | this->data.resize(this->grid->storeIndex_client.numElements()); |
---|
[352] | 41 | } |
---|
| 42 | |
---|
[369] | 43 | CArray<double,1> input(data.numElements()) ; |
---|
[352] | 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 |
---|