Changeset 1158 for XIOS/dev/dev_olga/src/io/onetcdf4.cpp
- Timestamp:
- 06/06/17 17:58:16 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/io/onetcdf4.cpp
r878 r1158 7 7 #include "netCdfInterface.hpp" 8 8 #include "netCdfException.hpp" 9 #include "timer.hpp" 9 10 10 11 namespace xios … … 55 56 if (!append || !std::ifstream(filename.c_str())) 56 57 { 58 CTimer::get("Files : create").resume(); 57 59 if (wmpi) 58 60 CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 59 61 else 60 62 CNetCdfInterface::create(filename, mode, this->ncidp); 61 63 CTimer::get("Files : create").suspend(); 64 62 65 this->appendMode = false; 63 66 } … … 65 68 { 66 69 mode |= NC_WRITE; 70 CTimer::get("Files : open").resume(); 67 71 if (wmpi) 68 72 CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 69 73 else 70 74 CNetCdfInterface::open(filename, mode, this->ncidp); 71 75 CTimer::get("Files : open").suspend(); 72 76 this->appendMode = true; 73 77 } … … 83 87 void CONetCDF4::close() 84 88 { 89 CTimer::get("Files : close").resume(); 85 90 CNetCdfInterface::close(this->ncidp); 91 CTimer::get("Files : close").suspend(); 86 92 } 87 93 … … 247 253 } 248 254 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 250 277 251 278 const CONetCDF4::CONetCDF4Path& CONetCDF4::getCurrentPath(void) const … … 503 530 void CONetCDF4::writeData_(int grpid, int varid, 504 531 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, 505 540 const std::vector<StdSize>& scount, const int* data) 506 541 { 507 542 CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 508 543 } 509 510 544 //--------------------------------------------------------------- 511 545 … … 528 562 529 563 this->getWriteDataInfos(name, 0, array_size, sstart, scount, NULL, NULL); 564 530 565 this->writeData_(grpid, varid, sstart, scount, data.dataFirst()); 566 531 567 } 532 568 … … 554 590 555 591 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 }564 592 this->writeData_(grpid, varid, sstart, scount, data.dataFirst()); 565 593 } 566 594 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 567 622 //--------------------------------------------------------------- 568 623
Note: See TracChangeset
for help on using the changeset viewer.