Changeset 651
- Timestamp:
- 07/24/15 16:40:05 (9 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/field.cpp
r650 r651 203 203 { 204 204 int rank = it->first; 205 data_srv.insert( pair<int, CArray<double,1>* >(rank, newCArray<double,1>(it->second.numElements())));206 foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant( *data_srv[rank]))));205 data_srv.insert(std::make_pair(rank, CArray<double,1>(it->second.numElements()))); 206 foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(data_srv[rank])))); 207 207 } 208 208 } … … 210 210 CContext* context = CContext::getCurrent(); 211 211 const CDate& currDate = context->getCalendar()->getCurrentDate(); 212 const CDate opeDate = *last_operation_srv + freq_operation_srv;213 const CDate writeDate = *last_Write_srv + freq_write_srv;212 const CDate opeDate = last_operation_srv + freq_operation_srv; 213 const CDate writeDate = last_Write_srv + freq_write_srv; 214 214 215 215 if (opeDate <= currDate) … … 221 221 (*foperation_srv[ranks[n]])(data_tmp); 222 222 } 223 *last_operation_srv = currDate;223 last_operation_srv = currDate; 224 224 } 225 225 … … 231 231 } 232 232 233 *last_Write_srv = writeDate;233 last_Write_srv = writeDate; 234 234 writeField(); 235 *lastlast_Write_srv = *last_Write_srv;235 lastlast_Write_srv = last_Write_srv; 236 236 } 237 237 } … … 305 305 bool hasData = readField(); 306 306 307 map<int, CArray<double,1> *>::iterator it;307 map<int, CArray<double,1> >::iterator it; 308 308 for (it = data_srv.begin(); it != data_srv.end(); it++) 309 309 { … … 312 312 msg << getId(); 313 313 if (hasData) 314 msg << getNStep() - 1 << *it->second;314 msg << getNStep() - 1 << it->second; 315 315 else 316 316 msg << size_t(-1); … … 329 329 { 330 330 for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 331 data_srv.insert( pair<int, CArray<double,1>*>(it->first, newCArray<double,1>(it->second.numElements())));331 data_srv.insert(std::make_pair(it->first, CArray<double,1>(it->second.numElements()))); 332 332 } 333 333 … … 483 483 484 484 solveGridReference(); 485 486 lastDataRequestedFromServer.setRelCalendar(*context->getCalendar());487 485 } 488 486 solveGridDomainAxisRef(doSending2Sever); … … 516 514 freq_write_srv = file->output_freq.getValue(); 517 515 518 lastlast_Write_srv = boost::shared_ptr<CDate>(new CDate(context->getCalendar()->getInitDate()));519 last_Write_srv = boost::shared_ptr<CDate>(new CDate(context->getCalendar()->getInitDate()));520 last_operation_srv = boost::shared_ptr<CDate>(new CDate(context->getCalendar()->getInitDate()));516 lastlast_Write_srv = context->getCalendar()->getInitDate(); 517 last_Write_srv = context->getCalendar()->getInitDate(); 518 last_operation_srv = context->getCalendar()->getInitDate(); 521 519 522 520 const CDuration toffset = freq_operation_srv - freq_offset.getValue() - context->getCalendar()->getTimeStep(); 523 *last_operation_srv = *last_operation_srv - toffset;521 last_operation_srv = last_operation_srv - toffset; 524 522 525 523 if (operation.isEmpty()) … … 792 790 void CField::scaleFactorAddOffset(double scaleFactor, double addOffset) 793 791 { 794 map<int, CArray<double,1> *>::iterator it;795 for (it = data_srv.begin(); it != data_srv.end(); it++) *it->second = (*it->second - addOffset) / scaleFactor;792 map<int, CArray<double,1> >::iterator it; 793 for (it = data_srv.begin(); it != data_srv.end(); it++) it->second = (it->second - addOffset) / scaleFactor; 796 794 } 797 795 798 796 void CField::invertScaleFactorAddOffset(double scaleFactor, double addOffset) 799 797 { 800 map<int, CArray<double,1> *>::iterator it;801 for (it = data_srv.begin(); it != data_srv.end(); it++) *it->second = *it->second * scaleFactor + addOffset;798 map<int, CArray<double,1> >::iterator it; 799 for (it = data_srv.begin(); it != data_srv.end(); it++) it->second = it->second * scaleFactor + addOffset; 802 800 } 803 801 804 802 void CField::outputField(CArray<double,3>& fieldOut) 805 803 { 806 map<int, CArray<double,1> *>::iterator it;804 map<int, CArray<double,1> >::iterator it; 807 805 for (it = data_srv.begin(); it != data_srv.end(); it++) 808 806 { 809 grid->outputField(it->first, *it->second, fieldOut.dataFirst());807 grid->outputField(it->first, it->second, fieldOut.dataFirst()); 810 808 } 811 809 } … … 813 811 void CField::outputField(CArray<double,2>& fieldOut) 814 812 { 815 map<int, CArray<double,1> *>::iterator it;813 map<int, CArray<double,1> >::iterator it; 816 814 for(it=data_srv.begin();it!=data_srv.end();it++) 817 815 { 818 grid->outputField(it->first, *it->second, fieldOut.dataFirst()) ;816 grid->outputField(it->first, it->second, fieldOut.dataFirst()) ; 819 817 } 820 818 } … … 822 820 void CField::outputField(CArray<double,1>& fieldOut) 823 821 { 824 map<int, CArray<double,1> *>::iterator it;822 map<int, CArray<double,1> >::iterator it; 825 823 826 824 for (it = data_srv.begin(); it != data_srv.end(); it++) 827 825 { 828 grid->outputField(it->first, *it->second, fieldOut.dataFirst()) ;826 grid->outputField(it->first, it->second, fieldOut.dataFirst()) ; 829 827 } 830 828 } … … 832 830 void CField::inputField(CArray<double,3>& fieldOut) 833 831 { 834 map<int, CArray<double,1> *>::iterator it;832 map<int, CArray<double,1> >::iterator it; 835 833 for (it = data_srv.begin(); it != data_srv.end(); it++) 836 834 { 837 grid->inputField(it->first, fieldOut.dataFirst(), *it->second);835 grid->inputField(it->first, fieldOut.dataFirst(), it->second); 838 836 } 839 837 } … … 841 839 void CField::inputField(CArray<double,2>& fieldOut) 842 840 { 843 map<int, CArray<double,1> *>::iterator it;841 map<int, CArray<double,1> >::iterator it; 844 842 for(it = data_srv.begin(); it != data_srv.end(); it++) 845 843 { 846 grid->inputField(it->first, fieldOut.dataFirst(), *it->second);844 grid->inputField(it->first, fieldOut.dataFirst(), it->second); 847 845 } 848 846 } … … 850 848 void CField::inputField(CArray<double,1>& fieldOut) 851 849 { 852 map<int, CArray<double,1> *>::iterator it;850 map<int, CArray<double,1> >::iterator it; 853 851 for (it = data_srv.begin(); it != data_srv.end(); it++) 854 852 { 855 grid->inputField(it->first, fieldOut.dataFirst(), *it->second);853 grid->inputField(it->first, fieldOut.dataFirst(), it->second); 856 854 } 857 855 } -
XIOS/trunk/src/node/field.hpp
r646 r651 65 65 EVENT_ID_UPDATE_DATA, EVENT_ID_READ_DATA, EVENT_ID_READ_DATA_READY, 66 66 EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP 67 } 67 }; 68 68 69 69 /// Constructeurs /// 70 70 CField(void); 71 explicit CField(const StdString 72 CField(const CField 73 CField(const CField 71 explicit CField(const StdString& id); 72 CField(const CField& field); // Not implemented yet. 73 CField(const CField* const field); // Not implemented yet. 74 74 75 75 /// Accesseurs /// 76 76 77 CGrid* getRelGrid(void) const 78 CFile* getRelFile(void) const 77 CGrid* getRelGrid(void) const; 78 CFile* getRelFile(void) const; 79 79 80 80 func::CFunctor::ETimeType getOperationTimeType() const; … … 91 91 void setRelFile(CFile* _file); 92 92 void incrementNStep(void); 93 void resetNStep() 93 void resetNStep(); 94 94 void resetNStepMax(); 95 95 … … 98 98 public : 99 99 bool isActive(void) const; 100 bool hasOutputFile 100 bool hasOutputFile; 101 101 102 102 /// Traitements /// … … 112 112 boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq); 113 113 114 // virtual void fromBinary(StdIStream 114 // virtual void fromBinary(StdIStream& is); 115 115 116 116 /// Destructeur /// … … 123 123 static ENodeType GetType(void); 124 124 125 template <int N> void setData(const CArray<double, N>& _data) 126 static bool dispatchEvent(CEventServer& event) 125 template <int N> void setData(const CArray<double, N>& _data); 126 static bool dispatchEvent(CEventServer& event); 127 127 void sendUpdateData(const CArray<double,1>& data); 128 static void recvUpdateData(CEventServer& event) 129 void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 130 void writeField(void) 128 static void recvUpdateData(CEventServer& event); 129 void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers); 130 void writeField(void); 131 131 void sendReadDataRequest(void); 132 132 bool sendReadDataRequestIfNeeded(void); … … 136 136 static void recvReadDataReady(CEventServer& event); 137 137 void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers); 138 void outputField(CArray<double,3>& fieldOut) 139 void outputField(CArray<double,2>& fieldOut) 140 void outputField(CArray<double,1>& fieldOut) 138 void outputField(CArray<double,3>& fieldOut); 139 void outputField(CArray<double,2>& fieldOut); 140 void outputField(CArray<double,1>& fieldOut); 141 141 void inputField(CArray<double,3>& fieldOut); 142 142 void inputField(CArray<double,2>& fieldOut); 143 143 void inputField(CArray<double,1>& fieldOut); 144 void scaleFactorAddOffset(double scaleFactor, double addOffset) 144 void scaleFactorAddOffset(double scaleFactor, double addOffset); 145 145 void invertScaleFactorAddOffset(double scaleFactor, double addOffset); 146 void parse(xml::CXMLNode & node);146 void parse(xml::CXMLNode& node); 147 147 148 148 void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); … … 150 150 CVariableGroup* getVirtualVariableGroup(void) const; 151 151 vector<CVariable*> getAllVariables(void) const; 152 virtual void solveDescInheritance(bool apply, const CAttributeMap 153 154 CVariable* addVariable(const string& id ="");155 CVariableGroup* addVariableGroup(const string& id ="");156 void sendAddVariable(const string& id ="");157 void sendAddVariableGroup(const string& id ="");158 static void recvAddVariable(CEventServer& event) 159 void recvAddVariable(CBufferIn& buffer) 160 static void recvAddVariableGroup(CEventServer& event) 161 void recvAddVariableGroup(CBufferIn& buffer) 152 virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0); 153 154 CVariable* addVariable(const string& id = ""); 155 CVariableGroup* addVariableGroup(const string& id = ""); 156 void sendAddVariable(const string& id = ""); 157 void sendAddVariableGroup(const string& id = ""); 158 static void recvAddVariable(CEventServer& event); 159 void recvAddVariable(CBufferIn& buffer); 160 static void recvAddVariableGroup(CEventServer& event); 161 void recvAddVariableGroup(CBufferIn& buffer); 162 162 void sendAddAllVariables(); 163 163 … … 167 167 public : 168 168 /// Propriétés privées /// 169 CVariableGroup* vVariableGroup 170 171 CGrid* grid 169 CVariableGroup* vVariableGroup; 170 171 CGrid* grid; 172 172 CFile* file; 173 173 … … 176 176 StdSize nstep, nstepMax; 177 177 bool isEOF; 178 boost::shared_ptr<CDate>lastlast_Write_srv, last_Write_srv, last_operation_srv;178 CDate lastlast_Write_srv, last_Write_srv, last_operation_srv; 179 179 CDate lastDataRequestedFromServer; 180 180 181 181 map<int,boost::shared_ptr<func::CFunctor> > foperation_srv; 182 182 183 map<int, CArray<double,1> * > data_srv;184 string content 183 map<int, CArray<double,1> > data_srv; 184 string content; 185 185 186 186 bool areAllReferenceSolved; -
XIOS/trunk/src/node/file.cpp
r645 r651 25 25 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 26 26 { 27 setVirtualFieldGroup() 28 setVirtualVariableGroup() 27 setVirtualFieldGroup(); 28 setVirtualVariableGroup(); 29 29 } 30 30 … … 33 33 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 34 34 { 35 setVirtualFieldGroup() 36 setVirtualVariableGroup() 35 setVirtualFieldGroup(); 36 setVirtualVariableGroup(); 37 37 } 38 38 … … 129 129 std::vector<CField*> newEnabledFields; 130 130 131 for ( it = this->enabledFields.begin() 131 for ( it = this->enabledFields.begin(); it != this->enabledFields.end(); it++ ) 132 132 { 133 133 if (!(*it)->enabled.isEmpty()) // Si l'attribut 'enabled' est défini ... … … 138 138 else // Si l'attribut 'enabled' n'est pas défini ... 139 139 { 140 if (!default_enabled) continue 140 if (!default_enabled) continue; 141 141 // { it--; this->enabledFields.erase(it+1); continue; } 142 142 } … … 144 144 if (!(*it)->level.isEmpty()) // Si l'attribut 'level' est défini ... 145 145 { 146 if ((*it)->level.getValue() > _outputlevel) continue 146 if ((*it)->level.getValue() > _outputlevel) continue; 147 147 // { it--; this->enabledFields.erase(it+1); continue; } 148 148 } 149 149 else // Si l'attribut 'level' n'est pas défini ... 150 150 { 151 if (default_level > _outputlevel) continue 151 if (default_level > _outputlevel) continue; 152 152 // { it--; this->enabledFields.erase(it+1); continue; } 153 153 } 154 154 155 // CField* field_tmp=(*it).get() 156 // shared_ptr<CField> sptfield=*it 157 // field_tmp->refObject.push_back(sptfield) 158 newEnabledFields.push_back(*it) 155 // CField* field_tmp=(*it).get(); 156 // shared_ptr<CField> sptfield=*it; 157 // field_tmp->refObject.push_back(sptfield); 158 newEnabledFields.push_back(*it); 159 159 // Le champ est finalement actif, on y ajoute sa propre reference. 160 160 // (*it)->refObject.push_back(*it); … … 164 164 // A faire, ajouter les references intermediaires... 165 165 } 166 enabledFields =newEnabledFields;166 enabledFields = newEnabledFields; 167 167 168 168 return (this->enabledFields); … … 198 198 bool CFile::isSyncTime(void) 199 199 { 200 CContext* context = CContext::getCurrent() 201 const CDate& currentDate = context->calendar->getCurrentDate() 200 CContext* context = CContext::getCurrent(); 201 const CDate& currentDate = context->calendar->getCurrentDate(); 202 202 if (!sync_freq.isEmpty()) 203 203 { 204 if ( *lastSync + sync_freq.getValue() < currentDate)204 if (lastSync + sync_freq.getValue() < currentDate) 205 205 { 206 *lastSync=currentDate;207 return true 206 lastSync = currentDate; 207 return true; 208 208 } 209 209 } 210 return false 210 return false; 211 211 } 212 212 … … 214 214 void CFile::initFile(void) 215 215 { 216 CContext* context = CContext::getCurrent() 217 const CDate& currentDate = context->calendar->getCurrentDate() 218 CContextServer* server =context->server;219 220 lastSync =new CDate(currentDate);221 lastSplit =new CDate(currentDate);222 isOpen =false;223 224 allDomainEmpty =true;216 CContext* context = CContext::getCurrent(); 217 const CDate& currentDate = context->calendar->getCurrentDate(); 218 CContextServer* server = context->server; 219 220 lastSync = currentDate; 221 lastSplit = currentDate; 222 isOpen = false; 223 224 allDomainEmpty = true; 225 225 226 226 set<CAxis*> setAxis; … … 243 243 244 244 // create sub communicator for file 245 int color=allDomainEmpty?0:1 ; 246 MPI_Comm_split(server->intraComm,color,server->intraCommRank,&fileComm) ; 247 if (allDomainEmpty) MPI_Comm_free(&fileComm) ; 248 // 249 245 int color = allDomainEmpty ? 0 : 1; 246 MPI_Comm_split(server->intraComm, color, server->intraCommRank, &fileComm); 247 if (allDomainEmpty) MPI_Comm_free(&fileComm); 250 248 } 251 249 … … 273 271 bool CFile::checkSync(void) 274 272 { 275 CContext* context = CContext::getCurrent() 276 const CDate& currentDate = context->calendar->getCurrentDate() 273 CContext* context = CContext::getCurrent(); 274 const CDate& currentDate = context->calendar->getCurrentDate(); 277 275 if (!sync_freq.isEmpty()) 278 276 { 279 if ( *lastSync + sync_freq.getValue() <= currentDate)277 if (lastSync + sync_freq.getValue() <= currentDate) 280 278 { 281 *lastSync=currentDate;282 data_out->syncFile() 283 return true 279 lastSync = currentDate; 280 data_out->syncFile(); 281 return true; 284 282 } 285 283 } 286 return false 284 return false; 287 285 } 288 286 … … 295 293 bool CFile::checkSplit(void) 296 294 { 297 CContext* context = CContext::getCurrent() 298 const CDate& currentDate = context->calendar->getCurrentDate() 295 CContext* context = CContext::getCurrent(); 296 const CDate& currentDate = context->calendar->getCurrentDate(); 299 297 if (!split_freq.isEmpty()) 300 298 { 301 if (currentDate > *lastSplit + split_freq.getValue())299 if (currentDate > lastSplit + split_freq.getValue()) 302 300 { 303 *lastSplit = *lastSplit + split_freq.getValue();301 lastSplit = lastSplit + split_freq.getValue(); 304 302 std::vector<CField*>::iterator it, end = this->enabledFields.end(); 305 303 for (it = this->enabledFields.begin(); it != end; it++) … … 309 307 } 310 308 if (mode.isEmpty() || mode.getValue() == mode_attr::write) 311 createHeader() 309 createHeader(); 312 310 else 313 311 openInReadMode(); 314 return true 312 return true; 315 313 } 316 314 } 317 return false 315 return false; 318 316 } 319 317 … … 324 322 void CFile::createHeader(void) 325 323 { 326 CContext* context = CContext::getCurrent() 327 CContextServer* server =context->server;324 CContext* context = CContext::getCurrent(); 325 CContextServer* server = context->server; 328 326 329 327 if (!allDomainEmpty) … … 336 334 if (!split_freq.isEmpty()) 337 335 { 338 string splitFormat 336 string splitFormat; 339 337 if (split_freq_format.isEmpty()) 340 338 { … … 346 344 else splitFormat = "%y"; 347 345 } 348 else splitFormat =split_freq_format;349 oss << "_" << lastSplit ->getStr(splitFormat)350 << "-" << ( *lastSplit + split_freq.getValue() - 1 * Second).getStr(splitFormat);346 else splitFormat = split_freq_format; 347 oss << "_" << lastSplit.getStr(splitFormat) 348 << "-" << (lastSplit + split_freq.getValue() - 1 * Second).getStr(splitFormat); 351 349 } 352 350 … … 355 353 bool useClassicFormat = !format.isEmpty() && format == format_attr::netcdf4_classic; 356 354 357 bool multifile =true;355 bool multifile = true; 358 356 if (!type.isEmpty()) 359 357 { 360 if (type ==type_attr::one_file) multifile=false;361 else if (type ==type_attr::multiple_file) multifile=true;358 if (type == type_attr::one_file) multifile = false; 359 else if (type == type_attr::multiple_file) multifile = true; 362 360 363 361 } … … 365 363 if (!multifile) 366 364 { 367 info(0) <<"!!! Warning -> Using non parallel version of netcdf, switching in multiple_file mode for file : "<<filename<<" ..."<<endl;368 multifile =true;365 info(0) << "!!! Warning -> Using non parallel version of netcdf, switching in multiple_file mode for file : " << filename << " ..." << endl; 366 multifile = true; 369 367 } 370 368 #endif 371 369 if (multifile) 372 370 { 373 int commSize, commRank 374 MPI_Comm_size(fileComm, &commSize);375 MPI_Comm_rank(fileComm, &commRank);371 int commSize, commRank; 372 MPI_Comm_size(fileComm, &commSize); 373 MPI_Comm_rank(fileComm, &commRank); 376 374 377 375 if (server->intraCommSize > 1) 378 376 { 379 oss << "_" 380 int width=0 ; int n=commSize-1;381 while (n != 0) { n=n/10 ; width++;}377 oss << "_" ; 378 int width=0; int n = commSize-1; 379 while (n != 0) { n = n / 10; width++;} 382 380 if (!min_digits.isEmpty()) 383 if (width <min_digits) width=min_digits;384 oss.width(width) 385 oss.fill('0') 386 oss <<right<< commRank;381 if (width < min_digits) width = min_digits; 382 oss.width(width); 383 oss.fill('0'); 384 oss << right << commRank; 387 385 } 388 386 } … … 416 414 } 417 415 418 vector<CVariable*> listVars = getAllVariables() 416 vector<CVariable*> listVars = getAllVariables(); 419 417 for (vector<CVariable*>::iterator it = listVars.begin(); it != listVars.end(); it++) 420 418 this->data_out->writeAttribute(*it); … … 431 429 { 432 430 CContext* context = CContext::getCurrent(); 433 CContextServer* server =context->server;431 CContextServer* server = context->server; 434 432 435 433 if (!allDomainEmpty) … … 452 450 else splitFormat = "%y"; 453 451 } 454 else splitFormat =split_freq_format;455 oss << "_" << lastSplit ->getStr(splitFormat)456 << "-" << ( *lastSplit + split_freq.getValue() - 1 * Second).getStr(splitFormat);452 else splitFormat = split_freq_format; 453 oss << "_" << lastSplit.getStr(splitFormat) 454 << "-" << (lastSplit + split_freq.getValue() - 1 * Second).getStr(splitFormat); 457 455 } 458 456 … … 478 476 if (server->intraCommSize > 1) 479 477 { 480 oss << "_" 478 oss << "_"; 481 479 int width = 0, n = commSize - 1; 482 480 while (n != 0) { n = n / 10; width++; } … … 502 500 void CFile::close(void) 503 501 { 504 delete lastSync ;505 delete lastSplit ;506 502 if (!allDomainEmpty) 507 503 if (isOpen) … … 512 508 this->data_in->closeFile(); 513 509 } 514 if (fileComm != MPI_COMM_NULL) MPI_Comm_free(&fileComm) 510 if (fileComm != MPI_COMM_NULL) MPI_Comm_free(&fileComm); 515 511 } 516 512 //---------------------------------------------------------------- … … 530 526 if (node.getElementName()=="field" || node.getElementName()=="field_group") this->getVirtualFieldGroup()->parseChild(node); 531 527 else if (node.getElementName()=="variable" || node.getElementName()=="variable_group") this->getVirtualVariableGroup()->parseChild(node); 532 } while (node.goToNextElement()) 528 } while (node.goToNextElement()); 533 529 node.goToParentElement(); 534 530 } … … 649 645 CField* CFile::addField(const string& id) 650 646 { 651 return vFieldGroup->createChild(id) 647 return vFieldGroup->createChild(id); 652 648 } 653 649 … … 661 657 CFieldGroup* CFile::addFieldGroup(const string& id) 662 658 { 663 return vFieldGroup->createChildGroup(id) 659 return vFieldGroup->createChildGroup(id); 664 660 } 665 661 … … 676 672 CVariable* CFile::addVariable(const string& id) 677 673 { 678 return vVariableGroup->createChild(id) 674 return vVariableGroup->createChild(id); 679 675 } 680 676 … … 688 684 CVariableGroup* CFile::addVariableGroup(const string& id) 689 685 { 690 return vVariableGroup->createChildGroup(id) 686 return vVariableGroup->createChildGroup(id); 691 687 } 692 688 … … 697 693 void CFile::sendAddField(const string& id) 698 694 { 699 CContext* context =CContext::getCurrent();695 CContext* context = CContext::getCurrent(); 700 696 701 697 if (! context->hasServer ) 702 698 { 703 CContextClient* client =context->client;704 705 CEventClient event(this->getType(),EVENT_ID_ADD_FIELD) 699 CContextClient* client = context->client; 700 701 CEventClient event(this->getType(),EVENT_ID_ADD_FIELD); 706 702 if (client->isServerLeader()) 707 703 { 708 CMessage msg 709 msg <<this->getId();710 msg <<id;704 CMessage msg; 705 msg << this->getId(); 706 msg << id; 711 707 const std::list<int>& ranks = client->getRanksServerLeader(); 712 708 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 713 709 event.push(*itRank,1,msg); 714 client->sendEvent(event) 710 client->sendEvent(event); 715 711 } 716 else client->sendEvent(event) 712 else client->sendEvent(event); 717 713 } 718 714 … … 725 721 void CFile::sendAddFieldGroup(const string& id) 726 722 { 727 CContext* context =CContext::getCurrent();723 CContext* context = CContext::getCurrent(); 728 724 if (! context->hasServer ) 729 725 { 730 CContextClient* client =context->client;731 732 CEventClient event(this->getType(),EVENT_ID_ADD_FIELD_GROUP) 726 CContextClient* client = context->client; 727 728 CEventClient event(this->getType(),EVENT_ID_ADD_FIELD_GROUP); 733 729 if (client->isServerLeader()) 734 730 { 735 CMessage msg 736 msg <<this->getId();737 msg <<id;731 CMessage msg; 732 msg << this->getId(); 733 msg << id; 738 734 const std::list<int>& ranks = client->getRanksServerLeader(); 739 735 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 740 736 event.push(*itRank,1,msg); 741 client->sendEvent(event) 737 client->sendEvent(event); 742 738 } 743 else client->sendEvent(event) 739 else client->sendEvent(event); 744 740 } 745 741 … … 753 749 { 754 750 755 CBufferIn* buffer =event.subEvents.begin()->buffer;751 CBufferIn* buffer = event.subEvents.begin()->buffer; 756 752 string id; 757 *buffer>>id 758 get(id)->recvAddField(*buffer) 753 *buffer>>id; 754 get(id)->recvAddField(*buffer); 759 755 } 760 756 … … 765 761 void CFile::recvAddField(CBufferIn& buffer) 766 762 { 767 string id 768 buffer>>id 769 addField(id) 763 string id; 764 buffer>>id; 765 addField(id); 770 766 } 771 767 … … 777 773 { 778 774 779 CBufferIn* buffer =event.subEvents.begin()->buffer;775 CBufferIn* buffer = event.subEvents.begin()->buffer; 780 776 string id; 781 *buffer>>id 782 get(id)->recvAddFieldGroup(*buffer) 777 *buffer>>id; 778 get(id)->recvAddFieldGroup(*buffer); 783 779 } 784 780 … … 789 785 void CFile::recvAddFieldGroup(CBufferIn& buffer) 790 786 { 791 string id 792 buffer>>id 793 addFieldGroup(id) 787 string id; 788 buffer>>id; 789 addFieldGroup(id); 794 790 } 795 791 … … 828 824 void CFile::sendAddVariable(const string& id) 829 825 { 830 CContext* context =CContext::getCurrent();826 CContext* context = CContext::getCurrent(); 831 827 832 828 if (! context->hasServer ) 833 829 { 834 CContextClient* client =context->client;835 836 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) 830 CContextClient* client = context->client; 831 832 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE); 837 833 if (client->isServerLeader()) 838 834 { 839 CMessage msg 840 msg <<this->getId();841 msg <<id;835 CMessage msg; 836 msg << this->getId(); 837 msg << id; 842 838 const std::list<int>& ranks = client->getRanksServerLeader(); 843 839 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 844 840 event.push(*itRank,1,msg); 845 client->sendEvent(event) 841 client->sendEvent(event); 846 842 } 847 else client->sendEvent(event) 843 else client->sendEvent(event); 848 844 } 849 845 … … 856 852 void CFile::sendAddVariableGroup(const string& id) 857 853 { 858 CContext* context =CContext::getCurrent();854 CContext* context = CContext::getCurrent(); 859 855 if (! context->hasServer ) 860 856 { 861 CContextClient* client =context->client;862 863 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) 857 CContextClient* client = context->client; 858 859 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP); 864 860 if (client->isServerLeader()) 865 861 { 866 CMessage msg 867 msg <<this->getId();868 msg <<id;862 CMessage msg; 863 msg << this->getId(); 864 msg << id; 869 865 const std::list<int>& ranks = client->getRanksServerLeader(); 870 866 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 871 867 event.push(*itRank,1,msg); 872 client->sendEvent(event) 868 client->sendEvent(event); 873 869 } 874 else client->sendEvent(event) 870 else client->sendEvent(event); 875 871 } 876 872 … … 884 880 { 885 881 886 CBufferIn* buffer =event.subEvents.begin()->buffer;882 CBufferIn* buffer = event.subEvents.begin()->buffer; 887 883 string id; 888 *buffer>>id 889 get(id)->recvAddVariable(*buffer) 884 *buffer>>id; 885 get(id)->recvAddVariable(*buffer); 890 886 } 891 887 … … 896 892 void CFile::recvAddVariable(CBufferIn& buffer) 897 893 { 898 string id 899 buffer>>id 900 addVariable(id) 894 string id; 895 buffer>>id; 896 addVariable(id); 901 897 } 902 898 … … 908 904 { 909 905 910 CBufferIn* buffer =event.subEvents.begin()->buffer;906 CBufferIn* buffer = event.subEvents.begin()->buffer; 911 907 string id; 912 *buffer>>id 913 get(id)->recvAddVariableGroup(*buffer) 908 *buffer>>id; 909 get(id)->recvAddVariableGroup(*buffer); 914 910 } 915 911 … … 920 916 void CFile::recvAddVariableGroup(CBufferIn& buffer) 921 917 { 922 string id 923 buffer>>id 924 addVariableGroup(id) 918 string id; 919 buffer>>id; 920 addVariableGroup(id); 925 921 } 926 922 … … 955 951 bool CFile::dispatchEvent(CEventServer& event) 956 952 { 957 if (SuperClass::dispatchEvent(event)) return true 953 if (SuperClass::dispatchEvent(event)) return true; 958 954 else 959 955 { … … 961 957 { 962 958 case EVENT_ID_ADD_FIELD : 963 recvAddField(event) 964 return true 965 break 959 recvAddField(event); 960 return true; 961 break; 966 962 967 963 case EVENT_ID_ADD_FIELD_GROUP : 968 recvAddFieldGroup(event) 969 return true 970 break 964 recvAddFieldGroup(event); 965 return true; 966 break; 971 967 972 968 case EVENT_ID_ADD_VARIABLE : 973 recvAddVariable(event) 974 return true 975 break 969 recvAddVariable(event); 970 return true; 971 break; 976 972 977 973 case EVENT_ID_ADD_VARIABLE_GROUP : 978 recvAddVariableGroup(event) 979 return true 980 break 974 recvAddVariableGroup(event); 975 return true; 976 break; 981 977 default : 982 ERROR("bool CFile::dispatchEvent(CEventServer& event)", << "Unknown Event");983 return false 978 ERROR("bool CFile::dispatchEvent(CEventServer& event)", << "Unknown Event"); 979 return false; 984 980 } 985 981 } -
XIOS/trunk/src/node/file.hpp
r645 r651 53 53 enum EEventId 54 54 { 55 EVENT_ID_ADD_FIELD =0,EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE,55 EVENT_ID_ADD_FIELD, EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE, 56 56 EVENT_ID_ADD_VARIABLE_GROUP, EVENT_ID_CREATE_ENABLED_FIELDS 57 } 57 }; 58 58 59 59 typedef CFileAttributes RelAttributes; … … 62 62 /// Constructeurs /// 63 63 CFile(void); 64 explicit CFile(const StdString 65 CFile(const CFile 66 CFile(const CFile 64 explicit CFile(const StdString& id); 65 CFile(const CFile& file); // Not implemented yet. 66 CFile(const CFile* const file); // Not implemented yet. 67 67 68 68 /// Destructeur /// … … 84 84 public : 85 85 // Some functions to verify state of file 86 bool isSyncTime(void) 87 bool checkSplit(void) 88 bool checkSync(void) 89 void checkFile(void) 90 void initFile(void) 86 bool isSyncTime(void); 87 bool checkSplit(void); 88 bool checkSync(void); 89 void checkFile(void); 90 void initFile(void); 91 91 92 92 /// Mutateurs /// … … 99 99 void createHeader(void); 100 100 void openInReadMode(void); 101 void close(void) 101 void close(void); 102 102 103 103 // Some processing on file 104 104 void solveFieldRefInheritance(bool apply); 105 void processEnabledFile(void) 105 void processEnabledFile(void); 106 106 void solveAllRefOfEnabledFields(bool sendToServer); 107 107 void buildFilterGraphOfEnabledFields(CGarbageCollector& gc); … … 110 110 111 111 // Add component into file 112 CField* addField(const string& id ="");113 CFieldGroup* addFieldGroup(const string& id ="");114 CVariable* addVariable(const string& id ="");115 CVariableGroup* addVariableGroup(const string& id ="");112 CField* addField(const string& id = ""); 113 CFieldGroup* addFieldGroup(const string& id = ""); 114 CVariable* addVariable(const string& id = ""); 115 CVariableGroup* addVariableGroup(const string& id = ""); 116 116 117 117 // Send info to serever 118 118 void sendEnabledFields(); 119 void sendAddField(const string& id ="");120 void sendAddFieldGroup(const string& id ="");119 void sendAddField(const string& id = ""); 120 void sendAddFieldGroup(const string& id = ""); 121 121 void sendAddAllVariables(); 122 void sendAddVariable(const string& id ="");123 void sendAddVariableGroup(const string& id ="");122 void sendAddVariable(const string& id = ""); 123 void sendAddVariableGroup(const string& id = ""); 124 124 125 125 // Receive info from client 126 static void recvAddField(CEventServer& event) 127 void recvAddField(CBufferIn& buffer) 128 static void recvAddFieldGroup(CEventServer& event) 129 void recvAddFieldGroup(CBufferIn& buffer) 130 static void recvAddVariable(CEventServer& event) 131 void recvAddVariable(CBufferIn& buffer) 132 static void recvAddVariableGroup(CEventServer& event) 133 void recvAddVariableGroup(CBufferIn& buffer) 126 static void recvAddField(CEventServer& event); 127 void recvAddField(CBufferIn& buffer); 128 static void recvAddFieldGroup(CEventServer& event); 129 void recvAddFieldGroup(CBufferIn& buffer); 130 static void recvAddVariable(CEventServer& event); 131 void recvAddVariable(CBufferIn& buffer); 132 static void recvAddVariableGroup(CEventServer& event); 133 void recvAddVariableGroup(CBufferIn& buffer); 134 134 135 135 // Dispatch event 136 static bool dispatchEvent(CEventServer& event) 136 static bool dispatchEvent(CEventServer& event); 137 137 138 138 public: … … 144 144 public: 145 145 /// Traitements /// 146 virtual void solveDescInheritance(bool apply, const CAttributeMap 146 virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0); 147 147 148 148 /// Autres /// 149 virtual void parse(xml::CXMLNode 149 virtual void parse(xml::CXMLNode& node); 150 150 virtual StdString toString(void) const; 151 151 public: 152 152 153 CDate * lastSync;154 CDate * lastSplit;153 CDate lastSync; 154 CDate lastSplit; 155 155 int nbAxis, nbDomains; 156 bool isOpen 157 bool allDomainEmpty 158 MPI_Comm fileComm 156 bool isOpen; 157 bool allDomainEmpty; 158 MPI_Comm fileComm; 159 159 160 160 private : 161 161 /// Propriétés privées /// 162 162 CFieldGroup* vFieldGroup; 163 CVariableGroup* vVariableGroup 163 CVariableGroup* vVariableGroup; 164 164 boost::shared_ptr<CDataOutput> data_out; 165 165 boost::shared_ptr<CDataInput> data_in; … … 167 167 168 168 public: 169 // virtual void toBinary (StdOStream 170 // virtual void fromBinary(StdIStream 169 // virtual void toBinary (StdOStream& os) const; 170 // virtual void fromBinary(StdIStream& is); 171 171 172 172 }; // class CFile -
XIOS/trunk/src/output/nc4_data_output.cpp
r645 r651 1154 1154 if (wtime) 1155 1155 { 1156 time_counter(0)= (Time( *field->last_Write_srv) + Time(*field->lastlast_Write_srv)) / 2;1156 time_counter(0)= (Time(field->last_Write_srv) + Time(field->lastlast_Write_srv)) / 2; 1157 1157 if (field->getOperationTimeType() == func::CFunctor::instant) 1158 time_data(0) = Time( *field->last_Write_srv);1158 time_data(0) = Time(field->last_Write_srv); 1159 1159 else if (field->getOperationTimeType() == func::CFunctor::centered) time_data(0) = time_counter(0); 1160 1160 1161 time_counter_bound(0) = Time( *field->lastlast_Write_srv);1162 time_counter_bound(1) = Time( *field->last_Write_srv);1161 time_counter_bound(0) = Time(field->lastlast_Write_srv); 1162 time_counter_bound(1) = Time(field->last_Write_srv); 1163 1163 if (field->getOperationTimeType() == func::CFunctor::instant) 1164 time_data_bound(0) = time_data_bound(1) = Time( *field->last_Write_srv);1164 time_data_bound(0) = time_data_bound(1) = Time(field->last_Write_srv); 1165 1165 else if (field->getOperationTimeType() == func::CFunctor::centered) 1166 1166 {
Note: See TracChangeset
for help on using the changeset viewer.