Changeset 1046


Ignore:
Timestamp:
02/02/17 14:40:34 (4 years ago)
Author:
ymipsl
Message:
  • Add 2 new file attributes to parameter timestamp : time_stamp_name and time_stamp_format.

Default value :
time_stamp_name="timestamp"
time_stamp_format="%Y-%b-%d %H:%M:%S %Z"

  • timestamp is now given in UTC time

YM

Location:
XIOS/trunk/src
Files:
5 edited

Legend:

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

    r1044 r1046  
    2727DECLARE_ENUM4(timeseries,    none, only, both, exclusive) 
    2828DECLARE_ATTRIBUTE(StdString, ts_prefix) 
    29  
     29DECLARE_ATTRIBUTE(StdString, time_stamp_name) 
     30DECLARE_ATTRIBUTE(StdString, time_stamp_format) 
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r1045 r1046  
    1616      /// ////////////////////// Dfinitions ////////////////////// /// 
    1717      CNc4DataOutput::CNc4DataOutput 
    18          (const StdString & filename, bool exist) 
     18         (CFile* file, const StdString & filename, bool exist) 
    1919            : SuperClass() 
    2020            , SuperClassWriter(filename, exist) 
    2121            , filename(filename) 
     22            , file(file) 
    2223      { 
    2324        SuperClass::type = MULTI_FILE; 
     
    2526 
    2627      CNc4DataOutput::CNc4DataOutput 
    27          (const StdString & filename, bool exist, bool useClassicFormat, bool useCFConvention, 
     28         (CFile* file, const StdString & filename, bool exist, bool useClassicFormat, bool useCFConvention, 
    2829          MPI_Comm comm_file, bool multifile, bool isCollective, const StdString& timeCounterName) 
    2930            : SuperClass() 
     
    3233            , filename(filename) 
    3334            , isCollective(isCollective) 
     35            , file(file) 
    3436      { 
    3537        SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; 
     
    19711973         struct tm * timeinfo = NULL; 
    19721974         char buffer [buffer_size]; 
    1973  
     1975         StdString formatStr; 
     1976         if (file->time_stamp_format.isEmpty()) formatStr="%Y-%b-%d %H:%M:%S %Z" ; 
     1977         else formatStr=file->time_stamp_format; 
     1978 
     1979//         time ( &rawtime ); 
     1980//         timeinfo = localtime ( &rawtime ); 
    19741981         time ( &rawtime ); 
    1975          timeinfo = localtime ( &rawtime ); 
    1976          strftime (buffer, buffer_size, "%Y-%b-%d %H:%M:%S %Z", timeinfo); 
     1982         timeinfo = gmtime ( &rawtime ); 
     1983         strftime (buffer, buffer_size, formatStr.c_str(), timeinfo); 
    19771984 
    19781985         return (StdString(buffer)); 
     
    20102017              field->getOperationTimeType() != func::CFunctor::once) 
    20112018          { 
    2012                         double factorUnit; 
    2013                         if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) 
    2014                            factorUnit=context->getCalendar()->getDayLengthInSeconds() ;  
    2015                         else factorUnit=1 ; 
     2019            double factorUnit; 
     2020            if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) 
     2021            factorUnit=context->getCalendar()->getDayLengthInSeconds() ; 
     2022            else factorUnit=1 ; 
    20162023            field->resetNStep(getRecordFromTime(field->last_Write_srv,factorUnit) + 1); 
    20172024          } 
     
    25612568           SuperClassWriter::addAttribute("Conventions", conventions); 
    25622569           // SuperClassWriter::addAttribute("production" , production); 
    2563            SuperClassWriter::addAttribute("timeStamp"  , timeStamp); 
     2570           StdString timeStampStr ; 
     2571           if (file->time_stamp_name.isEmpty()) timeStampStr="timeStamp" ; 
     2572           else timeStampStr=file->time_stamp_name ; 
     2573           SuperClassWriter::addAttribute(timeStampStr, timeStamp); 
    25642574         } 
    25652575         catch (CNetCdfException& e) 
  • XIOS/trunk/src/io/nc4_data_output.hpp

    r1044 r1046  
    2323            /// Constructeurs /// 
    2424            CNc4DataOutput 
    25                (const StdString & filename, bool exist); 
     25               (CFile* file, const StdString & filename, bool exist); 
    2626            CNc4DataOutput 
    27                (const StdString & filename, bool exist, bool useClassicFormat, 
     27               (CFile* file, const StdString & filename, bool exist, bool useClassicFormat, 
    2828                bool useCFConvention, 
    2929                MPI_Comm comm_file, bool multifile, bool isCollective = true, 
  • XIOS/trunk/src/node/file.cpp

    r1013 r1046  
    463463         if (isOpen) data_out->closeFile(); 
    464464 
    465         data_out = shared_ptr<CDataOutput>(new CNc4DataOutput(oss.str(), append, useClassicFormat, useCFConvention, 
     465        data_out = shared_ptr<CDataOutput>(new CNc4DataOutput(this, oss.str(), append, useClassicFormat, useCFConvention, 
    466466                                                              fileComm, multifile, isCollective, time_counter_name)); 
    467467        isOpen = true; 
  • XIOS/trunk/src/transformation/domain_algorithm_interpolate.cpp

    r1014 r1046  
    677677/*! Redefined some functions of CONetCDF4 to make use of them */ 
    678678CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, const MPI_Comm comm) 
    679   : CNc4DataOutput(filename, false, false, true, comm, false, true) {} 
     679  : CNc4DataOutput(NULL, filename, false, false, true, comm, false, true) {} 
    680680int CDomainAlgorithmInterpolate::WriteNetCdf::addDimensionWrite(const StdString& name,  
    681681                                                                const StdSize size) 
Note: See TracChangeset for help on using the changeset viewer.