source: XIOS3/branches/xios-3.0-beta/src/io/inetcdf4_impl.hpp @ 2414

Last change on this file since 2414 was 2308, checked in by ymipsl, 2 years ago

Fix problem when reading scalar on multiple servers.
YM

File size: 1.3 KB
Line 
1#ifndef __XIOS_INETCDF4_IMPL__
2#define __XIOS_INETCDF4_IMPL__
3
4#include "inetcdf4.hpp"
5#include "netCdfInterface.hpp"
6
7namespace xios
8{
9template <class T, int Ndim>
10void CINetCDF4::getData(CArray<T, Ndim>& data, const StdString& var,
11                       bool collective, StdSize record,
12                       const std::vector<StdSize>* start,
13                       const std::vector<StdSize>* count)
14{
15  int varid = this->getVariable(var);
16
17  if (this->mpi && collective)
18    CNetCdfInterface::varParAccess(ncidp, varid, NC_COLLECTIVE);
19  else if (this->mpi && !collective)
20    CNetCdfInterface::varParAccess(ncidp, varid, NC_INDEPENDENT);
21
22  std::vector<StdSize> sstart, scount;
23  StdSize array_size = 1;
24  this->getDataInfo(var, NULL, record, sstart, scount, array_size, start, count);
25
26  if (data.numElements() != array_size)
27  {
28    ERROR("CINetCDF4::getData(...)",
29          << "[ Array size = " << data.numElements()
30          << ", Data size = "  << array_size
31          << " ] Invalid array size");
32  }
33 
34  if (data.numElements()==0)
35  {
36    T data ;
37    CNetCdfInterface::getVaraType(ncidp, varid, &sstart[0], &scount[0], &data); // netcdf is very bad
38  }
39  else  CNetCdfInterface::getVaraType(ncidp, varid, &sstart[0], &scount[0], data.dataFirst());
40}
41
42} // namespace xios
43
44#endif //__XIOS_INETCDF4_IMPL__
Note: See TracBrowser for help on using the repository browser.