Changeset 572 for XIOS/branchs
- Timestamp:
- 03/10/15 13:30:08 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/branchs/xios-1.0/src/node/field_impl.hpp
r501 r572 16 16 void CField::setData(const CArray<double, N>& _data) 17 17 { 18 if (hasInstantData) 18 if (hasInstantData) 19 19 { 20 grid->inputField(_data, instantData); 21 for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it) it->first->setSlot(it->second) 20 grid->inputField(_data, instantData); 21 for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it) it->first->setSlot(it->second); 22 22 } 23 23 24 24 if (!hasExpression) 25 25 { 26 26 const std::vector<CField*>& refField=getAllReference(); 27 27 std::vector<CField*>::const_iterator it = refField.begin(), end = refField.end(); 28 29 for (; it != end; it++) (*it)->setData(_data) 30 if (hasOutputFile || hasFieldOut) updateData(_data) 28 29 for (; it != end; it++) (*it)->setData(_data); 30 if (hasOutputFile || hasFieldOut) updateData(_data); 31 31 } 32 33 32 } 34 33 35 34 void CField::setDataFromExpression(const CArray<double, 1>& _data) 36 35 { 37 if (hasInstantData) 36 if (hasInstantData) 38 37 { 39 instantData=_data; 40 for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it) it->first->setSlot(it->second) 38 instantData=_data; 39 for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it) it->first->setSlot(it->second); 41 40 } 42 41 43 42 if (!hasExpression) 44 43 { 45 44 const std::vector<CField*>& refField=getAllReference(); 46 45 std::vector<CField*>::const_iterator it = refField.begin(), end = refField.end(); 47 48 for (; it != end; it++) (*it)->setData (_data);49 if (hasOutputFile || hasFieldOut) updateData (_data);46 47 for (; it != end; it++) (*it)->setDataFromExpression(_data); 48 if (hasOutputFile || hasFieldOut) updateDataFromExpression(_data); 50 49 } 51 52 50 } 53 51 54 52 template <int N> 55 53 bool CField::updateData(const CArray<double, N>& _data) 56 { 54 { 57 55 CContext* context=CContext::getCurrent(); 58 56 const CDate & currDate = context->getCalendar()->getCurrentDate(); 59 57 const CDate opeDate = *last_operation + freq_operation; 60 const CDate writeDate = *last_Write + freq_write; 61 bool doOperation, doWrite; 58 const CDate writeDate = *last_Write + freq_write; 59 bool doOperation, doWrite; 62 60 63 61 64 62 info(50) << "CField::updateData " << currDate << " : send data to " << this->getBaseFieldId() << std::endl; 65 63 info(50) << "Next operation " << opeDate<<std::endl; 66 64 67 doOperation = (opeDate <= currDate) 65 doOperation = (opeDate <= currDate); 68 66 if (isOnceOperation) 69 if (isFirstOperation) doOperation=true 70 else doOperation=false 67 if (isFirstOperation) doOperation=true; 68 else doOperation=false; 71 69 72 70 if (doOperation) … … 76 74 this->data.resize(this->grid->storeIndex_client.numElements()); 77 75 } 78 79 CArray<double,1> input(data.numElements()) 80 this->grid->inputField(_data, input); 76 77 CArray<double,1> input(data.numElements()); 78 this->grid->inputField(_data, input); 81 79 (*this->foperation)(input); 82 80 83 81 *last_operation = currDate; 84 info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 82 info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 85 83 } 86 84 87 doWrite = (writeDate < (currDate + freq_operation)) 85 doWrite = (writeDate < (currDate + freq_operation)); 88 86 if (isOnceOperation) 89 { 90 if(isFirstOperation) 87 { 88 if(isFirstOperation) 91 89 { 92 doWrite=true 93 isFirstOperation=false 90 doWrite=true; 91 isFirstOperation=false; 94 92 } 95 else doWrite=false 93 else doWrite=false; 96 94 } 97 95 98 96 if (doWrite) 99 97 { … … 103 101 { 104 102 info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 105 CTimer::get("XIOS Send Data").resume() 106 sendUpdateData() 107 CTimer::get("XIOS Send Data").suspend() 103 CTimer::get("XIOS Send Data").resume(); 104 sendUpdateData(); 105 CTimer::get("XIOS Send Data").suspend(); 108 106 } 109 107 110 108 if (hasFieldOut) 111 109 { 112 fieldOut->setDataFromExpression(data) 110 fieldOut->setDataFromExpression(data); 113 111 } 114 return (true); 112 return (true); 115 113 } 116 114 117 115 return (false); 118 116 } 119 117 120 118 bool CField::updateDataFromExpression(const CArray<double, 1>& _data) 121 { 119 { 122 120 CContext* context=CContext::getCurrent(); 123 121 const CDate & currDate = context->getCalendar()->getCurrentDate(); 124 122 const CDate opeDate = *last_operation + freq_operation; 125 const CDate writeDate = *last_Write + freq_write; 126 bool doOperation, doWrite; 123 const CDate writeDate = *last_Write + freq_write; 124 bool doOperation, doWrite; 127 125 128 126 129 127 info(50) << "CField::updateData " << currDate << " : send data to " << this->getBaseFieldId() << std::endl; 130 128 info(50) << "Next operation " << opeDate<<std::endl; 131 129 132 doOperation = (opeDate <= currDate) 130 doOperation = (opeDate <= currDate); 133 131 if (isOnceOperation) 134 if (isFirstOperation) doOperation=true 135 else doOperation=false 132 if (isFirstOperation) doOperation=true; 133 else doOperation=false; 136 134 137 135 if (doOperation) … … 141 139 this->data.resize(this->grid->storeIndex_client.numElements()); 142 140 } 143 141 144 142 (*this->foperation)(_data); 145 143 146 144 *last_operation = currDate; 147 info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 145 info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 148 146 } 149 147 150 doWrite = (writeDate < (currDate + freq_operation)) 148 doWrite = (writeDate < (currDate + freq_operation)); 151 149 if (isOnceOperation) 152 { 153 if(isFirstOperation) 150 { 151 if(isFirstOperation) 154 152 { 155 doWrite=true 156 isFirstOperation=false 153 doWrite=true; 154 isFirstOperation=false; 157 155 } 158 else doWrite=false 156 else doWrite=false; 159 157 } 160 158 161 159 if (doWrite) 162 160 { 163 161 this->foperation->final(); 164 162 *last_Write = writeDate; 165 info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 166 CTimer::get("XIOS Send Data").resume() ; 167 sendUpdateData() ; 168 CTimer::get("XIOS Send Data").suspend() ; 169 return (true); 163 if (hasOutputFile) 164 { 165 info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 166 CTimer::get("XIOS Send Data").resume(); 167 sendUpdateData(); 168 CTimer::get("XIOS Send Data").suspend(); 169 } 170 171 if (hasFieldOut) 172 { 173 fieldOut->setDataFromExpression(data); 174 } 175 return (true); 170 176 } 171 177
Note: See TracChangeset
for help on using the changeset viewer.