Ignore:
Timestamp:
06/06/17 17:58:16 (7 years ago)
Author:
oabramkina
Message:

Two server levels: merging with trunk r1137.
There are bugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/io/onetcdf4.cpp

    r878 r1158  
    77#include "netCdfInterface.hpp" 
    88#include "netCdfException.hpp" 
     9#include "timer.hpp" 
    910 
    1011namespace xios 
     
    5556         if (!append || !std::ifstream(filename.c_str())) 
    5657         { 
     58            CTimer::get("Files : create").resume(); 
    5759            if (wmpi) 
    5860               CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 
    5961            else 
    6062               CNetCdfInterface::create(filename, mode, this->ncidp); 
    61  
     63            CTimer::get("Files : create").suspend(); 
     64  
    6265            this->appendMode = false; 
    6366         } 
     
    6568         { 
    6669            mode |= NC_WRITE; 
     70            CTimer::get("Files : open").resume(); 
    6771            if (wmpi) 
    6872               CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 
    6973            else 
    7074               CNetCdfInterface::open(filename, mode, this->ncidp); 
    71  
     75            CTimer::get("Files : open").suspend(); 
    7276            this->appendMode = true; 
    7377         } 
     
    8387      void CONetCDF4::close() 
    8488      { 
     89        CTimer::get("Files : close").resume(); 
    8590        CNetCdfInterface::close(this->ncidp); 
     91        CTimer::get("Files : close").suspend(); 
    8692      } 
    8793 
     
    247253      } 
    248254 
    249       //--------------------------------------------------------------- 
     255      void CONetCDF4::getTimeAxisBounds(CArray<double,2>& timeAxisBounds, const StdString& name, bool collective, size_t record) 
     256      { 
     257        int grpid = this->getCurrentGroup(); 
     258        int varid = this->getVariable(name); 
     259 
     260        std::vector<StdSize> start(2), count(2); 
     261        start[0] = record; 
     262        count[0] = 1 ; 
     263        start[1] = 0; 
     264        count[1] = 2; 
     265 
     266        timeAxisBounds.resize(2, 1); 
     267 
     268        if (this->wmpi && collective) 
     269          CNetCdfInterface::varParAccess(grpid, varid, NC_COLLECTIVE); 
     270        if (this->wmpi && !collective) 
     271          CNetCdfInterface::varParAccess(grpid, varid, NC_INDEPENDENT); 
     272 
     273        CNetCdfInterface::getVaraType(grpid, varid, &start[0], &count[0], timeAxisBounds.dataFirst()); 
     274      } 
     275 
     276 
    250277 
    251278      const CONetCDF4::CONetCDF4Path& CONetCDF4::getCurrentPath(void) const 
     
    503530      void CONetCDF4::writeData_(int grpid, int varid, 
    504531                                 const std::vector<StdSize>& sstart, 
     532                                 const std::vector<StdSize>& scount, char* data) 
     533      { 
     534          CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
     535      } 
     536       
     537      template <> 
     538      void CONetCDF4::writeData_(int grpid, int varid, 
     539                                 const std::vector<StdSize>& sstart, 
    505540                                 const std::vector<StdSize>& scount, const int* data) 
    506541      { 
    507542          CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
    508543      } 
    509  
    510544      //--------------------------------------------------------------- 
    511545 
     
    528562 
    529563         this->getWriteDataInfos(name, 0, array_size,  sstart, scount, NULL, NULL); 
     564 
    530565         this->writeData_(grpid, varid, sstart, scount, data.dataFirst()); 
     566 
    531567      } 
    532568 
     
    554590 
    555591         this->getWriteDataInfos(name, record, array_size,  sstart, scount, NULL, NULL); 
    556          if (using_netcdf_internal) 
    557          { 
    558            if (!isRoot) 
    559            { 
    560              sstart[0] = sstart[0] + 1; 
    561              scount[0] = 0; 
    562            } 
    563          } 
    564592         this->writeData_(grpid, varid, sstart, scount, data.dataFirst()); 
    565593       } 
    566594 
     595      void CONetCDF4::writeTimeAxisDataBounds(const CArray<double, 1>& data, const StdString& name, 
     596                                        bool collective, StdSize record, bool isRoot) 
     597      { 
     598         int grpid = this->getCurrentGroup(); 
     599         int varid = this->getVariable(name); 
     600 
     601         map<int,size_t>::iterator it=timeAxis.find(varid); 
     602         if (it == timeAxis.end()) timeAxis[varid] = record; 
     603         else 
     604         { 
     605           if (it->second >= record) return; 
     606           else it->second =record; 
     607         } 
     608 
     609         StdSize array_size = 1; 
     610         std::vector<StdSize> sstart, scount; 
     611 
     612         if (this->wmpi && collective) 
     613            CNetCdfInterface::varParAccess(grpid, varid, NC_COLLECTIVE); 
     614         if (this->wmpi && !collective) 
     615            CNetCdfInterface::varParAccess(grpid, varid, NC_INDEPENDENT); 
     616 
     617         this->getWriteDataInfos(name, record, array_size,  sstart, scount, NULL, NULL); 
     618         this->writeData_(grpid, varid, sstart, scount, data.dataFirst()); 
     619       } 
     620 
     621 
    567622      //--------------------------------------------------------------- 
    568623 
Note: See TracChangeset for help on using the changeset viewer.