Changeset 460
- Timestamp:
- 01/20/14 11:16:48 (11 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/attribute.hpp
r445 r460 42 42 // template <typename T> inline bool isType(void) const; 43 43 virtual void set(const CAttribute& ) =0 ; 44 virtual void reset(void ) =0 ; 44 45 /// Destructeur /// 45 46 virtual ~CAttribute(void); -
XIOS/trunk/src/attribute_array.hpp
r445 r460 36 36 void set(const CAttribute& attr) ; 37 37 void set(const CAttributeArray& attr) ; 38 38 void reset(void) ; 39 39 void setInheritedValue(const CAttributeArray& attr ); 40 40 void setInheritedValue(const CAttribute& attr ); -
XIOS/trunk/src/attribute_array_impl.hpp
r447 r460 41 41 ///-------------------------------------------------------------- 42 42 43 template <typename T_numtype, int N_rank> 44 void CAttributeArray<T_numtype, N_rank>::reset(void) 45 { 46 CArray<T_numtype, N_rank>::reset() ; 47 inheritedValue.reset() ; 48 } 49 43 50 template <typename T_numtype, int N_rank> 44 51 CArray<T_numtype,N_rank> CAttributeArray<T_numtype, N_rank>::getValue(void) const -
XIOS/trunk/src/attribute_enum.hpp
r445 r460 39 39 void set(const CAttribute& attr) ; 40 40 void set(const CAttributeEnum& attr) ; 41 void reset(void); 41 42 42 43 void setInheritedValue(const CAttributeEnum& attr ); -
XIOS/trunk/src/attribute_enum_impl.hpp
r445 r460 44 44 45 45 ///-------------------------------------------------------------- 46 46 template <class T> 47 void CAttributeEnum<T>::reset(void) 48 { 49 CEnum<T>::reset() ; 50 inheritedValue.reset() ; 51 } 52 47 53 template <class T> 48 54 typename T::t_enum CAttributeEnum<T>::getValue(void) const -
XIOS/trunk/src/attribute_template.hpp
r445 r460 48 48 void set(const CAttribute& attr) ; 49 49 void set(const CAttributeTemplate& attr) ; 50 void reset(void) ; 50 51 51 52 void setInheritedValue(const CAttributeTemplate& attr ); -
XIOS/trunk/src/attribute_template_impl.hpp
r445 r460 60 60 */ 61 61 ///-------------------------------------------------------------- 62 template <class T> 63 void CAttributeTemplate<T>::reset(void) 64 { 65 CType<T>::reset() ; 66 inheritedValue.reset() ; 67 } 68 62 69 63 70 template <class T> -
XIOS/trunk/src/node/field.cpp
r459 r460 25 25 , last_Write(), last_operation() 26 26 , foperation(), hasInstantData(false), hasExpression(false) 27 , active(false) , hasOutputFile(false), slotUpdateDate(NULL)27 , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL) 28 28 , processed(false) 29 29 { /* Ne rien faire de plus */ } … … 37 37 , last_Write(), last_operation() 38 38 , foperation(), hasExpression(false) 39 , active(false), hasOutputFile(false), slotUpdateDate(NULL)39 , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL) 40 40 , processed(false) 41 41 { /* Ne rien faire de plus */ } … … 387 387 using namespace func; 388 388 389 if (!hasOutputFile ) return ;389 if (!hasOutputFile && !hasFieldOut) return ; 390 390 391 391 StdString id ; … … 418 418 if (context->hasServer) 419 419 { 420 this->freq_operation_srv = 421 CDuration::FromString(this->file->output_freq.getValue()); 422 this->freq_write_srv = 423 CDuration::FromString(this->file->output_freq.getValue()); 420 if (hasOutputFile) 421 { 422 this->freq_operation_srv =CDuration::FromString(this->file->output_freq.getValue()); 423 this->freq_write_srv = CDuration::FromString(this->file->output_freq.getValue()); 424 } 424 425 this->lastlast_Write_srv = boost::shared_ptr<CDate> 425 426 (new CDate(context->getCalendar()->getInitDate())); … … 431 432 // boost::shared_ptr<func::CFunctor>(new CInstant(this->data_srv)); 432 433 433 const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep(); 434 *this->last_operation_srv = *this->last_operation_srv - toffset; 434 if (hasOutputFile) 435 { 436 const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep(); 437 *this->last_operation_srv = *this->last_operation_srv - toffset; 438 } 435 439 } 436 440 … … 438 442 // { 439 443 this->freq_operation = CDuration::FromString(freq_op.getValue()); 440 this->freq_write = CDuration::FromString(this->file->output_freq.getValue()); 444 if (hasOutputFile) this->freq_write = CDuration::FromString(this->file->output_freq.getValue()); 445 if (hasFieldOut) 446 { 447 this->freq_write = CDuration::FromString(this->fieldOut->freq_op.getValue()); 448 } 441 449 this->last_Write = boost::shared_ptr<CDate> 442 450 (new CDate(context->getCalendar()->getInitDate())); … … 665 673 expression=CFieldNode::newNode(simpleExpr) ; 666 674 delete simpleExpr ; 667 set<string> fieldIds ; 668 expression->getFieldIds(fieldIds) ; 669 for (set<string>::iterator it=fieldIds.begin() ; it!=fieldIds.end();++it) if (*it!="this") CField::get(*it)->processEnabledField() ; 670 671 expression->reduce(this) ; 672 673 slots.resize(fieldIds.size()) ; 675 set<string> instantFieldIds ; 676 map<string,CField*> associatedInstantFieldIds ; 677 expression->getInstantFieldIds(instantFieldIds) ; 678 for (set<string>::iterator it=instantFieldIds.begin() ; it!=instantFieldIds.end();++it) 679 { 680 if (*it!="this") 681 { 682 if (CField::has(*it)) 683 { 684 CField* field=CField::get(*it) ; 685 field->processEnabledField() ; 686 associatedInstantFieldIds[*it]=field ; 687 } 688 else ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ; 689 } 690 } 691 692 set<string> averageFieldIds ; 693 map<string,CField*> associatedAverageFieldIds ; 694 695 expression->getAverageFieldIds(averageFieldIds) ; 696 for (set<string>::iterator it=averageFieldIds.begin() ; it!=averageFieldIds.end();++it) 697 { 698 if (CField::has(*it)) 699 { 700 CFieldGroup* root=CFieldGroup::get("field_definition") ; 701 CField* averageField=root->createChild() ; 702 CField* instantField=root->createChild() ; 703 averageField->field_ref=*it ; 704 averageField->hasFieldOut=true ; 705 averageField->fieldOut=instantField ; 706 instantField->freq_op=freq_op ; 707 averageField-> processEnabledField() ; 708 cout<<" outputfreq of averageField "<< freq_op <<" "<<instantField->freq_op<<" "<< averageField->freq_write << endl ; 709 instantField->SuperClassAttribute::setAttributes(averageField, true); 710 instantField->field_ref.reset() ; 711 instantField->operation.reset() ; 712 713 instantField-> processEnabledField() ; 714 associatedAverageFieldIds[*it]=instantField ; 715 } 716 else ERROR("void CField::buildExpression(void)",<<" Field "<<*it<<" does not exist") ; 717 } 718 719 expression->reduce(this,associatedInstantFieldIds,associatedAverageFieldIds) ; 720 721 slots.resize(instantFieldIds.size()+averageFieldIds.size()) ; 674 722 resetSlots() ; 675 723 int slotId=0 ; -
XIOS/trunk/src/node/field.hpp
r459 r460 95 95 template <int N> bool updateData(const CArray<double, N>& data); 96 96 bool updateDataFromExpression(const CArray<double, 1>& data); 97 void setDataFromExpression(const CArray<double, 1>& _data) ; 97 98 98 99 bool updateDataServer … … 107 108 bool active ; 108 109 bool hasOutputFile ; 110 bool hasFieldOut ; 109 111 110 112 /// Traitements /// … … 143 145 CGrid* grid ; 144 146 CFile* file; 147 CField* fieldOut ; 145 148 146 149 CDuration freq_operation, freq_write; -
XIOS/trunk/src/node/field_impl.hpp
r459 r460 28 28 29 29 for (; it != end; it++) (*it)->setData(_data) ; 30 if (hasOutputFile ) updateData(_data) ;30 if (hasOutputFile || hasFieldOut) updateData(_data) ; 31 31 } 32 32 33 33 } 34 34 35 void CField::setDataFromExpression(const CArray<double, 1>& _data) 36 { 37 if (hasInstantData) 38 { 39 instantData=_data; 40 for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it) it->first->setSlot(it->second) ; 41 } 42 43 if (!hasExpression) 44 { 45 const std::vector<CField*>& refField=getAllReference(); 46 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) ; 50 } 51 52 } 35 53 36 54 template <int N> … … 82 100 this->foperation->final(); 83 101 *last_Write = writeDate; 84 info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 85 CTimer::get("XIOS Send Data").resume() ; 86 sendUpdateData() ; 87 CTimer::get("XIOS Send Data").suspend() ; 102 if (hasOutputFile) 103 { 104 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() ; 108 } 109 110 if (hasFieldOut) 111 { 112 fieldOut->setDataFromExpression(data) ; 113 } 88 114 return (true); 89 115 } -
XIOS/trunk/src/parse_expr/expr_node.cpp
r458 r460 34 34 }; 35 35 36 void CInstantFieldNode::reduce(CField* thisField )36 void CInstantFieldNode::reduce(CField* thisField, map<string,CField*>& associatedInstantField, map<string,CField*>& associatedAverageField) 37 37 { 38 38 if (!reduced) … … 44 44 reduced=true ; 45 45 } 46 else if (CField::has(fieldId))46 else 47 47 { 48 field =CField::get(fieldId);48 field=associatedInstantField[fieldId] ; 49 49 array=field->getInstantData() ; 50 50 reduced=true ; 51 51 } 52 else ERROR("void CInstantFieldNode::reduce(void)",<<" Field "<<fieldId<<" does not exist") 53 } 52 } 54 53 } 55 54 56 void CAverageFieldNode::reduce(CField* thisField )55 void CAverageFieldNode::reduce(CField* thisField, map<string,CField*>& associatedInstantField, map<string,CField*>& associatedAverageField) 57 56 { 58 57 if (!reduced) 59 58 { 60 if (CField::has(fieldId)) 61 { 62 field=thisField ; 63 array=CField::get(fieldId)->getInstantData() ; 64 reduced=true ; 65 } 66 else ERROR("void CAverageFieldNode::reduce(void)",<<" Field "<<fieldId<<" does not exist") 67 } 59 field=associatedAverageField[fieldId] ; 60 array=field->getInstantData() ; 61 reduced=true ; 62 } 68 63 } 69 64 -
XIOS/trunk/src/parse_expr/expr_node.hpp
r458 r460 193 193 CFieldNode(void) : CNodeExpr() {} 194 194 static CFieldNode* newNode(CSimpleNodeExpr* simpleNode) ; 195 virtual void reduce(CField* thisField = NULL) =0 ;195 virtual void reduce(CField* thisField, map<string,CField*>& associatedInstantField, map<string,CField*>& associatedAverageField) =0 ; 196 196 virtual CArray<double,1> compute(void)=0 ; 197 197 virtual void getFieldIds(set<string>& fieldIds)=0 ; 198 virtual void getInstantFieldIds(set<string>& fieldIds)=0 ; 199 virtual void getAverageFieldIds(set<string>& fieldIds)=0 ; 198 200 virtual void getFields(set<CField*>& fields)=0 ; 201 virtual void getInstantFields(set<CField*>& fields)=0 ; 202 virtual void getAverageFields(set<CField*>& fields)=0 ; 199 203 200 204 virtual ~CFieldNode() {} … … 212 216 public: 213 217 CInstantFieldNode(CSimpleNodeExpr* simpleNode) : CFieldNode(), fieldId(simpleNode->id) {} 214 virtual void reduce(CField* thisField = NULL) ;218 virtual void reduce(CField* thisField, map<string,CField*>& associatedInstantField, map<string,CField*>& associatedAverageField) ; 215 219 virtual CArray<double,1> compute(void) { return CArray<double,1>(*array);} 216 220 virtual ~CInstantFieldNode() { } 217 221 virtual void getFieldIds(set<string>& fieldIds) { fieldIds.insert(fieldId) ;} 222 virtual void getInstantFieldIds(set<string>& fieldIds) { fieldIds.insert(fieldId) ;} 223 virtual void getAverageFieldIds(set<string>& fieldIds) { } 218 224 virtual void getFields(set<CField*>& fields) { fields.insert(field) ;} 225 virtual void getInstantFields(set<CField*>& fields) { fields.insert(field) ;} 226 virtual void getAverageFields(set<CField*>& fields) { } 219 227 220 228 string fieldId; … … 238 246 CAverageFieldNode(CSimpleNodeExpr* simpleNode) : CFieldNode(), fieldId(simpleNode->id) {} 239 247 240 virtual void reduce(CField* thisField = NULL) ;248 virtual void reduce(CField* thisField, map<string,CField*>& associatedInstantField, map<string,CField*>& associatedAverageField) ; 241 249 virtual CArray<double,1> compute(void) { return CArray<double,1>(*array); } 242 250 virtual void getFieldIds(set<string>& fieldIds) { fieldIds.insert(fieldId) ;} 251 virtual void getInstantFieldIds(set<string>& fieldIds) { } 252 virtual void getAverageFieldIds(set<string>& fieldIds) { fieldIds.insert(fieldId) ;} 243 253 virtual void getFields(set<CField*>& fields) { fields.insert(field) ;} 254 virtual void getInstantFields(set<CField*>& fields) { } 255 virtual void getAverageFields(set<CField*>& fields) { fields.insert(field) ;} 244 256 virtual ~CAverageFieldNode() {} 245 257 string fieldId; … … 264 276 } 265 277 266 virtual void reduce(CField* thisField = NULL)267 { 268 child->reduce(thisField ) ;278 virtual void reduce(CField* thisField, map<string,CField*>& associatedInstantField, map<string,CField*>& associatedAverageField) 279 { 280 child->reduce(thisField, associatedInstantField, associatedAverageField) ; 269 281 op=operatorExpr.getOpField(opId) ; 270 282 reduced=true ; … … 272 284 273 285 virtual void getFieldIds(set<string>& fieldIds) {child-> getFieldIds(fieldIds);} 274 virtual void getFields(set<CField*>& fields) {child-> getFields(fields);} 275 286 virtual void getInstantFieldIds(set<string>& fieldIds) {child-> getInstantFieldIds(fieldIds) ;} 287 virtual void getAverageFieldIds(set<string>& fieldIds) {child-> getAverageFieldIds(fieldIds) ;} 288 virtual void getFields(set<CField*>& fields) { child-> getFields(fields) ;} 289 virtual void getInstantFields(set<CField*>& fields) {child-> getInstantFields(fields) ; } 290 virtual void getAverageFields(set<CField*>& fields) {child-> getAverageFields(fields) ; } 276 291 virtual CArray<double,1> compute(void) 277 292 { … … 303 318 } 304 319 305 virtual void reduce(CField* thisField = NULL)306 { 307 child1->reduce(thisField ) ;308 child2->reduce(thisField ) ;320 virtual void reduce(CField* thisField, map<string,CField*>& associatedInstantField, map<string,CField*>& associatedAverageField) 321 { 322 child1->reduce(thisField, associatedInstantField, associatedAverageField) ; 323 child2->reduce(thisField, associatedInstantField, associatedAverageField) ; 309 324 op=operatorExpr.getOpFieldField(opId) ; 310 325 reduced=true ; … … 312 327 313 328 virtual void getFieldIds(set<string>& fieldIds) {child1-> getFieldIds(fieldIds); child2-> getFieldIds(fieldIds);} 329 virtual void getInstantFieldIds(set<string>& fieldIds) {child1-> getInstantFieldIds(fieldIds); child2-> getInstantFieldIds(fieldIds);} 330 virtual void getAverageFieldIds(set<string>& fieldIds) {child1-> getAverageFieldIds(fieldIds); child2-> getAverageFieldIds(fieldIds);} 314 331 virtual void getFields(set<CField*>& fields) {child1-> getFields(fields); child2-> getFields(fields);} 332 virtual void getInstantFields(set<CField*>& fields) {child1-> getInstantFields(fields); child2-> getInstantFields(fields);} 333 virtual void getAverageFields(set<CField*>& fields) {child1-> getAverageFields(fields); child2-> getAverageFields(fields);} 315 334 316 335 virtual CArray<double,1> compute(void) … … 344 363 } 345 364 346 virtual void reduce(CField* thisField = NULL)365 virtual void reduce(CField* thisField, map<string,CField*>& associatedInstantField, map<string,CField*>& associatedAverageField) 347 366 { 348 367 child1->reduce() ; 349 child2->reduce(thisField ) ;368 child2->reduce(thisField, associatedInstantField, associatedAverageField) ; 350 369 op=operatorExpr.getOpScalarField(opId) ; 351 370 reduced=true ; … … 353 372 354 373 virtual void getFieldIds(set<string>& fieldIds) {child2-> getFieldIds(fieldIds);} 374 virtual void getInstantFieldIds(set<string>& fieldIds) {child2-> getInstantFieldIds(fieldIds);} 375 virtual void getAverageFieldIds(set<string>& fieldIds) {child2-> getAverageFieldIds(fieldIds);} 355 376 virtual void getFields(set<CField*>& fields) {child2-> getFields(fields);} 377 virtual void getInstantFields(set<CField*>& fields) {child2-> getInstantFields(fields);} 378 virtual void getAverageFields(set<CField*>& fields) {child2-> getAverageFields(fields);} 356 379 357 380 virtual CArray<double,1> compute(void) … … 385 408 } 386 409 387 virtual void reduce(CField* thisField = NULL)388 { 389 child1->reduce(thisField ) ;410 virtual void reduce(CField* thisField, map<string,CField*>& associatedInstantField, map<string,CField*>& associatedAverageField) 411 { 412 child1->reduce(thisField, associatedInstantField, associatedAverageField) ; 390 413 child2->reduce() ; 391 414 op=operatorExpr.getOpFieldScalar(opId) ; … … 399 422 400 423 virtual void getFieldIds(set<string>& fieldIds) {child1-> getFieldIds(fieldIds);} 424 virtual void getInstantFieldIds(set<string>& fieldIds) {child1-> getInstantFieldIds(fieldIds);} 425 virtual void getAverageFieldIds(set<string>& fieldIds) {child1-> getAverageFieldIds(fieldIds);} 401 426 virtual void getFields(set<CField*>& fields) {child1-> getFields(fields);} 427 virtual void getInstantFields(set<CField*>& fields) {child1-> getInstantFields(fields);} 428 virtual void getAverageFields(set<CField*>& fields) {child1-> getAverageFields(fields);} 402 429 403 430 ~COperatorFieldScalarNode() {delete child1, delete child2; }
Note: See TracChangeset
for help on using the changeset viewer.