Ignore:
Timestamp:
02/21/12 15:34:27 (12 years ago)
Author:
ymipsl
Message:
  • Adding new file attribut : sync_freq : flush file for a given frequency
  • Now, when a file has a single domain, domain id is not anymore appended to the coordinate name.

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/file.cpp

    r300 r318  
    1111#include "context_server.hpp" 
    1212#include "nc4_data_output.hpp" 
     13#include "calendar_util.hpp" 
     14#include "date.hpp" 
    1315 
    1416 
     
    125127 
    126128   //---------------------------------------------------------------- 
    127  
     129   bool CFile::isSyncTime(void) 
     130   { 
     131     shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 
     132     date::CDate& currentDate=context->calendar->getCurrentDate() ; 
     133     if (! sync_freq.isEmpty()) 
     134     { 
     135       if (*lastSync+syncFreq < currentDate) 
     136       { 
     137         *lastSync=currentDate ; 
     138         return true ; 
     139        } 
     140      } 
     141      return false ; 
     142    } 
     143       
    128144   void CFile::createHeader(void) 
    129145   { 
    130      
     146      shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 
     147 
     148      if (! sync_freq.isEmpty()) syncFreq = date::CDuration::FromString(sync_freq.getValue()); 
     149      lastSync=new date::CDate(context->calendar->getCurrentDate()) ; 
     150       
    131151      std::vector<boost::shared_ptr<CField> >::iterator it, end = this->enabledFields.end(); 
    132152 
    133153      AllDomainEmpty=true ; 
     154      set<CDomain*> setDomain ; 
    134155      for (it = this->enabledFields.begin() ;it != end; it++) 
    135156      { 
    136157         boost::shared_ptr<CField> field = *it; 
    137158         AllDomainEmpty&=field->grid->domain->isEmpty() ; 
    138       } 
    139        
     159         setDomain.insert(field->grid->domain.get()) ; 
     160      } 
     161      nbDomain=setDomain.size() ; 
     162 
    140163      if (!AllDomainEmpty ||  type.getValue()=="one_file") 
    141164      { 
     
    156179         }  
    157180          
    158          shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 
    159181         CContextServer* server=context->server ; 
    160182 
     
    188210     if (!AllDomainEmpty ||  type.getValue()=="one_file") 
    189211       this->data_out->closeFile(); 
     212     delete lastSync ; 
    190213   } 
    191214   //---------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.