Changeset 989


Ignore:
Timestamp:
11/16/16 14:53:20 (5 years ago)
Author:
mhnguyen
Message:

Allowing fields to have its own time_counter value if time_counter is not defined for file
(Credit to Yann)
+) time_counter of field is based on its operation time

Test
+) On Curie
+) Work

Location:
XIOS/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r973 r989  
    2121            , filename(filename) 
    2222      { 
    23     SuperClass::type = MULTI_FILE; 
     23        SuperClass::type = MULTI_FILE; 
    2424      } 
    2525 
     
    3333            , isCollective(isCollective) 
    3434      { 
    35     SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; 
     35        SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; 
    3636      } 
    3737 
     
    17601760       if (SuperClassWriter::useCFConvention) 
    17611761             this->writeFileAttributes(filename, description, 
    1762                                        StdString("CF-1.5"), 
     1762                                       StdString("CF-1.6"), 
    17631763                                       StdString("An IPSL model"), 
    17641764                                       this->getTimeStamp()); 
     
    19611961            time_data_bound(1) = lastWrite; 
    19621962          } 
    1963  
    1964           if (field->file->time_counter == CFile::time_counter_attr::instant) 
     1963           
     1964          if (field->file->time_counter.isEmpty()) 
     1965            if (field->hasTimeInstant && !field->hasTimeCentered) 
     1966              time_counter(0) = lastWrite; 
     1967            else  
     1968              time_counter(0) = (lastWrite + lastLastWrite) / 2; 
     1969 
     1970          else if (field->file->time_counter == CFile::time_counter_attr::instant) 
    19651971            time_counter(0) = lastWrite; 
    19661972          else if (field->file->time_counter == CFile::time_counter_attr::centered) 
     
    19701976 
    19711977 
    1972           if (field->file->time_counter == CFile::time_counter_attr::instant) 
     1978          if (field->file->time_counter.isEmpty()) 
     1979            if (field->hasTimeInstant && !field->hasTimeCentered) 
     1980              time_counter_bound(0) = time_counter_bound(1) = lastWrite; 
     1981            else  
     1982            { 
     1983              time_counter_bound(0) = lastLastWrite; 
     1984              time_counter_bound(1) = lastWrite; 
     1985            }           
     1986          else if (field->file->time_counter == CFile::time_counter_attr::instant) 
    19731987            time_counter_bound(0) = time_counter_bound(1) = lastWrite; 
    19741988          else if (field->file->time_counter == CFile::time_counter_attr::centered) 
     
    20192033                   SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1); 
    20202034                   SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1); 
    2021                    if (field->file->time_counter != CFile::time_counter_attr::none) 
     2035                   if (field->file->time_counter.isEmpty() ||   
     2036                      (field->file->time_counter != CFile::time_counter_attr::none)) 
    20222037                   { 
    20232038                     SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1); 
    2024                      if (field->file->time_counter != CFile::time_counter_attr::record) 
     2039                     if (field->file->time_counter.isEmpty() ||  
     2040                        (field->file->time_counter != CFile::time_counter_attr::record)) 
    20252041                       SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1); 
    20262042                   } 
     
    21552171                   SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 
    21562172                   SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 
    2157                    if (field->file->time_counter != CFile::time_counter_attr::none) 
     2173                   if (field->file->time_counter.isEmpty() ||  
     2174                      (field->file->time_counter != CFile::time_counter_attr::none)) 
    21582175                   { 
    21592176                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1, isRoot); 
    2160                      if (field->file->time_counter != CFile::time_counter_attr::record) 
     2177                     if (field->file->time_counter.isEmpty() ||   
     2178                        (field->file->time_counter != CFile::time_counter_attr::record)) 
    21612179                       SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 
    21622180                   } 
     
    21992217         StdString timeid(getTimeCounterName()); 
    22002218         StdString timeBoundId("axis_nbounds"); 
    2201  
     2219  
    22022220         if (field->getOperationTimeType() == func::CFunctor::instant) 
    22032221         { 
    22042222            axisid = "time_instant"; 
    22052223            axisBoundId = "time_instant_bounds"; 
    2206          } 
     2224            field->hasTimeInstant = true;                    
     2225         } 
     2226 
     2227         if (field->getOperationTimeType() == func::CFunctor::centered) 
     2228         { 
     2229            field->hasTimeCentered = true;             
     2230         }           
    22072231 
    22082232         try 
     
    22362260           } 
    22372261 
    2238            if (field->file->time_counter != CFile::time_counter_attr::none) 
     2262           if (field->file->time_counter.isEmpty() ||   
     2263              (field->file->time_counter != CFile::time_counter_attr::none)) 
    22392264           { 
    22402265             // Adding time_counter 
     
    22482273                SuperClassWriter::addAttribute("axis", string("T"), &axisid); 
    22492274 
    2250                 if (field->file->time_counter != CFile::time_counter_attr::record) 
     2275                if (field->file->time_counter.isEmpty() ||  
     2276                   (field->file->time_counter != CFile::time_counter_attr::record)) 
    22512277                { 
    22522278                  CDate timeOrigin = cal->getTimeOrigin(); 
     
    22602286 
    22612287             // Adding time_counter_bound dimension 
    2262              if (field->file->time_counter != CFile::time_counter_attr::record) 
     2288             if (field->file->time_counter.isEmpty() ||   
     2289                (field->file->time_counter != CFile::time_counter_attr::record)) 
    22632290             { 
    22642291                if (!SuperClassWriter::varExist(axisBoundId)) 
     
    24352462           SuperClassWriter::addAttribute("title"      , description); 
    24362463           SuperClassWriter::addAttribute("Conventions", conventions); 
    2437            SuperClassWriter::addAttribute("production" , production); 
     2464           // SuperClassWriter::addAttribute("production" , production); 
    24382465           SuperClassWriter::addAttribute("timeStamp"  , timeStamp); 
    24392466         } 
  • XIOS/trunk/src/node/field.cpp

    r988 r989  
    3737      , useCompressedOutput(false) 
    3838      , isReadDataRequestPending(false) 
     39      , hasTimeInstant(false) 
     40      , hasTimeCentered(false) 
    3941   { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 
    4042 
     
    4850      , useCompressedOutput(false) 
    4951      , isReadDataRequestPending(false) 
     52      , hasTimeInstant(false) 
     53      , hasTimeCentered(false) 
    5054   { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 
    5155 
  • XIOS/trunk/src/node/field.hpp

    r957 r989  
    204204         bool useCompressedOutput; 
    205205 
     206         // Two variable to identify the time_counter meta data written in file, which has no time_counter 
     207         bool hasTimeInstant; 
     208         bool hasTimeCentered; 
     209 
    206210         DECLARE_REF_FUNC(Field,field) 
    207211 
  • XIOS/trunk/src/node/file.cpp

    r957 r989  
    260260      if (allDomainEmpty) MPI_Comm_free(&fileComm); 
    261261 
    262       if (time_counter.isEmpty()) time_counter.setValue(time_counter_attr::centered); 
     262      // if (time_counter.isEmpty()) time_counter.setValue(time_counter_attr::centered); 
    263263      if (time_counter_name.isEmpty()) time_counter_name = "time_counter"; 
    264264    } 
Note: See TracChangeset for help on using the changeset viewer.