Changeset 431


Ignore:
Timestamp:
05/30/13 18:08:47 (11 years ago)
Author:
ymipsl
Message:

Bug fix : Solve problem in splitting date
Enhancement : Add file attribute split_freq_format to manage the suffix added in splitted file

Location:
XIOS/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/config/file_attribute.conf

    r391 r431  
    99DECLARE_ATTRIBUTE(StdString, sync_freq) 
    1010DECLARE_ATTRIBUTE(StdString, split_freq) 
     11DECLARE_ATTRIBUTE(StdString, split_freq_format) 
    1112DECLARE_ATTRIBUTE(bool,      enabled) 
    1213DECLARE_ENUM2(type,one_file,multiple_file) 
  • XIOS/trunk/src/date.cpp

    r423 r431  
    214214      } 
    215215       
    216        StdString CDate::toString(void) const 
     216 
     217      string CDate::getStr(const string& str) const 
     218      { 
     219        ostringstream oss ; 
     220        int level; 
     221         
     222        level=0 ; 
     223        for(string::const_iterator it=str.begin();it!=str.end();++it) 
     224        { 
     225          if (level==0) 
     226          { 
     227            if (*it=='%') level++ ; 
     228            else oss<<*it ; 
     229          } 
     230          else if (level==1) 
     231          { 
     232            switch (*it) 
     233            { 
     234              case 'y' : 
     235                oss.width (4);  oss.fill ('0') ; oss << year ; 
     236                level=0 ; 
     237                break ; 
     238              case 'm' : // month or minute 
     239                level++ ; 
     240                break ; 
     241              case 'd' : 
     242                oss.width (2);  oss.fill ('0') ; oss << day ; 
     243                level=0; 
     244                break ; 
     245              case 'h' : 
     246                oss.width (2);  oss.fill ('0') ; oss << hour ; 
     247                level=0; 
     248                break ; 
     249              case 's' : 
     250                oss.width (2);  oss.fill ('0') ; oss << second ; 
     251                level=0 ; 
     252                break; 
     253              default : 
     254                oss<<'%'<<*it ; 
     255                level=0 ; 
     256            } 
     257          } 
     258          else if (level==2) 
     259          { 
     260            switch (*it) 
     261            { 
     262              case 'o' : // month 
     263                oss.width (2);  oss.fill ('0') ; oss << month ; 
     264                level=0 ; 
     265                break ; 
     266              case 'i' : //minute 
     267                oss.width (2);  oss.fill ('0') ; oss << minute ; 
     268                level=0 ; 
     269                break ; 
     270              default : 
     271                oss<<"%m"<<*it ; 
     272                level=0 ; 
     273            } 
     274          } 
     275        } 
     276        return oss.str(); 
     277      } 
     278       
     279      StdString CDate::toString(void) const 
    217280      {  
    218281         StdOStringStream oss; 
  • XIOS/trunk/src/date.hpp

    r423 r431  
    5757            StdString toString(void) const; 
    5858            StdString getStryyyymmdd(void) const; 
     59            string getStr(const string& str) const; 
     60 
    5961 
    6062         public : /* static */ 
  • XIOS/trunk/src/node/file.cpp

    r391 r431  
    207207      if (! split_freq.isEmpty()) 
    208208      { 
    209         if (*lastSplit+splitFreq < currentDate) 
     209        if (currentDate > *lastSplit+splitFreq) 
    210210        { 
    211           *lastSplit=currentDate-outputFreq ; 
    212          
     211          *lastSplit=*lastSplit+splitFreq ;     
    213212          std::vector<CField*>::iterator it, end = this->enabledFields.end(); 
    214213          for (it = this->enabledFields.begin() ;it != end; it++)  (*it)->resetNStep() ; 
     
    231230         oss << filename; 
    232231         if (!name_suffix.isEmpty()) oss << name_suffix.getValue(); 
    233          if (!split_freq.isEmpty()) oss<<"_"<<lastSplit->getStryyyymmdd()<<"-"<< (*lastSplit+(splitFreq-1*Second)).getStryyyymmdd(); 
     232//         if (!split_freq.isEmpty()) oss<<"_"<<lastSplit->getStryyyymmdd()<<"-"<< (*lastSplit+(splitFreq-1*Second)).getStryyyymmdd(); 
     233//         if (!split_freq.isEmpty()) oss<<"_"<<lastSplit->getStr("%y_%mo_%d")<<"-"<< (*lastSplit+(splitFreq-1*Second)).getStr("%y_%mo_%d"); 
     234         if (!split_freq.isEmpty()) 
     235         { 
     236           string splitFormat ; 
     237           if (split_freq_format.isEmpty()) 
     238           { 
     239             if (splitFreq.second!=0) splitFormat="%y%mo%d%h%mi%s"; 
     240             else if (splitFreq.minute!=0) splitFormat="%y%mo%d%h%mi"; 
     241             else if (splitFreq.hour!=0) splitFormat="%y%mo%d%h"; 
     242             else if (splitFreq.day!=0) splitFormat="%y%mo%d"; 
     243             else if (splitFreq.month!=0) splitFormat="%y%mo"; 
     244             else splitFormat="%y"; 
     245           } 
     246           else splitFormat=split_freq_format ; 
     247           oss<<"_"<<lastSplit->getStr(splitFormat)<<"-"<< (*lastSplit+(splitFreq-1*Second)).getStr(splitFormat); 
     248         } 
     249            
    234250         bool multifile=true ; 
    235251         if (!type.isEmpty()) 
Note: See TracChangeset for help on using the changeset viewer.