- Timestamp:
- 11/13/14 15:09:14 (9 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/inputs/COMPLETE/context_surface.xml
r489 r509 7 7 <field id="field_A_srf_K" name="field_A_srf_K" field_ref="field_A_srf" long_name="Champ en degK" unit="degK"> field_A_srf + 273.15 </field> 8 8 <field id="field_A_srf_max" name="field_A_srf_max" field_ref="field_A_srf" long_name="maximum field_A_srf" operation="maximum" /> 9 <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C" > field_A_srf + field_ C_srf</field>9 <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C" > field_A_srf + field_A_srf_K </field> 10 10 11 11 </field_definition> … … 31 31 <variable id="my_attribute1" type="string" >surf_att</variable> 32 32 <variable id="my_attribute2" type="integer" >10</variable> 33 <variable id="my_attribute3" type="float" > 6.8</variable>33 <variable id="my_attribute3" type="float" >7.8</variable> 34 34 <variable id="my_attribute4" type="double" >100.201</variable> 35 35 </field> 36 <field field_ref="field_D_srf" /> 36 37 <field field_ref="field_A_srf_K" /> 37 38 <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" /> -
XIOS/trunk/src/attribute_map.cpp
r501 r509 13 13 CAttributeMap::~CAttributeMap(void) 14 14 { /* Ne rien faire de plus */ } 15 15 16 16 ///-------------------------------------------------------------- 17 17 … … 30 30 31 31 bool CAttributeMap::hasAttribute(const StdString & key) const 32 { 33 return (this->find(key) != this->end()); 34 } 35 36 //--------------------------------------------------------------- 37 32 { 33 return (this->find(key) != this->end()); 34 } 35 36 void CAttributeMap::clearAttribute(const StdString& key) 37 { 38 if (hasAttribute(key)) this->find(key)->second->reset(); 39 } 40 41 //--------------------------------------------------------------- 42 38 43 void CAttributeMap::setAttribute(const StdString & key, CAttribute * const attr) 39 44 { … … 47 52 // this->find(key)->second->setAnyValue(attr->getAnyValue()); 48 53 } 49 50 //--------------------------------------------------------------- 51 54 55 //--------------------------------------------------------------- 56 52 57 CAttribute * CAttributeMap::operator[](const StdString & key) 53 58 { … … 57 62 return (SuperClassMap::operator[](key)); 58 63 } 59 60 //--------------------------------------------------------------- 61 64 65 //--------------------------------------------------------------- 66 62 67 StdString CAttributeMap::toString(void) const 63 68 { 64 69 typedef std::pair<StdString, CAttribute*> StdStrAttPair; 65 70 StdOStringStream oss; 66 71 67 72 SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); 68 73 for (; it != end; it++) … … 74 79 return (oss.str()); 75 80 } 76 77 //--------------------------------------------------------------- 78 81 82 //--------------------------------------------------------------- 83 79 84 void CAttributeMap::fromString(const StdString & str) 80 { 85 { 81 86 ERROR("CAttributeMap::fromString(const StdString & str)", 82 << "[ str = " << str << "] Not implemented yet !"); 83 } 84 87 << "[ str = " << str << "] Not implemented yet !"); 88 } 89 85 90 //--------------------------------------------------------------- 86 91 87 92 //StdOStream & operator << (StdOStream & os, const CAttributeMap & attributmap) 88 93 //{ os << attributmap.toString(); return (os); } 89 90 //--------------------------------------------------------------- 91 94 95 //--------------------------------------------------------------- 96 92 97 void CAttributeMap::setAttributes(const xml::THashAttributes & attributes) 93 98 { … … 104 109 } 105 110 } 106 107 //--------------------------------------------------------------- 108 111 112 //--------------------------------------------------------------- 113 114 /*! 115 \brief Set attributes from a specific attributemap, considered parent. 116 The child attribute map will insert the attributes of its parent into its current attribute map. 117 The existing attributes can be filled with the values of the parent map if they are empty or 118 simply replaced by these values depending on choice of user. 119 \param [in] _parent Attribute map from which the current map gets attributes. 120 \param [in] apply Specify if current attribute map is replaced by the attributes of parent (false) 121 or filled in in case of emptyp (true) 122 */ 109 123 void CAttributeMap::setAttributes(const CAttributeMap * const _parent, bool apply) 110 124 { 111 125 typedef std::pair<StdString, CAttribute*> StdStrAttPair; 112 126 113 127 SuperClassMap::const_iterator it = _parent->begin(), end = _parent->end(); 114 128 for (; it != end; it++) … … 130 144 } 131 145 } 132 133 //--------------------------------------------------------------- 134 /* 146 147 //--------------------------------------------------------------- 148 /* 135 149 void CAttributeMap::toBinary(StdOStream & os) const 136 150 { 137 151 typedef std::pair<StdString, CAttribute*> StdStrAttPair; 138 152 SuperClassMap::const_iterator it = this->begin(), end = this->end(); 139 153 140 154 const StdSize nbatt = SuperClassMap::size(); 141 155 os.write (reinterpret_cast<const char*>(&nbatt) , sizeof(StdSize)); 142 156 143 157 for (; it != end; it++) 144 158 { 145 159 const StdString & key = it->first; 146 const CAttribute* value = it->second; 160 const CAttribute* value = it->second; 147 161 const StdSize size = key.size(); 148 162 149 163 os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize)); 150 164 os.write (key.data(), size * sizeof(char)); 151 165 152 166 if (!value->isEmpty()) 153 167 { … … 156 170 value->toBinary(os); 157 171 } 158 else 172 else 159 173 { 160 174 bool b = false; … … 163 177 } 164 178 } 165 166 //--------------------------------------------------------------- 167 179 180 //--------------------------------------------------------------- 181 168 182 void CAttributeMap::fromBinary(StdIStream & is) 169 183 { 170 184 StdSize nbatt = 0; 171 185 is.read (reinterpret_cast<char*>(&nbatt), sizeof(StdSize)); 172 186 173 187 for (StdSize i = 0; i < nbatt; i++) 174 188 { … … 178 192 StdString key(size, ' '); 179 193 is.read (const_cast<char *>(key.data()), size * sizeof(char)); 180 194 181 195 if (!this->hasAttribute(key)) 182 196 ERROR("CAttributeMap::fromBinary(StdIStream & is)", 183 197 << "[ key = " << key << "] key not found !"); 184 198 185 199 is.read (reinterpret_cast<char*>(&hasValue), sizeof(bool)); 186 187 if (hasValue) 200 201 if (hasValue) 188 202 this->operator[](key)->fromBinary(is); 189 203 } 190 204 } 191 */ 205 */ 192 206 void CAttributeMap::generateCInterface(ostream& oss, const string& className) 193 207 { … … 208 222 it->second->generateFortran2003Interface(oss,className) ; 209 223 it->second->generateFortran2003InterfaceIsDefined(oss,className) ; 210 224 211 225 oss<<iendl<<iendl ; 212 226 } 213 } 214 227 } 228 215 229 ///-------------------------------------------------------------- 216 230 … … 221 235 SuperClassMap::const_iterator it ; 222 236 SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); 223 224 oss2=new ostringstream ; 225 226 *oss2<<"( "<<className<<"_hdl" ; 227 228 for ( it=begin ; it != end; it++) 237 238 oss2=new ostringstream ; 239 240 *oss2<<"( "<<className<<"_hdl" ; 241 242 for ( it=begin ; it != end; it++) 229 243 { 230 244 *oss2<<", "<<it->second->getName()<<"_" ; 231 if (oss2->str().size()>90) 232 { 233 oss<<oss2->str()<<" &"<<iendl ; 234 delete oss2 ; 235 oss2=new ostringstream ; 236 } 237 } 238 *oss2<<" )" ; 239 oss<<oss2->str()<<iendl ; 240 oss<<iendl ; 241 delete oss2 ; 242 245 if (oss2->str().size()>90) 246 { 247 oss<<oss2->str()<<" &"<<iendl ; 248 delete oss2 ; 249 oss2=new ostringstream ; 250 } 251 } 252 *oss2<<" )" ; 253 oss<<oss2->str()<<iendl ; 254 oss<<iendl ; 255 delete oss2 ; 256 243 257 oss<<"IMPLICIT NONE"<<iendl++ ; 244 258 oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; 245 259 246 260 for (it=begin; it != end; it++) 247 261 { 248 262 it->second->generateFortranInterfaceDeclaration_(oss,className) ; 249 263 } 250 251 oss<<iendl ; 252 264 265 oss<<iendl ; 266 253 267 for (it=begin; it != end; it++) 254 268 { … … 256 270 oss<<iendl ; 257 271 } 258 272 259 273 oss<<iendl--<<iendl-- ; 260 274 oss<<"END SUBROUTINE xios(set_"<<className<<"_attr_hdl_)"<<iendl ; 261 262 } 275 276 } 263 277 264 278 void CAttributeMap::generateFortranInterfaceGet_hdl_(ostream& oss, const string& className) … … 268 282 SuperClassMap::const_iterator it ; 269 283 SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); 270 271 oss2=new ostringstream ; 272 273 *oss2<<"( "<<className<<"_hdl" ; 274 275 for ( it=begin ; it != end; it++) 284 285 oss2=new ostringstream ; 286 287 *oss2<<"( "<<className<<"_hdl" ; 288 289 for ( it=begin ; it != end; it++) 276 290 { 277 291 *oss2<<", "<<it->second->getName()<<"_" ; 278 if (oss2->str().size()>90) 279 { 280 oss<<oss2->str()<<" &"<<iendl ; 281 delete oss2 ; 282 oss2=new ostringstream ; 283 } 284 } 285 *oss2<<" )" ; 286 oss<<oss2->str()<<iendl ; 287 oss<<iendl ; 288 delete oss2 ; 289 292 if (oss2->str().size()>90) 293 { 294 oss<<oss2->str()<<" &"<<iendl ; 295 delete oss2 ; 296 oss2=new ostringstream ; 297 } 298 } 299 *oss2<<" )" ; 300 oss<<oss2->str()<<iendl ; 301 oss<<iendl ; 302 delete oss2 ; 303 290 304 oss<<"IMPLICIT NONE"<<iendl++ ; 291 305 oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; 292 306 293 307 for (it=begin; it != end; it++) 294 308 { 295 309 it->second->generateFortranInterfaceGetDeclaration_(oss,className) ; 296 310 } 297 298 oss<<iendl ; 299 311 312 oss<<iendl ; 313 300 314 for (it=begin; it != end; it++) 301 315 { … … 303 317 oss<<iendl ; 304 318 } 305 319 306 320 oss<<iendl--<<iendl-- ; 307 321 oss<<"END SUBROUTINE xios(get_"<<className<<"_attr_hdl_)"<<iendl ; 308 309 } 310 322 323 } 324 311 325 312 326 void CAttributeMap::generateFortranInterfaceIsDefined_hdl_(ostream& oss, const string& className) … … 316 330 SuperClassMap::const_iterator it ; 317 331 SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); 318 319 oss2=new ostringstream ; 320 321 *oss2<<"( "<<className<<"_hdl" ; 322 323 for ( it=begin ; it != end; it++) 332 333 oss2=new ostringstream ; 334 335 *oss2<<"( "<<className<<"_hdl" ; 336 337 for ( it=begin ; it != end; it++) 324 338 { 325 339 *oss2<<", "<<it->second->getName()<<"_" ; 326 if (oss2->str().size()>90) 327 { 328 oss<<oss2->str()<<" &"<<iendl ; 329 delete oss2 ; 330 oss2=new ostringstream ; 331 } 332 } 333 *oss2<<" )" ; 334 oss<<oss2->str()<<iendl ; 335 oss<<iendl ; 336 delete oss2 ; 337 340 if (oss2->str().size()>90) 341 { 342 oss<<oss2->str()<<" &"<<iendl ; 343 delete oss2 ; 344 oss2=new ostringstream ; 345 } 346 } 347 *oss2<<" )" ; 348 oss<<oss2->str()<<iendl ; 349 oss<<iendl ; 350 delete oss2 ; 351 338 352 oss<<"IMPLICIT NONE"<<iendl++ ; 339 353 oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; 340 354 341 355 for (it=begin; it != end; it++) 342 356 { 343 357 it->second->generateFortranInterfaceIsDefinedDeclaration_(oss,className) ; 344 358 } 345 346 oss<<iendl ; 347 359 360 oss<<iendl ; 361 348 362 for (it=begin; it != end; it++) 349 363 { … … 351 365 oss<<iendl ; 352 366 } 353 367 354 368 oss<<iendl--<<iendl-- ; 355 369 oss<<"END SUBROUTINE xios(is_defined_"<<className<<"_attr_hdl_)"<<iendl ; 356 357 } 358 370 371 } 372 359 373 360 374 void CAttributeMap::generateFortranInterface_hdl(ostream& oss, const string& className) … … 364 378 SuperClassMap::const_iterator it ; 365 379 SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); 366 367 oss2=new ostringstream ; 368 *oss2<<"( "<<className<<"_hdl" ; 369 for ( it=begin ; it != end; it++) 370 { 371 *oss2<<", "<<it->second->getName() ; 372 if (oss2->str().size()>90) 373 { 374 oss<<oss2->str()<<" &"<<iendl ; 375 delete oss2 ; 376 oss2=new ostringstream ; 377 } 378 } 379 *oss2<<" )" ; 380 oss<<oss2->str()<<iendl ; 381 oss<<iendl ; 382 delete oss2 ; 383 oss2=new ostringstream ; 384 380 381 oss2=new ostringstream ; 382 *oss2<<"( "<<className<<"_hdl" ; 383 for ( it=begin ; it != end; it++) 384 { 385 *oss2<<", "<<it->second->getName() ; 386 if (oss2->str().size()>90) 387 { 388 oss<<oss2->str()<<" &"<<iendl ; 389 delete oss2 ; 390 oss2=new ostringstream ; 391 } 392 } 393 *oss2<<" )" ; 394 oss<<oss2->str()<<iendl ; 395 oss<<iendl ; 396 delete oss2 ; 397 oss2=new ostringstream ; 398 385 399 oss<<"IMPLICIT NONE"<<iendl++ ; 386 400 oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; 387 401 388 402 for (it=begin; it != end; it++) 389 403 { 390 404 it->second->generateFortranInterfaceDeclaration(oss,className) ; 391 405 } 392 393 oss<<iendl ; 394 406 407 oss<<iendl ; 408 395 409 oss<<"CALL xios(set_"<<className<<"_attr_hdl_) &"<<iendl ; 396 397 *oss2<<"( "<<className<<"_hdl" ; 398 for ( it=begin ; it != end; it++) 399 { 400 *oss2<<", "<<it->second->getName() ; 401 if (oss2->str().size()>90) 410 411 *oss2<<"( "<<className<<"_hdl" ; 412 for ( it=begin ; it != end; it++) 413 { 414 *oss2<<", "<<it->second->getName() ; 415 if (oss2->str().size()>90) 402 416 { 403 417 oss<<oss2->str()<<" &"<<iendl ; … … 408 422 *oss2<<" )" ; 409 423 oss<<oss2->str() ; 410 delete oss2 ; 411 424 delete oss2 ; 425 412 426 oss<<iendl--<<iendl-- ; 413 427 oss<<"END SUBROUTINE xios(set_"<<className<<"_attr_hdl)"<<iendl ; 414 } 415 416 428 } 429 430 417 431 void CAttributeMap::generateFortranInterfaceGet_hdl(ostream& oss, const string& className) 418 432 { … … 421 435 SuperClassMap::const_iterator it ; 422 436 SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); 423 424 oss2=new ostringstream ; 425 *oss2<<"( "<<className<<"_hdl" ; 426 for ( it=begin ; it != end; it++) 427 { 428 *oss2<<", "<<it->second->getName() ; 429 if (oss2->str().size()>90) 430 { 431 oss<<oss2->str()<<" &"<<iendl ; 432 delete oss2 ; 433 oss2=new ostringstream ; 434 } 435 } 436 *oss2<<" )" ; 437 oss<<oss2->str()<<iendl ; 438 oss<<iendl ; 439 delete oss2 ; 440 oss2=new ostringstream ; 441 437 438 oss2=new ostringstream ; 439 *oss2<<"( "<<className<<"_hdl" ; 440 for ( it=begin ; it != end; it++) 441 { 442 *oss2<<", "<<it->second->getName() ; 443 if (oss2->str().size()>90) 444 { 445 oss<<oss2->str()<<" &"<<iendl ; 446 delete oss2 ; 447 oss2=new ostringstream ; 448 } 449 } 450 *oss2<<" )" ; 451 oss<<oss2->str()<<iendl ; 452 oss<<iendl ; 453 delete oss2 ; 454 oss2=new ostringstream ; 455 442 456 oss<<"IMPLICIT NONE"<<iendl++ ; 443 457 oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; 444 458 445 459 for (it=begin; it != end; it++) 446 460 { 447 461 it->second->generateFortranInterfaceGetDeclaration(oss,className) ; 448 462 } 449 450 oss<<iendl ; 451 463 464 oss<<iendl ; 465 452 466 oss<<"CALL xios(get_"<<className<<"_attr_hdl_) &"<<iendl ; 453 454 *oss2<<"( "<<className<<"_hdl" ; 455 for ( it=begin ; it != end; it++) 456 { 457 *oss2<<", "<<it->second->getName() ; 458 if (oss2->str().size()>90) 467 468 *oss2<<"( "<<className<<"_hdl" ; 469 for ( it=begin ; it != end; it++) 470 { 471 *oss2<<", "<<it->second->getName() ; 472 if (oss2->str().size()>90) 459 473 { 460 474 oss<<oss2->str()<<" &"<<iendl ; … … 465 479 *oss2<<" )" ; 466 480 oss<<oss2->str() ; 467 delete oss2 ; 468 481 delete oss2 ; 482 469 483 oss<<iendl--<<iendl-- ; 470 484 oss<<"END SUBROUTINE xios(get_"<<className<<"_attr_hdl)"<<iendl ; 471 } 485 } 472 486 473 487 … … 478 492 SuperClassMap::const_iterator it ; 479 493 SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); 480 481 oss2=new ostringstream ; 482 *oss2<<"( "<<className<<"_hdl" ; 483 for ( it=begin ; it != end; it++) 484 { 485 *oss2<<", "<<it->second->getName() ; 486 if (oss2->str().size()>90) 487 { 488 oss<<oss2->str()<<" &"<<iendl ; 489 delete oss2 ; 490 oss2=new ostringstream ; 491 } 492 } 493 *oss2<<" )" ; 494 oss<<oss2->str()<<iendl ; 495 oss<<iendl ; 496 delete oss2 ; 497 oss2=new ostringstream ; 498 494 495 oss2=new ostringstream ; 496 *oss2<<"( "<<className<<"_hdl" ; 497 for ( it=begin ; it != end; it++) 498 { 499 *oss2<<", "<<it->second->getName() ; 500 if (oss2->str().size()>90) 501 { 502 oss<<oss2->str()<<" &"<<iendl ; 503 delete oss2 ; 504 oss2=new ostringstream ; 505 } 506 } 507 *oss2<<" )" ; 508 oss<<oss2->str()<<iendl ; 509 oss<<iendl ; 510 delete oss2 ; 511 oss2=new ostringstream ; 512 499 513 oss<<"IMPLICIT NONE"<<iendl++ ; 500 514 oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; 501 515 502 516 for (it=begin; it != end; it++) 503 517 { 504 518 it->second->generateFortranInterfaceIsDefinedDeclaration(oss,className) ; 505 519 } 506 507 oss<<iendl ; 508 520 521 oss<<iendl ; 522 509 523 oss<<"CALL xios(is_defined_"<<className<<"_attr_hdl_) &"<<iendl ; 510 511 *oss2<<"( "<<className<<"_hdl" ; 512 for ( it=begin ; it != end; it++) 513 { 514 *oss2<<", "<<it->second->getName() ; 515 if (oss2->str().size()>90) 524 525 *oss2<<"( "<<className<<"_hdl" ; 526 for ( it=begin ; it != end; it++) 527 { 528 *oss2<<", "<<it->second->getName() ; 529 if (oss2->str().size()>90) 516 530 { 517 531 oss<<oss2->str()<<" &"<<iendl ; … … 522 536 *oss2<<" )" ; 523 537 oss<<oss2->str() ; 524 delete oss2 ; 525 538 delete oss2 ; 539 526 540 oss<<iendl--<<iendl-- ; 527 541 oss<<"END SUBROUTINE xios(is_defined_"<<className<<"_attr_hdl)"<<iendl ; 528 } 529 530 542 } 543 544 531 545 void CAttributeMap::generateFortranInterface_id(ostream& oss, const string& className) 532 546 { … … 535 549 SuperClassMap::const_iterator it ; 536 550 SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); 537 551 538 552 oss2=new ostringstream ; 539 553 *oss2<<"( "<<className<<"_id" ; 540 for ( it=begin ; it != end; it++) 541 { 542 *oss2<<", "<<it->second->getName() ; 543 if (oss2->str().size()>90) 544 { 545 oss<<oss2->str()<<" &"<<iendl ; 546 delete oss2 ; 547 oss2=new ostringstream ; 548 } 549 } 550 *oss2<<" )" ; 551 oss<<oss2->str()<<iendl ; 552 oss<<iendl ; 553 delete oss2 ; 554 oss2=new ostringstream ; 555 554 for ( it=begin ; it != end; it++) 555 { 556 *oss2<<", "<<it->second->getName() ; 557 if (oss2->str().size()>90) 558 { 559 oss<<oss2->str()<<" &"<<iendl ; 560 delete oss2 ; 561 oss2=new ostringstream ; 562 } 563 } 564 *oss2<<" )" ; 565 oss<<oss2->str()<<iendl ; 566 oss<<iendl ; 567 delete oss2 ; 568 oss2=new ostringstream ; 569 556 570 oss<<"IMPLICIT NONE"<<iendl++ ; 557 571 558 572 oss<<"TYPE(txios("<<className<<")) :: "<<className<<"_hdl"<<iendl ; 559 573 oss<<"CHARACTER(LEN=*), INTENT(IN) ::"<<className<<"_id"<<iendl ; 560 574 561 575 for (it=begin; it != end; it++) 562 576 { 563 577 it->second->generateFortranInterfaceDeclaration(oss,className) ; 564 578 } 565 566 oss<<iendl ; 567 oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ; 579 580 oss<<iendl ; 581 oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ; 568 582 oss<<"CALL xios(set_"<<className<<"_attr_hdl_) &"<<iendl ; 569 583 *oss2<<"( "<<className<<"_hdl" ; 570 for ( it=begin ; it != end; it++) 571 { 572 *oss2<<", "<<it->second->getName() ; 573 if (oss2->str().size()>90) 584 for ( it=begin ; it != end; it++) 585 { 586 *oss2<<", "<<it->second->getName() ; 587 if (oss2->str().size()>90) 574 588 { 575 589 oss<<oss2->str()<<" &"<<iendl ; … … 580 594 *oss2<<" )" ; 581 595 oss<<oss2->str() ; 582 delete oss2 ; 583 596 delete oss2 ; 597 584 598 oss<<iendl--<<iendl-- ; 585 599 oss<<"END SUBROUTINE xios(set_"<<className<<"_attr)"<<iendl ; 586 587 } 588 600 601 } 602 589 603 void CAttributeMap::generateFortranInterfaceGet_id(ostream& oss, const string& className) 590 604 { … … 593 607 SuperClassMap::const_iterator it ; 594 608 SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); 595 609 596 610 oss2=new ostringstream ; 597 611 *oss2<<"( "<<className<<"_id" ; 598 for ( it=begin ; it != end; it++) 599 { 600 *oss2<<", "<<it->second->getName() ; 601 if (oss2->str().size()>90) 602 { 603 oss<<oss2->str()<<" &"<<iendl ; 604 delete oss2 ; 605 oss2=new ostringstream ; 606 } 607 } 608 *oss2<<" )" ; 609 oss<<oss2->str()<<iendl ; 610 oss<<iendl ; 611 delete oss2 ; 612 oss2=new ostringstream ; 613 612 for ( it=begin ; it != end; it++) 613 { 614 *oss2<<", "<<it->second->getName() ; 615 if (oss2->str().size()>90) 616 { 617 oss<<oss2->str()<<" &"<<iendl ; 618 delete oss2 ; 619 oss2=new ostringstream ; 620 } 621 } 622 *oss2<<" )" ; 623 oss<<oss2->str()<<iendl ; 624 oss<<iendl ; 625 delete oss2 ; 626 oss2=new ostringstream ; 627 614 628 oss<<"IMPLICIT NONE"<<iendl++ ; 615 629 616 630 oss<<"TYPE(txios("<<className<<")) :: "<<className<<"_hdl"<<iendl ; 617 631 oss<<"CHARACTER(LEN=*), INTENT(IN) ::"<<className<<"_id"<<iendl ; 618 632 619 633 for (it=begin; it != end; it++) 620 634 { 621 635 it->second->generateFortranInterfaceGetDeclaration(oss,className) ; 622 636 } 623 624 oss<<iendl ; 625 oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ; 637 638 oss<<iendl ; 639 oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ; 626 640 oss<<"CALL xios(get_"<<className<<"_attr_hdl_) &"<<iendl ; 627 641 *oss2<<"( "<<className<<"_hdl" ; 628 for ( it=begin ; it != end; it++) 629 { 630 *oss2<<", "<<it->second->getName() ; 631 if (oss2->str().size()>90) 642 for ( it=begin ; it != end; it++) 643 { 644 *oss2<<", "<<it->second->getName() ; 645 if (oss2->str().size()>90) 632 646 { 633 647 oss<<oss2->str()<<" &"<<iendl ; … … 638 652 *oss2<<" )" ; 639 653 oss<<oss2->str() ; 640 delete oss2 ; 641 654 delete oss2 ; 655 642 656 oss<<iendl--<<iendl-- ; 643 657 oss<<"END SUBROUTINE xios(get_"<<className<<"_attr)"<<iendl ; 644 645 } 646 658 659 } 660 647 661 void CAttributeMap::generateFortranInterfaceIsDefined_id(ostream& oss, const string& className) 648 662 { … … 651 665 SuperClassMap::const_iterator it ; 652 666 SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); 653 667 654 668 oss2=new ostringstream ; 655 669 *oss2<<"( "<<className<<"_id" ; 656 for ( it=begin ; it != end; it++) 657 { 658 *oss2<<", "<<it->second->getName() ; 659 if (oss2->str().size()>90) 660 { 661 oss<<oss2->str()<<" &"<<iendl ; 662 delete oss2 ; 663 oss2=new ostringstream ; 664 } 665 } 666 *oss2<<" )" ; 667 oss<<oss2->str()<<iendl ; 668 oss<<iendl ; 669 delete oss2 ; 670 oss2=new ostringstream ; 671 670 for ( it=begin ; it != end; it++) 671 { 672 *oss2<<", "<<it->second->getName() ; 673 if (oss2->str().size()>90) 674 { 675 oss<<oss2->str()<<" &"<<iendl ; 676 delete oss2 ; 677 oss2=new ostringstream ; 678 } 679 } 680 *oss2<<" )" ; 681 oss<<oss2->str()<<iendl ; 682 oss<<iendl ; 683 delete oss2 ; 684 oss2=new ostringstream ; 685 672 686 oss<<"IMPLICIT NONE"<<iendl++ ; 673 687 674 688 oss<<"TYPE(txios("<<className<<")) :: "<<className<<"_hdl"<<iendl ; 675 689 oss<<"CHARACTER(LEN=*), INTENT(IN) ::"<<className<<"_id"<<iendl ; 676 690 677 691 for (it=begin; it != end; it++) 678 692 { 679 693 it->second->generateFortranInterfaceIsDefinedDeclaration(oss,className) ; 680 694 } 681 682 oss<<iendl ; 683 oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ; 695 696 oss<<iendl ; 697 oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ; 684 698 oss<<"CALL xios(is_defined_"<<className<<"_attr_hdl_) &"<<iendl ; 685 699 *oss2<<"( "<<className<<"_hdl" ; 686 for ( it=begin ; it != end; it++) 687 { 688 *oss2<<", "<<it->second->getName() ; 689 if (oss2->str().size()>90) 700 for ( it=begin ; it != end; it++) 701 { 702 *oss2<<", "<<it->second->getName() ; 703 if (oss2->str().size()>90) 690 704 { 691 705 oss<<oss2->str()<<" &"<<iendl ; … … 696 710 *oss2<<" )" ; 697 711 oss<<oss2->str() ; 698 delete oss2 ; 699 712 delete oss2 ; 713 700 714 oss<<iendl--<<iendl-- ; 701 715 oss<<"END SUBROUTINE xios(is_defined_"<<className<<"_attr)"<<iendl ; 702 703 } 716 717 } 704 718 ///-------------------------------------------------------------- 705 719 706 720 707 721 } // namespace xmlioser -
XIOS/trunk/src/attribute_map.hpp
r501 r509 33 33 void clearAllAttributes(void); 34 34 35 void clearAttribute(const StdString& key); 36 35 37 /// Destructeur /// 36 38 virtual ~CAttributeMap(void); … … 43 45 virtual StdString toString(void) const; 44 46 virtual void fromString(const StdString & str); 45 47 46 48 // virtual void toBinary (StdOStream & os) const; 47 49 // virtual void fromBinary(StdIStream & is); -
XIOS/trunk/src/buffer_client.cpp
r501 r509 10 10 namespace xios 11 11 { 12 12 13 13 size_t maxRequestSize=0 ; 14 15 CClientBuffer::CClientBuffer(MPI_Comm interComm_,int serverRank_ )14 15 CClientBuffer::CClientBuffer(MPI_Comm interComm_,int serverRank_, StdSize bfSize) 16 16 { 17 bufferSizeByServer= CXios::bufferSize ;17 bufferSizeByServer=bfSize; //CXios::bufferSize ; 18 18 info(10)<<"bufferSizeByServer "<<bufferSizeByServer<<endl ; 19 19 interComm=interComm_ ; 20 20 serverRank=serverRank_ ; 21 bufferSize=bufferSizeByServer/2 ;21 bufferSize=bufferSizeByServer/2; //2 ; 22 22 buffer[0]=new char[bufferSize] ; // transform it with MPI_ALLOC_MEM later 23 23 buffer[1]=new char[bufferSize] ; … … 27 27 retBuffer=new CBufferOut(buffer[current],bufferSize) ; 28 28 } 29 29 30 30 CClientBuffer::~CClientBuffer() 31 31 { … … 34 34 delete retBuffer ; 35 35 } 36 36 37 37 int CClientBuffer::remain(void) 38 38 { 39 39 return bufferSize-count ; 40 40 } 41 41 42 42 bool CClientBuffer::isBufferFree(int size) 43 43 { 44 44 if (size>maxRequestSize) maxRequestSize=size ; 45 45 46 46 if (size>bufferSize) ERROR("CClientBuffer::hasSpace(int size)", 47 47 <<"request size is too big for buffer, increase buffer client size"<<endl 48 48 <<"Current buffer_size : "<<CXios::bufferSize<<endl 49 49 <<"buffer_size must be > "<<size*2<<endl) 50 50 51 51 if (size<=remain()) return true ; 52 52 else return false ; 53 53 } 54 55 54 55 56 56 CBufferOut* CClientBuffer::getBuffer(int size) 57 57 { … … 68 68 return NULL ; 69 69 } 70 71 } 72 70 71 } 72 73 73 bool CClientBuffer::checkBuffer(void) 74 74 { 75 75 MPI_Status status ; 76 76 int flag ; 77 77 78 78 if (pending) 79 79 { … … 97 97 return pending ; 98 98 } 99 99 100 100 bool CClientBuffer::hasPendingRequest(void) 101 101 { … … 104 104 else return false ; 105 105 } 106 107 108 109 } 110 106 107 108 109 } 110 -
XIOS/trunk/src/buffer_client.hpp
r501 r509 5 5 #include "buffer_out.hpp" 6 6 #include "mpi.hpp" 7 #include "cxios.hpp" 7 8 8 9 namespace xios 9 10 { 10 11 extern size_t maxRequestSize ; 11 12 12 13 class CClientBuffer 13 14 { 14 15 15 16 public: 16 17 CClientBuffer(MPI_Comm intercomm,int serverRank ) ;17 18 CClientBuffer(MPI_Comm intercomm,int serverRank, StdSize bfSize = CXios::bufferSize) ; 18 19 ~CClientBuffer() ; 19 20 bool isBufferFree(int size) ; 20 CBufferOut* getBuffer(int size) ; 21 CBufferOut* getBuffer(int size) ; 21 22 bool checkBuffer(void) ; 22 23 bool hasPendingRequest(void) ; 23 24 24 25 char* buffer[2] ; 25 26 int remain(void) ; … … 30 31 int serverRank ; 31 32 bool pending ; 32 33 33 34 size_t bufferSizeByServer ; 34 35 35 36 MPI_Request request ; 36 37 CBufferOut* retBuffer; 37 38 CBufferOut* retBuffer; 38 39 MPI_Comm interComm ; 39 40 } ; -
XIOS/trunk/src/buffer_server.cpp
r501 r509 2 2 #include "exception.hpp" 3 3 #include "buffer_server.hpp" 4 #include "cxios.hpp" 4 5 5 6 6 namespace xios 7 7 { 8 8 9 CServerBuffer::CServerBuffer( void)9 CServerBuffer::CServerBuffer(StdSize buffSize) 10 10 { 11 bufferSizeByClient= CXios::bufferSize*CXios::bufferServerFactorSize ;11 bufferSizeByClient= buffSize * CXios::bufferServerFactorSize; //::bufferSize*CXios::bufferServerFactorSize ; 12 12 size=bufferSizeByClient ; 13 13 first=0 ; … … 21 21 delete [] buffer ; 22 22 } 23 23 24 24 25 25 bool CServerBuffer::isBufferFree(size_t count) 26 26 { 27 27 bool ret ; 28 28 29 29 if (count==0) return true ; 30 30 31 31 if (current>first) 32 32 { … … 72 72 return ret ; 73 73 } 74 74 75 75 76 76 void* CServerBuffer::getBuffer(size_t count) 77 77 { 78 78 char* ret ; 79 79 80 80 if (count==0) return buffer+current ; 81 81 82 82 if (current>first) 83 83 { … … 131 131 return ret ; 132 132 } 133 133 134 134 void CServerBuffer::freeBuffer(size_t count) 135 135 { 136 136 if (count==0) return ; 137 137 138 if (first==end-1) 138 if (first==end-1) 139 139 { 140 140 first=0 ; … … 145 145 if (first<=current) 146 146 { 147 if (first+count <current) 147 if (first+count <current) 148 148 { 149 149 first+=count ; … … 154 154 <<"cannot free required size in buffer") ; 155 155 } 156 156 157 157 } 158 158 else … … 168 168 } 169 169 } 170 } 171 170 } 171 172 172 } -
XIOS/trunk/src/buffer_server.hpp
r501 r509 5 5 #include "buffer.hpp" 6 6 #include "mpi.hpp" 7 #include "cxios.hpp" 7 8 8 9 namespace xios … … 11 12 class CServerBuffer 12 13 { 13 14 14 15 public: 15 16 CServerBuffer( void) ;16 17 CServerBuffer(StdSize bufSize = CXios::bufferSize) ; 17 18 ~CServerBuffer() ; 18 19 char* buffer ; 19 20 20 21 bool isBufferFree(size_t count) ; 21 22 void* getBuffer(size_t count) ; 22 23 void freeBuffer(size_t count) ; 23 24 24 25 size_t first ; // first occupied element 25 26 size_t current ; // first free element … … 28 29 size_t bufferSizeByClient ; 29 30 } ; 30 31 31 32 32 33 } -
XIOS/trunk/src/context_client.cpp
r501 r509 17 17 18 18 19 CContextClient::CContextClient(CContext* parent,MPI_Comm intraComm_, MPI_Comm interComm_) 19 CContextClient::CContextClient(CContext* parent,MPI_Comm intraComm_, MPI_Comm interComm_) : mapBufferSize_() 20 20 { 21 21 context=parent ; … … 24 24 MPI_Comm_rank(intraComm,&clientRank) ; 25 25 MPI_Comm_size(intraComm,&clientSize) ; 26 26 27 27 int flag ; 28 28 MPI_Comm_test_inter(interComm,&flag) ; 29 29 if (flag) MPI_Comm_remote_size(interComm,&serverSize); 30 30 else MPI_Comm_size(interComm,&serverSize) ; 31 31 32 32 timeLine=0 ; 33 33 … … 39 39 list<int>::iterator itServer ; 40 40 list<int> ranks ; 41 list<int> sizes ; 41 list<int> sizes ; 42 42 list<int>::iterator itSize ; 43 43 44 44 ranks=event.getRanks() ; 45 45 if (! event.isEmpty()) … … 51 51 for(list<int>::iterator it=sizes.begin();it!=sizes.end();it++) *it+=msg.size() ; 52 52 list<CBufferOut*> buffList=getBuffers(ranks,sizes) ; 53 54 list<CBufferOut*>::iterator it ; 53 54 list<CBufferOut*>::iterator it ; 55 55 for(it=buffList.begin(),itSize=sizes.begin();it!=buffList.end();++it,++itSize) 56 56 { … … 64 64 timeLine++ ; 65 65 } 66 66 67 void CContextClient::sendBufferSizeEvent() 68 { 69 std::map<int, CClientBuffer*>::iterator it, itE; 70 std::map<int, StdSize>::const_iterator itMap = mapBufferSize_.begin(), iteMap = mapBufferSize_.end(); 71 72 if (itMap == iteMap) 73 ERROR("CBufferOut* CContextClient::sendBufferSizeEvent() ;", 74 <<"No information about server buffer, that should not happen..."); 75 76 for (; itMap != iteMap; ++iteMap) 77 { 78 if (buffers.end() == buffers.find(itMap->first)) 79 newBuffer(itMap->first); 80 } 81 82 CBufferOut* bufOut(NULL); 83 itE = buffers.end(); 84 for (it = buffers.begin(); it != itE; ++it) 85 { 86 bufOut = (it->second)->getBuffer(sizeof(StdSize)); 87 bufOut->put(mapBufferSize_[it->first]); // Stupid C++ 88 (it->second)->checkBuffer(); 89 } 90 } 91 67 92 void CContextClient::waitEvent(list<int>& ranks) 68 93 { … … 78 103 context->server->eventLoop() ; 79 104 } 80 105 81 106 } 82 107 … … 84 109 { 85 110 list<int>::iterator itServer,itSize ; 86 list<CClientBuffer*> bufferList ; 87 map<int,CClientBuffer*>::iterator it ; 88 list<CClientBuffer*>::iterator itBuffer ; 111 list<CClientBuffer*> bufferList ; 112 map<int,CClientBuffer*>::iterator it ; 113 list<CClientBuffer*>::iterator itBuffer ; 89 114 list<CBufferOut*> retBuffer ; 90 115 bool free ; 91 116 92 for(itServer=serverList.begin();itServer!=serverList.end();itServer++) 117 for(itServer=serverList.begin();itServer!=serverList.end();itServer++) 93 118 { 94 119 it=buffers.find(*itServer) ; 95 if (it==buffers.end()) 120 if (it==buffers.end()) 96 121 { 97 122 newBuffer(*itServer) ; 98 123 it=buffers.find(*itServer) ; 99 } 124 } 100 125 bufferList.push_back(it->second) ; 101 126 } … … 118 143 retBuffer.push_back((*itBuffer)->getBuffer(*itSize)) ; 119 144 } 120 return retBuffer ; 121 122 } 123 145 return retBuffer ; 146 147 } 148 124 149 void CContextClient::newBuffer(int rank) 125 150 { 126 buffers[rank]=new CClientBuffer(interComm,rank) ; 127 } 151 // buffers[rank]=new CClientBuffer(interComm,rank); 152 buffers[rank]=new CClientBuffer(interComm,rank, mapBufferSize_[rank]) ; 153 } 128 154 129 155 bool CContextClient::checkBuffers(void) … … 133 159 for(itBuff=buffers.begin();itBuff!=buffers.end();itBuff++) pending|=itBuff->second->checkBuffer() ; 134 160 return pending ; 135 } 161 } 136 162 137 163 void CContextClient::releaseBuffers(void) … … 139 165 map<int,CClientBuffer*>::iterator itBuff ; 140 166 for(itBuff=buffers.begin();itBuff!=buffers.end();itBuff++) delete itBuff->second ; 141 } 167 } 142 168 143 169 bool CContextClient::checkBuffers(list<int>& ranks) … … 147 173 for(it=ranks.begin();it!=ranks.end();it++) pending|=buffers[*it]->checkBuffer() ; 148 174 return pending ; 149 } 175 } 176 177 void CContextClient::setBufferSize(const std::map<int, StdSize>& mapSize) 178 { 179 mapBufferSize_ = mapSize; 180 sendBufferSizeEvent(); 181 } 150 182 151 183 int CContextClient::getServerLeader(void) … … 153 185 int clientByServer=clientSize/serverSize ; 154 186 int remain=clientSize%serverSize ; 155 187 156 188 if (clientRank<(clientByServer+1)*remain) 157 189 { … … 164 196 return remain+rank/clientByServer ; 165 197 } 166 } 198 } 167 199 168 200 bool CContextClient::isServerLeader(void) … … 170 202 int clientByServer=clientSize/serverSize ; 171 203 int remain=clientSize%serverSize ; 172 204 173 205 if (clientRank<(clientByServer+1)*remain) 174 206 { … … 182 214 if (rank%clientByServer==0) return true ; 183 215 else return false ; 184 } 185 } 186 216 } 217 } 218 187 219 void CContextClient::finalize(void) 188 220 { 189 221 190 222 map<int,CClientBuffer*>::iterator itBuff ; 191 223 bool stop=true ; 192 224 193 CEventClient event(CContext::GetType(),CContext::EVENT_ID_CONTEXT_FINALIZE) ; 225 CEventClient event(CContext::GetType(),CContext::EVENT_ID_CONTEXT_FINALIZE) ; 194 226 if (isServerLeader()) 195 227 { … … 199 231 } 200 232 else sendEvent(event) ; 201 233 202 234 CTimer::get("Blocking time").resume(); 203 235 while(stop) … … 209 241 CTimer::get("Blocking time").suspend(); 210 242 report(0)<< " Memory report : Context <"<<context->getId()<<"> : client side : total memory used for buffer "<<buffers.size()*CXios::bufferSize<<" bytes"<<endl ; 211 243 212 244 releaseBuffers() ; 213 245 } 214 } 246 } -
XIOS/trunk/src/context_client.hpp
r501 r509 11 11 { 12 12 class CContext ; 13 13 14 14 class CContextClient 15 15 { 16 16 17 17 public: 18 18 CContextClient(CContext* parent,MPI_Comm intraComm, MPI_Comm interComm) ; 19 19 // void registerEvent(CEventClient& event) ; 20 20 21 // list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes) ; 21 // list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes) ; 22 22 void sendEvent(CEventClient& event) ; 23 23 … … 41 41 void waitEvent(list<int>& ranks) ; 42 42 43 void setBufferSize(const std::map<int, StdSize>& mapSize); 44 void sendBufferSizeEvent(); 45 43 46 CContext* context ; 47 48 private: 49 std::map<int, StdSize> mapBufferSize_; 44 50 // bool locked ; 45 51 46 52 } ; 47 53 -
XIOS/trunk/src/context_server.cpp
r501 r509 37 37 scheduled=false ; 38 38 finished=false ; 39 39 40 40 boost::hash<string> hashString ; 41 41 hashId=hashString(context->getId()) ; … … 80 80 it=buffers.find(rank) ; 81 81 if (it==buffers.end()) 82 it=(buffers.insert(pair<int,CServerBuffer*>(rank,new CServerBuffer))).first ;83 MPI_Get_count(&status,MPI_CHAR,&count) ;84 if (it->second->isBufferFree(count))85 82 { 86 addr=(char*)it->second->getBuffer(count) ; 87 MPI_Irecv(addr,count,MPI_CHAR,rank,20,interComm,&pendingRequest[rank]) ; 88 bufferRequest[rank]=addr ; 83 StdSize buffSize = 0; 84 MPI_Recv(&buffSize, 1, MPI_LONG, rank, 20, interComm, &status); 85 it=(buffers.insert(pair<int,CServerBuffer*>(rank,new CServerBuffer(buffSize)))).first ; 86 } 87 else 88 { 89 MPI_Get_count(&status,MPI_CHAR,&count) ; 90 if (it->second->isBufferFree(count)) 91 { 92 addr=(char*)it->second->getBuffer(count) ; 93 MPI_Irecv(addr,count,MPI_CHAR,rank,20,interComm,&pendingRequest[rank]) ; 94 bufferRequest[rank]=addr ; 95 } 89 96 } 90 97 } … … 158 165 { 159 166 event=it->second ; 160 167 161 168 if (event->isFull()) 162 169 { 163 170 if (!scheduled && !CXios::isServer) 164 171 { 165 CServer::eventScheduler->registerEvent(currentTimeLine,hashId) ; 172 CServer::eventScheduler->registerEvent(currentTimeLine,hashId) ; 166 173 scheduled=true ; 167 174 } 168 else if (CXios::isServer || CServer::eventScheduler->queryEvent(currentTimeLine,hashId) ) 175 else if (CXios::isServer || CServer::eventScheduler->queryEvent(currentTimeLine,hashId) ) 169 176 { 170 177 CTimer::get("Process events").resume() ; -
XIOS/trunk/src/cxios.cpp
r506 r509 47 47 void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 48 48 { 49 50 49 initialize() ; 51 50 … … 74 73 } 75 74 75 void CXios::initServer() 76 { 77 set_new_handler(noMemory); 78 std::set<StdString> parseList; 79 parseList.insert("xios"); 80 xml::CXMLParser::ParseFile(rootFile, parseList); 81 // parseFile(rootFile); 82 usingOasis=getin<bool>("using_oasis",false) ; 83 info.setLevel(getin<int>("info_level",0)) ; 84 printInfo2File=getin<bool>("print_file",false); 85 bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ; 86 bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ; 87 globalComm=MPI_COMM_WORLD ; 88 89 } 76 90 77 91 void CXios::initServerSide(void) 78 92 { 79 initialize();80 93 // initialize(); 94 initServer(); 81 95 isClient=true; 82 96 isServer=false ; -
XIOS/trunk/src/cxios.hpp
r501 r509 53 53 static bool isServerSide; 54 54 55 static void initServer(); 56 55 57 } ; 56 58 -
XIOS/trunk/src/generate_interface_impl.hpp
r501 r509 10 10 11 11 namespace xios 12 { 12 { 13 13 template<> string CInterface::getStrFortranType<int>(void) {return string("INTEGER") ;} 14 14 template<> string CInterface::getStrFortranType<bool>(void) {return string("LOGICAL") ;} 15 15 template<> string CInterface::getStrFortranType<double>(void) {return string("REAL") ;} 16 16 template<> string CInterface::getStrFortranType<float>(void) {return string("REAL") ;} 17 17 18 18 template<> string CInterface::getStrFortranKind<int>(void) {return string("") ;} 19 19 template<> string CInterface::getStrFortranKind<bool>(void) {return string("") ;} 20 20 template<> string CInterface::getStrFortranKind<double>(void) {return string("(KIND=8)") ;} 21 21 template<> string CInterface::getStrFortranKind<float>(void) {return string("(KIND=4)") ;} 22 22 23 23 template<> string CInterface::getStrFortranKindC<int>(void) {return string("(KIND=C_INT)") ;} 24 24 template<> string CInterface::getStrFortranKindC<bool>(void) {return string("(KIND=C_BOOL)") ;} 25 25 template<> string CInterface::getStrFortranKindC<double>(void) {return string("(KIND=C_DOUBLE)") ;} 26 26 template<> string CInterface::getStrFortranKindC<float>(void) {return string("(KIND=C_FLOAT)") ;} 27 28 template<> bool CInterface::matchingTypeCFortran<int>(void) { return true ; } 29 template<> bool CInterface::matchingTypeCFortran<bool>(void) { return false ;} 27 28 template<> bool CInterface::matchingTypeCFortran<int>(void) { return true ; } 29 template<> bool CInterface::matchingTypeCFortran<bool>(void) { return false ;} 30 30 template<> bool CInterface::matchingTypeCFortran<double>(void) { return true; } 31 31 template<> bool CInterface::matchingTypeCFortran<float>(void) { return true; } 32 32 33 33 34 34 // ///////////////////////////////////////////////// … … 36 36 // ///////////////////////////////////////////////// 37 37 38 38 39 39 void CInterface::AttributeIsDefinedCInterface(ostream& oss, const string& className,const string& name) 40 40 { … … 47 47 oss<<iendl ; 48 48 } 49 49 50 50 template <class T> 51 51 void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name) 52 52 { 53 53 string typeName=getStrType<T>() ; 54 54 55 55 oss<<"void cxios_set_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, "<< typeName<<" "<<name<<")"<<iendl ; 56 56 oss<<"{"<<iendl ; 57 57 oss<<" CTimer::get(\"XIOS\").resume();"<<iendl ; 58 58 oss<<" "<<className<<"_hdl->"<<name<<".setValue("<<name<<");"<<iendl ; 59 oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;59 // oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ; 60 60 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ; 61 61 oss<<"}"<<iendl ; 62 62 63 63 oss<<iendl ; 64 64 oss<<"void cxios_get_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, "<< typeName<<"* "<<name<<")"<<iendl ; … … 68 68 oss<<iendl ; 69 69 } 70 71 70 71 72 72 template<> 73 void CInterface::AttributeCInterface<string>(ostream& oss, const string& className,const string& name) 73 void CInterface::AttributeCInterface<string>(ostream& oss, const string& className,const string& name) 74 74 { 75 75 oss<<"void cxios_set_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, const char * "<<name<<", int "<<name<<"_size)"<<iendl ; … … 79 79 oss<<" CTimer::get(\"XIOS\").resume();"<<iendl ; 80 80 oss<<" "<<className<<"_hdl->"<<name<<".setValue("<<name<<"_str);"<<iendl ; 81 oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;81 // oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ; 82 82 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ; 83 83 oss<<"}"<<iendl ; 84 84 85 85 oss<<iendl ; 86 86 87 87 oss<<"void cxios_get_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, char * "<<name<<", int "<<name<<"_size)"<<iendl ; 88 88 oss<<"{"<<iendl ; … … 94 94 oss<<"}"<<iendl ; 95 95 oss<<iendl ; 96 96 97 97 } 98 98 99 99 template<> 100 void CInterface::AttributeCInterface<CEnumBase>(ostream& oss, const string& className,const string& name) 100 void CInterface::AttributeCInterface<CEnumBase>(ostream& oss, const string& className,const string& name) 101 101 { 102 102 oss<<"void cxios_set_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, const char * "<<name<<", int "<<name<<"_size)"<<iendl ; … … 106 106 oss<<" CTimer::get(\"XIOS\").resume();"<<iendl ; 107 107 oss<<" "<<className<<"_hdl->"<<name<<".fromString("<<name<<"_str);"<<iendl ; 108 oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;108 // oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ; 109 109 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ; 110 110 oss<<"}"<<iendl ; 111 111 112 112 oss<<iendl ; 113 113 114 114 oss<<"void cxios_get_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, char * "<<name<<", int "<<name<<"_size)"<<iendl ; 115 115 oss<<"{"<<iendl ; … … 121 121 oss<<"}"<<iendl ; 122 122 oss<<iendl ; 123 123 124 124 } 125 125 // if (!array_copy(domain_hdl->mask.getValue(), mask, extent1, extent2)) … … 139 139 oss<<" std::copy("<<name<<", &("<<name<<"[array_tmp->num_elements()]), array_tmp->data());"<<iendl ;\ 140 140 oss<<" "<<className<<"_hdl->"<<name<<".setValue(array_tmp);"<<iendl ;\ 141 oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\141 // oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 142 142 oss<<"}"<<iendl ;\ 143 143 oss<<iendl; \ … … 162 162 oss<<" std::copy("<<name<<", &("<<name<<"[array_tmp->num_elements()]), array_tmp->data());"<<iendl ;\ 163 163 oss<<" "<<className<<"_hdl->"<<name<<".setValue(array_tmp);"<<iendl ;\ 164 oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\164 // oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 165 165 oss<<"}"<<iendl ;\ 166 166 oss<<iendl; \ … … 185 185 oss<<" std::copy("<<name<<", &("<<name<<"[array_tmp->num_elements()]), array_tmp->data());"<<iendl ;\ 186 186 oss<<" "<<className<<"_hdl->"<<name<<".setValue(array_tmp);"<<iendl ;\ 187 oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\187 // oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 188 188 oss<<"}"<<iendl ;\ 189 189 oss<<iendl; \ … … 202 202 */ 203 203 204 #undef macro 204 #undef macro 205 205 206 206 // ///////////////////////////////////////////////// … … 213 213 oss<<" LOGICAL(kind=C_BOOL) :: cxios_is_defined_"<<className<<"_"<<name<<iendl; 214 214 oss<<" INTEGER (kind = C_INTPTR_T), VALUE :: "<<className<<"_hdl"<<iendl ; 215 oss<<"END FUNCTION cxios_is_defined_"<<className<<"_"<<name<<iendl ; 216 } 217 215 oss<<"END FUNCTION cxios_is_defined_"<<className<<"_"<<name<<iendl ; 216 } 217 218 218 template <class T> 219 219 void CInterface::AttributeFortran2003Interface(ostream& oss,const string& className,const string& name) … … 221 221 string fortranType=getStrFortranType<T>() ; 222 222 string fortranKindC=getStrFortranKindC<T>() ; 223 223 224 224 oss<<"SUBROUTINE cxios_set_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<") BIND(C)"<<iendl ; 225 225 oss<<" USE ISO_C_BINDING"<<iendl ; … … 227 227 oss<<" "<<fortranType<<" "<<fortranKindC<<" , VALUE :: "<<name<<iendl ; 228 228 oss<<"END SUBROUTINE cxios_set_"<<className<<"_"<<name<<iendl ; 229 oss<<iendl ; 229 oss<<iendl ; 230 230 oss<<"SUBROUTINE cxios_get_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<") BIND(C)"<<iendl ; 231 231 oss<<" USE ISO_C_BINDING"<<iendl ; … … 235 235 oss<<iendl ; 236 236 } 237 238 237 238 239 239 template <> 240 240 void CInterface::AttributeFortran2003Interface<string>(ostream& oss,const string& className,const string& name) 241 241 { 242 242 243 243 oss<<"SUBROUTINE cxios_set_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<", "<<name<<"_size) BIND(C)"<<iendl ; 244 244 oss<<" USE ISO_C_BINDING"<<iendl ; … … 247 247 oss<<" INTEGER (kind = C_INT) , VALUE :: "<<name<<"_size"<<iendl ; 248 248 oss<<"END SUBROUTINE cxios_set_"<<className<<"_"<<name<<iendl ; 249 oss<<iendl ; 249 oss<<iendl ; 250 250 oss<<"SUBROUTINE cxios_get_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<", "<<name<<"_size) BIND(C)"<<iendl ; 251 251 oss<<" USE ISO_C_BINDING"<<iendl ; … … 327 327 oss<<"END SUBROUTINE cxios_get_"<<className<<"_"<<name<<iendl ; \ 328 328 } 329 329 330 330 macro(bool) 331 331 macro(double) … … 333 333 334 334 #undef macro 335 */ 335 */ 336 336 template <class T> 337 337 void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss,const string& className,const string& name) … … 347 347 if (!matchingTypeCFortran<T>()) oss<<getStrFortranType<T>()<<" "<<getStrFortranKindC<T>()<<" :: "<<name<<"_tmp"<<iendl ; 348 348 } 349 349 350 350 void CInterface::AttributeFortranInterfaceIsDefinedDeclaration(ostream& oss,const string& className,const string& name) 351 351 { … … 353 353 oss<<"LOGICAL(KIND=C_BOOL) :: "<<name<<"_tmp"<<iendl ; 354 354 } 355 355 356 356 template <> 357 357 void CInterface::AttributeFortranInterfaceDeclaration<string>(ostream& oss,const string& className,const string& name) … … 359 359 oss<<"CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: "<<name<<iendl ; 360 360 } 361 361 362 362 template <> 363 363 void CInterface::AttributeFortranInterfaceGetDeclaration<string>(ostream& oss,const string& className,const string& name) … … 407 407 oss<<getStrFortranType<T>()<<" "<<getStrFortranKind<T>() <<" , OPTIONAL, INTENT(OUT) :: "<<name<<"(:,:,:)"<<iendl ; \ 408 408 if (!matchingTypeCFortran<T>()) oss<<getStrFortranType<T>()<<" "<<getStrFortranKindC<T>() <<" , ALLOCATABLE :: "<<name<<"_tmp(:,:,:)"<<iendl ; \ 409 } 410 409 } 410 411 411 macro(bool) 412 412 macro(double) … … 415 415 #undef macro 416 416 */ 417 417 418 418 template <class T> 419 419 void CInterface::AttributeFortranInterfaceBody(ostream& oss,const string& className,const string& name) 420 420 { 421 421 string name_tmp=name+"__tmp" ; 422 422 423 423 oss<<"IF (PRESENT("<<name<<"_)) THEN"<<iendl ; 424 if (!matchingTypeCFortran<T>()) 424 if (!matchingTypeCFortran<T>()) 425 425 { 426 426 oss<<" "<<name_tmp<<"="<<name<<"_"<<iendl ; … … 430 430 oss<<"ENDIF"<<iendl ; 431 431 } 432 432 433 433 template <class T> 434 434 void CInterface::AttributeFortranInterfaceGetBody(ostream& oss,const string& className,const string& name) 435 435 { 436 436 string name_tmp=name+"__tmp" ; 437 437 438 438 oss<<"IF (PRESENT("<<name<<"_)) THEN"<<iendl ; 439 if (!matchingTypeCFortran<T>()) 439 if (!matchingTypeCFortran<T>()) 440 440 { 441 441 oss<<" CALL cxios_get_"<<className<<"_"<<name<<"("<<className<<"_hdl%daddr, "<<name_tmp<<")"<<iendl ; … … 449 449 { 450 450 string name_tmp=name+"__tmp" ; 451 451 452 452 oss<<"IF (PRESENT("<<name<<"_)) THEN"<<iendl ; 453 453 oss<<" "<<name<<"__tmp=cxios_is_defined_"<<className<<"_"<<name<<"("<<className<<"_hdl%daddr)"<<iendl ; … … 455 455 oss<<"ENDIF"<<iendl ; 456 456 } 457 457 458 458 template <> 459 459 void CInterface::AttributeFortranInterfaceBody<string>(ostream& oss,const string& className,const string& name) … … 521 521 oss<<"ENDIF"<<iendl ; \ 522 522 } 523 523 524 524 macro(bool) 525 525 macro(double) … … 578 578 oss<<"ENDIF"<<iendl ; \ 579 579 } 580 580 581 581 macro(bool) 582 582 macro(double) … … 602 602 oss<<" CArray<"<<typeName<<",1> tmp("<<name<<",shape(extent1),neverDeleteData) ;"<<iendl ;\ 603 603 oss<<" "<<className<<"_hdl->"<<name<<".reference(tmp.copy());"<<iendl ;\ 604 oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\604 /* oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;*/\ 605 605 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ;\ 606 606 oss<<"}"<<iendl ;\ … … 626 626 oss<<" CArray<"<<typeName<<",2> tmp("<<name<<",shape(extent1,extent2),neverDeleteData) ;"<<iendl ;\ 627 627 oss<<" "<<className<<"_hdl->"<<name<<".reference(tmp.copy());"<<iendl ;\ 628 oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\628 /*oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;*/\ 629 629 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ;\ 630 630 oss<<"}"<<iendl ;\ … … 650 650 oss<<" CArray<"<<typeName<<",3> tmp("<<name<<",shape(extent1,extent2,extent3),neverDeleteData) ;"<<iendl ;\ 651 651 oss<<" "<<className<<"_hdl->"<<name<<".reference(tmp.copy());"<<iendl ;\ 652 oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\652 /*oss<<" "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;*/\ 653 653 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ;\ 654 654 oss<<"}"<<iendl ;\ … … 668 668 macro(int) 669 669 670 #undef macro 670 #undef macro 671 671 672 672 // ///////////////////////////////////////////////// … … 675 675 676 676 677 677 678 678 #define macro(T)\ 679 679 template <>\ … … 748 748 oss<<iendl ;\ 749 749 } 750 750 751 751 macro(bool) 752 752 macro(double) 753 753 macro(int) 754 754 755 755 #undef macro 756 756 757 757 758 758 #define macro(T)\ … … 796 796 oss<<getStrFortranType<T>()<<" "<<getStrFortranKind<T>() <<" , OPTIONAL, INTENT(OUT) :: "<<name<<"(:,:,:)"<<iendl ; \ 797 797 if (!matchingTypeCFortran<T>()) oss<<getStrFortranType<T>()<<" "<<getStrFortranKindC<T>() <<" , ALLOCATABLE :: "<<name<<"_tmp(:,:,:)"<<iendl ; \ 798 } 799 798 } 799 800 800 macro(bool) 801 801 macro(double) … … 804 804 #undef macro 805 805 806 806 807 807 808 808 #define macro(T) \ … … 854 854 oss<<"ENDIF"<<iendl ; \ 855 855 } 856 856 857 857 macro(bool) 858 858 macro(double) … … 909 909 oss<<"ENDIF"<<iendl ; \ 910 910 } 911 911 912 912 macro(bool) 913 913 macro(double) -
XIOS/trunk/src/interface/c/icdata.cpp
r501 r509 92 92 CTimer::get("XIOS close definition").resume() ; 93 93 CContext* context = CContext::getCurrent() ; 94 // context->setClientServerBuffer(); 94 95 context->closeDefinition() ; 95 96 CTimer::get("XIOS close definition").suspend() ; … … 257 258 { 258 259 CVariable::get(context->getId(),varIdStr)->setData<double>(data); 259 CVariable::get(context->getId(),varIdStr)->sendValue();260 //CVariable::get(context->getId(),varIdStr)->sendValue(); 260 261 } 261 262 … … 278 279 { 279 280 CVariable::get(context->getId(),varIdStr)->setData<float>(data); 280 CVariable::get(context->getId(),varIdStr)->sendValue();281 //CVariable::get(context->getId(),varIdStr)->sendValue(); 281 282 } 282 283 … … 299 300 { 300 301 CVariable::get(context->getId(),varIdStr)->setData<int>(data); 301 CVariable::get(context->getId(),varIdStr)->sendValue();302 //CVariable::get(context->getId(),varIdStr)->sendValue(); 302 303 } 303 304 … … 321 322 { 322 323 CVariable::get(context->getId(),varIdStr)->setData<bool>(data); 323 CVariable::get(context->getId(),varIdStr)->sendValue();324 //CVariable::get(context->getId(),varIdStr)->sendValue(); 324 325 } 325 326 … … 347 348 { 348 349 CVariable::get(context->getId(),varIdStr)->setData<string>(dataStr); 349 CVariable::get(context->getId(),varIdStr)->sendValue();350 //CVariable::get(context->getId(),varIdStr)->sendValue(); 350 351 } 351 352 -
XIOS/trunk/src/interface/c/icdate.cpp
r501 r509 31 31 CDuration dur = {ts_year, ts_month, ts_day, ts_hour, ts_minute, ts_second, 0}; 32 32 xios::CContext* context = CContext::getCurrent() ; 33 34 context->timestep.setValue(dur.toString()); 35 context->sendAttributToServer("timestep") ; 36 CTimer::get("XIOS").suspend() ; 33 context->timestep.setValue(dur.toString()); 34 CTimer::get("XIOS").suspend() ; 37 35 } 38 36 catch (xios::CException & exc) … … 42 40 } 43 41 } 44 42 45 43 void cxios_update_calendar(int step) 46 44 { … … 51 49 context->sendUpdateCalendar(step) ; 52 50 CTimer::get("XIOS").suspend() ; 53 54 51 } 55 52 -
XIOS/trunk/src/interface/c/icxml_tree.cpp
r501 r509 44 44 typedef xios::CAxis * XAxisPtr; 45 45 typedef xios::CAxisGroup * XAxisGroupPtr; 46 46 47 47 typedef xios::CVariable * XVariablePtr; 48 48 typedef xios::CVariableGroup * XVariableGroupPtr; 49 49 50 50 // ----------------------- Ajout d'enfant à un parent ----------------------- 51 51 52 52 void cxios_xml_tree_add_field 53 53 (XFieldGroupPtr parent_, XFieldPtr * child_, const char * child_id, int child_id_size) 54 54 { 55 std::string child_id_str; 56 CTimer::get("XIOS").resume() ; 57 if (cstr2string(child_id, child_id_size, child_id_str)) 58 { 59 *child_ = parent_->createChild(child_id_str) ; 60 parent_->sendCreateChild(child_id_str) ; 61 } 62 else 63 { 64 *child_ = parent_->createChild() ; 65 parent_->sendCreateChild() ; 55 std::string child_id_str; 56 CTimer::get("XIOS").resume() ; 57 if (cstr2string(child_id, child_id_size, child_id_str)) 58 { 59 *child_ = parent_->createChild(child_id_str) ; 60 } 61 else 62 { 63 *child_ = parent_->createChild() ; 66 64 } 67 65 CTimer::get("XIOS").suspend() ; 68 66 } 69 67 70 68 void cxios_xml_tree_add_grid 71 69 (XGridGroupPtr parent_, XGridPtr * child_, const char * child_id, int child_id_size) 72 70 { 73 std::string child_id_str; 74 CTimer::get("XIOS").resume() ; 75 if (cstr2string(child_id, child_id_size, child_id_str)) 76 { 77 *child_ = parent_->createChild(child_id_str) ; 78 parent_->sendCreateChild(child_id_str) ; 79 } 80 else 81 { 82 *child_ = parent_->createChild() ; 83 parent_->sendCreateChild() ; 84 } 85 CTimer::get("XIOS").suspend() ; 86 } 87 71 std::string child_id_str; 72 CTimer::get("XIOS").resume() ; 73 if (cstr2string(child_id, child_id_size, child_id_str)) 74 { 75 *child_ = parent_->createChild(child_id_str) ; 76 } 77 else 78 { 79 *child_ = parent_->createChild() ; 80 } 81 CTimer::get("XIOS").suspend() ; 82 } 83 88 84 void cxios_xml_tree_add_file 89 85 (XFileGroupPtr parent_, XFilePtr * child_, const char * child_id, int child_id_size) 90 86 { 91 std::string child_id_str; 92 CTimer::get("XIOS").resume() ; 93 if (cstr2string(child_id, child_id_size, child_id_str)) 94 { 95 *child_ = parent_->createChild(child_id_str) ; 96 parent_->sendCreateChild(child_id_str) ; 97 } 98 else 99 { 100 *child_ = parent_->createChild() ; 101 parent_->sendCreateChild() ; 102 } 103 CTimer::get("XIOS").suspend() ; 104 } 105 87 std::string child_id_str; 88 CTimer::get("XIOS").resume() ; 89 if (cstr2string(child_id, child_id_size, child_id_str)) 90 { 91 *child_ = parent_->createChild(child_id_str) ; 92 } 93 else 94 { 95 *child_ = parent_->createChild() ; 96 } 97 CTimer::get("XIOS").suspend() ; 98 } 99 106 100 void cxios_xml_tree_add_axis 107 101 (XAxisGroupPtr parent_, XAxisPtr * child_, const char * child_id, int child_id_size) 108 102 { 109 std::string child_id_str; 110 CTimer::get("XIOS").resume() ; 111 if (cstr2string(child_id, child_id_size, child_id_str)) 112 { 113 *child_ = parent_->createChild(child_id_str) ; 114 parent_->sendCreateChild(child_id_str) ; 115 } 116 else 117 { 118 *child_ = parent_->createChild() ; 119 parent_->sendCreateChild() ; 120 } 121 CTimer::get("XIOS").suspend() ; 122 } 123 103 std::string child_id_str; 104 CTimer::get("XIOS").resume() ; 105 if (cstr2string(child_id, child_id_size, child_id_str)) 106 { 107 *child_ = parent_->createChild(child_id_str) ; 108 } 109 else 110 { 111 *child_ = parent_->createChild() ; 112 } 113 CTimer::get("XIOS").suspend() ; 114 } 115 124 116 void cxios_xml_tree_add_domain 125 117 (XDomainGroupPtr parent_, XDomainPtr * child_, const char * child_id, int child_id_size) … … 130 122 { 131 123 *child_ = parent_->createChild(child_id_str) ; 132 parent_->sendCreateChild(child_id_str) ; 133 } 134 else 135 { 136 *child_ = parent_->createChild() ; 137 parent_->sendCreateChild() ; 138 } 139 CTimer::get("XIOS").suspend() ; 140 } 141 124 } 125 else 126 { 127 *child_ = parent_->createChild() ; 128 } 129 CTimer::get("XIOS").suspend() ; 130 } 131 142 132 void cxios_xml_tree_add_fieldtofile 143 133 (XFilePtr parent_, XFieldPtr * child_, const char * child_id, int child_id_size) … … 145 135 std::string child_id_str; 146 136 CTimer::get("XIOS").resume() ; 147 137 148 138 if (cstr2string(child_id, child_id_size, child_id_str)) 149 139 { 150 140 *child_ = parent_->addField(child_id_str); 151 parent_->sendAddField(child_id_str) ;152 141 } 153 142 else 154 143 { 155 144 *child_ = parent_->addField(); 156 parent_->sendAddField() ;157 145 } 158 146 CTimer::get("XIOS").suspend() ; … … 164 152 std::string child_id_str; 165 153 CTimer::get("XIOS").resume() ; 166 154 167 155 if (cstr2string(child_id, child_id_size, child_id_str)) 168 156 { 169 157 *child_ = parent_->addVariable(child_id_str); 170 parent_->sendAddVariable(child_id_str) ;171 158 } 172 159 else 173 160 { 174 161 *child_ = parent_->addVariable(); 175 parent_->sendAddVariable() ; 176 } 177 CTimer::get("XIOS").suspend() ; 178 } 179 162 } 163 CTimer::get("XIOS").suspend() ; 164 } 165 180 166 void cxios_xml_tree_add_variabletofield 181 167 (XFieldPtr parent_, XVariablePtr * child_, const char * child_id, int child_id_size) … … 183 169 std::string child_id_str; 184 170 CTimer::get("XIOS").resume() ; 185 171 186 172 if (cstr2string(child_id, child_id_size, child_id_str)) 187 173 { 188 174 *child_ = parent_->addVariable(child_id_str); 189 parent_->sendAddVariable(child_id_str) ;190 175 } 191 176 else 192 177 { 193 178 *child_ = parent_->addVariable(); 194 parent_->sendAddVariable() ; 195 } 196 CTimer::get("XIOS").suspend() ; 197 } 179 } 180 CTimer::get("XIOS").suspend() ; 181 } 198 182 // ----------------------- Ajout de groupe à un parent ---------------------- 199 183 … … 201 185 (XFieldGroupPtr parent_, XFieldGroupPtr * child_, const char * child_id, int child_id_size) 202 186 { 203 std::string child_id_str; 204 CTimer::get("XIOS").resume() ; 205 if (cstr2string(child_id, child_id_size, child_id_str)) 206 { 207 *child_ = parent_->createChildGroup(child_id_str) ; 208 parent_->sendCreateChildGroup(child_id_str) ; 209 } 210 else 211 { 212 *child_ = parent_->createChildGroup() ; 213 parent_->sendCreateChildGroup(child_id_str) ; 187 std::string child_id_str; 188 CTimer::get("XIOS").resume() ; 189 if (cstr2string(child_id, child_id_size, child_id_str)) 190 { 191 *child_ = parent_->createChildGroup(child_id_str) ; 192 } 193 else 194 { 195 *child_ = parent_->createChildGroup() ; 214 196 } 215 197 CTimer::get("XIOS").suspend() ; … … 224 206 { 225 207 *child_ = parent_->createChildGroup(child_id_str) ; 226 parent_->sendCreateChildGroup(child_id_str) ; 227 } 228 else 229 { 230 *child_ = parent_->createChildGroup() ; 231 parent_->sendCreateChildGroup(child_id_str) ; 208 } 209 else 210 { 211 *child_ = parent_->createChildGroup() ; 232 212 } 233 213 CTimer::get("XIOS").suspend() ; … … 242 222 { 243 223 *child_ = parent_->createChildGroup(child_id_str) ; 244 parent_->sendCreateChildGroup(child_id_str) ; 245 } 246 else 247 { 248 *child_ = parent_->createChildGroup() ; 249 parent_->sendCreateChildGroup(child_id_str) ; 224 } 225 else 226 { 227 *child_ = parent_->createChildGroup() ; 250 228 } 251 229 CTimer::get("XIOS").suspend() ; … … 260 238 { 261 239 *child_ = parent_->createChildGroup(child_id_str) ; 262 parent_->sendCreateChildGroup(child_id_str) ; 263 } 264 else 265 { 266 *child_ = parent_->createChildGroup() ; 267 parent_->sendCreateChildGroup(child_id_str) ; 240 } 241 else 242 { 243 *child_ = parent_->createChildGroup() ; 268 244 } 269 245 CTimer::get("XIOS").suspend() ; … … 278 254 { 279 255 *child_ = parent_->createChildGroup(child_id_str) ; 280 parent_->sendCreateChildGroup(child_id_str) ; 281 } 282 else 283 { 284 *child_ = parent_->createChildGroup() ; 285 parent_->sendCreateChildGroup(child_id_str) ; 256 } 257 else 258 { 259 *child_ = parent_->createChildGroup() ; 286 260 } 287 261 CTimer::get("XIOS").suspend() ; … … 291 265 (XFilePtr parent_, XFieldGroupPtr * child_, const char * child_id, int child_id_size) 292 266 { 293 std::string child_id_str; 267 std::string child_id_str; 294 268 CTimer::get("XIOS").resume() ; 295 269 if (cstr2string(child_id, child_id_size, child_id_str)) 296 270 { 297 271 *child_ = parent_->addFieldGroup(child_id_str); 298 parent_->sendAddFieldGroup(child_id_str) ;299 272 } 300 273 else 301 274 { 302 275 *child_ = parent_->addFieldGroup(); 303 parent_->sendAddFieldGroup() ; 304 } 305 CTimer::get("XIOS").suspend() ; 306 } 307 276 } 277 CTimer::get("XIOS").suspend() ; 278 } 279 308 280 void cxios_xml_tree_add_variablegrouptofile 309 281 (XFilePtr parent_, XVariableGroupPtr * child_, const char * child_id, int child_id_size) 310 282 { 311 std::string child_id_str; 283 std::string child_id_str; 312 284 CTimer::get("XIOS").resume() ; 313 285 if (cstr2string(child_id, child_id_size, child_id_str)) 314 286 { 315 287 *child_ = parent_->addVariableGroup(child_id_str); 316 parent_->sendAddVariableGroup(child_id_str) ;317 288 } 318 289 else 319 290 { 320 291 *child_ = parent_->addVariableGroup(); 321 parent_->sendAddVariableGroup() ; 322 } 323 CTimer::get("XIOS").suspend() ; 324 } 325 292 } 293 CTimer::get("XIOS").suspend() ; 294 } 295 326 296 void cxios_xml_tree_add_variablegrouptofield 327 297 (XFieldPtr parent_, XVariableGroupPtr * child_, const char * child_id, int child_id_size) 328 298 { 329 std::string child_id_str; 299 std::string child_id_str; 330 300 CTimer::get("XIOS").resume() ; 331 301 if (cstr2string(child_id, child_id_size, child_id_str)) 332 302 { 333 303 *child_ = parent_->addVariableGroup(child_id_str); 334 parent_->sendAddVariableGroup(child_id_str) ;335 304 } 336 305 else 337 306 { 338 307 *child_ = parent_->addVariableGroup(); 339 parent_->sendAddVariableGroup() ; 340 } 341 CTimer::get("XIOS").suspend() ; 342 } 343 344 308 } 309 CTimer::get("XIOS").suspend() ; 310 } 311 312 345 313 // ----------------------- Affichage de l'arborescence ---------------------- 346 347 // void cxios_xml_tree_show (const char * filename, int filename_size) 314 315 // void cxios_xml_tree_show (const char * filename, int filename_size) 348 316 // { 349 317 // std::string filename_str; … … 361 329 // } 362 330 // } 363 364 331 332 365 333 // ----------------------- Parsing de document xml -------------------------- 366 334 367 335 // void cxios_xml_parse_file (const char * filename , int filename_size)// 368 336 // { 369 // std::string filename_str; 337 // std::string filename_str; 370 338 // if (!cstr2string(filename, filename_size, filename_str)) return; 371 339 // … … 380 348 // } 381 349 // } 382 350 383 351 // void cxios_xml_parse_string(const char * xmlcontent, int xmlcontent_size) 384 352 // { 385 // std::string xmlcontent_str; 353 // std::string xmlcontent_str; 386 354 // if (!cstr2string(xmlcontent, xmlcontent_size, xmlcontent_str)) return; 387 355 // … … 396 364 // } 397 365 // } 398 366 399 367 400 368 -
XIOS/trunk/src/interface/c_attr/icaxis_attr.cpp
r501 r509 23 23 CTimer::get("XIOS").resume(); 24 24 axis_hdl->long_name.setValue(long_name_str); 25 axis_hdl->sendAttributToServer(axis_hdl->long_name);26 25 CTimer::get("XIOS").suspend(); 27 26 } … … 50 49 CTimer::get("XIOS").resume(); 51 50 axis_hdl->name.setValue(name_str); 52 axis_hdl->sendAttributToServer(axis_hdl->name);53 51 CTimer::get("XIOS").suspend(); 54 52 } … … 77 75 CTimer::get("XIOS").resume(); 78 76 axis_hdl->positive.fromString(positive_str); 79 axis_hdl->sendAttributToServer(axis_hdl->positive);80 77 CTimer::get("XIOS").suspend(); 81 78 } … … 102 99 CTimer::get("XIOS").resume(); 103 100 axis_hdl->size.setValue(size); 104 axis_hdl->sendAttributToServer(axis_hdl->size);105 101 CTimer::get("XIOS").suspend(); 106 102 } … … 126 122 CTimer::get("XIOS").resume(); 127 123 axis_hdl->standard_name.setValue(standard_name_str); 128 axis_hdl->sendAttributToServer(axis_hdl->standard_name);129 124 CTimer::get("XIOS").suspend(); 130 125 } … … 153 148 CTimer::get("XIOS").resume(); 154 149 axis_hdl->unit.setValue(unit_str); 155 axis_hdl->sendAttributToServer(axis_hdl->unit);156 150 CTimer::get("XIOS").suspend(); 157 151 } … … 179 173 CArray<double,1> tmp(value,shape(extent1),neverDeleteData) ; 180 174 axis_hdl->value.reference(tmp.copy()); 181 axis_hdl->sendAttributToServer(axis_hdl->value);182 175 CTimer::get("XIOS").suspend(); 183 176 } … … 204 197 CTimer::get("XIOS").resume(); 205 198 axis_hdl->zoom_begin.setValue(zoom_begin); 206 axis_hdl->sendAttributToServer(axis_hdl->zoom_begin);207 199 CTimer::get("XIOS").suspend(); 208 200 } … … 226 218 CTimer::get("XIOS").resume(); 227 219 axis_hdl->zoom_end.setValue(zoom_end); 228 axis_hdl->sendAttributToServer(axis_hdl->zoom_end);229 220 CTimer::get("XIOS").suspend(); 230 221 } … … 248 239 CTimer::get("XIOS").resume(); 249 240 axis_hdl->zoom_size.setValue(zoom_size); 250 axis_hdl->sendAttributToServer(axis_hdl->zoom_size);251 241 CTimer::get("XIOS").suspend(); 252 242 } -
XIOS/trunk/src/interface/c_attr/icaxisgroup_attr.cpp
r501 r509 23 23 CTimer::get("XIOS").resume(); 24 24 axisgroup_hdl->group_ref.setValue(group_ref_str); 25 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->group_ref);26 25 CTimer::get("XIOS").suspend(); 27 26 } … … 50 49 CTimer::get("XIOS").resume(); 51 50 axisgroup_hdl->long_name.setValue(long_name_str); 52 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->long_name);53 51 CTimer::get("XIOS").suspend(); 54 52 } … … 77 75 CTimer::get("XIOS").resume(); 78 76 axisgroup_hdl->name.setValue(name_str); 79 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->name);80 77 CTimer::get("XIOS").suspend(); 81 78 } … … 104 101 CTimer::get("XIOS").resume(); 105 102 axisgroup_hdl->positive.fromString(positive_str); 106 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->positive);107 103 CTimer::get("XIOS").suspend(); 108 104 } … … 129 125 CTimer::get("XIOS").resume(); 130 126 axisgroup_hdl->size.setValue(size); 131 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->size);132 127 CTimer::get("XIOS").suspend(); 133 128 } … … 153 148 CTimer::get("XIOS").resume(); 154 149 axisgroup_hdl->standard_name.setValue(standard_name_str); 155 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->standard_name);156 150 CTimer::get("XIOS").suspend(); 157 151 } … … 180 174 CTimer::get("XIOS").resume(); 181 175 axisgroup_hdl->unit.setValue(unit_str); 182 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->unit);183 176 CTimer::get("XIOS").suspend(); 184 177 } … … 206 199 CArray<double,1> tmp(value,shape(extent1),neverDeleteData) ; 207 200 axisgroup_hdl->value.reference(tmp.copy()); 208 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->value);209 201 CTimer::get("XIOS").suspend(); 210 202 } … … 231 223 CTimer::get("XIOS").resume(); 232 224 axisgroup_hdl->zoom_begin.setValue(zoom_begin); 233 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->zoom_begin);234 225 CTimer::get("XIOS").suspend(); 235 226 } … … 253 244 CTimer::get("XIOS").resume(); 254 245 axisgroup_hdl->zoom_end.setValue(zoom_end); 255 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->zoom_end);256 246 CTimer::get("XIOS").suspend(); 257 247 } … … 275 265 CTimer::get("XIOS").resume(); 276 266 axisgroup_hdl->zoom_size.setValue(zoom_size); 277 axisgroup_hdl->sendAttributToServer(axisgroup_hdl->zoom_size);278 267 CTimer::get("XIOS").suspend(); 279 268 } -
XIOS/trunk/src/interface/c_attr/iccontext_attr.cpp
r501 r509 23 23 CTimer::get("XIOS").resume(); 24 24 context_hdl->calendar_type.setValue(calendar_type_str); 25 context_hdl->sendAttributToServer(context_hdl->calendar_type);26 25 CTimer::get("XIOS").suspend(); 27 26 } … … 50 49 CTimer::get("XIOS").resume(); 51 50 context_hdl->output_dir.setValue(output_dir_str); 52 context_hdl->sendAttributToServer(context_hdl->output_dir);53 51 CTimer::get("XIOS").suspend(); 54 52 } … … 77 75 CTimer::get("XIOS").resume(); 78 76 context_hdl->start_date.setValue(start_date_str); 79 context_hdl->sendAttributToServer(context_hdl->start_date);80 77 CTimer::get("XIOS").suspend(); 81 78 } … … 104 101 CTimer::get("XIOS").resume(); 105 102 context_hdl->time_origin.setValue(time_origin_str); 106 context_hdl->sendAttributToServer(context_hdl->time_origin);107 103 CTimer::get("XIOS").suspend(); 108 104 } … … 131 127 CTimer::get("XIOS").resume(); 132 128 context_hdl->timestep.setValue(timestep_str); 133 context_hdl->sendAttributToServer(context_hdl->timestep);134 129 CTimer::get("XIOS").suspend(); 135 130 } -
XIOS/trunk/src/interface/c_attr/icdomain_attr.cpp
r501 r509 22 22 CArray<double,2> tmp(bounds_lat,shape(extent1,extent2),neverDeleteData) ; 23 23 domain_hdl->bounds_lat.reference(tmp.copy()); 24 domain_hdl->sendAttributToServer(domain_hdl->bounds_lat);25 24 CTimer::get("XIOS").suspend(); 26 25 } … … 48 47 CArray<double,2> tmp(bounds_lon,shape(extent1,extent2),neverDeleteData) ; 49 48 domain_hdl->bounds_lon.reference(tmp.copy()); 50 domain_hdl->sendAttributToServer(domain_hdl->bounds_lon);51 49 CTimer::get("XIOS").suspend(); 52 50 } … … 73 71 CTimer::get("XIOS").resume(); 74 72 domain_hdl->data_dim.setValue(data_dim); 75 domain_hdl->sendAttributToServer(domain_hdl->data_dim);76 73 CTimer::get("XIOS").suspend(); 77 74 } … … 96 93 CArray<int,1> tmp(data_i_index,shape(extent1),neverDeleteData) ; 97 94 domain_hdl->data_i_index.reference(tmp.copy()); 98 domain_hdl->sendAttributToServer(domain_hdl->data_i_index);99 95 CTimer::get("XIOS").suspend(); 100 96 } … … 121 117 CTimer::get("XIOS").resume(); 122 118 domain_hdl->data_ibegin.setValue(data_ibegin); 123 domain_hdl->sendAttributToServer(domain_hdl->data_ibegin);124 119 CTimer::get("XIOS").suspend(); 125 120 } … … 144 139 CArray<int,1> tmp(data_j_index,shape(extent1),neverDeleteData) ; 145 140 domain_hdl->data_j_index.reference(tmp.copy()); 146 domain_hdl->sendAttributToServer(domain_hdl->data_j_index);147 141 CTimer::get("XIOS").suspend(); 148 142 } … … 169 163 CTimer::get("XIOS").resume(); 170 164 domain_hdl->data_jbegin.setValue(data_jbegin); 171 domain_hdl->sendAttributToServer(domain_hdl->data_jbegin);172 165 CTimer::get("XIOS").suspend(); 173 166 } … … 191 184 CTimer::get("XIOS").resume(); 192 185 domain_hdl->data_n_index.setValue(data_n_index); 193 domain_hdl->sendAttributToServer(domain_hdl->data_n_index);194 186 CTimer::get("XIOS").suspend(); 195 187 } … … 213 205 CTimer::get("XIOS").resume(); 214 206 domain_hdl->data_ni.setValue(data_ni); 215 domain_hdl->sendAttributToServer(domain_hdl->data_ni);216 207 CTimer::get("XIOS").suspend(); 217 208 } … … 235 226 CTimer::get("XIOS").resume(); 236 227 domain_hdl->data_nj.setValue(data_nj); 237 domain_hdl->sendAttributToServer(domain_hdl->data_nj);238 228 CTimer::get("XIOS").suspend(); 239 229 } … … 259 249 CTimer::get("XIOS").resume(); 260 250 domain_hdl->domain_group_ref.setValue(domain_group_ref_str); 261 domain_hdl->sendAttributToServer(domain_hdl->domain_group_ref);262 251 CTimer::get("XIOS").suspend(); 263 252 } … … 285 274 CArray<int,2> tmp(i_index,shape(extent1,extent2),neverDeleteData) ; 286 275 domain_hdl->i_index.reference(tmp.copy()); 287 domain_hdl->sendAttributToServer(domain_hdl->i_index);288 276 CTimer::get("XIOS").suspend(); 289 277 } … … 310 298 CTimer::get("XIOS").resume(); 311 299 domain_hdl->ibegin.setValue(ibegin); 312 domain_hdl->sendAttributToServer(domain_hdl->ibegin);313 300 CTimer::get("XIOS").suspend(); 314 301 } … … 332 319 CTimer::get("XIOS").resume(); 333 320 domain_hdl->iend.setValue(iend); 334 domain_hdl->sendAttributToServer(domain_hdl->iend);335 321 CTimer::get("XIOS").suspend(); 336 322 } … … 355 341 CArray<int,2> tmp(j_index,shape(extent1,extent2),neverDeleteData) ; 356 342 domain_hdl->j_index.reference(tmp.copy()); 357 domain_hdl->sendAttributToServer(domain_hdl->j_index);358 343 CTimer::get("XIOS").suspend(); 359 344 } … … 380 365 CTimer::get("XIOS").resume(); 381 366 domain_hdl->jbegin.setValue(jbegin); 382 domain_hdl->sendAttributToServer(domain_hdl->jbegin);383 367 CTimer::get("XIOS").suspend(); 384 368 } … … 402 386 CTimer::get("XIOS").resume(); 403 387 domain_hdl->jend.setValue(jend); 404 domain_hdl->sendAttributToServer(domain_hdl->jend);405 388 CTimer::get("XIOS").suspend(); 406 389 } … … 425 408 CArray<double,1> tmp(latvalue,shape(extent1),neverDeleteData) ; 426 409 domain_hdl->latvalue.reference(tmp.copy()); 427 domain_hdl->sendAttributToServer(domain_hdl->latvalue);428 410 CTimer::get("XIOS").suspend(); 429 411 } … … 452 434 CTimer::get("XIOS").resume(); 453 435 domain_hdl->long_name.setValue(long_name_str); 454 domain_hdl->sendAttributToServer(domain_hdl->long_name);455 436 CTimer::get("XIOS").suspend(); 456 437 } … … 478 459 CArray<double,1> tmp(lonvalue,shape(extent1),neverDeleteData) ; 479 460 domain_hdl->lonvalue.reference(tmp.copy()); 480 domain_hdl->sendAttributToServer(domain_hdl->lonvalue);481 461 CTimer::get("XIOS").suspend(); 482 462 } … … 504 484 CArray<bool,2> tmp(mask,shape(extent1,extent2),neverDeleteData) ; 505 485 domain_hdl->mask.reference(tmp.copy()); 506 domain_hdl->sendAttributToServer(domain_hdl->mask);507 486 CTimer::get("XIOS").suspend(); 508 487 } … … 531 510 CTimer::get("XIOS").resume(); 532 511 domain_hdl->name.setValue(name_str); 533 domain_hdl->sendAttributToServer(domain_hdl->name);534 512 CTimer::get("XIOS").suspend(); 535 513 } … … 556 534 CTimer::get("XIOS").resume(); 557 535 domain_hdl->ni.setValue(ni); 558 domain_hdl->sendAttributToServer(domain_hdl->ni);559 536 CTimer::get("XIOS").suspend(); 560 537 } … … 578 555 CTimer::get("XIOS").resume(); 579 556 domain_hdl->ni_glo.setValue(ni_glo); 580 domain_hdl->sendAttributToServer(domain_hdl->ni_glo);581 557 CTimer::get("XIOS").suspend(); 582 558 } … … 600 576 CTimer::get("XIOS").resume(); 601 577 domain_hdl->nj.setValue(nj); 602 domain_hdl->sendAttributToServer(domain_hdl->nj);603 578 CTimer::get("XIOS").suspend(); 604 579 } … … 622 597 CTimer::get("XIOS").resume(); 623 598 domain_hdl->nj_glo.setValue(nj_glo); 624 domain_hdl->sendAttributToServer(domain_hdl->nj_glo);625 599 CTimer::get("XIOS").suspend(); 626 600 } … … 644 618 CTimer::get("XIOS").resume(); 645 619 domain_hdl->nvertex.setValue(nvertex); 646 domain_hdl->sendAttributToServer(domain_hdl->nvertex);647 620 CTimer::get("XIOS").suspend(); 648 621 } … … 668 641 CTimer::get("XIOS").resume(); 669 642 domain_hdl->standard_name.setValue(standard_name_str); 670 domain_hdl->sendAttributToServer(domain_hdl->standard_name);671 643 CTimer::get("XIOS").suspend(); 672 644 } … … 695 667 CTimer::get("XIOS").resume(); 696 668 domain_hdl->type.fromString(type_str); 697 domain_hdl->sendAttributToServer(domain_hdl->type);698 669 CTimer::get("XIOS").suspend(); 699 670 } … … 720 691 CTimer::get("XIOS").resume(); 721 692 domain_hdl->zoom_ibegin.setValue(zoom_ibegin); 722 domain_hdl->sendAttributToServer(domain_hdl->zoom_ibegin);723 693 CTimer::get("XIOS").suspend(); 724 694 } … … 742 712 CTimer::get("XIOS").resume(); 743 713 domain_hdl->zoom_ibegin_loc.setValue(zoom_ibegin_loc); 744 domain_hdl->sendAttributToServer(domain_hdl->zoom_ibegin_loc);745 714 CTimer::get("XIOS").suspend(); 746 715 } … … 764 733 CTimer::get("XIOS").resume(); 765 734 domain_hdl->zoom_jbegin.setValue(zoom_jbegin); 766 domain_hdl->sendAttributToServer(domain_hdl->zoom_jbegin);767 735 CTimer::get("XIOS").suspend(); 768 736 } … … 786 754 CTimer::get("XIOS").resume(); 787 755 domain_hdl->zoom_jbegin_loc.setValue(zoom_jbegin_loc); 788 domain_hdl->sendAttributToServer(domain_hdl->zoom_jbegin_loc);789 756 CTimer::get("XIOS").suspend(); 790 757 } … … 808 775 CTimer::get("XIOS").resume(); 809 776 domain_hdl->zoom_ni.setValue(zoom_ni); 810 domain_hdl->sendAttributToServer(domain_hdl->zoom_ni);811 777 CTimer::get("XIOS").suspend(); 812 778 } … … 830 796 CTimer::get("XIOS").resume(); 831 797 domain_hdl->zoom_ni_loc.setValue(zoom_ni_loc); 832 domain_hdl->sendAttributToServer(domain_hdl->zoom_ni_loc);833 798 CTimer::get("XIOS").suspend(); 834 799 } … … 852 817 CTimer::get("XIOS").resume(); 853 818 domain_hdl->zoom_nj.setValue(zoom_nj); 854 domain_hdl->sendAttributToServer(domain_hdl->zoom_nj);855 819 CTimer::get("XIOS").suspend(); 856 820 } … … 874 838 CTimer::get("XIOS").resume(); 875 839 domain_hdl->zoom_nj_loc.setValue(zoom_nj_loc); 876 domain_hdl->sendAttributToServer(domain_hdl->zoom_nj_loc);877 840 CTimer::get("XIOS").suspend(); 878 841 } -
XIOS/trunk/src/interface/c_attr/icdomaingroup_attr.cpp
r501 r509 22 22 CArray<double,2> tmp(bounds_lat,shape(extent1,extent2),neverDeleteData) ; 23 23 domaingroup_hdl->bounds_lat.reference(tmp.copy()); 24 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->bounds_lat);25 24 CTimer::get("XIOS").suspend(); 26 25 } … … 48 47 CArray<double,2> tmp(bounds_lon,shape(extent1,extent2),neverDeleteData) ; 49 48 domaingroup_hdl->bounds_lon.reference(tmp.copy()); 50 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->bounds_lon);51 49 CTimer::get("XIOS").suspend(); 52 50 } … … 73 71 CTimer::get("XIOS").resume(); 74 72 domaingroup_hdl->data_dim.setValue(data_dim); 75 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->data_dim);76 73 CTimer::get("XIOS").suspend(); 77 74 } … … 96 93 CArray<int,1> tmp(data_i_index,shape(extent1),neverDeleteData) ; 97 94 domaingroup_hdl->data_i_index.reference(tmp.copy()); 98 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->data_i_index);99 95 CTimer::get("XIOS").suspend(); 100 96 } … … 121 117 CTimer::get("XIOS").resume(); 122 118 domaingroup_hdl->data_ibegin.setValue(data_ibegin); 123 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->data_ibegin);124 119 CTimer::get("XIOS").suspend(); 125 120 } … … 144 139 CArray<int,1> tmp(data_j_index,shape(extent1),neverDeleteData) ; 145 140 domaingroup_hdl->data_j_index.reference(tmp.copy()); 146 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->data_j_index);147 141 CTimer::get("XIOS").suspend(); 148 142 } … … 169 163 CTimer::get("XIOS").resume(); 170 164 domaingroup_hdl->data_jbegin.setValue(data_jbegin); 171 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->data_jbegin);172 165 CTimer::get("XIOS").suspend(); 173 166 } … … 191 184 CTimer::get("XIOS").resume(); 192 185 domaingroup_hdl->data_n_index.setValue(data_n_index); 193 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->data_n_index);194 186 CTimer::get("XIOS").suspend(); 195 187 } … … 213 205 CTimer::get("XIOS").resume(); 214 206 domaingroup_hdl->data_ni.setValue(data_ni); 215 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->data_ni);216 207 CTimer::get("XIOS").suspend(); 217 208 } … … 235 226 CTimer::get("XIOS").resume(); 236 227 domaingroup_hdl->data_nj.setValue(data_nj); 237 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->data_nj);238 228 CTimer::get("XIOS").suspend(); 239 229 } … … 259 249 CTimer::get("XIOS").resume(); 260 250 domaingroup_hdl->domain_group_ref.setValue(domain_group_ref_str); 261 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->domain_group_ref);262 251 CTimer::get("XIOS").suspend(); 263 252 } … … 286 275 CTimer::get("XIOS").resume(); 287 276 domaingroup_hdl->group_ref.setValue(group_ref_str); 288 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->group_ref);289 277 CTimer::get("XIOS").suspend(); 290 278 } … … 312 300 CArray<int,2> tmp(i_index,shape(extent1,extent2),neverDeleteData) ; 313 301 domaingroup_hdl->i_index.reference(tmp.copy()); 314 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->i_index);315 302 CTimer::get("XIOS").suspend(); 316 303 } … … 337 324 CTimer::get("XIOS").resume(); 338 325 domaingroup_hdl->ibegin.setValue(ibegin); 339 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->ibegin);340 326 CTimer::get("XIOS").suspend(); 341 327 } … … 359 345 CTimer::get("XIOS").resume(); 360 346 domaingroup_hdl->iend.setValue(iend); 361 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->iend);362 347 CTimer::get("XIOS").suspend(); 363 348 } … … 382 367 CArray<int,2> tmp(j_index,shape(extent1,extent2),neverDeleteData) ; 383 368 domaingroup_hdl->j_index.reference(tmp.copy()); 384 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->j_index);385 369 CTimer::get("XIOS").suspend(); 386 370 } … … 407 391 CTimer::get("XIOS").resume(); 408 392 domaingroup_hdl->jbegin.setValue(jbegin); 409 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->jbegin);410 393 CTimer::get("XIOS").suspend(); 411 394 } … … 429 412 CTimer::get("XIOS").resume(); 430 413 domaingroup_hdl->jend.setValue(jend); 431 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->jend);432 414 CTimer::get("XIOS").suspend(); 433 415 } … … 452 434 CArray<double,1> tmp(latvalue,shape(extent1),neverDeleteData) ; 453 435 domaingroup_hdl->latvalue.reference(tmp.copy()); 454 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->latvalue);455 436 CTimer::get("XIOS").suspend(); 456 437 } … … 479 460 CTimer::get("XIOS").resume(); 480 461 domaingroup_hdl->long_name.setValue(long_name_str); 481 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->long_name);482 462 CTimer::get("XIOS").suspend(); 483 463 } … … 505 485 CArray<double,1> tmp(lonvalue,shape(extent1),neverDeleteData) ; 506 486 domaingroup_hdl->lonvalue.reference(tmp.copy()); 507 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->lonvalue);508 487 CTimer::get("XIOS").suspend(); 509 488 } … … 531 510 CArray<bool,2> tmp(mask,shape(extent1,extent2),neverDeleteData) ; 532 511 domaingroup_hdl->mask.reference(tmp.copy()); 533 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->mask);534 512 CTimer::get("XIOS").suspend(); 535 513 } … … 558 536 CTimer::get("XIOS").resume(); 559 537 domaingroup_hdl->name.setValue(name_str); 560 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->name);561 538 CTimer::get("XIOS").suspend(); 562 539 } … … 583 560 CTimer::get("XIOS").resume(); 584 561 domaingroup_hdl->ni.setValue(ni); 585 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->ni);586 562 CTimer::get("XIOS").suspend(); 587 563 } … … 605 581 CTimer::get("XIOS").resume(); 606 582 domaingroup_hdl->ni_glo.setValue(ni_glo); 607 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->ni_glo);608 583 CTimer::get("XIOS").suspend(); 609 584 } … … 627 602 CTimer::get("XIOS").resume(); 628 603 domaingroup_hdl->nj.setValue(nj); 629 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->nj);630 604 CTimer::get("XIOS").suspend(); 631 605 } … … 649 623 CTimer::get("XIOS").resume(); 650 624 domaingroup_hdl->nj_glo.setValue(nj_glo); 651 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->nj_glo);652 625 CTimer::get("XIOS").suspend(); 653 626 } … … 671 644 CTimer::get("XIOS").resume(); 672 645 domaingroup_hdl->nvertex.setValue(nvertex); 673 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->nvertex);674 646 CTimer::get("XIOS").suspend(); 675 647 } … … 695 667 CTimer::get("XIOS").resume(); 696 668 domaingroup_hdl->standard_name.setValue(standard_name_str); 697 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->standard_name);698 669 CTimer::get("XIOS").suspend(); 699 670 } … … 722 693 CTimer::get("XIOS").resume(); 723 694 domaingroup_hdl->type.fromString(type_str); 724 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->type);725 695 CTimer::get("XIOS").suspend(); 726 696 } … … 747 717 CTimer::get("XIOS").resume(); 748 718 domaingroup_hdl->zoom_ibegin.setValue(zoom_ibegin); 749 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->zoom_ibegin);750 719 CTimer::get("XIOS").suspend(); 751 720 } … … 769 738 CTimer::get("XIOS").resume(); 770 739 domaingroup_hdl->zoom_ibegin_loc.setValue(zoom_ibegin_loc); 771 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->zoom_ibegin_loc);772 740 CTimer::get("XIOS").suspend(); 773 741 } … … 791 759 CTimer::get("XIOS").resume(); 792 760 domaingroup_hdl->zoom_jbegin.setValue(zoom_jbegin); 793 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->zoom_jbegin);794 761 CTimer::get("XIOS").suspend(); 795 762 } … … 813 780 CTimer::get("XIOS").resume(); 814 781 domaingroup_hdl->zoom_jbegin_loc.setValue(zoom_jbegin_loc); 815 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->zoom_jbegin_loc);816 782 CTimer::get("XIOS").suspend(); 817 783 } … … 835 801 CTimer::get("XIOS").resume(); 836 802 domaingroup_hdl->zoom_ni.setValue(zoom_ni); 837 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->zoom_ni);838 803 CTimer::get("XIOS").suspend(); 839 804 } … … 857 822 CTimer::get("XIOS").resume(); 858 823 domaingroup_hdl->zoom_ni_loc.setValue(zoom_ni_loc); 859 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->zoom_ni_loc);860 824 CTimer::get("XIOS").suspend(); 861 825 } … … 879 843 CTimer::get("XIOS").resume(); 880 844 domaingroup_hdl->zoom_nj.setValue(zoom_nj); 881 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->zoom_nj);882 845 CTimer::get("XIOS").suspend(); 883 846 } … … 901 864 CTimer::get("XIOS").resume(); 902 865 domaingroup_hdl->zoom_nj_loc.setValue(zoom_nj_loc); 903 domaingroup_hdl->sendAttributToServer(domaingroup_hdl->zoom_nj_loc);904 866 CTimer::get("XIOS").suspend(); 905 867 } -
XIOS/trunk/src/interface/c_attr/icfield_attr.cpp
r501 r509 21 21 CTimer::get("XIOS").resume(); 22 22 field_hdl->add_offset.setValue(add_offset); 23 field_hdl->sendAttributToServer(field_hdl->add_offset);24 23 CTimer::get("XIOS").suspend(); 25 24 } … … 45 44 CTimer::get("XIOS").resume(); 46 45 field_hdl->axis_ref.setValue(axis_ref_str); 47 field_hdl->sendAttributToServer(field_hdl->axis_ref);48 46 CTimer::get("XIOS").suspend(); 49 47 } … … 70 68 CTimer::get("XIOS").resume(); 71 69 field_hdl->default_value.setValue(default_value); 72 field_hdl->sendAttributToServer(field_hdl->default_value);73 70 CTimer::get("XIOS").suspend(); 74 71 } … … 92 89 CTimer::get("XIOS").resume(); 93 90 field_hdl->detect_missing_value.setValue(detect_missing_value); 94 field_hdl->sendAttributToServer(field_hdl->detect_missing_value);95 91 CTimer::get("XIOS").suspend(); 96 92 } … … 116 112 CTimer::get("XIOS").resume(); 117 113 field_hdl->domain_ref.setValue(domain_ref_str); 118 field_hdl->sendAttributToServer(field_hdl->domain_ref);119 114 CTimer::get("XIOS").suspend(); 120 115 } … … 141 136 CTimer::get("XIOS").resume(); 142 137 field_hdl->enabled.setValue(enabled); 143 field_hdl->sendAttributToServer(field_hdl->enabled);144 138 CTimer::get("XIOS").suspend(); 145 139 } … … 165 159 CTimer::get("XIOS").resume(); 166 160 field_hdl->field_ref.setValue(field_ref_str); 167 field_hdl->sendAttributToServer(field_hdl->field_ref);168 161 CTimer::get("XIOS").suspend(); 169 162 } … … 192 185 CTimer::get("XIOS").resume(); 193 186 field_hdl->freq_offset.setValue(freq_offset_str); 194 field_hdl->sendAttributToServer(field_hdl->freq_offset);195 187 CTimer::get("XIOS").suspend(); 196 188 } … … 219 211 CTimer::get("XIOS").resume(); 220 212 field_hdl->freq_op.setValue(freq_op_str); 221 field_hdl->sendAttributToServer(field_hdl->freq_op);222 213 CTimer::get("XIOS").suspend(); 223 214 } … … 246 237 CTimer::get("XIOS").resume(); 247 238 field_hdl->grid_ref.setValue(grid_ref_str); 248 field_hdl->sendAttributToServer(field_hdl->grid_ref);249 239 CTimer::get("XIOS").suspend(); 250 240 } … … 271 261 CTimer::get("XIOS").resume(); 272 262 field_hdl->level.setValue(level); 273 field_hdl->sendAttributToServer(field_hdl->level);274 263 CTimer::get("XIOS").suspend(); 275 264 } … … 295 284 CTimer::get("XIOS").resume(); 296 285 field_hdl->long_name.setValue(long_name_str); 297 field_hdl->sendAttributToServer(field_hdl->long_name);298 286 CTimer::get("XIOS").suspend(); 299 287 } … … 322 310 CTimer::get("XIOS").resume(); 323 311 field_hdl->name.setValue(name_str); 324 field_hdl->sendAttributToServer(field_hdl->name);325 312 CTimer::get("XIOS").suspend(); 326 313 } … … 349 336 CTimer::get("XIOS").resume(); 350 337 field_hdl->operation.setValue(operation_str); 351 field_hdl->sendAttributToServer(field_hdl->operation);352 338 CTimer::get("XIOS").suspend(); 353 339 } … … 374 360 CTimer::get("XIOS").resume(); 375 361 field_hdl->prec.setValue(prec); 376 field_hdl->sendAttributToServer(field_hdl->prec);377 362 CTimer::get("XIOS").suspend(); 378 363 } … … 396 381 CTimer::get("XIOS").resume(); 397 382 field_hdl->scale_factor.setValue(scale_factor); 398 field_hdl->sendAttributToServer(field_hdl->scale_factor);399 383 CTimer::get("XIOS").suspend(); 400 384 } … … 420 404 CTimer::get("XIOS").resume(); 421 405 field_hdl->standard_name.setValue(standard_name_str); 422 field_hdl->sendAttributToServer(field_hdl->standard_name);423 406 CTimer::get("XIOS").suspend(); 424 407 } … … 447 430 CTimer::get("XIOS").resume(); 448 431 field_hdl->unit.setValue(unit_str); 449 field_hdl->sendAttributToServer(field_hdl->unit);450 432 CTimer::get("XIOS").suspend(); 451 433 } … … 472 454 CTimer::get("XIOS").resume(); 473 455 field_hdl->valid_max.setValue(valid_max); 474 field_hdl->sendAttributToServer(field_hdl->valid_max);475 456 CTimer::get("XIOS").suspend(); 476 457 } … … 494 475 CTimer::get("XIOS").resume(); 495 476 field_hdl->valid_min.setValue(valid_min); 496 field_hdl->sendAttributToServer(field_hdl->valid_min);497 477 CTimer::get("XIOS").suspend(); 498 478 } -
XIOS/trunk/src/interface/c_attr/icfieldgroup_attr.cpp
r501 r509 21 21 CTimer::get("XIOS").resume(); 22 22 fieldgroup_hdl->add_offset.setValue(add_offset); 23 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->add_offset);24 23 CTimer::get("XIOS").suspend(); 25 24 } … … 45 44 CTimer::get("XIOS").resume(); 46 45 fieldgroup_hdl->axis_ref.setValue(axis_ref_str); 47 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->axis_ref);48 46 CTimer::get("XIOS").suspend(); 49 47 } … … 70 68 CTimer::get("XIOS").resume(); 71 69 fieldgroup_hdl->default_value.setValue(default_value); 72 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->default_value);73 70 CTimer::get("XIOS").suspend(); 74 71 } … … 92 89 CTimer::get("XIOS").resume(); 93 90 fieldgroup_hdl->detect_missing_value.setValue(detect_missing_value); 94 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->detect_missing_value);95 91 CTimer::get("XIOS").suspend(); 96 92 } … … 116 112 CTimer::get("XIOS").resume(); 117 113 fieldgroup_hdl->domain_ref.setValue(domain_ref_str); 118 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->domain_ref);119 114 CTimer::get("XIOS").suspend(); 120 115 } … … 141 136 CTimer::get("XIOS").resume(); 142 137 fieldgroup_hdl->enabled.setValue(enabled); 143 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->enabled);144 138 CTimer::get("XIOS").suspend(); 145 139 } … … 165 159 CTimer::get("XIOS").resume(); 166 160 fieldgroup_hdl->field_ref.setValue(field_ref_str); 167 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->field_ref);168 161 CTimer::get("XIOS").suspend(); 169 162 } … … 192 185 CTimer::get("XIOS").resume(); 193 186 fieldgroup_hdl->freq_offset.setValue(freq_offset_str); 194 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->freq_offset);195 187 CTimer::get("XIOS").suspend(); 196 188 } … … 219 211 CTimer::get("XIOS").resume(); 220 212 fieldgroup_hdl->freq_op.setValue(freq_op_str); 221 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->freq_op);222 213 CTimer::get("XIOS").suspend(); 223 214 } … … 246 237 CTimer::get("XIOS").resume(); 247 238 fieldgroup_hdl->grid_ref.setValue(grid_ref_str); 248 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->grid_ref);249 239 CTimer::get("XIOS").suspend(); 250 240 } … … 273 263 CTimer::get("XIOS").resume(); 274 264 fieldgroup_hdl->group_ref.setValue(group_ref_str); 275 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->group_ref);276 265 CTimer::get("XIOS").suspend(); 277 266 } … … 298 287 CTimer::get("XIOS").resume(); 299 288 fieldgroup_hdl->level.setValue(level); 300 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->level);301 289 CTimer::get("XIOS").suspend(); 302 290 } … … 322 310 CTimer::get("XIOS").resume(); 323 311 fieldgroup_hdl->long_name.setValue(long_name_str); 324 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->long_name);325 312 CTimer::get("XIOS").suspend(); 326 313 } … … 349 336 CTimer::get("XIOS").resume(); 350 337 fieldgroup_hdl->name.setValue(name_str); 351 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->name);352 338 CTimer::get("XIOS").suspend(); 353 339 } … … 376 362 CTimer::get("XIOS").resume(); 377 363 fieldgroup_hdl->operation.setValue(operation_str); 378 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->operation);379 364 CTimer::get("XIOS").suspend(); 380 365 } … … 401 386 CTimer::get("XIOS").resume(); 402 387 fieldgroup_hdl->prec.setValue(prec); 403 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->prec);404 388 CTimer::get("XIOS").suspend(); 405 389 } … … 423 407 CTimer::get("XIOS").resume(); 424 408 fieldgroup_hdl->scale_factor.setValue(scale_factor); 425 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->scale_factor);426 409 CTimer::get("XIOS").suspend(); 427 410 } … … 447 430 CTimer::get("XIOS").resume(); 448 431 fieldgroup_hdl->standard_name.setValue(standard_name_str); 449 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->standard_name);450 432 CTimer::get("XIOS").suspend(); 451 433 } … … 474 456 CTimer::get("XIOS").resume(); 475 457 fieldgroup_hdl->unit.setValue(unit_str); 476 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->unit);477 458 CTimer::get("XIOS").suspend(); 478 459 } … … 499 480 CTimer::get("XIOS").resume(); 500 481 fieldgroup_hdl->valid_max.setValue(valid_max); 501 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->valid_max);502 482 CTimer::get("XIOS").suspend(); 503 483 } … … 521 501 CTimer::get("XIOS").resume(); 522 502 fieldgroup_hdl->valid_min.setValue(valid_min); 523 fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->valid_min);524 503 CTimer::get("XIOS").suspend(); 525 504 } -
XIOS/trunk/src/interface/c_attr/icfile_attr.cpp
r501 r509 23 23 CTimer::get("XIOS").resume(); 24 24 file_hdl->description.setValue(description_str); 25 file_hdl->sendAttributToServer(file_hdl->description);26 25 CTimer::get("XIOS").suspend(); 27 26 } … … 48 47 CTimer::get("XIOS").resume(); 49 48 file_hdl->enabled.setValue(enabled); 50 file_hdl->sendAttributToServer(file_hdl->enabled);51 49 CTimer::get("XIOS").suspend(); 52 50 } … … 70 68 CTimer::get("XIOS").resume(); 71 69 file_hdl->min_digits.setValue(min_digits); 72 file_hdl->sendAttributToServer(file_hdl->min_digits);73 70 CTimer::get("XIOS").suspend(); 74 71 } … … 94 91 CTimer::get("XIOS").resume(); 95 92 file_hdl->name.setValue(name_str); 96 file_hdl->sendAttributToServer(file_hdl->name);97 93 CTimer::get("XIOS").suspend(); 98 94 } … … 121 117 CTimer::get("XIOS").resume(); 122 118 file_hdl->name_suffix.setValue(name_suffix_str); 123 file_hdl->sendAttributToServer(file_hdl->name_suffix);124 119 CTimer::get("XIOS").suspend(); 125 120 } … … 148 143 CTimer::get("XIOS").resume(); 149 144 file_hdl->output_freq.setValue(output_freq_str); 150 file_hdl->sendAttributToServer(file_hdl->output_freq);151 145 CTimer::get("XIOS").suspend(); 152 146 } … … 173 167 CTimer::get("XIOS").resume(); 174 168 file_hdl->output_level.setValue(output_level); 175 file_hdl->sendAttributToServer(file_hdl->output_level);176 169 CTimer::get("XIOS").suspend(); 177 170 } … … 197 190 CTimer::get("XIOS").resume(); 198 191 file_hdl->par_access.setValue(par_access_str); 199 file_hdl->sendAttributToServer(file_hdl->par_access);200 192 CTimer::get("XIOS").suspend(); 201 193 } … … 224 216 CTimer::get("XIOS").resume(); 225 217 file_hdl->split_freq.setValue(split_freq_str); 226 file_hdl->sendAttributToServer(file_hdl->split_freq);227 218 CTimer::get("XIOS").suspend(); 228 219 } … … 251 242 CTimer::get("XIOS").resume(); 252 243 file_hdl->split_freq_format.setValue(split_freq_format_str); 253 file_hdl->sendAttributToServer(file_hdl->split_freq_format);254 244 CTimer::get("XIOS").suspend(); 255 245 } … … 278 268 CTimer::get("XIOS").resume(); 279 269 file_hdl->sync_freq.setValue(sync_freq_str); 280 file_hdl->sendAttributToServer(file_hdl->sync_freq);281 270 CTimer::get("XIOS").suspend(); 282 271 } … … 305 294 CTimer::get("XIOS").resume(); 306 295 file_hdl->type.fromString(type_str); 307 file_hdl->sendAttributToServer(file_hdl->type);308 296 CTimer::get("XIOS").suspend(); 309 297 } -
XIOS/trunk/src/interface/c_attr/icfilegroup_attr.cpp
r501 r509 23 23 CTimer::get("XIOS").resume(); 24 24 filegroup_hdl->description.setValue(description_str); 25 filegroup_hdl->sendAttributToServer(filegroup_hdl->description);26 25 CTimer::get("XIOS").suspend(); 27 26 } … … 48 47 CTimer::get("XIOS").resume(); 49 48 filegroup_hdl->enabled.setValue(enabled); 50 filegroup_hdl->sendAttributToServer(filegroup_hdl->enabled);51 49 CTimer::get("XIOS").suspend(); 52 50 } … … 72 70 CTimer::get("XIOS").resume(); 73 71 filegroup_hdl->group_ref.setValue(group_ref_str); 74 filegroup_hdl->sendAttributToServer(filegroup_hdl->group_ref);75 72 CTimer::get("XIOS").suspend(); 76 73 } … … 97 94 CTimer::get("XIOS").resume(); 98 95 filegroup_hdl->min_digits.setValue(min_digits); 99 filegroup_hdl->sendAttributToServer(filegroup_hdl->min_digits);100 96 CTimer::get("XIOS").suspend(); 101 97 } … … 121 117 CTimer::get("XIOS").resume(); 122 118 filegroup_hdl->name.setValue(name_str); 123 filegroup_hdl->sendAttributToServer(filegroup_hdl->name);124 119 CTimer::get("XIOS").suspend(); 125 120 } … … 148 143 CTimer::get("XIOS").resume(); 149 144 filegroup_hdl->name_suffix.setValue(name_suffix_str); 150 filegroup_hdl->sendAttributToServer(filegroup_hdl->name_suffix);151 145 CTimer::get("XIOS").suspend(); 152 146 } … … 175 169 CTimer::get("XIOS").resume(); 176 170 filegroup_hdl->output_freq.setValue(output_freq_str); 177 filegroup_hdl->sendAttributToServer(filegroup_hdl->output_freq);178 171 CTimer::get("XIOS").suspend(); 179 172 } … … 200 193 CTimer::get("XIOS").resume(); 201 194 filegroup_hdl->output_level.setValue(output_level); 202 filegroup_hdl->sendAttributToServer(filegroup_hdl->output_level);203 195 CTimer::get("XIOS").suspend(); 204 196 } … … 224 216 CTimer::get("XIOS").resume(); 225 217 filegroup_hdl->par_access.setValue(par_access_str); 226 filegroup_hdl->sendAttributToServer(filegroup_hdl->par_access);227 218 CTimer::get("XIOS").suspend(); 228 219 } … … 251 242 CTimer::get("XIOS").resume(); 252 243 filegroup_hdl->split_freq.setValue(split_freq_str); 253 filegroup_hdl->sendAttributToServer(filegroup_hdl->split_freq);254 244 CTimer::get("XIOS").suspend(); 255 245 } … … 278 268 CTimer::get("XIOS").resume(); 279 269 filegroup_hdl->split_freq_format.setValue(split_freq_format_str); 280 filegroup_hdl->sendAttributToServer(filegroup_hdl->split_freq_format);281 270 CTimer::get("XIOS").suspend(); 282 271 } … … 305 294 CTimer::get("XIOS").resume(); 306 295 filegroup_hdl->sync_freq.setValue(sync_freq_str); 307 filegroup_hdl->sendAttributToServer(filegroup_hdl->sync_freq);308 296 CTimer::get("XIOS").suspend(); 309 297 } … … 332 320 CTimer::get("XIOS").resume(); 333 321 filegroup_hdl->type.fromString(type_str); 334 filegroup_hdl->sendAttributToServer(filegroup_hdl->type);335 322 CTimer::get("XIOS").suspend(); 336 323 } -
XIOS/trunk/src/interface/c_attr/icgrid_attr.cpp
r501 r509 23 23 CTimer::get("XIOS").resume(); 24 24 grid_hdl->axis_ref.setValue(axis_ref_str); 25 grid_hdl->sendAttributToServer(grid_hdl->axis_ref);26 25 CTimer::get("XIOS").suspend(); 27 26 } … … 50 49 CTimer::get("XIOS").resume(); 51 50 grid_hdl->description.setValue(description_str); 52 grid_hdl->sendAttributToServer(grid_hdl->description);53 51 CTimer::get("XIOS").suspend(); 54 52 } … … 77 75 CTimer::get("XIOS").resume(); 78 76 grid_hdl->domain_ref.setValue(domain_ref_str); 79 grid_hdl->sendAttributToServer(grid_hdl->domain_ref);80 77 CTimer::get("XIOS").suspend(); 81 78 } … … 103 100 CArray<bool,3> tmp(mask,shape(extent1,extent2,extent3),neverDeleteData) ; 104 101 grid_hdl->mask.reference(tmp.copy()); 105 grid_hdl->sendAttributToServer(grid_hdl->mask);106 102 CTimer::get("XIOS").suspend(); 107 103 } … … 130 126 CTimer::get("XIOS").resume(); 131 127 grid_hdl->name.setValue(name_str); 132 grid_hdl->sendAttributToServer(grid_hdl->name);133 128 CTimer::get("XIOS").suspend(); 134 129 } -
XIOS/trunk/src/interface/c_attr/icgridgroup_attr.cpp
r501 r509 23 23 CTimer::get("XIOS").resume(); 24 24 gridgroup_hdl->axis_ref.setValue(axis_ref_str); 25 gridgroup_hdl->sendAttributToServer(gridgroup_hdl->axis_ref);26 25 CTimer::get("XIOS").suspend(); 27 26 } … … 50 49 CTimer::get("XIOS").resume(); 51 50 gridgroup_hdl->description.setValue(description_str); 52 gridgroup_hdl->sendAttributToServer(gridgroup_hdl->description);53 51 CTimer::get("XIOS").suspend(); 54 52 } … … 77 75 CTimer::get("XIOS").resume(); 78 76 gridgroup_hdl->domain_ref.setValue(domain_ref_str); 79 gridgroup_hdl->sendAttributToServer(gridgroup_hdl->domain_ref);80 77 CTimer::get("XIOS").suspend(); 81 78 } … … 104 101 CTimer::get("XIOS").resume(); 105 102 gridgroup_hdl->group_ref.setValue(group_ref_str); 106 gridgroup_hdl->sendAttributToServer(gridgroup_hdl->group_ref);107 103 CTimer::get("XIOS").suspend(); 108 104 } … … 130 126 CArray<bool,3> tmp(mask,shape(extent1,extent2,extent3),neverDeleteData) ; 131 127 gridgroup_hdl->mask.reference(tmp.copy()); 132 gridgroup_hdl->sendAttributToServer(gridgroup_hdl->mask);133 128 CTimer::get("XIOS").suspend(); 134 129 } … … 157 152 CTimer::get("XIOS").resume(); 158 153 gridgroup_hdl->name.setValue(name_str); 159 gridgroup_hdl->sendAttributToServer(gridgroup_hdl->name);160 154 CTimer::get("XIOS").suspend(); 161 155 } -
XIOS/trunk/src/interface/c_attr/icvariable_attr.cpp
r501 r509 23 23 CTimer::get("XIOS").resume(); 24 24 variable_hdl->name.setValue(name_str); 25 variable_hdl->sendAttributToServer(variable_hdl->name);26 25 CTimer::get("XIOS").suspend(); 27 26 } … … 50 49 CTimer::get("XIOS").resume(); 51 50 variable_hdl->type.setValue(type_str); 52 variable_hdl->sendAttributToServer(variable_hdl->type);53 51 CTimer::get("XIOS").suspend(); 54 52 } -
XIOS/trunk/src/interface/c_attr/icvariablegroup_attr.cpp
r501 r509 23 23 CTimer::get("XIOS").resume(); 24 24 variablegroup_hdl->group_ref.setValue(group_ref_str); 25 variablegroup_hdl->sendAttributToServer(variablegroup_hdl->group_ref);26 25 CTimer::get("XIOS").suspend(); 27 26 } … … 50 49 CTimer::get("XIOS").resume(); 51 50 variablegroup_hdl->name.setValue(name_str); 52 variablegroup_hdl->sendAttributToServer(variablegroup_hdl->name);53 51 CTimer::get("XIOS").suspend(); 54 52 } … … 77 75 CTimer::get("XIOS").resume(); 78 76 variablegroup_hdl->type.setValue(type_str); 79 variablegroup_hdl->sendAttributToServer(variablegroup_hdl->type);80 77 CTimer::get("XIOS").suspend(); 81 78 } -
XIOS/trunk/src/node/context.cpp
r501 r509 16 16 17 17 namespace xios { 18 18 19 19 shared_ptr<CContextGroup> CContext::root ; 20 20 21 21 /// ////////////////////// Définitions ////////////////////// /// 22 22 23 23 CContext::CContext(void) 24 24 : CObjectTemplate<CContext>(), CContextAttributes() 25 , calendar(),hasClient(false),hasServer(false) 25 , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_() 26 26 { /* Ne rien faire de plus */ } 27 27 28 28 CContext::CContext(const StdString & id) 29 29 : CObjectTemplate<CContext>(id), CContextAttributes() 30 , calendar(),hasClient(false),hasServer(false) 30 , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_() 31 31 { /* Ne rien faire de plus */ } 32 32 33 33 CContext::~CContext(void) 34 { 34 { 35 35 if (hasClient) delete client ; 36 36 if (hasServer) delete server ; … … 38 38 39 39 //---------------------------------------------------------------- 40 40 //! Get name of context 41 41 StdString CContext::GetName(void) { return (StdString("context")); } 42 42 StdString CContext::GetDefName(void){ return (CContext::GetName()); } … … 44 44 45 45 //---------------------------------------------------------------- 46 46 /*! 47 \brief Get context group (context root) 48 \return Context root 49 */ 47 50 CContextGroup* CContext::getRoot(void) 48 { 51 { 49 52 if (root.get()==NULL) root=shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())) ; 50 return root.get(); 51 } 52 53 54 //---------------------------------------------------------------- 55 53 return root.get(); 54 } 55 56 57 //---------------------------------------------------------------- 58 /*! 59 \brief Get calendar of a context 60 \return Calendar 61 */ 56 62 boost::shared_ptr<CCalendar> CContext::getCalendar(void) const 57 63 { 58 64 return (this->calendar); 59 65 } 60 61 //---------------------------------------------------------------- 62 66 67 //---------------------------------------------------------------- 68 /*! 69 \brief Set a context with a calendar 70 \param[in] newCalendar new calendar 71 */ 63 72 void CContext::setCalendar(boost::shared_ptr<CCalendar> newCalendar) 64 73 { … … 67 76 start_date.setValue(this->calendar->getInitDate().toString()); 68 77 } 69 70 //---------------------------------------------------------------- 71 78 79 //---------------------------------------------------------------- 80 //! Process all information of calendar 72 81 void CContext::solveCalendar(void) 73 82 { … … 97 106 << "The calendar is not defined !"); 98 107 } 99 100 //---------------------------------------------------------------- 101 108 109 //---------------------------------------------------------------- 110 /*! 111 \brief Parse xml file and write information into context object 112 \param [in] node xmld node corresponding in xml file 113 */ 102 114 void CContext::parse(xml::CXMLNode & node) 103 115 { … … 135 147 136 148 if (attributes.end() != attributes.find("id")) 137 { DEBUG(<< "Definition node has an id," 138 << "it will not be taking account !"); } 149 { 150 DEBUG(<< "Definition node has an id," 151 << "it will not be taking account !"); 152 } 139 153 140 154 #define DECLARE_NODE(Name_, name_) \ … … 155 169 156 170 //---------------------------------------------------------------- 157 171 //! Show tree structure of context 158 172 void CContext::ShowTree(StdOStream & out) 159 173 { … … 166 180 out << "<? xml version=\"1.0\" ?>" << std::endl; 167 181 out << "<" << xml::CXMLNode::GetRootName() << " >" << std::endl; 168 182 169 183 for (; it != end; it++) 170 184 { 171 CContext* context = *it; 172 CContext::setCurrent(context->getId()); 185 CContext* context = *it; 186 CContext::setCurrent(context->getId()); 173 187 out << *context << std::endl; 174 188 } 175 189 176 190 out << "</" << xml::CXMLNode::GetRootName() << " >" << std::endl; 177 CContext::setCurrent(currentContextId); 178 } 179 180 181 //---------------------------------------------------------------- 182 191 CContext::setCurrent(currentContextId); 192 } 193 194 195 //---------------------------------------------------------------- 196 197 //! Convert context object into string (to print) 183 198 StdString CContext::toString(void) const 184 199 { … … 209 224 //---------------------------------------------------------------- 210 225 226 /*! 227 \brief Find all inheritace among objects in a context. 228 \param [in] apply (true) write attributes of parent into ones of child if they are empty 229 (false) write attributes of parent into a new container of child 230 \param [in] parent unused 231 */ 211 232 void CContext::solveDescInheritance(bool apply, const CAttributeMap * const UNUSED(parent)) 212 233 { … … 220 241 //---------------------------------------------------------------- 221 242 243 //! Verify if all root definition in the context have child. 222 244 bool CContext::hasChild(void) const 223 245 { … … 230 252 } 231 253 232 //----------------------------------------------------------------233 234 void CContext::solveFieldRefInheritance(bool apply)235 {236 if (!this->hasId()) return;237 vector<CField*> allField = CField::getAll() ;238 // = CObjectTemplate<CField>::GetAllVectobject(this->getId());239 std::vector<CField*>::iterator 240 it = allField.begin(), end = allField.end();241 242 for (; it != end; it++)243 {244 CField* field = *it;245 field->solveRefInheritance(apply);246 }247 }254 // //---------------------------------------------------------------- 255 // 256 // void CContext::solveFieldRefInheritance(bool apply) 257 // { 258 // if (!this->hasId()) return; 259 // vector<CField*> allField = CField::getAll() ; 260 //// = CObjectTemplate<CField>::GetAllVectobject(this->getId()); 261 // std::vector<CField*>::iterator 262 // it = allField.begin(), end = allField.end(); 263 // 264 // for (; it != end; it++) 265 // { 266 // CField* field = *it; 267 // field->solveRefInheritance(apply); 268 // } 269 // } 248 270 249 271 //---------------------------------------------------------------- … … 256 278 } 257 279 ///--------------------------------------------------------------- 258 280 281 //! Initialize client side 259 282 void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm) 260 283 { 261 284 hasClient=true ; 262 285 client = new CContextClient(this,intraComm, interComm) ; 263 } 264 286 } 287 288 void CContext::setClientServerBuffer() 289 { 290 if (hasClient) 291 { 292 client->setBufferSize(getDataSize()); 293 } 294 } 295 296 //! Verify whether a context is initialized 265 297 bool CContext::isInitialized(void) 266 298 { 267 299 return hasClient ; 268 300 } 269 301 302 //! Initialize server 270 303 void CContext::initServer(MPI_Comm intraComm,MPI_Comm interComm) 271 304 { 272 305 hasServer=true ; 273 306 server = new CContextServer(this,intraComm,interComm) ; 274 } 275 307 } 308 309 //! Server side: Put server into a loop in order to listen message from client 276 310 bool CContext::eventLoop(void) 277 311 { 278 312 return server->eventLoop() ; 279 } 280 313 } 314 315 //! Terminate a context 281 316 void CContext::finalize(void) 282 317 { … … 290 325 } 291 326 } 292 293 294 295 327 328 /*! 329 \brief Close all the context defintion and do processing data 330 After everything is well defined on client side, they will be processed and sent to server 331 From the version 2.0, sever and client work no more on the same database. Moreover, client(s) will send 332 all necessary information to server, from which each server can build its own database. 333 Because the role of server is to write out field data on a specific netcdf file, 334 the only information that it needs is the enabled files 335 and the active fields (fields will be written onto active files) 336 */ 296 337 void CContext::closeDefinition(void) 297 338 { 298 if (hasClient && !hasServer) sendCloseDefinition() ; 299 300 solveCalendar(); 301 302 // Résolution des héritages pour le context actuel. 303 this->solveAllInheritance(); 304 305 //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 306 this->findEnabledFiles(); 307 308 309 this->processEnabledFiles() ; 310 311 /* 339 if (hasClient && !hasServer) 340 { 341 // After xml is parsed, there are some more works with post processing 342 postProcessing(); 343 344 setClientServerBuffer(); 345 346 // Send all attributes of current context to server 347 this->sendAllAttributesToServer(); 348 349 // We have enough information to send to server 350 // First of all, send all enabled files 351 sendEnabledFiles(); 352 353 // Then, send all enabled fields 354 sendEnabledFields(); 355 356 // After that, send all grid (if any) 357 sendRefGrid(); 358 359 // At last, we have all info of domain and axis, then send them 360 sendRefDomainsAxis(); 361 } 362 363 // Now tell server that it can process all messages from client 364 if (hasClient && !hasServer) this->sendCloseDefinition(); 365 366 // We have a xml tree on the server side and now, it should be also processed 367 if (hasClient && !hasServer) sendPostProcessing(); 368 369 // There are some processings that should be done after all of above. For example: check mask or index 370 if (hasClient && !hasServer) 371 { 372 this->solveAllRefOfEnabledFields(true); 373 this->buildAllExpressionOfEnabledFields(); 374 } 375 376 // if (hasClient) 377 // { 378 // //solveCalendar(); 379 // 380 // // Résolution des héritages pour le context actuel. 381 //// this->solveAllInheritance(); 382 // 383 // 384 //// //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 385 //// this->findEnabledFiles(); 386 // 387 // this->processEnabledFiles() ; 388 // 389 // this->solveAllGridRef(); 390 // } 391 392 393 394 395 // solveCalendar(); 396 // 397 // // Résolution des héritages pour le context actuel. 398 // this->solveAllInheritance(); 399 // 400 // //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 401 // this->findEnabledFiles(); 402 // 403 // 404 // this->processEnabledFiles() ; 405 406 /* 312 407 //Recherche des champs à sortir (enable à true + niveau de sortie correct) 313 408 // pour chaque fichier précédemment listé. … … 324 419 */ 325 420 // Nettoyage de l'arborescence 326 CleanTree(); 421 if (hasClient && !hasServer) CleanTree(); // Only on client side?? 422 // if (hasClient) CleanTree(); 327 423 if (hasClient) sendCreateFileHeader() ; 328 424 } 329 425 330 426 void CContext::findAllEnabledFields(void) 331 427 { … … 333 429 (void)this->enabledFiles[i]->getEnabledFields(); 334 430 } 335 336 void CContext::processEnabledFiles(void) 337 { 338 for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 339 this->enabledFiles[i]->processEnabledFile(); 340 } 341 342 343 void CContext::solveAllGridRef(void) 344 { 345 for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 346 this->enabledFiles[i]->solveEFGridRef(); 347 } 348 349 void CContext::solveAllOperation(void) 350 { 351 for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 352 this->enabledFiles[i]->solveEFOperation(); 353 } 354 355 void CContext::solveAllExpression(void) 356 { 357 for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 358 this->enabledFiles[i]->solveEFExpression(); 359 } 360 431 432 // void CContext::processEnabledFiles(void) 433 // { 434 // for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 435 // this->enabledFiles[i]->processEnabledFile(); 436 // } 437 438 439 void CContext::solveAllRefOfEnabledFields(bool sendToServer) 440 { 441 int size = this->enabledFiles.size(); 442 for (int i = 0; i < size; ++i) 443 { 444 this->enabledFiles[i]->solveAllRefOfEnabledFields(sendToServer); 445 } 446 } 447 448 void CContext::buildAllExpressionOfEnabledFields() 449 { 450 int size = this->enabledFiles.size(); 451 for (int i = 0; i < size; ++i) 452 { 453 this->enabledFiles[i]->buildAllExpressionOfEnabledFields(); 454 } 455 } 456 457 // void CContext::solveAllGridRef(void) 458 // { 459 // for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 460 // this->enabledFiles[i]->solveEFGridRef(); 461 // } 462 // 463 // void CContext::solveAllOperation(void) 464 // { 465 // for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 466 // this->enabledFiles[i]->solveEFOperation(); 467 // } 468 // 469 // void CContext::solveAllExpression(void) 470 // { 471 // for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 472 // this->enabledFiles[i]->solveEFExpression(); 473 // } 474 361 475 void CContext::solveAllInheritance(bool apply) 362 476 { … … 368 482 const vector<CFile*> allFiles=CFile::getAll() ; 369 483 484 if (hasClient && !hasServer) 370 485 for (unsigned int i = 0; i < allFiles.size(); i++) 371 486 allFiles[i]->solveFieldRefInheritance(apply); … … 383 498 } 384 499 else enabledFiles.push_back(allFiles[i]); // otherwise true by default 385 500 386 501 387 502 if (enabledFiles.size() == 0) … … 394 509 std::vector<CFile*>::const_iterator 395 510 it = this->enabledFiles.begin(), end = this->enabledFiles.end(); 396 511 397 512 for (; it != end; it++) 398 513 { … … 401 516 } 402 517 } 403 518 519 /*! 520 \brief Dispatch event received from client 521 Whenever a message is received in buffer of server, it will be processed depending on 522 its event type. A new event type should be added in the switch list to make sure 523 it processed on server side. 524 \param [in] event: Received message 525 */ 404 526 bool CContext::dispatchEvent(CEventServer& event) 405 527 { 406 528 407 529 if (SuperClass::dispatchEvent(event)) return true ; 408 530 else … … 422 544 return true ; 423 545 break ; 546 case EVENT_ID_POST_PROCESS: 547 recvPostProcessing(event) ; 548 return true ; 549 break ; 424 550 default : 425 551 ERROR("bool CContext::dispatchEvent(CEventServer& event)", … … 429 555 } 430 556 } 431 557 558 //! Client side: Send a message to server to make it close 432 559 void CContext::sendCloseDefinition(void) 433 560 { 434 435 CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION) ; 561 CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION) ; 436 562 if (client->isServerLeader()) 437 563 { … … 443 569 else client->sendEvent(event) ; 444 570 } 445 571 572 //! Server side: Receive a message of client announcing a context close 446 573 void CContext::recvCloseDefinition(CEventServer& event) 447 574 { 448 575 449 576 CBufferIn* buffer=event.subEvents.begin()->buffer; 450 577 string id; 451 578 *buffer>>id ; 452 get(id)->closeDefinition() ; 453 } 454 579 get(id)->closeDefinition(); 580 } 581 582 //! Client side: Send a message to update calendar in each time step 455 583 void CContext::sendUpdateCalendar(int step) 456 584 { 457 585 if (!hasServer) 458 586 { 459 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR) ; 587 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR) ; 460 588 if (client->isServerLeader()) 461 589 { … … 468 596 } 469 597 } 470 598 599 //! Server side: Receive a message of client annoucing calendar update 471 600 void CContext::recvUpdateCalendar(CEventServer& event) 472 601 { 473 602 474 603 CBufferIn* buffer=event.subEvents.begin()->buffer; 475 604 string id; … … 477 606 get(id)->recvUpdateCalendar(*buffer) ; 478 607 } 479 608 609 //! Server side: Receive a message of client annoucing calendar update 480 610 void CContext::recvUpdateCalendar(CBufferIn& buffer) 481 611 { … … 484 614 updateCalendar(step) ; 485 615 } 486 616 617 //! Client side: Send a message to create header part of netcdf file 487 618 void CContext::sendCreateFileHeader(void) 488 619 { 489 490 CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER) ; 620 CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER) ; 491 621 if (client->isServerLeader()) 492 622 { … … 498 628 else client->sendEvent(event) ; 499 629 } 500 630 631 //! Server side: Receive a message of client annoucing the creation of header part of netcdf file 501 632 void CContext::recvCreateFileHeader(CEventServer& event) 502 633 { 503 504 634 CBufferIn* buffer=event.subEvents.begin()->buffer; 505 635 string id; … … 507 637 get(id)->recvCreateFileHeader(*buffer) ; 508 638 } 509 639 640 //! Server side: Receive a message of client annoucing the creation of header part of netcdf file 510 641 void CContext::recvCreateFileHeader(CBufferIn& buffer) 511 642 { 512 643 createFileHeader() ; 513 644 } 514 645 646 //! Client side: Send a message to do some post processing on server 647 void CContext::sendPostProcessing() 648 { 649 if (!hasServer) 650 { 651 CEventClient event(getType(),EVENT_ID_POST_PROCESS) ; 652 if (client->isServerLeader()) 653 { 654 CMessage msg ; 655 msg<<this->getId(); 656 event.push(client->getServerLeader(),1,msg) ; 657 client->sendEvent(event) ; 658 } 659 else client->sendEvent(event) ; 660 } 661 } 662 663 //! Server side: Receive a message to do some post processing 664 void CContext::recvPostProcessing(CEventServer& event) 665 { 666 CBufferIn* buffer=event.subEvents.begin()->buffer; 667 string id; 668 *buffer>>id; 669 get(id)->recvPostProcessing(*buffer); 670 } 671 672 //! Server side: Receive a message to do some post processing 673 void CContext::recvPostProcessing(CBufferIn& buffer) 674 { 675 postProcessing(); 676 } 677 678 /*! 679 \brief Do some simple post processings after parsing xml file 680 After the xml file (iodef.xml) is parsed, it is necessary to build all relations among 681 created object, e.g: inhertance among fields, domain, axis. After that, all fiels as well as their parents (reference fields), 682 which will be written out into netcdf files, are processed 683 */ 684 void CContext::postProcessing() 685 { 686 if (isPostProcessed) return; 687 688 this->solveCalendar(); 689 690 // Solve calendar for both side: client and server 691 this->solveCalendar(); 692 693 // Find all inheritance in xml structure 694 this->solveAllInheritance(); 695 696 //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 697 this->findEnabledFiles(); 698 699 // Find all enabled fields of each file 700 this->findAllEnabledFields(); 701 702 // Search and rebuild all reference object of enabled fields 703 this->solveAllRefOfEnabledFields(false); 704 isPostProcessed = true; 705 } 706 707 std::map<int, StdSize>& CContext::getDataSize() 708 { 709 std::set<StdString> domainIds; 710 711 // Find all reference domain and axis of all active fields 712 int numEnabledFiles = this->enabledFiles.size(); 713 for (int i = 0; i < numEnabledFiles; ++i) 714 { 715 std::vector<CField*> enabledFields = this->enabledFiles[i]->getEnabledFields(); 716 int numEnabledFields = enabledFields.size(); 717 for (int j = 0; j < numEnabledFields; ++j) 718 { 719 const std::pair<StdString, StdString>& prDomAxisId = enabledFields[j]->getDomainAxisIds(); 720 const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataSize(); 721 if (dataSize_.empty()) 722 { 723 dataSize_ = mapSize; 724 domainIds.insert(prDomAxisId.first); 725 } 726 else 727 { 728 if (domainIds.find(prDomAxisId.first) == domainIds.end()) 729 { 730 std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 731 for (; it != itE; ++it) 732 { 733 if (0 < dataSize_.count(it->first)) dataSize_[it->first] += it->second; 734 else dataSize_.insert(make_pair(it->first, it->second)); 735 } 736 } 737 738 } 739 740 } 741 } 742 743 return dataSize_; 744 } 745 746 //! Client side: Send infomation of active files (files are enabled to write out) 747 void CContext::sendEnabledFiles() 748 { 749 int size = this->enabledFiles.size(); 750 751 // In a context, each type has a root definition, e.g: axis, domain, field. 752 // Every object must be a child of one of these root definition. In this case 753 // all new file objects created on server must be children of the root "file_definition" 754 StdString fileDefRoot("file_definition"); 755 CFileGroup* cfgrpPtr = CFileGroup::get(fileDefRoot); 756 757 for (int i = 0; i < size; ++i) 758 { 759 cfgrpPtr->sendCreateChild(this->enabledFiles[i]->getId()); 760 this->enabledFiles[i]->sendAllAttributesToServer(); 761 this->enabledFiles[i]->sendAddAllVariables(); 762 } 763 } 764 765 //! Client side: Send information of active fields (ones are written onto files) 766 void CContext::sendEnabledFields() 767 { 768 int size = this->enabledFiles.size(); 769 for (int i = 0; i < size; ++i) 770 { 771 this->enabledFiles[i]->sendEnabledFields(); 772 } 773 } 774 775 //! Client side: Send information of reference grid of active fields 776 void CContext::sendRefGrid() 777 { 778 std::set<StdString> gridIds; 779 int sizeFile = this->enabledFiles.size(); 780 CFile* filePtr(NULL); 781 782 // Firstly, find all reference grids of all active fields 783 for (int i = 0; i < sizeFile; ++i) 784 { 785 filePtr = this->enabledFiles[i]; 786 std::vector<CField*> enabledFields = filePtr->getEnabledFields(); 787 int sizeField = enabledFields.size(); 788 for (int numField = 0; numField < sizeField; ++numField) 789 { 790 if (0 != enabledFields[numField]->getRelGrid()) 791 gridIds.insert(CGrid::get(enabledFields[numField]->getRelGrid())->getId()); 792 } 793 } 794 795 // Create all reference grids on server side 796 StdString gridDefRoot("grid_definition"); 797 CGridGroup* gridPtr = CGridGroup::get(gridDefRoot); 798 std::set<StdString>::const_iterator it, itE = gridIds.end(); 799 for (it = gridIds.begin(); it != itE; ++it) 800 { 801 gridPtr->sendCreateChild(*it); 802 CGrid::get(*it)->sendAllAttributesToServer(); 803 } 804 } 805 806 807 //! Client side: Send information of reference domain and axis of active fields 808 void CContext::sendRefDomainsAxis() 809 { 810 std::set<StdString> domainIds; 811 std::set<StdString> axisIds; 812 813 // Find all reference domain and axis of all active fields 814 int numEnabledFiles = this->enabledFiles.size(); 815 for (int i = 0; i < numEnabledFiles; ++i) 816 { 817 std::vector<CField*> enabledFields = this->enabledFiles[i]->getEnabledFields(); 818 int numEnabledFields = enabledFields.size(); 819 for (int j = 0; j < numEnabledFields; ++j) 820 { 821 const std::pair<StdString, StdString>& prDomAxisId = enabledFields[j]->getDomainAxisIds(); 822 domainIds.insert(prDomAxisId.first); 823 axisIds.insert(prDomAxisId.second); 824 } 825 } 826 827 // Create all reference axis on server side 828 std::set<StdString>::iterator itDom, itAxis; 829 std::set<StdString>::const_iterator itE; 830 831 StdString axiDefRoot("axis_definition"); 832 CAxisGroup* axisPtr = CAxisGroup::get(axiDefRoot); 833 itE = axisIds.end(); 834 for (itAxis = axisIds.begin(); itAxis != itE; ++itAxis) 835 { 836 axisPtr->sendCreateChild(*itAxis); 837 CAxis::get(*itAxis)->sendAllAttributesToServer(); 838 } 839 840 // Create all reference domains on server side 841 StdString domDefRoot("domain_definition"); 842 CDomainGroup* domPtr = CDomainGroup::get(domDefRoot); 843 itE = domainIds.end(); 844 for (itDom = domainIds.begin(); itDom != itE; ++itDom) 845 { 846 domPtr->sendCreateChild(*itDom); 847 CDomain::get(*itDom)->sendAllAttributesToServer(); 848 } 849 } 850 851 //! Update calendar in each time step 515 852 void CContext::updateCalendar(int step) 516 853 { … … 519 856 info(50)<<"updateCalendar : after : "<<calendar->getCurrentDate()<<endl ; 520 857 } 521 858 859 //! Server side: Create header of netcdf file 522 860 void CContext::createFileHeader(void ) 523 861 { 524 862 vector<CFile*>::const_iterator it ; 525 863 526 864 for (it=enabledFiles.begin(); it != enabledFiles.end(); it++) 527 865 { 528 866 (*it)->initFile(); 529 867 } 530 } 531 868 } 869 870 //! Get current context 532 871 CContext* CContext::getCurrent(void) 533 872 { 534 873 return CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()).get() ; 535 874 } 536 875 876 /*! 877 \brief Set context with an id be the current context 878 \param [in] id identity of context to be set to current 879 */ 537 880 void CContext::setCurrent(const string& id) 538 881 { … … 540 883 CGroupFactory::SetCurrentContextId(id); 541 884 } 542 885 886 /*! 887 \brief Create a context with specific id 888 \param [in] id identity of new context 889 \return pointer to the new context or already-existed one with identity id 890 */ 543 891 CContext* CContext::create(const StdString& id) 544 892 { 545 893 CContext::setCurrent(id) ; 546 894 547 895 bool hasctxt = CContext::has(id); 548 896 CContext* context = CObjectFactory::CreateObject<CContext>(id).get(); -
XIOS/trunk/src/node/context.hpp
r501 r509 18 18 class CContextClient ; 19 19 class CContextServer ; 20 21 20 21 22 22 /// ////////////////////// Déclarations ////////////////////// /// 23 23 class CContextGroup; … … 33 33 34 34 ///-------------------------------------------------------------- 35 35 /*! 36 \class CContext 37 This class corresponds to the concrete presentation of context in xml file and in play an essential role in XIOS 38 Each object of this class contains all root definition of elements: files, fiels, domains, axis, etc, ... from which 39 we can have access to each element. 40 In fact, every thing must a be inside a particuliar context. After the xml file (iodef.xml) is parsed, 41 object of the class is created and its contains all information of other elements in the xml file. 42 */ 36 43 class CContext 37 44 : public CObjectTemplate<CContext> … … 42 49 { 43 50 EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, 44 EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE 51 EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, 52 EVENT_ID_POST_PROCESS 45 53 } ; 46 54 47 55 /// typedef /// 48 56 typedef CObjectTemplate<CContext> SuperClass; … … 70 78 71 79 public : 72 80 73 81 /// Mutateurs /// 74 82 void setCalendar(boost::shared_ptr<CCalendar> newCalendar); 75 83 76 84 /// Accesseurs /// 77 85 boost::shared_ptr<CCalendar> getCalendar(void) const; 78 86 79 /// Accesseurs statiques /// 80 static StdString GetName(void); 81 static StdString GetDefName(void); 82 static ENodeType GetType(void); 83 84 static CContextGroup* GetContextGroup(void); 85 86 public : 87 88 /// Traitements /// 89 virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); 90 void solveFieldRefInheritance(bool apply); 91 void solveCalendar(void); 92 93 /// Autres méthodes statiques /// 94 static void ShowTree(StdOStream & out = std::clog); 95 static void CleanTree(void); 96 97 /// Test /// 98 virtual bool hasChild(void) const; 99 87 public : 88 // Initialize server or client 89 void initServer(MPI_Comm intraComm, MPI_Comm interComm) ; 90 void initClient(MPI_Comm intraComm, MPI_Comm interComm) ; 91 bool isInitialized(void) ; 92 93 // Put sever or client into loop state 100 94 bool eventLoop(void) ; 101 95 bool serverLoop(void) ; 102 96 void clientLoop(void) ; 103 void initServer(MPI_Comm intraComm, MPI_Comm interComm) ; 104 void initClient(MPI_Comm intraComm, MPI_Comm interComm) ; 105 bool isInitialized(void) ; 106 CContextServer* server ; 107 CContextClient* client ; 108 bool hasClient ; 109 bool hasServer ; 97 98 // Process all information of calendar 99 void solveCalendar(void); 100 101 // Finalize a context 110 102 void finalize(void) ; 111 103 void closeDefinition(void) ; 104 105 // Some functions to process context 112 106 void findAllEnabledFields(void); 113 107 void processEnabledFiles(void) ; 114 void solveAllGridRef(void);115 void solveAllOperation(void);116 void solveAllExpression(void);117 108 void solveAllInheritance(bool apply=true) ; 118 109 void findEnabledFiles(void); … … 120 111 void updateCalendar(int step) ; 121 112 void createFileHeader(void ) ; 122 // dispatch event 123 static bool dispatchEvent(CEventServer& event) ; 113 void solveAllRefOfEnabledFields(bool sendToServer); 114 void buildAllExpressionOfEnabledFields(); 115 void postProcessing(); 116 117 std::map<int, StdSize>& getDataSize(); 118 void setClientServerBuffer(); 119 120 // Send context close definition 124 121 void sendCloseDefinition(void) ; 122 // There are something to send on closing context defintion 125 123 void sendUpdateCalendar(int step) ; 126 124 void sendCreateFileHeader(void) ; 125 void sendEnabledFiles(); 126 void sendEnabledFields(); 127 void sendRefDomainsAxis(); 128 void sendRefGrid(); 129 void sendPostProcessing(); 130 131 // Client side: Receive and process messages 127 132 static void recvUpdateCalendar(CEventServer& event) ; 128 133 void recvUpdateCalendar(CBufferIn& buffer) ; … … 130 135 static void recvCreateFileHeader(CEventServer& event) ; 131 136 void recvCreateFileHeader(CBufferIn& buffer) ; 132 static CContext* getCurrent(void) ; 133 static CContextGroup* getRoot(void) ; 134 static void setCurrent(const string& id) ; 135 static CContext* create(const string& id = "") ; 136 137 public : 138 139 /// Autres /// 137 static void recvSolveInheritanceContext(CEventServer& event); 138 void recvSolveInheritanceContext(CBufferIn& buffer); 139 static void recvPostProcessing(CEventServer& event); 140 void recvPostProcessing(CBufferIn& buffer); 141 142 // dispatch event 143 static bool dispatchEvent(CEventServer& event) ; 144 145 public: 146 // Get current context 147 static CContext* getCurrent(void); 148 149 // Get context root 150 static CContextGroup* getRoot(void); 151 152 // Set current context 153 static void setCurrent(const string& id); 154 155 // Create new context 156 static CContext* create(const string& id = ""); 157 158 /// Accesseurs statiques /// 159 static StdString GetName(void); 160 static StdString GetDefName(void); 161 static ENodeType GetType(void); 162 163 static CContextGroup* GetContextGroup(void); 164 165 // Some functions to visualize structure of current context 166 static void ShowTree(StdOStream & out = std::clog); 167 static void CleanTree(void); 168 169 public : 170 // Parse xml node and write all info into context 140 171 virtual void parse(xml::CXMLNode & node); 141 172 173 // Visualize a context 142 174 virtual StdString toString(void) const; 143 // virtual void toBinary (StdOStream & os) const; 144 // virtual void fromBinary(StdIStream & is); 145 146 public : 147 148 boost::shared_ptr<CCalendar> calendar; 149 175 176 177 // Solve all inheritance relation in current context 178 virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); 179 180 // Verify if all root definition in a context have children 181 virtual bool hasChild(void) const; 182 183 public : 184 // Calendar of context 185 boost::shared_ptr<CCalendar> calendar; 186 187 // List of all enabled files (files on which fields are written) 150 188 std::vector<CFile*> enabledFiles; 189 190 // Context root 151 191 static shared_ptr<CContextGroup> root ; 152 192 193 // Determine context on client or not 194 bool hasClient ; 195 196 // Determine context on server or not 197 bool hasServer ; 198 199 // Concrete context server 200 CContextServer* server ; 201 202 // Concrete contex client 203 CContextClient* client ; 204 205 private: 206 bool isPostProcessed; 207 std::map<int, StdSize> dataSize_; 208 209 210 public: // Some function maybe removed in the near future 211 // virtual void toBinary (StdOStream & os) const; 212 // virtual void fromBinary(StdIStream & is); 213 // void solveAllGridRef(void); 214 // void solveAllOperation(void); 215 // void solveAllExpression(void); 216 // void solveFieldRefInheritance(bool apply); 153 217 154 218 }; // class CContext -
XIOS/trunk/src/node/domain.cpp
r501 r509 16 16 17 17 namespace xios { 18 18 19 19 /// ////////////////////// Définitions ////////////////////// /// 20 20 21 21 CDomain::CDomain(void) 22 22 : CObjectTemplate<CDomain>(), CDomainAttributes() 23 , isChecked(false), relFiles()23 , isChecked(false), relFiles(), isClientChecked(false) 24 24 { /* Ne rien faire de plus */ } 25 25 26 26 CDomain::CDomain(const StdString & id) 27 27 : CObjectTemplate<CDomain>(id), CDomainAttributes() 28 , isChecked(false), relFiles() 28 , isChecked(false), relFiles(), isClientChecked(false) 29 29 { /* Ne rien faire de plus */ } 30 30 31 31 CDomain::~CDomain(void) 32 { 32 { 33 33 } 34 34 … … 37 37 const std::set<StdString> & CDomain::getRelFiles(void) const 38 38 { 39 return (this->relFiles); 40 } 41 42 //---------------------------------------------------------------- 43 39 return (this->relFiles); 40 } 41 42 //---------------------------------------------------------------- 43 44 44 bool CDomain::hasZoom(void) const 45 45 { 46 return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && 46 return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && 47 47 (this->zoom_nj.getValue() != this->nj_glo.getValue())); 48 48 } 49 50 //---------------------------------------------------------------- 51 49 50 //---------------------------------------------------------------- 51 52 52 bool CDomain::isEmpty(void) const 53 53 { 54 return ((this->zoom_ni_srv == 0) || 54 return ((this->zoom_ni_srv == 0) || 55 55 (this->zoom_nj_srv == 0)); 56 56 } … … 86 86 << "[ Id = " << this->getId() << " ] " 87 87 << "The global domain is badly defined," 88 << " check the \'ni_glo\' value !") 88 << " check the \'ni_glo\' value !") 89 89 } 90 90 nj_glo=ni_glo ; … … 111 111 ibegin=1 ; 112 112 iend=1 ; 113 113 114 114 } 115 115 else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || … … 119 119 << "[ Id = " << this->getId() << " ] " 120 120 << "The global domain is badly defined," 121 << " check the \'ni_glo\' et \'nj_glo\' values !") 121 << " check the \'ni_glo\' et \'nj_glo\' values !") 122 122 } 123 123 checkLocalIDomain() ; 124 124 checkLocalJDomain() ; 125 125 126 126 if (i_index.isEmpty()) 127 127 { 128 128 i_index.resize(ni,nj) ; 129 129 for(int j=0;j<nj;j++) 130 for(int i=0;i<ni;i++) i_index(i,j)=i ; 130 for(int i=0;i<ni;i++) i_index(i,j)=i ; 131 131 } 132 132 133 133 if (j_index.isEmpty()) 134 134 { 135 135 j_index.resize(ni,nj) ; 136 136 for(int j=0;j<nj;j++) 137 for(int i=0;i<ni;i++) j_index(i,j)=j ; 137 for(int i=0;i<ni;i++) j_index(i,j)=j ; 138 138 } 139 139 140 140 } 141 141 … … 211 211 << "Domain is wrong defined," 212 212 << " Check the values : nj, nj_glo, jbegin, jend") ; 213 213 214 214 ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; 215 215 jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; … … 221 221 { 222 222 using namespace std; 223 223 224 224 int ibegin_mask = 0, 225 225 jbegin_mask = 0, 226 226 iend_mask = iend.getValue() - ibegin.getValue(), 227 227 jend_mask = jend.getValue() - jbegin.getValue(); 228 228 229 229 if (!zoom_ibegin.isEmpty()) 230 230 { 231 231 int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; 232 232 int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; 233 233 234 234 ibegin_mask = max (ibegin.getValue(), zoom_ibegin.getValue()); 235 235 jbegin_mask = max (jbegin.getValue(), zoom_jbegin.getValue()); 236 236 iend_mask = min (iend.getValue(), zoom_iend); 237 237 jend_mask = min (jend.getValue(), zoom_jend); 238 238 239 239 ibegin_mask -= ibegin.getValue(); 240 240 jbegin_mask -= jbegin.getValue(); … … 242 242 jend_mask -= jbegin.getValue(); 243 243 } 244 244 245 245 246 246 if (!mask.isEmpty()) … … 251 251 <<"the mask has not the same size than the local domain"<<endl 252 252 <<"Local size is "<<ni<<"x"<<nj<<endl 253 <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 253 <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 254 254 for (int i = 0; i < ni; i++) 255 255 { … … 283 283 284 284 void CDomain::checkDomainData(void) 285 { 285 { 286 286 if (!data_dim.isEmpty() && 287 287 !(data_dim.getValue() == 1 || data_dim.getValue() == 2)) … … 378 378 data_i_index.resize(dni) ; 379 379 data_j_index.resize(dni) ; 380 380 381 381 data_n_index.setValue(dni); 382 382 383 383 for(int count = 0, j = 0; j < data_nj.getValue(); j++) 384 384 { … … 394 394 395 395 //---------------------------------------------------------------- 396 396 397 397 void CDomain::completeLonLatClient(void) 398 398 { … … 402 402 CArray<double,2> bounds_lon_temp(nvertex,ni*nj) ; 403 403 CArray<double,2> bounds_lat_temp(nvertex,ni*nj) ; 404 404 405 405 if (type.isEmpty()) 406 406 { 407 if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) 407 if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) 408 408 { 409 409 type.setValue(type_attr::curvilinear) ; 410 410 isCurvilinear=true ; 411 411 } 412 else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) 412 else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) 413 413 { 414 414 type.setValue(type_attr::regular) ; … … 429 429 { 430 430 for(j=0;j<nj;j++) 431 for(i=0;i<ni;i++) 431 for(i=0;i<ni;i++) 432 432 { 433 433 k=j*ni+i ; … … 436 436 if (hasBounds) 437 437 { 438 for(int n=0;n<nvertex;n++) 438 for(int n=0;n<nvertex;n++) 439 439 { 440 440 bounds_lon_temp(n,k)=bounds_lon(n,i) ; … … 444 444 } 445 445 } 446 446 447 447 StdSize dm = zoom_ni_client * zoom_nj_client; 448 448 449 449 lonvalue.resize(dm); 450 450 latvalue.resize(dm); 451 451 452 452 for (int i = 0; i < zoom_ni_client; i++) 453 453 { 454 454 for (int j = 0; j < zoom_nj_client; j++) 455 455 { 456 lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 456 lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 457 457 latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client - jbegin)*ni ); 458 458 if (hasBounds) 459 459 { 460 for(int n=0;n<nvertex;n++) 460 for(int n=0;n<nvertex;n++) 461 461 { 462 bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 462 bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 463 463 bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client -jbegin)*ni ); 464 464 } … … 467 467 } 468 468 } 469 469 470 470 471 471 //---------------------------------------------------------------- … … 487 487 int zoom_iend = zoom_ibegin + zoom_ni - 1; 488 488 int zoom_jend = zoom_jbegin + zoom_nj - 1; 489 489 490 490 if (zoom_ibegin < 1 || zoom_jbegin < 1 || zoom_iend > ni_glo || zoom_jend > nj_glo) 491 491 ERROR("CDomain::checkZoom(void)", … … 496 496 else 497 497 { 498 zoom_ni = ni_glo; 498 zoom_ni = ni_glo; 499 499 zoom_nj = nj_glo; 500 500 zoom_ibegin = 1; 501 501 zoom_jbegin = 1; 502 502 } 503 503 504 504 // compute client zoom indices 505 505 … … 510 510 if (zoom_ni_client<0) zoom_ni_client=0 ; 511 511 512 512 513 513 int zoom_jend=zoom_jbegin+zoom_nj-1 ; 514 514 zoom_jbegin_client = jbegin_client > zoom_jbegin ? jbegin_client : zoom_jbegin ; … … 518 518 519 519 } 520 520 521 521 void CDomain::checkBounds(void) 522 522 { … … 524 524 { 525 525 hasBounds=true ; 526 526 527 527 } 528 else 528 else 529 529 { 530 530 hasBounds=false; … … 532 532 } 533 533 } 534 535 //---------------------------------------------------------------- 536 537 void CDomain::checkAttributes(void) 538 { 539 if (this->isChecked) return; 540 CContext* context=CContext::getCurrent() ; 534 535 //---------------------------------------------------------------- 536 // Divide function checkAttributes into 2 seperate ones 537 // This function only checks all attributes of current domain 538 void CDomain::checkAttributesOnClient() 539 { 540 if (this->isClientChecked) return; 541 CContext* context=CContext::getCurrent(); 541 542 542 543 this->checkDomain(); 543 544 this->checkZoom(); 544 545 this->checkBounds(); 545 546 546 547 if (context->hasClient) 547 548 { // CÃŽté client uniquement … … 550 551 this->checkCompression(); 551 552 this->completeLonLatClient(); 553 this->computeConnectedServer() ; 552 554 } 553 555 else … … 556 558 // ne sert plus // this->completeLonLatServer(); 557 559 } 558 560 561 this->isClientChecked = true; 562 } 563 564 // Send all checked attributes to server 565 void CDomain::sendCheckedAttributes() 566 { 567 if (!this->isClientChecked) checkAttributesOnClient(); 568 CContext* context=CContext::getCurrent() ; 569 570 if (this->isChecked) return; 571 if (context->hasClient) 572 { 573 sendServerAttribut() ; 574 sendLonLat() ; 575 } 576 577 this->isChecked = true; 578 } 579 580 void CDomain::checkAttributes(void) 581 { 582 if (this->isChecked) return; 583 CContext* context=CContext::getCurrent() ; 584 585 this->checkDomain(); 586 this->checkZoom(); 587 this->checkBounds(); 588 589 if (context->hasClient) 590 { // CÃŽté client uniquement 591 this->checkMask(); 592 this->checkDomainData(); 593 this->checkCompression(); 594 this->completeLonLatClient(); 595 } 596 else 597 { // CÃŽté serveur uniquement 598 // if (!this->isEmpty()) 599 // ne sert plus // this->completeLonLatServer(); 600 } 601 559 602 if (context->hasClient) 560 603 { … … 563 606 sendLonLat() ; 564 607 } 565 608 566 609 this->isChecked = true; 567 610 } 568 611 569 612 void CDomain::sendServerAttribut(void) 570 613 { … … 572 615 int ibegin_srv=1 ; 573 616 int iend_srv=ni_glo.getValue() ; 574 617 575 618 int nj_srv ; 576 619 int jbegin_srv ; 577 620 int jend_srv ; 578 621 579 622 CContext* context=CContext::getCurrent() ; 580 623 CContextClient* client=context->client ; 581 624 int nbServer=client->serverSize ; 582 625 int serverRank=client->getServerLeader() ; 583 626 584 627 jend_srv=0 ; 585 628 for(int i=0;i<=serverRank;i++) … … 590 633 jend_srv=jbegin_srv+nj_srv-1 ; 591 634 } 592 593 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 635 636 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 594 637 if (client->isServerLeader()) 595 638 { … … 606 649 { 607 650 int i,j,i_ind,j_ind ; 608 651 609 652 ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; 610 653 jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; 611 654 612 655 CContext* context = CContext::getCurrent() ; 613 656 CContextClient* client=context->client ; … … 617 660 int zoom_iend=zoom_ibegin+zoom_ni-1 ; 618 661 int zoom_jend=zoom_jbegin+zoom_nj-1 ; 619 662 620 663 int blockSize=nj_glo/nbServer ; 621 664 int ns=nj_glo%nbServer ; 622 665 int pos=ns*(blockSize+1) ; 623 666 int serverNum ; 624 667 625 668 mapConnectedServer.resize(ni,nj) ; 626 669 vector<int> nbData(nbServer,0) ; 627 670 vector<int> indServer(nbServer,-1) ; 628 671 vector<bool> IsConnected(nbServer,false) ; 629 672 630 673 for(j=0;j<nj;j++) 631 674 for(i=0;i<ni;i++) … … 633 676 i_ind=ibegin+i_index(i,j)-1 ; 634 677 j_ind=jbegin+j_index(i,j)-1 ; 635 678 636 679 if (j_ind<pos) serverNum=j_ind/(blockSize+1) ; 637 680 else serverNum=ns+(j_ind-pos)/blockSize ; 638 681 IsConnected[serverNum]=true ; 639 682 640 683 if (i_ind >= zoom_ibegin-1 && i_ind <= zoom_iend-1 && j_ind >= zoom_jbegin-1 && j_ind <= zoom_jend-1) 641 684 { … … 647 690 648 691 649 for(serverNum=0 ; serverNum<nbServer ; serverNum++) 692 for(serverNum=0 ; serverNum<nbServer ; serverNum++) 650 693 if (IsConnected[serverNum]) 651 694 { … … 655 698 nbDataSrv.push_back(nbData[serverNum]) ; 656 699 } 657 700 658 701 i_indSrv.resize(connectedServer.size()) ; 659 702 j_indSrv.resize(connectedServer.size()) ; 660 703 661 704 for(j=0;j<nj;j++) 662 for(i=0;i<ni;i++) 705 for(i=0;i<ni;i++) 663 706 { 664 707 if (mapConnectedServer(i,j)>=0) … … 670 713 } 671 714 } 672 715 673 716 int nbConnectedServer=connectedServer.size() ; 674 717 … … 677 720 int* sendBuff=new int[nbConnectedServer] ; 678 721 valarray<int> nbClient(0,client->serverSize) ; 679 722 680 723 for(int n=0;n<nbConnectedServer;n++) sendBuff[n]=connectedServer[n] ; 681 724 682 725 // get connected server for everybody 683 726 MPI_Allgather(&nbConnectedServer,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm) ; 684 727 685 728 displ[0]=0 ; 686 729 for(int n=1;n<client->clientSize;n++) displ[n]=displ[n-1]+recvCount[n-1] ; 687 730 int recvSize=displ[client->clientSize-1]+recvCount[client->clientSize-1] ; 688 731 int* recvBuff=new int[recvSize] ; 689 690 732 733 691 734 MPI_Allgatherv(sendBuff,nbConnectedServer,MPI_INT,recvBuff,recvCount,displ,MPI_INT,client->intraComm) ; 692 735 for(int n=0;n<recvSize;n++) nbClient[recvBuff[n]]++ ; 693 736 694 737 for(int n=0;n<nbConnectedServer;n++) nbSenders.push_back(nbClient[connectedServer[n]]) ; 695 738 696 739 delete [] recvCount ; 697 740 delete [] displ ; … … 708 751 // send lon lat for each connected server 709 752 CEventClient event(getType(),EVENT_ID_LON_LAT) ; 710 711 list<shared_ptr<CMessage> > list_msg ; 753 754 list<shared_ptr<CMessage> > list_msg ; 712 755 list< CArray<int,1>* > list_indi,list_indj ; 713 756 list< CArray<double,1>* >list_lon,list_lat ; … … 723 766 CArray<double,2> boundslon(nvertex,nbData) ; 724 767 CArray<double,2> boundslat(nvertex,nbData) ; 725 726 for(n=0;n<nbData;n++) 768 769 for(n=0;n<nbData;n++) 727 770 { 728 771 i=i_indSrv[ns][n] ; 729 772 j=j_indSrv[ns][n] ; 730 773 ind=(i-(zoom_ibegin_client-1))+(j-(zoom_jbegin_client-1))*zoom_ni_client ; 731 774 732 775 lon(n)=lonvalue(ind) ; 733 776 lat(n)=latvalue(ind) ; … … 743 786 indj(n)=jbegin+j_index(i-ibegin+1,j-jbegin+1)-1 ; 744 787 } 745 788 746 789 list_indi.push_back(new CArray<int,1>(indi.copy())) ; 747 790 list_indj.push_back(new CArray<int,1>(indj.copy())) ; … … 761 804 762 805 client->sendEvent(event) ; 763 764 806 807 765 808 for(list<CArray<int,1>* >::iterator it=list_indi.begin();it!=list_indi.end();it++) delete *it; 766 809 for(list<CArray<int,1>* >::iterator it=list_indj.begin();it!=list_indj.end();it++) delete *it; … … 768 811 for(list<CArray<double,1>* >::iterator it=list_lat.begin();it!=list_lat.end();it++) delete *it; 769 812 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslon.begin();it!=list_boundslon.end();it++) delete *it; 770 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslat.begin();it!=list_boundslat.end();it++) delete *it; 771 813 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslat.begin();it!=list_boundslat.end();it++) delete *it; 814 772 815 } 773 774 816 817 775 818 bool CDomain::dispatchEvent(CEventServer& event) 776 819 { 777 820 778 821 if (SuperClass::dispatchEvent(event)) return true ; 779 822 else … … 796 839 } 797 840 } 798 841 799 842 void CDomain::recvServerAttribut(CEventServer& event) 800 843 { … … 804 847 get(domainId)->recvServerAttribut(*buffer) ; 805 848 } 806 849 807 850 void CDomain::recvServerAttribut(CBufferIn& buffer) 808 851 { … … 811 854 812 855 buffer>>ni_srv>>ibegin_srv>>iend_srv>>nj_srv>>jbegin_srv>>jend_srv; 813 814 856 857 815 858 zoom_ibegin_srv = zoom_ibegin.getValue() > ibegin_srv ? zoom_ibegin.getValue() : ibegin_srv ; 816 859 zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; 817 860 zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; 818 861 819 862 zoom_jbegin_srv = zoom_jbegin.getValue() > jbegin_srv ? zoom_jbegin.getValue() : jbegin_srv ; 820 863 zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; 821 864 zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; 822 865 823 if (zoom_ni_srv<=0 || zoom_nj_srv<=0) 866 if (zoom_ni_srv<=0 || zoom_nj_srv<=0) 824 867 { 825 868 zoom_ibegin_srv=1 ; zoom_iend_srv=0 ; zoom_ni_srv=0 ; … … 830 873 latvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 831 874 latvalue_srv = 0. ; 832 if (hasBounds) 875 if (hasBounds) 833 876 { 834 877 bounds_lon_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; … … 838 881 } 839 882 } 840 883 841 884 void CDomain::recvLonLat(CEventServer& event) 842 885 { … … 850 893 } 851 894 } 852 895 853 896 void CDomain::recvLonLat(CBufferIn& buffer) 854 897 { … … 859 902 CArray<double,2> boundslon ; 860 903 CArray<double,2> boundslat ; 861 904 862 905 int type_int ; 863 906 buffer>>type_int>>isCurvilinear>>indi>>indj>>lon>>lat ; … … 872 915 lonvalue_srv(ind_srv)=lon(ind) ; 873 916 latvalue_srv(ind_srv)=lat(ind) ; 874 if (hasBounds) 875 { 876 for(int nv=0;nv<nvertex;nv++) 917 if (hasBounds) 918 { 919 for(int nv=0;nv<nvertex;nv++) 877 920 { 878 921 bounds_lon_srv(nv,ind_srv)=boundslon(nv,ind) ; … … 883 926 } 884 927 //---------------------------------------------------------------- 885 886 887 928 929 930 888 931 ///--------------------------------------------------------------- 889 932 -
XIOS/trunk/src/node/domain.hpp
r501 r509 15 15 16 16 namespace xios { 17 17 18 18 /// ////////////////////// Déclarations ////////////////////// /// 19 19 … … 39 39 EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_LON_LAT 40 40 } ; 41 41 42 42 /// typedef /// 43 43 typedef CObjectTemplate<CDomain> SuperClass; … … 58 58 void checkAttributes(void); 59 59 60 void checkAttributesOnClient(); 61 62 void sendCheckedAttributes(); 63 60 64 private : 61 65 … … 68 72 void checkDomainData(void); 69 73 void checkCompression(void); 70 74 71 75 void checkZoom(void); 72 76 void checkBounds(void); … … 74 78 75 79 public : 76 80 77 81 /// Autres /// 78 82 … … 84 88 bool hasZoom(void) const; 85 89 bool isEmpty(void) const; 86 87 90 91 88 92 int ni_client,ibegin_client,iend_client ; 89 93 int zoom_ni_client,zoom_ibegin_client,zoom_iend_client ; … … 100 104 CArray<double, 1> lonvalue_srv, latvalue_srv ; 101 105 CArray<double, 2> bounds_lon_srv, bounds_lat_srv ; 102 103 104 vector<int> connectedServer ; // list of connected server 106 107 108 vector<int> connectedServer ; // list of connected server 105 109 vector<int> nbSenders ; // for each communication with a server, number of communicating client 106 vector<int> nbDataSrv ; // size of data to send to each server 110 vector<int> nbDataSrv ; // size of data to send to each server 107 111 vector< vector<int> > i_indSrv ; // for each server, i global index to send 108 112 vector< vector<int> > j_indSrv ; // for each server, j global index to send 109 113 110 114 CArray<int,2> mapConnectedServer ; // (ni,nj) => mapped to connected server number, -1 if no server is target 111 115 112 116 // vector<int> ib_srv, ie_srv, in_srv ; 113 117 // vector<int> jb_srv, je_srv, jn_srv ; 114 118 115 119 public : 116 120 117 121 /// Mutateur /// 118 122 void addRelFile(const StdString & filename); … … 126 130 void recvLonLat(CBufferIn& buffer) ; 127 131 void recvServerAttribut(CBufferIn& buffer) ; 128 132 129 133 /// Destructeur /// 130 134 virtual ~CDomain(void); … … 133 137 static StdString GetName(void); 134 138 static StdString GetDefName(void); 135 139 136 140 static ENodeType GetType(void); 137 141 … … 144 148 bool isChecked; 145 149 std::set<StdString> relFiles; 150 bool isClientChecked; // Verify whether all attributes of domain on the client side is good 146 151 147 152 }; // class CDomain -
XIOS/trunk/src/node/field.cpp
r501 r509 14 14 15 15 namespace xios{ 16 16 17 17 /// ////////////////////// Définitions ////////////////////// /// 18 18 … … 26 26 , foperation(), hasInstantData(false), hasExpression(false) 27 27 , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL) 28 , processed(false) 28 , processed(false), domAxisIds_("",""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 29 29 { setVirtualVariableGroup() ; } 30 30 … … 38 38 , foperation(), hasInstantData(false), hasExpression(false) 39 39 , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL) 40 , processed(false) 40 , processed(false), domAxisIds_("",""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 41 41 { setVirtualVariableGroup() ; } 42 42 … … 48 48 if (hasExpression) delete expression ; 49 49 if (slotUpdateDate!=NULL) delete slotUpdateDate ; 50 50 51 51 } 52 52 … … 55 55 56 56 void CField::setVirtualVariableGroup(CVariableGroup* newVVariableGroup) 57 { 58 this->vVariableGroup = newVVariableGroup; 59 } 60 57 { 58 this->vVariableGroup = newVVariableGroup; 59 } 60 61 61 void CField::setVirtualVariableGroup(void) 62 62 { 63 63 this->setVirtualVariableGroup(CVariableGroup::create()); 64 64 } 65 65 66 66 CVariableGroup* CField::getVirtualVariableGroup(void) const 67 67 { … … 69 69 } 70 70 71 71 72 72 std::vector<CVariable*> CField::getAllVariables(void) const 73 73 { 74 74 return (this->vVariableGroup->getAllChildren()); 75 75 } 76 76 77 77 void CField::solveDescInheritance(bool apply, const CAttributeMap * const parent) 78 78 { … … 88 88 { 89 89 const CDate opeDate = *last_operation + freq_operation; 90 const CDate writeDate = *last_Write + freq_write; 91 90 const CDate writeDate = *last_Write + freq_write; 91 92 92 if (opeDate <= currDate) 93 93 { … … 95 95 { 96 96 this->data.resize(this->grid->storeIndex[0] ->numElements()); 97 } 97 } 98 98 CArray<double,1> input(data.numElements()) ; 99 this->grid->inputFieldServer(storedClient, input); 99 this->grid->inputFieldServer(storedClient, input); 100 100 (*this->foperation)(input); 101 101 *last_operation = currDate; … … 106 106 this->incrementNStep(); 107 107 *last_Write = writeDate; 108 return (true); 108 return (true); 109 109 } 110 110 return (false); 111 111 } 112 112 113 113 bool CField::dispatchEvent(CEventServer& event) 114 114 { 115 115 116 116 if (SuperClass::dispatchEvent(event)) return true ; 117 117 else … … 128 128 return true ; 129 129 break ; 130 130 131 131 case EVENT_ID_ADD_VARIABLE_GROUP : 132 132 recvAddVariableGroup(event) ; 133 133 return true ; 134 break ; 135 134 break ; 135 136 136 default : 137 137 ERROR("bool CField::dispatchEvent(CEventServer& event)",<<"Unknown Event") ; … … 140 140 } 141 141 } 142 142 143 143 void CField::sendUpdateData(void) 144 144 { 145 145 CContext* context = CContext::getCurrent() ; 146 146 CContextClient* client=context->client ; 147 147 148 148 CEventClient event(getType(),EVENT_ID_UPDATE_DATA) ; 149 149 150 150 map<int,CArray<int, 1>* >::iterator it ; 151 151 list<shared_ptr<CMessage> > list_msg ; 152 152 list< CArray<double,1>* > list_data ; 153 153 154 154 for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++) 155 155 { … … 157 157 CArray<int,1>& index = *(it->second) ; 158 158 CArray<double,1> data_tmp(index.numElements()) ; 159 159 160 160 for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ; 161 161 list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; … … 165 165 } 166 166 client->sendEvent(event) ; 167 167 168 168 for(list< CArray<double,1>* >::iterator it=list_data.begin();it!=list_data.end();it++) delete *it ; 169 169 } 170 170 171 171 void CField::recvUpdateData(CEventServer& event) 172 172 { 173 173 vector<int> ranks ; 174 174 vector<CBufferIn*> buffers ; 175 175 176 176 list<CEventServer::SSubEvent>::iterator it ; 177 177 string fieldId ; … … 185 185 buffers.push_back(buffer) ; 186 186 } 187 get(fieldId)->recvUpdateData(ranks,buffers) ; 188 } 189 187 get(fieldId)->recvUpdateData(ranks,buffers) ; 188 } 189 190 190 void CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 191 191 { 192 192 193 193 if (data_srv.empty()) 194 194 { … … 205 205 const CDate & currDate = context->getCalendar()->getCurrentDate(); 206 206 const CDate opeDate = *last_operation_srv + freq_operation_srv; 207 const CDate writeDate = *last_Write_srv + freq_write_srv; 208 209 210 207 const CDate writeDate = *last_Write_srv + freq_write_srv; 208 209 210 211 211 if (opeDate <= currDate) 212 212 { … … 219 219 *last_operation_srv = currDate; 220 220 } 221 221 222 222 if (writeDate < (currDate + freq_operation_srv)) 223 223 { … … 226 226 this->foperation_srv[ranks[n]]->final(); 227 227 } 228 228 229 229 *last_Write_srv = writeDate; 230 230 writeField() ; … … 232 232 } 233 233 } 234 234 235 235 void CField::writeField(void) 236 236 { … … 246 246 247 247 void CField::setRelFile(CFile* _file) 248 { 248 { 249 249 this->file = _file; 250 hasOutputFile=true ; 250 hasOutputFile=true ; 251 251 } 252 252 … … 260 260 261 261 CGrid* CField::getRelGrid(void) const 262 { 263 return (this->grid); 262 { 263 return (this->grid); 264 264 } 265 265 … … 267 267 268 268 CFile* CField::getRelFile(void) const 269 { 269 { 270 270 return (this->file); 271 271 } 272 272 273 273 StdSize CField::getNStep(void) const 274 274 { 275 275 return (this->nstep); 276 276 } 277 277 278 278 void CField::incrementNStep(void) 279 279 { 280 280 this->nstep++; 281 281 } 282 282 283 283 void CField::resetNStep(void) 284 284 { … … 288 288 //---------------------------------------------------------------- 289 289 290 /*! 291 \brief Get pointer to direct field to which the current field refers. 292 */ 290 293 CField* CField::getDirectFieldReference(void) const 291 294 { … … 304 307 305 308 CField* CField::getBaseFieldReference(void) const 306 { 307 return (baseRefObject); 308 } 309 310 //---------------------------------------------------------------- 311 312 const std::vector<CField*>& CField::getAllReference(void) const 313 { 309 { 310 return (baseRefObject); 311 } 312 313 //---------------------------------------------------------------- 314 315 const std::vector<CField*>& CField::getAllReference(void) const 316 { 314 317 return (refObject); 315 318 } … … 318 321 319 322 const StdString & CField::getBaseFieldId(void) const 320 { 323 { 321 324 return (this->getBaseFieldReference()->getId()); 322 325 } 323 324 //---------------------------------------------------------------- 325 326 327 //---------------------------------------------------------------- 328 326 329 const CDuration & CField::getFreqOperation(void) const 327 330 { 328 331 return (this->freq_operation); 329 332 } 330 333 331 334 //---------------------------------------------------------------- 332 335 const CDuration & CField::getFreqWrite(void) const … … 334 337 return (this->freq_write); 335 338 } 336 337 //---------------------------------------------------------------- 338 339 340 //---------------------------------------------------------------- 341 339 342 boost::shared_ptr<func::CFunctor> CField::getFieldOperation(void) const 340 343 { … … 345 348 346 349 bool CField::hasDirectFieldReference(void) const 347 { 348 return (!this->field_ref.isEmpty()); 349 } 350 350 { 351 return (!this->field_ref.isEmpty()); 352 } 353 351 354 bool CField::isActive(void) const 352 { 353 return (!this->refObject.empty()); 354 } 355 //---------------------------------------------------------------- 356 355 { 356 return (!this->refObject.empty()); 357 } 358 //---------------------------------------------------------------- 359 357 360 CArray<double, 1> CField::getData(void) const 358 361 { … … 376 379 //---------------------------------------------------------------- 377 380 378 void CField::processEnabledField(void) 379 { 380 if (!processed) 381 { 382 processed=true ; 383 solveRefInheritance(true) ; 384 solveBaseReference() ; 385 solveOperation() ; 386 solveGridReference() ; 387 388 if (hasDirectFieldReference()) baseRefObject->processEnabledField() ; 389 buildExpression(); 390 active=true; 391 } 392 } 393 381 // void CField::processEnabledField(void) 382 // { 383 // if (!processed) 384 // { 385 // processed=true ; 386 // solveRefInheritance(true) ; 387 // solveBaseReference() ; 388 // solveOperation() ; 389 // solveGridReference() ; 390 // 391 // if (hasDirectFieldReference()) baseRefObject->processEnabledField() ; 392 // buildExpression(); 393 // active=true; 394 // } 395 // } 396 397 void CField::solveAllReferenceEnabledField(bool doSending2Sever) 398 { 399 CContext* context = CContext::getCurrent(); 400 if (!areAllReferenceSolved) 401 { 402 areAllReferenceSolved = true; 403 if (!context->hasServer) 404 { 405 solveRefInheritance(true); 406 solveBaseReference(); 407 } 408 409 solveOperation(); 410 solveGridReference(); 411 } 412 solveGridDomainAxisRef(doSending2Sever); 413 solveCheckMaskIndex(doSending2Sever); 414 } 415 416 std::map<int, StdSize> CField::getGridDataSize() 417 { 418 return grid->getConnectedServerDataSize(); 419 } 420 421 void CField::buildAllExpressionEnabledField() 422 { 423 if (!areAllReferenceSolved) solveAllReferenceEnabledField(true); 424 if (!areAllExpressionBuilt) 425 { 426 areAllExpressionBuilt = true; 427 // solveCheckMaskIndex(true); 428 // solveCheckMaskIndex(); 429 if (hasDirectFieldReference()) baseRefObject->buildAllExpressionEnabledField(); 430 buildExpression(); 431 active=true; 432 } 433 } 434 435 /*! 436 \brief Searching for all reference of a field 437 If a field refers to (an)other field(s), we will search for all its referenced parents. 438 Moreover, if any father, direct or indirect (e.g: two levels up), has non-empty attributes, 439 all its attributes will be added to the current field 440 \param [in] apply Flag to specify whether current field uses attributes of its father 441 in case the attribute is empty (true) or its attributes are replaced by ones of its father (false) 442 */ 394 443 void CField::solveRefInheritance(bool apply) 395 444 { … … 397 446 CField* refer_sptr; 398 447 CField * refer_ptr = this; 399 448 400 449 while (refer_ptr->hasDirectFieldReference()) 401 450 { … … 413 462 sset.insert(refer_ptr); 414 463 } 415 464 } 465 466 467 /*! 468 \brief Only on SERVER side. Remove all field_ref from current field 469 On creating a new field on server side, redundant "field_ref" is still kept in the attribute list 470 of the current field. This function removes this from current field 471 */ 472 void CField::removeRefInheritance() 473 { 474 if (this->field_ref.isEmpty()) return; 475 this->clearAttribute("field_ref"); 416 476 } 417 477 … … 421 481 CField* refer_sptr; 422 482 CField * refer_ptr = this; 423 483 424 484 if (this->hasDirectFieldReference()) baseRefObject = getDirectFieldReference(); 425 485 else baseRefObject = CField::get(this); 426 486 427 487 while (refer_ptr->hasDirectFieldReference()) 428 488 { … … 439 499 sset.insert(refer_ptr); 440 500 } 441 501 442 502 if (hasDirectFieldReference()) baseRefObject->addReference(this) ; 443 503 } 444 504 445 505 //---------------------------------------------------------------- 446 506 … … 448 508 { 449 509 using namespace func; 450 510 451 511 if (!hasOutputFile && !hasFieldOut) return ; 452 512 453 513 StdString id ; 454 514 if (hasId()) id=getId(); 455 515 else if (!name.isEmpty()) id=name ; 456 516 else if (hasDirectFieldReference()) id=baseRefObject->getId() ; 457 517 458 518 CContext* context = CContext::getCurrent(); 459 519 460 520 if (freq_op.isEmpty()) freq_op=string("1ts") ; 461 521 462 522 if (operation.isEmpty() ) 463 523 { … … 466 526 << "Impossible to define an operation for this field !"); 467 527 } 468 528 469 529 CDuration freq_offset_ = NoneDu; 470 530 if (!freq_offset.isEmpty()) … … 475 535 { 476 536 freq_offset.setValue(NoneDu.toString()); 477 } 537 } 478 538 479 539 // if (CXIOSManager::GetStatus() == CXIOSManager::LOC_SERVER) 480 540 if (context->hasServer) 481 541 { 482 if (hasOutputFile) 542 if (hasOutputFile) 483 543 { 484 544 this->freq_operation_srv =CDuration::FromString(this->file->output_freq.getValue()); … … 493 553 // this->foperation_srv = 494 554 // boost::shared_ptr<func::CFunctor>(new CInstant(this->data_srv)); 495 496 if (hasOutputFile) 555 556 if (hasOutputFile) 497 557 { 498 const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep(); 558 const CDuration toffset = this->freq_operation_srv - freq_offset_ - context->getCalendar()->getTimeStep(); 499 559 *this->last_operation_srv = *this->last_operation_srv - toffset; 500 560 } 501 561 } 502 562 503 563 // if (context->hasClient) 504 // { 564 // { 505 565 this->freq_operation = CDuration::FromString(freq_op.getValue()); 506 566 if (hasOutputFile) this->freq_write = CDuration::FromString(this->file->output_freq.getValue()); 507 if (hasFieldOut) 567 if (hasFieldOut) 508 568 { 509 569 this->freq_write = CDuration::FromString(this->fieldOut->freq_op.getValue()); … … 513 573 this->last_operation = boost::shared_ptr<CDate> 514 574 (new CDate(context->getCalendar()->getInitDate())); 515 516 const CDuration toffset = this->freq_operation - freq_offset_ - context->getCalendar()->getTimeStep(); 517 *this->last_operation = *this->last_operation - toffset; 518 575 576 const CDuration toffset = this->freq_operation - freq_offset_ - context->getCalendar()->getTimeStep(); 577 *this->last_operation = *this->last_operation - toffset; 578 519 579 if (operation.get()=="once") isOnceOperation=true ; 520 580 else isOnceOperation=false; 521 581 isFirstOperation=true; 522 523 582 583 524 584 #define DECLARE_FUNCTOR(MType, mtype) \ 525 585 if (operation.getValue().compare(#mtype) == 0) \ … … 537 597 return; \ 538 598 } 539 599 540 600 #include "functor_type.conf" 541 601 542 602 ERROR("CField::solveOperation(void)", 543 603 << "[ operation = " << operation.getValue() << "]" 544 604 << "The operation is not defined !"); 545 605 // } 546 547 548 } 549 606 607 608 } 609 550 610 //---------------------------------------------------------------- 551 611 /* … … 598 658 << grid_ref.getValue() << "\' is wrong"); 599 659 } 600 660 601 661 if (grid_ref.isEmpty() && domain_ref.isEmpty()) 602 662 { … … 605 665 606 666 } 607 667 608 668 CType<string> goodDomain ; 609 669 CType<string> goodAxis ; … … 615 675 if (!domain_ref.isEmpty()) goodDomain=domain_ref ; 616 676 if (!axis_ref.isEmpty()) goodAxis=axis_ref ; 617 618 619 if (goodDomain.isEmpty()) 677 678 679 if (goodDomain.isEmpty()) 620 680 { 621 681 ERROR("CField::solveGridReference(void)", << "The horizontal domain for this field is not defined"); 622 682 } 623 else 683 else 624 684 { 625 685 if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain) ; 626 686 else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'"<<goodDomain.get() << "\' is wrong") ; 627 687 } 628 688 629 689 if (!goodAxis.isEmpty()) 630 690 { … … 632 692 else ERROR("CField::solveGridReference(void)", << "Reference to the axis \'" 633 693 << goodAxis.get() <<"\' is wrong") ; 634 } 635 694 } 695 636 696 bool nothingToDo=false ; 637 697 638 698 if (!grid_ref.isEmpty()) 639 699 { 640 700 if (!grid->domain_ref.isEmpty() && goodDomain.get() == grid->domain_ref.get()) 641 701 if (goodAxis.isEmpty()) nothingToDo=true ; 642 else if (!grid->axis_ref.isEmpty()) 702 else if (!grid->axis_ref.isEmpty()) 643 703 if (grid->axis_ref.get()==goodAxis.get()) nothingToDo=true ; 644 704 } 645 705 646 706 if (!nothingToDo) 647 707 { … … 655 715 this->grid = CGrid::createGrid(domain) ; 656 716 this->grid_ref.setValue(this->grid->getId()); 657 } 717 } 658 718 } 659 719 660 grid->solveReference() ; 661 662 } 663 720 // grid->solveReference() ; 721 // grid->solveDomainAxisRef(); 722 // grid->checkMaskIndex(); 723 } 724 725 void CField::solveGridDomainAxisRef(bool checkAtt) 726 { 727 grid->solveDomainAxisRef(checkAtt); 728 } 729 730 void CField::solveCheckMaskIndex(bool doSendingIndex) 731 { 732 grid->checkMaskIndex(doSendingIndex); 733 } 664 734 665 735 ///------------------------------------------------------------------- … … 680 750 681 751 std::vector<CField*> allChildren = group->getAllChildren(); 682 std::vector<CField*>::iterator 752 std::vector<CField*>::iterator 683 753 it = allChildren.begin(), end = allChildren.end(); 684 754 685 755 for (; it != end; it++) 686 756 { 687 757 CField* child = *it; 688 758 if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId()) ; 689 690 } 691 } 692 759 760 } 761 } 762 693 763 void CField::scaleFactorAddOffset(double scaleFactor, double addOffset) 694 764 { … … 696 766 for(it=data_srv.begin();it!=data_srv.end();it++) *it->second = (*it->second -addOffset) * 1./scaleFactor ; 697 767 } 698 768 699 769 void CField::outputField(CArray<double,3>& fieldOut) 700 770 { … … 702 772 for(it=data_srv.begin();it!=data_srv.end();it++) 703 773 grid->outputField(it->first,*it->second, fieldOut) ; 704 705 } 706 774 775 } 776 707 777 void CField::outputField(CArray<double,2>& fieldOut) 708 778 { … … 719 789 { 720 790 SuperClass::parse(node); 721 if (! node.getContent(this->content)) 791 if (! node.getContent(this->content)) 722 792 { 723 793 if (node.goToChildElement()) … … 731 801 } 732 802 } 733 803 734 804 CArray<double,1>* CField::getInstantData(void) 735 805 { 736 if (!hasInstantData) 806 if (!hasInstantData) 737 807 { 738 808 instantData.resize(grid->storeIndex_client.numElements()) ; … … 741 811 return &instantData ; 742 812 } 743 813 744 814 void CField::addReference(CField* field) 745 815 { 746 816 refObject.push_back(field) ; 747 817 } 748 818 749 819 void CField::addDependency(CField* field, int slotId) 750 820 { 751 821 fieldDependency.push_back(pair<CField*,int>(field,slotId)) ; 752 822 } 753 823 754 824 void CField::buildExpression(void) 755 825 { 756 if (content.size() > 0) 826 if (content.size() > 0) 757 827 { 758 828 CSimpleNodeExpr* simpleExpr=parseExpr(content+'\0') ; … … 762 832 map<string,CField*> associatedInstantFieldIds ; 763 833 expression->getInstantFieldIds(instantFieldIds) ; 764 for (set<string>::iterator it=instantFieldIds.begin() ; it!=instantFieldIds.end();++it) 765 { 766 if (*it!="this") 834 for (set<string>::iterator it=instantFieldIds.begin() ; it!=instantFieldIds.end();++it) 835 { 836 if (*it!="this") 767 837 { 768 if (CField::has(*it)) 838 if (CField::has(*it)) 769 839 { 770 840 CField* field=CField::get(*it) ; 771 field->processEnabledField() ; 841 // field->processEnabledField() ; 842 field->buildAllExpressionEnabledField(); 772 843 associatedInstantFieldIds[*it]=field ; 773 844 } … … 775 846 } 776 847 } 777 848 778 849 set<string> averageFieldIds ; 779 850 map<string,CField*> associatedAverageFieldIds ; 780 851 781 852 expression->getAverageFieldIds(averageFieldIds) ; 782 for (set<string>::iterator it=averageFieldIds.begin() ; it!=averageFieldIds.end();++it) 783 { 784 if (CField::has(*it)) 853 for (set<string>::iterator it=averageFieldIds.begin() ; it!=averageFieldIds.end();++it) 854 { 855 if (CField::has(*it)) 785 856 { 786 857 CFieldGroup* root=CFieldGroup::get("field_definition") ; … … 791 862 averageField->fieldOut=instantField ; 792 863 instantField->freq_op=freq_op ; 793 averageField-> processEnabledField() ; 864 // averageField-> processEnabledField() ; 865 averageField->buildAllExpressionEnabledField(); 794 866 instantField->SuperClassAttribute::setAttributes(averageField, true); 795 867 instantField->field_ref.reset() ; 796 868 instantField->operation.reset() ; 797 869 798 instantField-> processEnabledField() ; 870 // instantField-> processEnabledField() ; 871 instantField->buildAllExpressionEnabledField(); 799 872 associatedAverageFieldIds[*it]=instantField ; 800 873 } … … 810 883 expression->getFields(fields) ; 811 884 for (set<CField*>::iterator it=fields.begin() ; it!=fields.end();++it,++slotId) (*it)->addDependency(this,slotId) ; 812 hasExpression=true; 813 } 814 } 815 885 hasExpression=true; 886 } 887 } 888 816 889 void CField::resetSlots(void) 817 890 { 818 891 for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) *it=false ; 819 892 } 820 893 821 894 bool CField::slotsFull(void) 822 895 { … … 826 899 } 827 900 828 901 829 902 void CField::setSlot(int slotId) 830 903 { 831 904 CContext* context = CContext::getCurrent() ; 832 905 const CDate & currDate = context->getCalendar()->getCurrentDate(); 833 if (slotUpdateDate==NULL || currDate!=*slotUpdateDate) 906 if (slotUpdateDate==NULL || currDate!=*slotUpdateDate) 834 907 { 835 908 resetSlots() ; … … 841 914 { 842 915 CArray<double,1> expr(expression->compute()) ; 843 844 if (hasInstantData) 916 917 if (hasInstantData) 845 918 { 846 919 instantData=expr ; 847 for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it) 920 for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it) 848 921 if (it->first!=this) it->first->setSlot(it->second) ; 849 922 } 850 923 851 924 if (hasOutputFile) updateDataFromExpression(expr) ; 852 853 } 854 } 855 856 925 926 } 927 } 928 929 /*! 930 This function retrieves Id of corresponding domain_ref and axis_ref (if any) 931 of a field. In some cases, only domain exists but axis doesn't 932 \return pair of Domain and Axis id 933 */ 934 const std::pair<StdString,StdString>& CField::getDomainAxisIds() 935 { 936 CGrid* cgPtr = getRelGrid(); 937 if (NULL != cgPtr) 938 { 939 if (NULL != cgPtr->getRelDomain()) domAxisIds_.first = cgPtr->getRelDomain()->getId(); 940 if (NULL != cgPtr->getRelAxis()) domAxisIds_.second = cgPtr->getRelAxis()->getId(); 941 } 942 943 return (domAxisIds_); 944 } 857 945 858 946 CVariable* CField::addVariable(const string& id) … … 867 955 868 956 957 void CField::sendAddAllVariables() 958 { 959 if (!getAllVariables().empty()) 960 { 961 // Firstly, it's necessary to add virtual variable group 962 sendAddVariableGroup(getVirtualVariableGroup()->getId()); 963 964 // Okie, now we can add to this variable group 965 std::vector<CVariable*> allVar = getAllVariables(); 966 std::vector<CVariable*>::const_iterator it = allVar.begin(); 967 std::vector<CVariable*>::const_iterator itE = allVar.end(); 968 969 for (; it != itE; ++it) 970 { 971 std::cout << "Variable Fields " << (*it)->getId() << std::endl; 972 this->sendAddVariable((*it)->getId()); 973 (*it)->sendAllAttributesToServer(); 974 (*it)->sendValue(); 975 } 976 } 977 } 978 869 979 void CField::sendAddVariable(const string& id) 870 980 { 871 981 CContext* context=CContext::getCurrent() ; 872 982 873 983 if (! context->hasServer ) 874 984 { 875 985 CContextClient* client=context->client ; 876 986 877 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ; 987 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ; 878 988 if (client->isServerLeader()) 879 989 { … … 886 996 else client->sendEvent(event) ; 887 997 } 888 889 } 890 891 998 999 } 1000 1001 892 1002 void CField::sendAddVariableGroup(const string& id) 893 1003 { … … 897 1007 CContextClient* client=context->client ; 898 1008 899 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ; 1009 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ; 900 1010 if (client->isServerLeader()) 901 1011 { … … 908 1018 else client->sendEvent(event) ; 909 1019 } 910 911 } 912 1020 1021 } 1022 913 1023 void CField::recvAddVariable(CEventServer& event) 914 1024 { 915 1025 916 1026 CBufferIn* buffer=event.subEvents.begin()->buffer; 917 1027 string id; … … 919 1029 get(id)->recvAddVariable(*buffer) ; 920 1030 } 921 922 1031 1032 923 1033 void CField::recvAddVariable(CBufferIn& buffer) 924 1034 { … … 930 1040 void CField::recvAddVariableGroup(CEventServer& event) 931 1041 { 932 1042 933 1043 CBufferIn* buffer=event.subEvents.begin()->buffer; 934 1044 string id; … … 936 1046 get(id)->recvAddVariableGroup(*buffer) ; 937 1047 } 938 939 1048 1049 940 1050 void CField::recvAddVariableGroup(CBufferIn& buffer) 941 1051 { … … 947 1057 948 1058 949 1059 950 1060 } // namespace xios -
XIOS/trunk/src/node/field.hpp
r501 r509 18 18 19 19 namespace xios { 20 20 21 21 /// ////////////////////// Déclarations ////////////////////// /// 22 22 … … 56 56 EVENT_ID_UPDATE_DATA, EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP 57 57 } ; 58 58 59 59 /// Constructeurs /// 60 60 CField(void); … … 83 83 84 84 boost::shared_ptr<func::CFunctor> getFieldOperation(void) const; 85 85 86 86 CArray<double, 1> getData(void) const; 87 87 … … 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) ; 98 97 void setDataFromExpression(const CArray<double, 1>& _data) ; 98 99 99 bool updateDataServer 100 100 (const CDate & currDate, 101 101 const std::deque< CArray<double, 1>* > storedClient); 102 102 103 std::map<int, StdSize> getGridDataSize(); 104 103 105 public : 104 106 … … 116 118 void solveGridReference(void); 117 119 void solveOperation(void); 120 void solveCheckMaskIndex(bool doSendingIndex); 121 void solveAllReferenceEnabledField(bool doSending2Sever); 122 void buildAllExpressionEnabledField(); 123 void solveGridDomainAxisRef(bool checkAtt); 124 void removeRefInheritance(); // Remove all reference of current field (it refers to itself) 118 125 119 126 // virtual void fromBinary(StdIStream & is); … … 125 132 static StdString GetName(void); 126 133 static StdString GetDefName(void); 127 134 128 135 static ENodeType GetType(void); 129 136 130 137 template <int N> void setData(const CArray<double, N>& _data) ; 131 138 static bool dispatchEvent(CEventServer& event) ; … … 139 146 void parse(xml::CXMLNode & node) ; 140 147 CArray<double,1>* getInstantData(void) ; 141 148 142 149 void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); 143 150 void setVirtualVariableGroup(void); … … 145 152 vector<CVariable*> getAllVariables(void) const; 146 153 virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); 147 154 148 155 CVariable* addVariable(const string& id="") ; 149 156 CVariableGroup* addVariableGroup(const string& id="") ; … … 154 161 static void recvAddVariableGroup(CEventServer& event) ; 155 162 void recvAddVariableGroup(CBufferIn& buffer) ; 156 163 void sendAddAllVariables(); 164 165 166 const std::pair<StdString, StdString>& getDomainAxisIds(); 157 167 public : 158 168 159 169 /// Propriétés privées /// 160 170 CVariableGroup* vVariableGroup ; 161 171 162 172 std::vector<CField*> refObject; 163 173 CField* baseRefObject; … … 172 182 boost::shared_ptr<CDate> last_Write, last_operation; 173 183 boost::shared_ptr<CDate> lastlast_Write_srv,last_Write_srv, last_operation_srv; 174 184 175 185 boost::shared_ptr<func::CFunctor> foperation; 176 186 map<int,boost::shared_ptr<func::CFunctor> > foperation_srv; 177 187 178 188 CArray<double, 1> data; 179 189 CArray<double, 1> instantData; … … 183 193 bool isFirstOperation ; 184 194 string content ; 185 195 186 196 list< pair<CField *,int> > fieldDependency ; 187 197 void buildExpression(void) ; … … 195 205 void setSlot(int slotId); 196 206 bool processed ; 207 bool areAllReferenceSolved; 208 bool areAllExpressionBuilt; 209 std::pair<StdString,StdString> domAxisIds_; 197 210 198 211 }; // class CField -
XIOS/trunk/src/node/file.cpp
r501 r509 18 18 19 19 namespace xios { 20 20 21 21 /// ////////////////////// Définitions ////////////////////// /// 22 22 … … 24 24 : CObjectTemplate<CFile>(), CFileAttributes() 25 25 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 26 { 26 { 27 27 setVirtualFieldGroup() ; 28 28 setVirtualVariableGroup() ; … … 32 32 : CObjectTemplate<CFile>(id), CFileAttributes() 33 33 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 34 { 34 { 35 35 setVirtualFieldGroup() ; 36 36 setVirtualVariableGroup() ; … … 41 41 42 42 ///--------------------------------------------------------------- 43 43 //! Get name of file 44 44 StdString CFile::GetName(void) { return (StdString("file")); } 45 45 StdString CFile::GetDefName(void){ return (CFile::GetName()); } … … 47 47 48 48 //---------------------------------------------------------------- 49 49 /*! 50 \brief Get data that will be written out. 51 Each enabled file in xml represents a physical netcdf file. 52 This function allows to access to data to be written out into netcdf file 53 \return data written out. 54 */ 50 55 boost::shared_ptr<CDataOutput> CFile::getDataOutput(void) const 51 56 { … … 53 58 } 54 59 60 /*! 61 \brief Get virtual field group 62 In each file, there always exists a field group which is the ancestor of all 63 fields in the file. This is considered be virtual because it is created automatically during 64 file initialization and it normally doesn't appear on xml file 65 \return Pointer to field group 66 */ 55 67 CFieldGroup* CFile::getVirtualFieldGroup(void) const 56 68 { … … 58 70 } 59 71 72 /*! 73 \brief Get virtual variable group 74 In each file, there always exists a variable group which is the ancestor of all 75 variable in the file. This is considered be virtual because it is created automatically during 76 file initialization and it normally doesn't appear on xml file 77 \return Pointer to variable group 78 */ 60 79 CVariableGroup* CFile::getVirtualVariableGroup(void) const 61 80 { … … 63 82 } 64 83 84 //! Get all fields of a file 65 85 std::vector<CField*> CFile::getAllFields(void) const 66 86 { 67 87 return (this->vFieldGroup->getAllChildren()); 68 88 } 69 89 90 //! Get all variables of a file 70 91 std::vector<CVariable*> CFile::getAllVariables(void) const 71 92 { … … 74 95 75 96 //---------------------------------------------------------------- 76 77 std::vector<CField*> CFile::getEnabledFields(int default_outputlevel, 97 /*! 98 \brief Get all enabled fields of file 99 A field is considered to be enabled if it fullfil these conditions: it is enabled, inside a enabled file 100 and its own level is not larger than file output level. 101 \param [in] default_outputlevel default value output level of file 102 \param [in] default_level default value level of field 103 \param [in] default_enabled flag determine by default if field is enabled 104 \return Vector of pointers of enabled fields 105 */ 106 std::vector<CField*> CFile::getEnabledFields(int default_outputlevel, 78 107 int default_level, 79 108 bool default_enabled) … … 88 117 89 118 std::vector<CField*> newEnabledFields; 90 119 91 120 for ( it = this->enabledFields.begin() ; it != this->enabledFields.end(); it++ ) 92 121 { … … 112 141 // { it--; this->enabledFields.erase(it+1); continue; } 113 142 } 114 143 115 144 // CField* field_tmp=(*it).get() ; 116 145 // shared_ptr<CField> sptfield=*it ; … … 130 159 131 160 //---------------------------------------------------------------- 132 161 //! Change virtual field group to a new one 133 162 void CFile::setVirtualFieldGroup(CFieldGroup* newVFieldGroup) 134 { 135 this->vFieldGroup = newVFieldGroup; 136 } 137 163 { 164 this->vFieldGroup = newVFieldGroup; 165 } 166 167 //! Change virtual variable group to new one 138 168 void CFile::setVirtualVariableGroup(CVariableGroup* newVVariableGroup) 139 { 140 this->vVariableGroup = newVVariableGroup; 141 } 142 143 //---------------------------------------------------------------- 144 169 { 170 this->vVariableGroup = newVVariableGroup; 171 } 172 173 //---------------------------------------------------------------- 174 //! Create virtual field group, which is done normally on initializing file 145 175 void CFile::setVirtualFieldGroup(void) 146 176 { … … 148 178 } 149 179 180 //! Create virtual variable group, which is done normally on initializing file 150 181 void CFile::setVirtualVariableGroup(void) 151 182 { … … 168 199 return false ; 169 200 } 170 201 202 //! Initialize a file in order to write into it 171 203 void CFile::initFile(void) 172 204 { … … 174 206 CDate& currentDate=context->calendar->getCurrentDate() ; 175 207 CContextServer* server=context->server ; 176 208 177 209 if (! sync_freq.isEmpty()) syncFreq = CDuration::FromString(sync_freq.getValue()); 178 210 if (! split_freq.isEmpty()) splitFreq = CDuration::FromString(split_freq.getValue()); … … 194 226 nbDomain=setDomain.size() ; 195 227 196 // create sub communicator for file 228 // create sub communicator for file 197 229 int color=allDomainEmpty?0:1 ; 198 230 MPI_Comm_split(server->intraComm,color,server->intraCommRank,&fileComm) ; 199 231 if (allDomainEmpty) MPI_Comm_free(&fileComm) ; 200 232 // 201 202 } 203 233 234 } 235 236 //! Verify state of a file 204 237 void CFile::checkFile(void) 205 238 { … … 208 241 checkSplit() ; 209 242 } 210 211 243 244 245 /*! 246 \brief Verify if synchronisation should be done 247 If syn option is enabled, syn frequence and current time will be used to 248 calculate the moment to syn file(s) 249 \return True if it is the moment to synchronize file, otherwise false 250 */ 212 251 bool CFile::checkSync(void) 213 252 { … … 225 264 return false ; 226 265 } 227 228 266 267 /*! 268 \brief Verify if splitting should be done 269 If split option is enabled, split frequence and current time will be used to 270 calculate the moment to split file 271 \return True if it is the moment to split file, otherwise false 272 */ 229 273 bool CFile::checkSplit(void) 230 274 { … … 235 279 if (currentDate > *lastSplit+splitFreq) 236 280 { 237 *lastSplit=*lastSplit+splitFreq ; 281 *lastSplit=*lastSplit+splitFreq ; 238 282 std::vector<CField*>::iterator it, end = this->enabledFields.end(); 239 283 for (it = this->enabledFields.begin() ;it != end; it++) (*it)->resetNStep() ; … … 244 288 return false ; 245 289 } 246 290 291 /*! 292 \brief Create header of netcdf file 293 There are some information to fill in header of each netcdf. 294 */ 247 295 void CFile::createHeader(void) 248 296 { 249 297 CContext* context = CContext::getCurrent() ; 250 298 CContextServer* server=context->server ; 251 299 252 300 if (!allDomainEmpty) 253 301 { … … 273 321 oss<<"_"<<lastSplit->getStr(splitFormat)<<"-"<< (*lastSplit+(splitFreq-1*Second)).getStr(splitFormat); 274 322 } 275 323 276 324 bool multifile=true ; 277 325 if (!type.isEmpty()) … … 280 328 else if (type==type_attr::multiple_file) multifile=true ; 281 329 282 } 330 } 283 331 #ifndef USING_NETCDF_PAR 284 332 if (!multifile) … … 288 336 } 289 337 #endif 290 if (multifile) 338 if (multifile) 291 339 { 292 340 int commSize, commRank ; 293 341 MPI_Comm_size(fileComm,&commSize) ; 294 342 MPI_Comm_rank(fileComm,&commRank) ; 295 296 if (server->intraCommSize > 1) 343 344 if (server->intraCommSize > 1) 297 345 { 298 346 oss << "_" ; 299 347 int width=0 ; int n=commSize-1 ; 300 348 while(n != 0) { n=n/10 ; width++ ;} 301 if (!min_digits.isEmpty()) 349 if (!min_digits.isEmpty()) 302 350 if (width<min_digits) width=min_digits ; 303 351 oss.width(width) ; … … 314 362 if (par_access.getValue()=="independent") isCollective=false ; 315 363 else if (par_access.getValue()=="collective") isCollective=true ; 316 else 364 else 317 365 { 318 366 ERROR("void Context::createDataOutput(void)", … … 332 380 } 333 381 this->data_out->writeTimeDimension(); 334 382 335 383 for (it = this->enabledFields.begin() ;it != end; it++) 336 384 { … … 338 386 this->data_out->writeField(field); 339 387 } 340 388 341 389 vector<CVariable*> listVars = getAllVariables() ; 342 390 for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) this-> data_out-> writeAttribute(*it) ; 343 391 344 392 this->data_out->definition_end(); 345 393 } 346 394 } 347 395 396 //! Close file 348 397 void CFile::close(void) 349 398 { … … 351 400 delete lastSplit ; 352 401 if (!allDomainEmpty) 353 if (isOpen) 402 if (isOpen) 354 403 { 355 404 this->data_out->closeFile(); … … 359 408 //---------------------------------------------------------------- 360 409 410 /*! 411 \brief Parse xml file and write information into file object 412 \param [in] node xmld node corresponding in xml file 413 */ 361 414 void CFile::parse(xml::CXMLNode & node) 362 415 { 363 416 SuperClass::parse(node); 364 417 365 418 if (node.goToChildElement()) 366 419 { … … 376 429 //---------------------------------------------------------------- 377 430 431 /*! 432 \brief Represent a file in form of string with all its info 433 \return String 434 */ 378 435 StdString CFile::toString(void) const 379 436 { … … 391 448 392 449 //---------------------------------------------------------------- 393 450 451 /*! 452 \brief Find all inheritace among objects in a file. 453 \param [in] apply (true) write attributes of parent into ones of child if they are empty 454 (false) write attributes of parent into a new container of child 455 \param [in] parent 456 */ 394 457 void CFile::solveDescInheritance(bool apply, const CAttributeMap * const parent) 395 458 { 396 459 SuperClassAttribute::setAttributes(parent,apply); 397 this->getVirtualFieldGroup()->solveDescInheritance(apply, NULL); 460 this->getVirtualFieldGroup()->solveDescInheritance(apply, NULL); 398 461 this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL); 399 462 } … … 401 464 //---------------------------------------------------------------- 402 465 403 void CFile::processEnabledFile(void) 404 { 405 if (output_freq.isEmpty()) ERROR("void CFile::processEnabledFile(void)", 406 <<"File attribute <<output_freq>> is undefined"); 407 solveFieldRefInheritance(true) ; 408 getEnabledFields() ; 409 processEnabledFields() ; 410 } 411 412 void CFile::processEnabledFields(void) 413 { 414 for (unsigned int i = 0; i < this->enabledFields.size(); i++) 415 { 416 this->enabledFields[i]->processEnabledField() ; 417 } 418 } 419 466 // void CFile::processEnabledFile(void) 467 // { 468 // if (output_freq.isEmpty()) ERROR("void CFile::processEnabledFile(void)", 469 // <<"File attribute <<output_freq>> is undefined"); 470 // solveFieldRefInheritance(true) ; 471 // getEnabledFields() ; 472 // processEnabledFields() ; 473 // } 474 475 // void CFile::processEnabledFields(void) 476 // { 477 // for (unsigned int i = 0; i < this->enabledFields.size(); i++) 478 // { 479 // this->enabledFields[i]->processEnabledField() ; 480 // } 481 // } 482 483 /*! 484 \brief Resolve all reference of active fields. 485 In order to know exactly which data each active field has, a search for all its 486 reference to find its parents or/and its base reference object must be done. Moreover 487 during this search, there are some information that can only be sent to server AFTER 488 all information of active fields are created on server side, e.g: checking mask or index 489 \param [in] sendToServer: Send all info to server (true) or only a part of it (false) 490 */ 491 void CFile::solveAllRefOfEnabledFields(bool sendToServer) 492 { 493 int size = this->enabledFields.size(); 494 for (int i = 0; i < size; ++i) 495 { 496 this->enabledFields[i]->solveAllReferenceEnabledField(sendToServer); 497 } 498 } 499 500 /*! 501 \brief Contruct all expression related to active fields. 502 Each field can do some expressions which appear on the xml file, and itself can be 503 a result of an expression among some other fields. This function builds all possible expression 504 relating to active fields. 505 */ 506 void CFile::buildAllExpressionOfEnabledFields() 507 { 508 int size = this->enabledFields.size(); 509 for (int i = 0; i < size; ++i) 510 { 511 this->enabledFields[i]->buildAllExpressionEnabledField(); 512 } 513 } 514 420 515 void CFile::solveFieldRefInheritance(bool apply) 421 516 { … … 441 536 this->enabledFields[i]->solveOperation(); 442 537 } 443 538 444 539 void CFile::solveEFExpression(void) 445 540 { 446 541 for (unsigned int i = 0; i < this->enabledFields.size(); i++) 447 542 this->enabledFields[i]->buildExpression(); 448 } 449 450 543 } 544 545 /*! 546 \brief Add a field into file. 547 A field is added into file and it will be written out if the file is enabled and 548 level of this field is smaller than level_output. A new field won't be created if one 549 with id has already existed 550 \param [in] id String identity of new field 551 \return Pointer to added (or already existed) field 552 */ 451 553 CField* CFile::addField(const string& id) 452 554 { … … 454 556 } 455 557 558 /*! 559 \brief Add a field group into file. 560 A field group is added into file and it will play a role as parents for fields. 561 A new field group won't be created if one with id has already existed 562 \param [in] id String identity of new field group 563 \return Pointer to added (or already existed) field group 564 */ 456 565 CFieldGroup* CFile::addFieldGroup(const string& id) 457 566 { 458 567 return vFieldGroup->createChildGroup(id) ; 459 568 } 460 569 570 /*! 571 \brief Add a variable into file. 572 A variable is added into file and if one with id has already existed, pointer to 573 it will be returned. 574 Variable as long as attributes are information container of file. 575 However, whereas attributes are "fixed" information, variables provides a more flexible way to user 576 to fill in (extra) information for a file. 577 \param [in] id String identity of new variable 578 \return Pointer to added (or already existed) variable 579 */ 461 580 CVariable* CFile::addVariable(const string& id) 462 581 { … … 464 583 } 465 584 585 /*! 586 \brief Add a variable group into file. 587 A variable group is added into file and it will play a role as parents for variables. 588 A new variable group won't be created if one with id has already existed 589 \param [in] id String identity of new variable group 590 \return Pointer to added (or already existed) variable group 591 */ 466 592 CVariableGroup* CFile::addVariableGroup(const string& id) 467 593 { 468 594 return vVariableGroup->createChildGroup(id) ; 469 595 } 470 471 596 597 /*! 598 \brief Send a message to create a field on server side 599 \param[in] id String identity of field that will be created on server 600 */ 472 601 void CFile::sendAddField(const string& id) 473 602 { 474 603 CContext* context=CContext::getCurrent() ; 475 604 476 605 if (! context->hasServer ) 477 606 { 478 607 CContextClient* client=context->client ; 479 608 480 CEventClient event(this->getType(),EVENT_ID_ADD_FIELD) ; 609 CEventClient event(this->getType(),EVENT_ID_ADD_FIELD) ; 481 610 if (client->isServerLeader()) 482 611 { … … 489 618 else client->sendEvent(event) ; 490 619 } 491 492 } 493 620 621 } 622 623 /*! 624 \brief Send a message to create a field group on server side 625 \param[in] id String identity of field group that will be created on server 626 */ 494 627 void CFile::sendAddFieldGroup(const string& id) 495 628 { … … 499 632 CContextClient* client=context->client ; 500 633 501 CEventClient event(this->getType(),EVENT_ID_ADD_FIELD_GROUP) ; 634 CEventClient event(this->getType(),EVENT_ID_ADD_FIELD_GROUP) ; 502 635 if (client->isServerLeader()) 503 636 { … … 510 643 else client->sendEvent(event) ; 511 644 } 512 513 } 514 645 646 } 647 648 /*! 649 \brief Receive a message annoucing the creation of a field on server side 650 \param[in] event Received event 651 */ 515 652 void CFile::recvAddField(CEventServer& event) 516 653 { 517 654 518 655 CBufferIn* buffer=event.subEvents.begin()->buffer; 519 656 string id; … … 521 658 get(id)->recvAddField(*buffer) ; 522 659 } 523 524 660 661 /*! 662 \brief Receive a message annoucing the creation of a field on server side 663 \param[in] buffer Buffer containing message 664 */ 525 665 void CFile::recvAddField(CBufferIn& buffer) 526 666 { … … 530 670 } 531 671 672 /*! 673 \brief Receive a message annoucing the creation of a field group on server side 674 \param[in] event Received event 675 */ 532 676 void CFile::recvAddFieldGroup(CEventServer& event) 533 677 { 534 678 535 679 CBufferIn* buffer=event.subEvents.begin()->buffer; 536 680 string id; … … 538 682 get(id)->recvAddFieldGroup(*buffer) ; 539 683 } 540 541 684 685 /*! 686 \brief Receive a message annoucing the creation of a field group on server side 687 \param[in] buffer Buffer containing message 688 */ 542 689 void CFile::recvAddFieldGroup(CBufferIn& buffer) 543 690 { … … 546 693 addFieldGroup(id) ; 547 694 } 548 549 550 551 552 553 554 555 556 557 558 695 696 /*! 697 \brief Send messages to duplicate all variables on server side 698 Because each variable has also its attributes. So first thing to do is replicate 699 all these attributes on server side. Because variable can have a value, the second thing 700 is to duplicate this value on server, too. 701 */ 702 void CFile::sendAddAllVariables() 703 { 704 if (!getAllVariables().empty()) 705 { 706 // Firstly, it's necessary to add virtual variable group 707 sendAddVariableGroup(getVirtualVariableGroup()->getId()); 708 709 // Okie, now we can add to this variable group 710 std::vector<CVariable*> allVar = getAllVariables(); 711 std::vector<CVariable*>::const_iterator it = allVar.begin(); 712 std::vector<CVariable*>::const_iterator itE = allVar.end(); 713 714 for (; it != itE; ++it) 715 { 716 std::cout << "Variable Files " << (*it)->getId() << std::endl; 717 this->sendAddVariable((*it)->getId()); 718 (*it)->sendAllAttributesToServer(); 719 (*it)->sendValue(); 720 } 721 } 722 } 723 724 /*! 725 \brief Send a message to create a variable on server side 726 A variable always belongs to a variable group 727 \param[in] id String identity of variable that will be created on server 728 */ 559 729 void CFile::sendAddVariable(const string& id) 560 730 { 561 731 CContext* context=CContext::getCurrent() ; 562 732 563 733 if (! context->hasServer ) 564 734 { 565 735 CContextClient* client=context->client ; 566 736 567 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ; 737 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ; 568 738 if (client->isServerLeader()) 569 739 { … … 576 746 else client->sendEvent(event) ; 577 747 } 578 579 } 580 748 749 } 750 751 /*! 752 \brief Send a message to create a variable group on server side 753 \param[in] id String identity of variable group that will be created on server 754 */ 581 755 void CFile::sendAddVariableGroup(const string& id) 582 756 { … … 586 760 CContextClient* client=context->client ; 587 761 588 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ; 762 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ; 589 763 if (client->isServerLeader()) 590 764 { … … 597 771 else client->sendEvent(event) ; 598 772 } 599 600 } 601 773 774 } 775 776 /*! 777 \brief Receive a message annoucing the creation of a variable on server side 778 \param[in] event Received event 779 */ 602 780 void CFile::recvAddVariable(CEventServer& event) 603 781 { 604 782 605 783 CBufferIn* buffer=event.subEvents.begin()->buffer; 606 784 string id; … … 608 786 get(id)->recvAddVariable(*buffer) ; 609 787 } 610 611 788 789 /*! 790 \brief Receive a message annoucing the creation of a variable on server side 791 \param[in] buffer Buffer containing message 792 */ 612 793 void CFile::recvAddVariable(CBufferIn& buffer) 613 794 { … … 617 798 } 618 799 800 /*! 801 \brief Receive a message annoucing the creation of a variable group on server side 802 \param[in] event Received event 803 */ 619 804 void CFile::recvAddVariableGroup(CEventServer& event) 620 805 { 621 806 622 807 CBufferIn* buffer=event.subEvents.begin()->buffer; 623 808 string id; … … 625 810 get(id)->recvAddVariableGroup(*buffer) ; 626 811 } 627 628 812 813 /*! 814 \brief Receive a message annoucing the creation of a variable group on server side 815 \param[in] buffer Buffer containing message 816 */ 629 817 void CFile::recvAddVariableGroup(CBufferIn& buffer) 630 818 { … … 634 822 } 635 823 636 637 638 639 824 /*! 825 \brief Sending all active (enabled) fields from client to server. 826 Each field is identified uniquely by its string identity. Not only should we 827 send the id to server but also we need to send ids of reference domain and reference axis. 828 With these two id, it's easier to make reference to grid where all data should be written. 829 Remark: This function must be called AFTER all active (enabled) files have been created on the server side 830 */ 831 void CFile::sendEnabledFields() 832 { 833 int size = this->enabledFields.size(); 834 CField* fieldPtr(0); 835 for (int i = 0; i < size; ++i) 836 { 837 fieldPtr = this->enabledFields[i]; 838 if (fieldPtr->name.isEmpty()) fieldPtr->name.setValue(fieldPtr->getBaseFieldReference()->getId()); 839 std::cout << "Enabled Fields " << i << " " << CField::get(fieldPtr)->getId() << std::endl; 840 this->sendAddField(fieldPtr->getId()); 841 fieldPtr->sendAllAttributesToServer(); 842 fieldPtr->sendAddAllVariables(); 843 } 844 } 845 846 /*! 847 \brief Dispatch event received from client 848 Whenever a message is received in buffer of server, it will be processed depending on 849 its event type. A new event type should be added in the switch list to make sure 850 it processed on server side. 851 \param [in] event: Received message 852 */ 640 853 bool CFile::dispatchEvent(CEventServer& event) 641 854 { … … 649 862 return true ; 650 863 break ; 651 864 652 865 case EVENT_ID_ADD_FIELD_GROUP : 653 866 recvAddFieldGroup(event) ; 654 867 return true ; 655 break ; 656 868 break ; 869 657 870 case EVENT_ID_ADD_VARIABLE : 658 871 recvAddVariable(event) ; 659 872 return true ; 660 873 break ; 661 874 662 875 case EVENT_ID_ADD_VARIABLE_GROUP : 663 876 recvAddVariableGroup(event) ; 664 877 return true ; 665 break ; 878 break ; 666 879 default : 667 880 ERROR("bool CFile::dispatchEvent(CEventServer& event)", <<"Unknown Event") ; … … 670 883 } 671 884 } 672 673 674 675 885 886 887 888 676 889 ///--------------------------------------------------------------- 677 890 -
XIOS/trunk/src/node/file.hpp
r501 r509 15 15 16 16 namespace xios { 17 17 18 18 /// ////////////////////// Déclarations ////////////////////// /// 19 19 … … 31 31 ///-------------------------------------------------------------- 32 32 33 /*! 34 \class CFile 35 This class corresponds to file component of the xml. 36 The class contains all the nessceary information to write data into a netcdf file: The most important thing 37 is the field(s) which will be written into file. Besides, there are some options to write 38 data into file, e.g: writting into only one file or multiple file; splitting a running into several files. 39 Moreover, there are some other attributes of netcdf file which are also stored in this class 40 */ 33 41 class CFile 34 42 : public CObjectTemplate<CFile> … … 38 46 typedef CObjectTemplate<CFile> SuperClass; 39 47 typedef CFileAttributes SuperClassAttribute; 40 48 41 49 public : 42 50 enum EEventId 43 51 { 44 EVENT_ID_ADD_FIELD=0,EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE,EVENT_ID_ADD_VARIABLE_GROUP 52 EVENT_ID_ADD_FIELD=0,EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE, 53 EVENT_ID_ADD_VARIABLE_GROUP, EVENT_ID_CREATE_ENABLED_FIELDS 45 54 } ; 46 55 47 56 typedef CFileAttributes RelAttributes; 48 57 typedef CFileGroup RelGroup; … … 54 63 CFile(const CFile * const file); // Not implemented yet. 55 64 65 /// Destructeur /// 66 virtual ~CFile(void); 67 68 public: 56 69 /// Accesseurs /// 57 70 boost::shared_ptr<CDataOutput> getDataOutput(void) const; … … 66 79 67 80 public : 68 69 /// Mutateurs /// 70 void setVirtualFieldGroup(CFieldGroup* newVFieldGroup); 71 void setVirtualFieldGroup(void); 72 void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); 73 void setVirtualVariableGroup(void); 74 void processEnabledFile(void) ; 75 void processEnabledFields(void) ; 76 void createHeader(void); 77 void close(void) ; 78 79 /// Traitements /// 80 virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); 81 void solveFieldRefInheritance(bool apply); 82 void solveEFGridRef(void); 83 void solveEFOperation(void); 84 void solveEFExpression(void); 85 86 /// Destructeur /// 87 virtual ~CFile(void); 88 89 /// Autres /// 90 virtual void parse(xml::CXMLNode & node); 91 virtual StdString toString(void) const; 92 93 // virtual void toBinary (StdOStream & os) const; 94 // virtual void fromBinary(StdIStream & is); 95 96 /// Accesseurs statiques /// 97 static StdString GetName(void); 98 static StdString GetDefName(void); 99 100 static ENodeType GetType(void); 101 102 bool allDomainEmpty ; 103 CField* addField(const string& id="") ; 104 CFieldGroup* addFieldGroup(const string& id="") ; 105 CVariable* addVariable(const string& id="") ; 106 CVariableGroup* addVariableGroup(const string& id="") ; 107 void sendAddField(const string& id="") ; 108 void sendAddFieldGroup(const string& id="") ; 109 static void recvAddField(CEventServer& event) ; 110 void recvAddField(CBufferIn& buffer) ; 111 static void recvAddFieldGroup(CEventServer& event) ; 112 void recvAddFieldGroup(CBufferIn& buffer) ; 113 114 void sendAddVariable(const string& id="") ; 115 void sendAddVariableGroup(const string& id="") ; 116 static void recvAddVariable(CEventServer& event) ; 117 void recvAddVariable(CBufferIn& buffer) ; 118 static void recvAddVariableGroup(CEventServer& event) ; 119 void recvAddVariableGroup(CBufferIn& buffer) ; 120 static bool dispatchEvent(CEventServer& event) ; 121 81 // Some functions to verify state of file 122 82 bool isSyncTime(void) ; 123 83 bool checkSplit(void) ; … … 125 85 void checkFile(void) ; 126 86 void initFile(void) ; 87 88 /// Mutateurs /// 89 // Set some root definitions in a file 90 void setVirtualFieldGroup(CFieldGroup* newVFieldGroup); 91 void setVirtualFieldGroup(void); 92 void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); 93 void setVirtualVariableGroup(void); 94 95 void createHeader(void); 96 void close(void) ; 97 98 // Some processing on file 99 void solveFieldRefInheritance(bool apply); 100 void solveEFGridRef(void); 101 void solveEFOperation(void); 102 void solveEFExpression(void); 103 void processEnabledFile(void) ; 104 void processEnabledFields(void) ; 105 void solveAllRefOfEnabledFields(bool sendToServer); 106 void buildAllExpressionOfEnabledFields(); 107 108 // Add component into file 109 CField* addField(const string& id="") ; 110 CFieldGroup* addFieldGroup(const string& id="") ; 111 CVariable* addVariable(const string& id="") ; 112 CVariableGroup* addVariableGroup(const string& id="") ; 113 114 // Send info to serever 115 void sendEnabledFields(); 116 void sendAddField(const string& id="") ; 117 void sendAddFieldGroup(const string& id="") ; 118 void sendAddAllVariables(); 119 void sendAddVariable(const string& id="") ; 120 void sendAddVariableGroup(const string& id="") ; 121 122 // Receive info from client 123 static void recvAddField(CEventServer& event) ; 124 void recvAddField(CBufferIn& buffer) ; 125 static void recvAddFieldGroup(CEventServer& event) ; 126 void recvAddFieldGroup(CBufferIn& buffer) ; 127 static void recvAddVariable(CEventServer& event) ; 128 void recvAddVariable(CBufferIn& buffer) ; 129 static void recvAddVariableGroup(CEventServer& event) ; 130 void recvAddVariableGroup(CBufferIn& buffer) ; 131 132 // Dispatch event 133 static bool dispatchEvent(CEventServer& event) ; 134 135 public: 136 /// Accesseurs statiques /// 137 static StdString GetName(void); 138 static StdString GetDefName(void); 139 140 static ENodeType GetType(void); 141 public: 142 /// Traitements /// 143 virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); 144 145 /// Autres /// 146 virtual void parse(xml::CXMLNode & node); 147 virtual StdString toString(void) const; 148 public: 149 127 150 CDate* lastSync ; 128 151 CDate* lastSplit ; … … 132 155 int nbDomain ; 133 156 bool isOpen ; 157 bool allDomainEmpty ; 134 158 MPI_Comm fileComm ; 159 135 160 private : 136 137 161 /// Propriétés privées /// 138 162 CFieldGroup* vFieldGroup; … … 140 164 boost::shared_ptr<CDataOutput> data_out; 141 165 std::vector<CField*> enabledFields; 166 167 public: 168 // virtual void toBinary (StdOStream & os) const; 169 // virtual void fromBinary(StdIStream & is); 142 170 143 171 }; // class CFile -
XIOS/trunk/src/node/grid.cpp
r501 r509 19 19 CGrid::CGrid(void) 20 20 : CObjectTemplate<CGrid>(), CGridAttributes() 21 , withAxis(false), isChecked(false), axis(), domain()22 , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1) 21 , withAxis(false), isChecked(false), isDomainAxisChecked(false), axis(), domain() 22 , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1), isDomConServerComputed_(false) 23 23 { /* Ne rien faire de plus */ } 24 24 25 25 CGrid::CGrid(const StdString & id) 26 26 : CObjectTemplate<CGrid>(id), CGridAttributes() 27 , withAxis(false), isChecked(false), axis(), domain()28 , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1) 27 , withAxis(false), isChecked(false), isDomainAxisChecked(false), axis(), domain() 28 , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1), isDomConServerComputed_(false) 29 29 { /* Ne rien faire de plus */ } 30 30 31 31 CGrid::~CGrid(void) 32 { 32 { 33 33 // this->axis.reset() ; 34 34 // this->domain.reset() ; 35 35 deque< CArray<int, 1>* >::iterator it ; 36 36 37 37 for(deque< CArray<int,1>* >::iterator it=storeIndex.begin(); it!=storeIndex.end();it++) delete *it ; 38 38 for(deque< CArray<int,1>* >::iterator it=out_i_index.begin();it!=out_i_index.end();it++) delete *it ; … … 55 55 56 56 const std::deque< CArray<int,1>* > & CGrid::getStoreIndex(void) const 57 { 57 { 58 58 return (this->storeIndex ); 59 59 } … … 62 62 63 63 const std::deque< CArray<int,1>* > & CGrid::getOutIIndex(void) const 64 { 65 return (this->out_i_index ); 64 { 65 return (this->out_i_index ); 66 66 } 67 67 … … 69 69 70 70 const std::deque< CArray<int,1>* > & CGrid::getOutJIndex(void) const 71 { 72 return (this->out_j_index ); 71 { 72 return (this->out_j_index ); 73 73 } 74 74 … … 76 76 77 77 const std::deque< CArray<int,1>* > & CGrid::getOutLIndex(void) const 78 { 79 return (this->out_l_index ); 78 { 79 return (this->out_l_index ); 80 80 } 81 81 … … 83 83 84 84 const CAxis* CGrid::getRelAxis (void) const 85 { 86 return (this->axis ); 85 { 86 return (this->axis ); 87 87 } 88 88 … … 90 90 91 91 const CDomain* CGrid::getRelDomain(void) const 92 { 93 return (this->domain ); 94 } 95 96 //--------------------------------------------------------------- 97 98 bool CGrid::hasAxis(void) const 99 { 100 return (this->withAxis); 92 { 93 return (this->domain ); 94 } 95 96 //--------------------------------------------------------------- 97 98 bool CGrid::hasAxis(void) const 99 { 100 return (this->withAxis); 101 101 } 102 102 … … 122 122 */ 123 123 //--------------------------------------------------------------- 124 124 125 125 /* 126 126 StdSize CGrid::getLocalSize(void) const … … 147 147 //--------------------------------------------------------------- 148 148 149 /* 149 /* 150 150 StdSize CGrid::getGlobalSize(void) const 151 151 { … … 166 166 } 167 167 168 //--------------------------------------------------------------- 169 170 void CGrid::solveReference(void) 171 { 172 if (this->isChecked) return; 173 CContext* context = CContext::getCurrent() ; 174 CContextClient* client=context->client ; 175 176 this->solveDomainRef() ; 177 this->solveAxisRef() ; 178 179 if (context->hasClient) 180 { 181 checkMask() ; 182 this->computeIndex() ; 183 184 this->storeIndex.push_front(new CArray<int,1>() ); 185 this->out_i_index.push_front(new CArray<int,1>()); 186 this->out_j_index.push_front(new CArray<int,1>()); 187 this->out_l_index.push_front(new CArray<int,1>()); 188 } 168 std::map<int, StdSize> CGrid::getConnectedServerDataSize() 169 { 170 std::map<int, StdSize> ret; 171 std::map<int, int>::const_iterator it = domConnectedServerSide_.begin(), 172 itE = domConnectedServerSide_.end(); 173 StdSize retVal = StdSize(0.0); 174 for (; it != itE; ++it) 175 { 176 retVal = it->second; 177 if (this->withAxis) retVal *= this->axis->size.getValue(); 178 retVal *= sizeof(double); 179 ret.insert(make_pair(it->first, retVal)); 180 } 181 return ret; 182 } 183 184 185 //--------------------------------------------------------------- 186 187 // void CGrid::solveReference(void) 188 // { 189 // if (this->isChecked) return; 190 // CContext* context = CContext::getCurrent() ; 191 // CContextClient* client=context->client ; 192 // 193 // this->solveDomainRef() ; 194 // this->solveAxisRef() ; 195 // 196 // if (context->hasClient) 197 // { 198 // checkMask() ; 199 // this->computeIndex() ; 200 // 201 // this->storeIndex.push_front(new CArray<int,1>() ); 202 // this->out_i_index.push_front(new CArray<int,1>()); 203 // this->out_j_index.push_front(new CArray<int,1>()); 204 // this->out_l_index.push_front(new CArray<int,1>()); 205 // } 206 //// this->computeIndexServer(); 207 // this->isChecked = true; 208 // } 209 210 void CGrid::solveDomainAxisRef(bool areAttributesChecked) 211 { 212 if (this->isDomainAxisChecked) return; 213 214 this->solveDomainRef(areAttributesChecked); 215 this->solveAxisRef(areAttributesChecked); 216 217 this->isDomainAxisChecked = areAttributesChecked; 218 } 219 220 void CGrid::checkMaskIndex(bool doSendingIndex) 221 { 222 CContext* context = CContext::getCurrent() ; 223 CContextClient* client=context->client ; 224 225 if (context->hasClient) 226 if (this->isChecked && doSendingIndex) sendIndex(); 227 228 if (this->isChecked) return; 229 230 if (context->hasClient) 231 { 232 checkMask() ; 233 this->computeIndex() ; 234 235 this->storeIndex.push_front(new CArray<int,1>() ); 236 this->out_i_index.push_front(new CArray<int,1>()); 237 this->out_j_index.push_front(new CArray<int,1>()); 238 this->out_l_index.push_front(new CArray<int,1>()); 239 } 189 240 // this->computeIndexServer(); 190 241 this->isChecked = true; 191 242 } 192 243 … … 206 257 (mask.extent(2) != nlu)) 207 258 ERROR("CGrid::checkAttributes(void)", 208 <<"The mask has not the same size than the local grid"<<endl 259 <<"The mask has not the same size than the local grid"<<endl 209 260 <<"Local size is "<<niu<<"x"<<nju<<"x"<<nlu<<endl 210 261 <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)<<"x"<<mask.extent(2)); 211 262 } 212 else 263 else 213 264 { 214 265 mask.resize(niu,nju,nlu) ; 215 266 mask=true ; 216 267 } 217 268 218 269 CArray<bool,2>& domainMask = domain->mask ; 219 270 for (int l=0; l < nlu ; l++) 220 271 for (int j=0; j < nju ; j++) 221 272 for(int i=0; i<niu ; i++) mask(i,j,l) = mask(i,j,l) && domainMask(i,j) ; 222 223 224 } 225 226 //--------------------------------------------------------------- 227 228 void CGrid::solveDomainRef(void) 273 274 275 } 276 277 //--------------------------------------------------------------- 278 279 // void CGrid::solveDomainRef(void) 280 // { 281 // if (!domain_ref.isEmpty()) 282 // { 283 // if (CDomain::has(domain_ref.getValue())) 284 // { 285 // this->domain = CDomain::get(domain_ref.getValue()) ; 286 // domain->checkAttributes() ; 287 // } 288 // else ERROR("CGrid::solveDomainRef(void)", 289 // << "Wrong domain reference") ; 290 // } 291 // else ERROR("CGrid::solveDomainRef(void)", 292 // << "Domain reference is not defined") ; 293 // } 294 // 295 // //--------------------------------------------------------------- 296 // 297 // void CGrid::solveAxisRef(void) 298 // { 299 // if (!axis_ref.isEmpty()) 300 // { 301 // this->withAxis = true ; 302 // if (CAxis::get(axis_ref.getValue())) 303 // { 304 // this->axis = CAxis::get(axis_ref.getValue()) ; 305 // axis->checkAttributes() ; 306 // } 307 // else ERROR("CGrid::solveAxisRef(void)", 308 // << "Wrong axis reference") ; 309 // } 310 // else withAxis = false ; 311 // } 312 313 314 void CGrid::solveDomainRef(bool sendAtt) 229 315 { 230 316 if (!domain_ref.isEmpty()) … … 233 319 { 234 320 this->domain = CDomain::get(domain_ref.getValue()) ; 235 domain->checkAttributes() ; 321 if (sendAtt) domain->sendCheckedAttributes(); 322 else domain->checkAttributesOnClient() ; 236 323 } 237 324 else ERROR("CGrid::solveDomainRef(void)", … … 244 331 //--------------------------------------------------------------- 245 332 246 void CGrid::solveAxisRef( void)333 void CGrid::solveAxisRef(bool checkAtt) 247 334 { 248 335 if (!axis_ref.isEmpty()) … … 263 350 264 351 void CGrid::computeIndex(void) 265 { 266 352 { 353 267 354 const int ni = domain->ni.getValue() , 268 355 nj = domain->nj.getValue() , … … 280 367 CArray<int,1> data_i_index = domain->data_i_index ; 281 368 CArray<int,1> data_j_index = domain->data_j_index ; 282 369 283 370 284 371 int indexCount = 0; … … 302 389 } 303 390 } 304 391 305 392 storeIndex[0] = new CArray<int,1>(indexCount) ; 306 393 out_i_index[0] = new CArray<int,1>(indexCount) ; 307 394 out_j_index[0] = new CArray<int,1>(indexCount) ; 308 395 out_l_index[0] = new CArray<int,1>(indexCount) ; 309 396 310 397 storeIndex_client.resize(indexCount) ; 311 398 out_i_client.resize(indexCount) ; 312 399 out_j_client.resize(indexCount) ; 313 400 out_l_client.resize(indexCount) ; 314 315 401 402 316 403 for(int count = 0, indexCount = 0, l = 0; l < size; l++) 317 404 { … … 334 421 (*out_i_index[0])(indexCount) = i ; 335 422 (*out_j_index[0])(indexCount) = j ; 336 423 337 424 storeIndex_client(indexCount) = count ; 338 425 out_i_client(indexCount)=i+domain->ibegin_client-1 ; … … 343 430 } 344 431 } 345 sendIndex() ; 432 computeDomConServer(); 433 // sendIndex() ; 346 434 347 435 … … 370 458 //---------------------------------------------------------------- 371 459 372 void CGrid::outputField(int rank, const CArray<double, 1>& stored, CArray<double, 3>& field) 460 void CGrid::outputField(int rank, const CArray<double, 1>& stored, CArray<double, 3>& field) 373 461 { 374 462 CArray<int,1>& out_i=*out_i_fromClient[rank] ; 375 463 CArray<int,1>& out_j=*out_j_fromClient[rank] ; 376 464 CArray<int,1>& out_l=*out_l_fromClient[rank] ; 377 465 378 466 for(StdSize n = 0; n < stored.numElements(); n++) 379 467 field(out_i(n), out_j(n), out_l(n)) = stored(n) ; 380 468 } 381 469 382 void CGrid::outputField(int rank, const CArray<double, 1>& stored, CArray<double, 2>& field) 470 void CGrid::outputField(int rank, const CArray<double, 1>& stored, CArray<double, 2>& field) 383 471 { 384 472 CArray<int,1>& out_i=*out_i_fromClient[rank] ; 385 473 CArray<int,1>& out_j=*out_j_fromClient[rank] ; 386 474 387 475 for(StdSize n = 0; n < stored.numElements(); n++) 388 476 field(out_i(n), out_j(n)) = stored(n) ; } … … 393 481 { 394 482 CArray<int,1>& out_i=*out_i_fromClient[rank] ; 395 483 396 484 for(StdSize n = 0; n < stored.numElements(); n++) 397 485 field(out_i(n)) = stored(n) ; … … 399 487 400 488 //---------------------------------------------------------------- 401 489 402 490 403 491 void CGrid::storeField_arr … … 409 497 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)] ; 410 498 } 411 412 //--------------------------------------------------------------- 499 500 //--------------------------------------------------------------- 501 502 // void CGrid::sendIndex(void) 503 // { 504 // CContext* context = CContext::getCurrent() ; 505 // CContextClient* client=context->client ; 506 // 507 // CEventClient event(getType(),EVENT_ID_INDEX) ; 508 // int rank ; 509 // list<shared_ptr<CMessage> > list_msg ; 510 // list< CArray<int,1>* > list_out_i,list_out_j,list_out_l ; 511 // 512 // for(int ns=0;ns<domain->connectedServer.size();ns++) 513 // { 514 // rank=domain->connectedServer[ns] ; 515 // 516 // int i,j ; 517 // int nb=0 ; 518 // for(int k=0;k<storeIndex_client.numElements();k++) 519 // { 520 // i=out_i_client(k)- domain->ibegin +1; 521 // j=out_j_client(k)- domain->jbegin +1; 522 // if (domain->mapConnectedServer(i,j)==ns) nb++ ; 523 // } 524 // 525 // CArray<int,1> storeIndex(nb) ; 526 // CArray<int,1> out_i(nb) ; 527 // CArray<int,1> out_j(nb) ; 528 // CArray<int,1> out_l(nb) ; 529 // 530 // 531 // nb=0 ; 532 // for(int k=0;k<storeIndex_client.numElements();k++) 533 // { 534 // i=out_i_client(k)- domain->ibegin +1 ; 535 // j=out_j_client(k)- domain->jbegin +1 ; 536 // if (domain->mapConnectedServer(i,j)==ns) 537 // { 538 // storeIndex(nb)=k ; 539 // out_i(nb)=domain->i_index(i,j) + domain->ibegin-1; 540 // out_j(nb)=domain->j_index(i,j) + domain->jbegin-1; 541 // out_l(nb)=out_l_client(k) ; 542 // nb++ ; 543 // } 544 // } 545 // 546 // storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(storeIndex) )) ; 547 // nbSenders.insert(pair<int,int>(rank,domain->nbSenders[ns])) ; 548 // list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 549 // list_out_i.push_back(new CArray<int,1>(out_i)) ; 550 // list_out_j.push_back(new CArray<int,1>(out_j)) ; 551 // list_out_l.push_back(new CArray<int,1>(out_l)) ; 552 // 553 // *list_msg.back()<<getId()<<*list_out_i.back()<<*list_out_j.back()<<*list_out_l.back() ; 554 // event.push(rank,domain->nbSenders[ns],*list_msg.back()) ; 555 // } 556 // client->sendEvent(event) ; 557 // 558 // for(list<CArray<int,1>* >::iterator it=list_out_i.begin();it!=list_out_i.end();it++) delete *it ; 559 // for(list<CArray<int,1>* >::iterator it=list_out_j.begin();it!=list_out_j.end();it++) delete *it ; 560 // for(list<CArray<int,1>* >::iterator it=list_out_l.begin();it!=list_out_l.end();it++) delete *it ; 561 // 562 // } 563 564 void CGrid::computeDomConServer() 565 { 566 if (!isDomConServerComputed_) 567 { 568 for(int ns=0;ns<domain->connectedServer.size(); ++ns) 569 { 570 int rank=domain->connectedServer[ns] ; 571 572 int i,j ; 573 int nb=0 ; 574 for(int k=0;k<storeIndex_client.numElements();++k) 575 { 576 i=out_i_client(k)- domain->ibegin +1; 577 j=out_j_client(k)- domain->jbegin +1; 578 if (domain->mapConnectedServer(i,j)==ns) ++nb ; 579 } 580 581 domConnectedServerSide_.insert(std::make_pair(rank, nb)); 582 } 583 isDomConServerComputed_ = true; 584 } 585 } 586 587 588 std::map<int, int> CGrid::getDomConServerSide() 589 { 590 return domConnectedServerSide_; 591 } 413 592 414 593 void CGrid::sendIndex(void) … … 416 595 CContext* context = CContext::getCurrent() ; 417 596 CContextClient* client=context->client ; 418 597 419 598 CEventClient event(getType(),EVENT_ID_INDEX) ; 420 599 int rank ; 421 600 list<shared_ptr<CMessage> > list_msg ; 422 601 list< CArray<int,1>* > list_out_i,list_out_j,list_out_l ; 423 602 603 if (!isDomConServerComputed_) computeDomConServer(); 604 424 605 for(int ns=0;ns<domain->connectedServer.size();ns++) 425 606 { 426 607 rank=domain->connectedServer[ns] ; 427 428 int i,j ; 429 int nb=0 ; 430 for(int k=0;k<storeIndex_client.numElements();k++) 431 { 432 i=out_i_client(k)- domain->ibegin +1; 433 j=out_j_client(k)- domain->jbegin +1; 434 if (domain->mapConnectedServer(i,j)==ns) nb++ ; 435 } 436 608 609 int nb = domConnectedServerSide_.find(rank)->second; 437 610 CArray<int,1> storeIndex(nb) ; 438 611 CArray<int,1> out_i(nb) ; 439 612 CArray<int,1> out_j(nb) ; 440 613 CArray<int,1> out_l(nb) ; 441 442 614 615 int i, j; 443 616 nb=0 ; 444 617 for(int k=0;k<storeIndex_client.numElements();k++) … … 450 623 storeIndex(nb)=k ; 451 624 out_i(nb)=domain->i_index(i,j) + domain->ibegin-1; 452 out_j(nb)=domain->j_index(i,j) + domain->jbegin-1; 625 out_j(nb)=domain->j_index(i,j) + domain->jbegin-1; 453 626 out_l(nb)=out_l_client(k) ; 454 627 nb++ ; 455 628 } 456 629 } 457 630 458 631 storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(storeIndex) )) ; 459 632 nbSenders.insert(pair<int,int>(rank,domain->nbSenders[ns])) ; … … 471 644 for(list<CArray<int,1>* >::iterator it=list_out_j.begin();it!=list_out_j.end();it++) delete *it ; 472 645 for(list<CArray<int,1>* >::iterator it=list_out_l.begin();it!=list_out_l.end();it++) delete *it ; 473 646 474 647 } 475 648 476 649 void CGrid::recvIndex(CEventServer& event) 477 650 { … … 486 659 } 487 660 } 488 661 489 662 void CGrid::recvIndex(int rank, CBufferIn& buffer) 490 663 { … … 492 665 CArray<int,1> out_j ; 493 666 CArray<int,1> out_l ; 494 667 495 668 buffer>>out_i>>out_j>>out_l ; 496 669 497 670 out_i -= domain->zoom_ibegin_srv-1 ; 498 671 out_j -= domain->zoom_jbegin_srv-1 ; 499 672 500 673 out_i_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_i) )) ; 501 674 out_j_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_j) )) ; … … 505 678 bool CGrid::dispatchEvent(CEventServer& event) 506 679 { 507 680 508 681 if (SuperClass::dispatchEvent(event)) return true ; 509 682 else … … 515 688 return true ; 516 689 break ; 517 690 518 691 default : 519 692 ERROR("bool CDomain::dispatchEvent(CEventServer& event)", … … 532 705 << "Data from clients are missing!") ; 533 706 storedServer.resize(storeIndex[0]->numElements()); 534 707 535 708 for (StdSize i = 0, n = 0; i < storedClient.size(); i++) 536 709 for (StdSize j = 0; j < storedClient[i]->numElements(); j++) … … 543 716 int nb=index.numElements() ; 544 717 fieldOut.resize(nb) ; 545 718 546 719 for(int k=0;k<nb;k++) fieldOut(k)=fieldIn(index(k)) ; 547 720 } -
XIOS/trunk/src/node/grid.hpp
r501 r509 13 13 14 14 namespace xios { 15 15 16 16 /// ////////////////////// Déclarations ////////////////////// /// 17 17 … … 46 46 EVENT_ID_INDEX 47 47 } ; 48 48 49 49 /// Constructeurs /// 50 50 CGrid(void); … … 54 54 55 55 /// Traitements /// 56 void solveReference(void); 56 // void solveReference(void); 57 58 void solveDomainAxisRef(bool areAttributesChecked); 59 60 void checkMaskIndex(bool doCalculateIndex); 57 61 58 62 // virtual void toBinary (StdOStream & os) const; … … 74 78 75 79 StdSize getDimension(void) const; 76 80 77 81 // StdSize getLocalSize(void) const; 78 82 // StdSize getGlobalSize(void) const; … … 84 88 template <int n> 85 89 void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; 86 90 87 91 void inputFieldServer(const std::deque< CArray<double, 1>* > storedClient, 88 92 CArray<double, 1>& storedServer) const; … … 90 94 void outputField(int rank, const CArray<double,1>& stored, CArray<double,3>& field) ; 91 95 void outputField(int rank, const CArray<double,1>& stored, CArray<double,2>& field) ; 92 void outputField(int rank, const CArray<double,1>& stored, CArray<double,1>& field) ; 93 96 void outputField(int rank, const CArray<double,1>& stored, CArray<double,1>& field) ; 97 94 98 /// Destructeur /// 95 99 virtual ~CGrid(void); … … 100 104 static StdString GetName(void); 101 105 static StdString GetDefName(void); 102 106 103 107 static ENodeType GetType(void); 104 108 … … 115 119 void computeIndexServer(void); 116 120 void computeIndex(void); 117 void solveDomainRef(void); 118 void solveAxisRef(void); 121 // void solveDomainRef(void); //TODO temporarily comment 122 // void solveAxisRef(void); // TODO: temporarily comment 123 124 void solveDomainRef(bool checkAtt); 125 void solveAxisRef(bool checkAtt); 119 126 120 127 static bool dispatchEvent(CEventServer& event) ; … … 123 130 void recvIndex(int rank, CBufferIn& buffer) ; 124 131 void sendIndex(void) ; 125 132 133 void computeDomConServer(); 134 std::map<int, int> getDomConServerSide(); 135 std::map<int, StdSize> getConnectedServerDataSize(); 126 136 public: 127 137 … … 129 139 bool withAxis ; 130 140 bool isChecked; 141 bool isDomainAxisChecked; 131 142 132 143 CAxis* axis ; … … 137 148 std::deque< CArray<int, 1>* > out_j_index ; 138 149 std::deque< CArray<int, 1>* > out_l_index ; 139 150 140 151 CArray<int, 1> storeIndex_client ; 141 152 CArray<int, 1> out_i_client ; 142 153 CArray<int, 1> out_j_client ; 143 154 CArray<int, 1> out_l_client ; 144 155 145 156 map<int, CArray<int, 1>* > storeIndex_toSrv ; 146 157 map<int,int> nbSenders ; … … 148 159 // std::deque<ARRAY(int, 1)> out_j_toSrv ; 149 160 // std::deque<ARRAY(int, 1)> out_l_toSrv ; 150 161 151 162 map<int, CArray<int, 1>* > out_i_fromClient ; 152 163 map<int, CArray<int, 1>* > out_j_fromClient ; 153 164 map<int, CArray<int, 1>* > out_l_fromClient ; 154 165 void checkMask(void) ; 166 167 std::map<int, int> domConnectedServerSide_; 168 bool isDomConServerComputed_; 155 169 }; // class CGrid 156 170 -
XIOS/trunk/src/object_template.hpp
r501 r509 26 26 typedef CObject SuperClass; 27 27 typedef T DerivedType; 28 28 29 29 enum EEventId 30 30 { … … 42 42 virtual string getName(void) const ; 43 43 virtual void parse(xml::CXMLNode & node); 44 44 45 45 /// Accesseurs /// 46 46 ENodeType getType(void) const; … … 56 56 void sendAttributToServer(const string& id); 57 57 void sendAttributToServer(CAttribute& attr) ; 58 void sendAllAttributesToServer(); 58 59 static void recvAttributFromClient(CEventServer& event) ; 59 60 static bool dispatchEvent(CEventServer& event) ; … … 65 66 /// Destructeur /// 66 67 virtual ~CObjectTemplate(void); 67 68 68 69 static bool has(const string& id) ; 69 70 static bool has(const string& contextId, const string& id) ; … … 74 75 shared_ptr<T> getShared(void) ; 75 76 static shared_ptr<T> getShared(const T* ptr) ; 76 77 77 78 static T* create(const string& id=string("")) ; 78 79 static const vector<T*> getAll() ; 79 80 static const vector<T*> getAll(const string& contextId) ; 80 81 81 82 void generateCInterface(ostream& oss) ; 82 83 void generateFortran2003Interface(ostream& oss) ; 83 84 void generateFortranInterface(ostream& oss) ; 84 85 85 86 protected : 86 87 … … 97 98 static xios_map<StdString, 98 99 xios_map<StdString, 99 boost::shared_ptr<DerivedType> > > AllMapObj; 100 boost::shared_ptr<DerivedType> > > AllMapObj; 100 101 static xios_map<StdString, 101 102 std::vector<boost::shared_ptr<DerivedType> > > AllVectObj; 102 103 103 104 static xios_map< StdString, long int > GenId ; 104 105 -
XIOS/trunk/src/object_template_impl.hpp
r501 r509 55 55 ERROR("CObjectTemplate<T> construtor 3", << "Not completly implemented yet !"); 56 56 } 57 57 58 58 template <class T> 59 59 CObjectTemplate<T>::~CObjectTemplate(void) … … 65 65 std::vector<boost::shared_ptr<T> > & 66 66 CObjectTemplate<T>::GetAllVectobject(const StdString & contextId) 67 { 68 return (CObjectTemplate<T>::AllVectObj[contextId]); 69 } 70 71 //--------------------------------------------------------------- 72 67 { 68 return (CObjectTemplate<T>::AllVectObj[contextId]); 69 } 70 71 //--------------------------------------------------------------- 72 73 73 template <class T> 74 74 StdString CObjectTemplate<T>::toString(void) const … … 84 84 template <class T> 85 85 void CObjectTemplate<T>::fromString(const StdString & str) 86 { 86 { 87 87 ERROR("CObjectTemplate<T>::fromString(str)", 88 << "[ str = " << str << "] Not implemented yet !"); 89 } 90 91 //--------------------------------------------------------------- 92 93 /* 88 << "[ str = " << str << "] Not implemented yet !"); 89 } 90 91 //--------------------------------------------------------------- 92 93 /* 94 94 template <class T> 95 95 void CObjectTemplate<T>::toBinary(StdOStream & os) const 96 96 { 97 SuperClassMap::toBinary(os); 98 } 99 97 SuperClassMap::toBinary(os); 98 } 99 100 100 template <class T> 101 101 void CObjectTemplate<T>::fromBinary(StdIStream & is) 102 102 { 103 SuperClassMap::fromBinary(is); 103 SuperClassMap::fromBinary(is); 104 104 } 105 105 */ … … 121 121 return (T::GetType()); 122 122 } 123 123 124 124 template <class T> 125 125 string CObjectTemplate<T>::getName(void) const … … 127 127 return (T::GetName()); 128 128 } 129 129 130 130 //--------------------------------------------------------------- 131 131 132 132 template <class T> 133 133 bool CObjectTemplate<T>::hasChild(void) const 134 { 135 return (false); 134 { 135 return (false); 136 136 } 137 137 … … 140 140 template <class T> 141 141 void CObjectTemplate<T>::solveDescInheritance(bool apply, const CAttributeMap * const parent) 142 { 143 SuperClassMap::setAttributes(parent, apply); 142 { 143 SuperClassMap::setAttributes(parent, apply); 144 144 } 145 145 … … 160 160 } 161 161 162 template<typename T> 163 void CObjectTemplate<T>::sendAllAttributesToServer() 164 { 165 CAttributeMap& attrMap = *this; 166 CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end(); 167 for (; it != itE; ++it) 168 { 169 if (!(it->second)->isEmpty()) sendAttributToServer(*(it->second)); 170 } 171 172 } 173 162 174 template <class T> 163 175 void CObjectTemplate<T>::sendAttributToServer(const string& id) … … 172 184 { 173 185 CContext* context=CContext::getCurrent() ; 174 186 175 187 if (!context->hasServer) 176 188 { 177 189 CContextClient* client=context->client ; 178 190 179 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE) ; 191 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE) ; 180 192 if (client->isServerLeader()) 181 193 { … … 189 201 else client->sendEvent(event) ; 190 202 } 191 203 192 204 } 193 205 194 206 template <class T> 195 207 void CObjectTemplate<T>::recvAttributFromClient(CEventServer& event) 196 208 { 197 209 198 210 CBufferIn* buffer=event.subEvents.begin()->buffer; 199 211 string id,attrId; … … 220 232 return true ; 221 233 break ; 222 234 223 235 default : 224 236 return false ; … … 227 239 } 228 240 } 229 241 230 242 template <typename T> 231 243 bool CObjectTemplate<T>::has(const string & id) … … 251 263 return CObjectFactory::GetObject<T>(ptr).get() ; 252 264 } 253 265 254 266 template <typename T> 255 267 shared_ptr<T> CObjectTemplate<T>::getShared(const T* ptr) … … 263 275 return CObjectFactory::GetObject<T>((T*)this) ; 264 276 } 265 277 266 278 template <typename T> 267 279 const vector<T*> CObjectTemplate<T>::getAll() … … 269 281 const vector< shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(); 270 282 vector<T*> vect ; 271 283 272 284 typename vector<shared_ptr<T> >::const_iterator it; 273 285 for(it=shared_vect.begin();it!=shared_vect.end();++it) vect.push_back(it->get()) ; … … 280 292 const vector< shared_ptr<T> >& shared_vect= CObjectFactory::GetObjectVector<T>(id); 281 293 vector<T*> vect ; 282 294 283 295 typename vector<shared_ptr<T> >::const_iterator it; 284 296 for(it=shared_vect.begin();it!=shared_vect.end();++it) vect.push_back(it->get()) ; … … 303 315 return CObjectFactory::GetObject<T>((T*)this).get() ; 304 316 } 305 317 306 318 template <typename T> 307 319 void CObjectTemplate<T>::generateCInterface(ostream& oss) … … 310 322 int found=className.find_first_of("_") ; 311 323 if (found!=string::npos) className.replace(found,1,0,'x') ; 312 324 313 325 oss<<"/* ************************************************************************** *"<<iendl ; 314 326 oss<<" * Interface auto generated - do not modify *"<<iendl ; … … 340 352 int found=className.find_first_of("_") ; 341 353 if (found!=string::npos) className.replace(found,1,0,'x') ; 342 354 343 355 oss<<"! * ************************************************************************** *"<<iendl ; 344 356 oss<<"! * Interface auto generated - do not modify *"<<iendl ; … … 349 361 oss<<iendl ; 350 362 oss<<"INTERFACE ! Do not call directly / interface FORTRAN 2003 <-> C99"<<iendl++ ; 351 oss<<iendl ; 363 oss<<iendl ; 352 364 oss<<iendl ; 353 365 SuperClassMap::generateFortran2003Interface(oss,className) ; … … 356 368 oss<<"END MODULE "<<className<<"_interface_attr"<<iendl ; 357 369 } 358 370 359 371 template <typename T> 360 372 void CObjectTemplate<T>::generateFortranInterface(ostream& oss) … … 366 378 found=superClassName.find("_group") ; 367 379 if (found!=string::npos) superClassName.erase(found,6) ; 368 380 369 381 oss<<"! * ************************************************************************** *"<<iendl ; 370 382 oss<<"! * Interface auto generated - do not modify *"<<iendl ; … … 398 410 SuperClassMap::generateFortranInterfaceIsDefined_hdl(oss,className) ; 399 411 oss<<iendl ; 400 SuperClassMap::generateFortranInterfaceIsDefined_hdl_(oss,className) ; 412 SuperClassMap::generateFortranInterfaceIsDefined_hdl_(oss,className) ; 401 413 oss<<iendl-- ; 402 414 oss<<"END MODULE i"<<className<<"_attr"<<iendl ; -
XIOS/trunk/src/xml_parser.cpp
r501 r509 13 13 /// ////////////////////// Définitions ////////////////////// /// 14 14 15 void CXMLParser::ParseFile(const StdString & filename )15 void CXMLParser::ParseFile(const StdString & filename, const std::set<StdString>& parseContextList) 16 16 { 17 17 StdIFStream ifs ( filename.c_str() , StdIFStream::in ); … … 20 20 <<endl<< "Can not open <"<<filename<<"> file" ); 21 21 22 CXMLParser::ParseStream(ifs, filename );22 CXMLParser::ParseStream(ifs, filename, parseContextList); 23 23 } 24 24 … … 26 26 { 27 27 StdIStringStream iss ( xmlContent /*, StdIStringStream::in*/ ); 28 CXMLParser::ParseStream(iss,"string"); 28 std::set<StdString> contxtList; 29 CXMLParser::ParseStream(iss,"string", contxtList); 29 30 } 30 31 31 void CXMLParser::ParseStream(StdIStream & stream, const string& fluxId )32 void CXMLParser::ParseStream(StdIStream & stream, const string& fluxId, const std::set<StdString>& parseContextList) 32 33 { 33 34 if (!stream.good()) … … 50 51 << node.getElementName() << "\')!"); 51 52 53 std::set<StdString>::iterator it; 54 std::set<StdString>::const_iterator itE = parseContextList.end(); 55 bool isParseAll = (parseContextList.empty()); 52 56 if (node.goToChildElement()) 53 57 { … … 55 59 { 56 60 CContextGroup* group_context = CContext::getRoot() ; 57 61 58 62 attributes = node.getAttributes(); 59 63 60 64 if (attributes.end() == attributes.find("id")) 61 { 65 { 62 66 DEBUG("The context will not be processed because it is not identified (missing id)"); 63 continue; 67 continue; 64 68 } 65 69 … … 69 73 70 74 if(hasctxt) 71 { 75 { 72 76 DEBUG("The context will not be processed because it exist an other context with the same id" ); 73 continue; 77 continue; 74 78 } 75 79 76 CContext* context = CContext::create(attributes["id"]); 80 if (isParseAll) 81 { 82 CContext* context = CContext::create(attributes["id"]); 77 83 // if (!hasctxt) group_context->addChild(context); 78 context->parse(node);84 context->parse(node); 79 85 80 attributes.clear(); 86 attributes.clear(); 87 } 88 else 89 { 90 it = parseContextList.find(attributes["id"]); 91 if (itE != it) 92 { 93 CContext* context = CContext::create(*it); 94 // if (!hasctxt) group_context->addChild(context); 95 context->parse(node); 81 96 97 attributes.clear(); 98 } 99 } 82 100 } while (node.goToNextElement()); 83 101 } … … 93 111 const char* line; 94 112 const char* endLine; 95 113 96 114 for(const char* i=content;i<content+pos; ++i, ++columnNumber) if (*i=='\n') { lineNumber++ ; line=i ; columnNumber=0 ;} 97 115 for(endLine=content+pos; *endLine!='\n' && *endLine!='\0' ; ++endLine) ; 98 116 string strLine(line,endLine-line) ; 99 117 100 118 ERROR("CXMLParser::ParseStream(StdIStream & stream)", << endl 101 119 << "Error is occuring when parsing XML flux from <"<<fluxId<<"> at character "<< pos<<" line "<<lineNumber<<" column "<< columnNumber<< endl -
XIOS/trunk/src/xml_parser.hpp
r501 r509 17 17 public : 18 18 19 static void ParseFile(const StdString & filename );19 static void ParseFile(const StdString & filename, const std::set<StdString>& parseList = std::set<StdString>()); 20 20 static void ParseString(const StdString & xmlContent); 21 static void ParseStream(StdIStream & stream, const string& fluxId );21 static void ParseStream(StdIStream & stream, const string& fluxId, const std::set<StdString>& parseList); 22 22 template <class T> 23 23 static void ParseInclude(StdIStream & stream, const string& fluxId, T & object);
Note: See TracChangeset
for help on using the changeset viewer.