XIOS  1.0
Xml I/O Server
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Amis Macros
onetcdf4.cpp
Aller à la documentation de ce fichier.
1 #include <fstream>
2 
3 #include "onetcdf4.hpp"
4 #include "group_template.hpp"
5 #include "mpi.hpp"
6 #include "netcdf.hpp"
7 #include "netCdfInterface.hpp"
8 #include "netCdfException.hpp"
9 #include "timer.hpp"
10 
11 namespace xios
12 {
14 
15  CONetCDF4::CONetCDF4(const StdString& filename, bool append, bool useClassicFormat,
16  bool useCFConvention,
17  const MPI_Comm* comm, bool multifile, const StdString& timeCounterName)
18  : path()
19  , wmpi(false)
20  , useClassicFormat(useClassicFormat)
21  , useCFConvention(useCFConvention)
22  {
23  this->initialize(filename, append, useClassicFormat, useCFConvention, comm, multifile, timeCounterName);
24  }
25 
26  //---------------------------------------------------------------
27 
29  {
30  }
31 
33 
34  void CONetCDF4::initialize(const StdString& filename, bool append, bool useClassicFormat, bool useCFConvention,
35  const MPI_Comm* comm, bool multifile, const StdString& timeCounterName)
36  {
37  this->useClassicFormat = useClassicFormat;
38  this->useCFConvention = useCFConvention;
39 
40  int mode = useClassicFormat ? 0 : NC_NETCDF4;
41 
42  // Don't use parallel mode if there is only one process
43  if (comm)
44  {
45  int commSize = 0;
46  MPI_Comm_size(*comm, &commSize);
47  if (commSize <= 1)
48  comm = NULL;
49  }
50  wmpi = comm && !multifile;
51 
52  if (wmpi)
53  mode |= useClassicFormat ? NC_PNETCDF : NC_MPIIO;
54 
55  // If the file does not exist, we always create it
56  if (!append || !std::ifstream(filename.c_str()))
57  {
58  CTimer::get("Files : create").resume();
59  if (wmpi)
60  CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp);
61  else
62  CNetCdfInterface::create(filename, mode, this->ncidp);
63  CTimer::get("Files : create").suspend();
64 
65  this->appendMode = false;
66  }
67  else
68  {
69  mode |= NC_WRITE;
70  CTimer::get("Files : open").resume();
71  if (wmpi)
72  CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp);
73  else
74  CNetCdfInterface::open(filename, mode, this->ncidp);
75  CTimer::get("Files : open").suspend();
76  this->appendMode = true;
77  }
78 
79  // If the classic NetCDF format is used, we enable the "no-fill mode" globally.
80  // This is done per variable for the NetCDF4 format.
81  if (useClassicFormat)
82  CNetCdfInterface::setFill(this->ncidp, false);
83 
84  this->timeCounterName = timeCounterName;
85  }
86 
88  {
89  CTimer::get("Files : close").resume();
91  CTimer::get("Files : close").suspend();
92  }
93 
94  //---------------------------------------------------------------
95 
97  {
99  }
100 
101  //---------------------------------------------------------------
102 
104  {
106  }
107 
108  //---------------------------------------------------------------
109 
111  {
112  return this->getGroup(this->getCurrentPath());
113  }
114 
115  //---------------------------------------------------------------
116 
118  {
119  int retvalue = this->ncidp;
120 
121  CONetCDF4Path::const_iterator it = path.begin(), end = path.end();
122 
123  for (; it != end; it++)
124  {
125  const StdString& groupid = *it;
126  CNetCdfInterface::inqNcId(retvalue, groupid, retvalue);
127  }
128  return retvalue;
129  }
130 
131  //---------------------------------------------------------------
132 
133  int CONetCDF4::getVariable(const StdString& varname)
134  {
135  int varid = 0;
136  int grpid = this->getCurrentGroup();
137  CNetCdfInterface::inqVarId(grpid, varname, varid);
138  return varid;
139  }
140 
141  //---------------------------------------------------------------
142 
143  int CONetCDF4::getDimension(const StdString& dimname)
144  {
145  int dimid = 0;
146  int grpid = this->getCurrentGroup();
147  CNetCdfInterface::inqDimId(grpid, dimname, dimid);
148  return dimid;
149  }
150 
151  //---------------------------------------------------------------
152 
154  {
155  int dimid = 0;
156  int grpid = this->getCurrentGroup();
157  CNetCdfInterface::inqUnLimDim(grpid, dimid);
158  return dimid;
159  }
160 
162  {
163  int grpid = this->getGroup(path);
164  int dimid = this->getUnlimitedDimension();
165 
166  StdString dimname;
167  if (dimid != -1)
168  CNetCdfInterface::inqDimName(grpid, dimid, dimname);
169  return dimname;
170  }
171 
172  //---------------------------------------------------------------
173 
174  std::vector<StdSize> CONetCDF4::getDimensions(const StdString& varname)
175  {
176  StdSize size = 0;
177  std::vector<StdSize> retvalue;
178  int grpid = this->getCurrentGroup();
179  int varid = this->getVariable(varname);
180  int nbdim = 0, *dimid = NULL;
181 
182  CNetCdfInterface::inqVarNDims(grpid, varid, nbdim);
183  dimid = new int[nbdim]();
184  CNetCdfInterface::inqVarDimId(grpid, varid, dimid);
185 
186  for (int i = 0; i < nbdim; i++)
187  {
188  CNetCdfInterface::inqDimLen(grpid, dimid[i], size);
189  if (size == NC_UNLIMITED)
190  size = UNLIMITED_DIM;
191  retvalue.push_back(size);
192  }
193  delete [] dimid;
194  return retvalue;
195  }
196 
197  std::vector<std::string> CONetCDF4::getDimensionsIdList(const std::string* _varname)
198  {
199  int nDimNull = 0;
200  int nbdim = 0, *dimid = NULL;
201  int grpid = this->getCurrentGroup();
202  int varid = (_varname != NULL) ? this->getVariable(*_varname) : NC_GLOBAL;
203  std::vector<std::string> retvalue;
204 
205  if (_varname != NULL)
206  {
207  CNetCdfInterface::inqVarNDims(grpid, varid, nbdim);
208  dimid = new int[nbdim]();
209  CNetCdfInterface::inqVarDimId(grpid, varid, dimid);
210  }
211  else
212  {
213  CNetCdfInterface::inqDimIds(grpid, nbdim, NULL, 1);
214  dimid = new int[nbdim]();
215  CNetCdfInterface::inqDimIds(grpid, nDimNull, dimid, 1);
216  }
217 
218  for (int i = 0; i < nbdim; i++)
219  {
220  std::string dimname;
221  CNetCdfInterface::inqDimName(grpid, dimid[i], dimname);
222  retvalue.push_back(dimname);
223  }
224  delete [] dimid;
225 
226  return retvalue;
227  }
228 
229  //---------------------------------------------------------------
230 
231  void CONetCDF4::getTimeAxisBounds(CArray<double,2>& timeAxisBounds, const StdString& name, bool collective)
232  {
233  int grpid = this->getCurrentGroup();
234  int varid = this->getVariable(name);
235 
236  std::vector<StdSize> start(2), count(2);
237  start[0] = 0;
238  // Find out how many temporal records have been written already to the file we are opening
239  int ncUnlimitedDimId;
240  CNetCdfInterface::inqUnLimDim(this->ncidp, ncUnlimitedDimId);
241  CNetCdfInterface::inqDimLen(this->ncidp, ncUnlimitedDimId, count[0]);
242  start[1] = 0;
243  count[1] = 2;
244 
245  timeAxisBounds.resize(count[1], count[0]);
246 
247  if (this->wmpi && collective)
249  if (this->wmpi && !collective)
251 
252  CNetCdfInterface::getVaraType(grpid, varid, &start[0], &count[0], timeAxisBounds.dataFirst());
253  }
254 
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)
270  if (this->wmpi && !collective)
272 
273  CNetCdfInterface::getVaraType(grpid, varid, &start[0], &count[0], timeAxisBounds.dataFirst());
274  }
275 
276 
277 
279  { return this->path; }
280 
282  { this->path = path; }
283 
284  //---------------------------------------------------------------
285 
287  {
288  int retvalue = 0;
289  int grpid = this->getCurrentGroup();
290  CNetCdfInterface::defGrp(grpid, name, retvalue);
291  return retvalue;
292  }
293 
294  //---------------------------------------------------------------
295 
296  int CONetCDF4::addDimension(const StdString& name, const StdSize size)
297  {
298  int retvalue = 0;
299  int grpid = this->getCurrentGroup();
300  if (size != UNLIMITED_DIM)
301  CNetCdfInterface::defDim(grpid, name, size, retvalue);
302  else
303  CNetCdfInterface::defDim(grpid, name, NC_UNLIMITED, retvalue);
304  return retvalue;
305  }
306 
307  //---------------------------------------------------------------
308 
309  int CONetCDF4::addVariable(const StdString& name, nc_type type,
310  const std::vector<StdString>& dim, int compressionLevel)
311  {
312  int varid = 0;
313  std::vector<int> dimids;
314  std::vector<StdSize> dimsizes;
315  int dimSize = dim.size();
316 
317  StdSize size;
318  StdSize totalSize;
319  StdSize maxSize = 1024 * 1024 * 256; // == 2GB/8 if output double
320 
321  int grpid = this->getCurrentGroup();
322 
323  std::vector<StdString>::const_iterator it = dim.begin(), end = dim.end();
324 
325  for (int idx = 0; it != end; it++, ++idx)
326  {
327  const StdString& dimid = *it;
328  dimids.push_back(this->getDimension(dimid));
329  CNetCdfInterface::inqDimLen(grpid, this->getDimension(dimid), size);
330  if (size == NC_UNLIMITED) size = 1;
331  dimsizes.push_back(size);
332  }
333 
334  CNetCdfInterface::defVar(grpid, name, type, dimids.size(), &dimids[0], varid);
335 
336  // The classic NetCDF format does not support chunking nor fill parameters
337  if (!useClassicFormat)
338  {
339  // set chunksize : size of one record
340  // but must not be > 2GB (netcdf or HDF5 problem)
341  totalSize = 1;
342  for (vector<StdSize>::reverse_iterator it = dimsizes.rbegin(); it != dimsizes.rend(); ++it)
343  {
344  totalSize *= *it;
345  if (totalSize >= maxSize) *it = 1;
346  }
347  int storageType = (0 == dimSize) ? NC_CONTIGUOUS : NC_CHUNKED;
348  CNetCdfInterface::defVarChunking(grpid, varid, storageType, &dimsizes[0]);
349  CNetCdfInterface::defVarFill(grpid, varid, true, NULL);
350  }
351 
352  setCompressionLevel(name, compressionLevel) ;
353 
354  return varid;
355  }
356 
357  //---------------------------------------------------------------
358 
359  void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)
360  {
361  if (compressionLevel < 0 || compressionLevel > 9)
362  ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)",
363  "Invalid compression level for variable \"" << varname << "\", the value should range between 0 and 9.");
364  if (compressionLevel && wmpi)
365  ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)",
366  "Impossible to use compression for variable \"" << varname << "\" when using parallel mode.");
367 
368  int grpid = this->getCurrentGroup();
369  int varid = this->getVariable(varname);
370  CNetCdfInterface::defVarDeflate(grpid, varid, compressionLevel);
371  }
372 
373  //---------------------------------------------------------------
374 
375  template <>
376  void CONetCDF4::addAttribute(const StdString& name, const StdString& value, const StdString* varname)
377  {
378  int grpid = this->getCurrentGroup();
379  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
380  CNetCdfInterface::putAttType(grpid, varid, name, value.size(), value.c_str());
381  }
382 
383  //---------------------------------------------------------------
384 
385  template <>
386  void CONetCDF4::addAttribute(const StdString& name, const double& value, const StdString* varname)
387  {
388  int grpid = this->getCurrentGroup();
389  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
390  CNetCdfInterface::putAttType(grpid, varid, name, 1, &value);
391  }
392 
393  template <>
394  void CONetCDF4::addAttribute(const StdString& name, const CArray<double,1>& value, const StdString* varname)
395  {
396  int grpid = this->getCurrentGroup();
397  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
398  CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst());
399  }
400  //---------------------------------------------------------------
401 
402  template <>
403  void CONetCDF4::addAttribute(const StdString& name, const float& value, const StdString* varname)
404  {
405  int grpid = this->getCurrentGroup();
406  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
407  CNetCdfInterface::putAttType(grpid, varid, name, 1, &value);
408  }
409 
410  template <>
411  void CONetCDF4::addAttribute(const StdString& name, const CArray<float,1>& value, const StdString* varname)
412  {
413  int grpid = this->getCurrentGroup();
414  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
415  CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst());
416  }
417 
418  //---------------------------------------------------------------
419 
420  template <>
421  void CONetCDF4::addAttribute(const StdString& name, const int& value, const StdString* varname)
422  {
423  int grpid = this->getCurrentGroup();
424  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
425  CNetCdfInterface::putAttType(grpid, varid, name, 1, &value);
426  }
427 
428  template <>
429  void CONetCDF4::addAttribute(const StdString& name, const CArray<int,1>& value, const StdString* varname)
430  {
431  int grpid = this->getCurrentGroup();
432  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
433  CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst());
434  }
435 
436  template <>
437  void CONetCDF4::addAttribute(const StdString& name, const short int& value, const StdString* varname)
438  {
439  int grpid = this->getCurrentGroup();
440  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
441  CNetCdfInterface::putAttType(grpid, varid, name, 1, &value);
442  }
443 
444  template <>
445  void CONetCDF4::addAttribute(const StdString& name, const CArray<short int,1>& value, const StdString* varname)
446  {
447  int grpid = this->getCurrentGroup();
448  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
449  CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst());
450  }
451 
452  template <>
453  void CONetCDF4::addAttribute(const StdString& name, const long int& value, const StdString* varname)
454  {
455  int grpid = this->getCurrentGroup();
456  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
457  CNetCdfInterface::putAttType(grpid, varid, name, 1, &value);
458  }
459 
460  template <>
461  void CONetCDF4::addAttribute(const StdString& name, const CArray<long int,1>& value, const StdString* varname)
462  {
463  int grpid = this->getCurrentGroup();
464  int varid = (varname == NULL) ? NC_GLOBAL : this->getVariable(*varname);
465  CNetCdfInterface::putAttType(grpid, varid, name, value.numElements(), value.dataFirst());
466  }
467 
468  //---------------------------------------------------------------
469 
470  void CONetCDF4::getWriteDataInfos(const StdString& name, StdSize record, StdSize& array_size,
471  std::vector<StdSize>& sstart,
472  std::vector<StdSize>& scount,
473  const std::vector<StdSize>* start,
474  const std::vector<StdSize>* count)
475  {
476  std::vector<std::size_t> sizes = this->getDimensions(name);
477  if (sizes.size()==0)
478  {
479  array_size=1 ;
480  sstart.push_back(0);
481  scount.push_back(1);
482  }
483  else
484  {
485  std::vector<std::string> iddims = this->getDimensionsIdList (&name);
486  std::vector<std::size_t>::const_iterator
487  it = sizes.begin(), end = sizes.end();
488  int i = 0;
489 
490  if (iddims.begin()->compare(timeCounterName) == 0)
491  {
492  sstart.push_back(record);
493  scount.push_back(1);
494  if ((start == NULL) &&
495  (count == NULL)) i++;
496  it++;
497  }
498 
499  for (;it != end; it++)
500  {
501  if ((start != NULL) && (count != NULL))
502  {
503  sstart.push_back((*start)[i]);
504  scount.push_back((*count)[i]);
505  array_size *= (*count)[i];
506  i++;
507  }
508  else
509  {
510  sstart.push_back(0);
511  scount.push_back(sizes[i]);
512  array_size *= sizes[i];
513  i++;
514  }
515  }
516 
517  }
518  }
519 
520 
521  template <>
522  void CONetCDF4::writeData_(int grpid, int varid,
523  const std::vector<StdSize>& sstart,
524  const std::vector<StdSize>& scount, const double* data)
525  {
526  CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data);
527  }
528 
529  //---------------------------------------------------------------
530 
531  template <>
532  void CONetCDF4::writeData_(int grpid, int varid,
533  const std::vector<StdSize>& sstart,
534  const std::vector<StdSize>& scount, char* data)
535  {
536  CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data);
537  }
538 
539  template <>
540 
541  void CONetCDF4::writeData_(int grpid, int varid,
542  const std::vector<StdSize>& sstart,
543  const std::vector<StdSize>& scount, const int* data)
544  {
545  CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data);
546  }
547  //---------------------------------------------------------------
548 
549  template <>
550  void CONetCDF4::writeData_(int grpid, int varid,
551  const std::vector<StdSize>& sstart,
552  const std::vector<StdSize>& scount, const float* data)
553  {
554  CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data);
555  }
556 
557  //---------------------------------------------------------------
558 
559  void CONetCDF4::writeData(const CArray<int, 2>& data, const StdString& name)
560  {
561  int grpid = this->getCurrentGroup();
562  int varid = this->getVariable(name);
563  StdSize array_size = 1;
564  std::vector<StdSize> sstart, scount;
565 
566  this->getWriteDataInfos(name, 0, array_size, sstart, scount, NULL, NULL);
567 
568  this->writeData_(grpid, varid, sstart, scount, data.dataFirst());
569 
570  }
571 
573  bool collective, StdSize record, bool isRoot)
574  {
575  int grpid = this->getCurrentGroup();
576  int varid = this->getVariable(name);
577 
578  map<int,size_t>::iterator it=timeAxis.find(varid);
579  if (it == timeAxis.end()) timeAxis[varid] = record;
580  else
581  {
582  if (it->second >= record) return;
583  else it->second =record;
584  }
585 
586  StdSize array_size = 1;
587  std::vector<StdSize> sstart, scount;
588 
589  if (this->wmpi && collective)
591  if (this->wmpi && !collective)
593 
594  this->getWriteDataInfos(name, record, array_size, sstart, scount, NULL, NULL);
595  this->writeData_(grpid, varid, sstart, scount, data.dataFirst());
596  }
597 
599  bool collective, StdSize record, bool isRoot)
600  {
601  int grpid = this->getCurrentGroup();
602  int varid = this->getVariable(name);
603 
604  map<int,size_t>::iterator it=timeAxis.find(varid);
605  if (it == timeAxis.end()) timeAxis[varid] = record;
606  else
607  {
608  if (it->second >= record) return;
609  else it->second =record;
610  }
611 
612  StdSize array_size = 1;
613  std::vector<StdSize> sstart, scount;
614 
615  if (this->wmpi && collective)
617  if (this->wmpi && !collective)
619 
620  this->getWriteDataInfos(name, record, array_size, sstart, scount, NULL, NULL);
621  this->writeData_(grpid, varid, sstart, scount, data.dataFirst());
622  }
623 
624 
625  //---------------------------------------------------------------
626 
627  bool CONetCDF4::varExist(const StdString& varname)
628  {
629  int grpid = this->getCurrentGroup();
630  return CNetCdfInterface::isVarExisted(grpid, varname);
631  }
632 
633  bool CONetCDF4::dimExist(const StdString& dimname)
634  {
635  int grpid = this->getCurrentGroup();
636  return CNetCdfInterface::isDimExisted(grpid, dimname);
637  }
638 
639  void CONetCDF4::sync(void)
640  {
642  }
644  } // namespace xios
static int defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[])
Define variable chunking size.
const CONetCDF4Path & getCurrentPath(void) const
Accesseur ///.
Definition: onetcdf4.cpp:278
bool dimExist(const StdString &dimname)
Definition: onetcdf4.cpp:633
int count
Definition: tracer.cpp:26
static int putAttType(int ncid, int varid, const StdString &attrName, StdSize numVal, const T *data)
Set an attribute.
static int reDef(int ncId)
Put netcdf file into define mode.
static int setFill(int ncid, bool fill)
Set or unset the fill mode.
static int openPar(const StdString &path, int cmode, MPI_Comm comm, MPI_Info info, int &ncId)
Open a netcdf file.
std::vector< StdString > CONetCDF4Path
Définition de type ///.
Definition: onetcdf4.hpp:25
static int endDef(int ncId)
End define mode of a netcdf file.
static int inqDimId(int ncid, const StdString &dimName, int &dimId)
Query identity of a named dimension.
int getVariable(const StdString &varname)
Definition: onetcdf4.cpp:133
Wrapper of netcdf functions.
map< int, size_t > timeAxis
Definition: onetcdf4.hpp:128
std::vector< StdSize > getDimensions(const StdString &varname)
Definition: onetcdf4.cpp:174
virtual ~CONetCDF4(void)
Destructeur ///.
Definition: onetcdf4.cpp:28
static int close(int ncId)
Close a netcdf file.
static int inqUnLimDim(int ncid, int &dimId)
Query identity of unlimited dimension.
CONetCDF4Path path
Propriétés privées ///.
Definition: onetcdf4.hpp:125
void sync(void)
Definition: onetcdf4.cpp:639
bool useCFConvention
If true data is written in the CF convention otherwise in UGRID.
Definition: onetcdf4.hpp:108
static int putVaraType(int ncid, int varid, const StdSize *start, const StdSize *count, const T *data)
Set data for a variable.
void getTimeAxisBounds(CArray< double, 2 > &timeAxisBounds, const StdString &name, bool collective)
Definition: onetcdf4.cpp:231
int getCurrentGroup(void)
Accesseurs ///.
Definition: onetcdf4.cpp:110
void addAttribute(const StdString &name, const T &value, const StdString *varname=NULL)
void suspend(void)
Definition: timer.cpp:23
void writeTimeAxisData(const CArray< double, 1 > &data, const StdString &name, bool collective, StdSize record, bool Isroot)
Definition: onetcdf4.cpp:572
std::string StdString
Definition: xios_spl.hpp:48
#define xios(arg)
static int defVar(int ncid, const StdString &varName, nc_type xtype, int nDims, const int dimIds[], int &varId)
Define a variable.
static int open(const StdString &path, int oMode, int &ncId)
Open a netcdf file.
void initialize(const StdString &filename, bool append, bool useClassicFormat, bool useCFConvention, const MPI_Comm *comm, bool multifile, const StdString &timeCounterName)
Initialisation ///.
Definition: onetcdf4.cpp:34
std::vector< StdString > getDimensionsIdList(const StdString *varname)
Definition: onetcdf4.cpp:197
static int inqVarNDims(int ncid, int varId, int &nDims)
Query number of dimension of a variable with its id.
#define NC_INDEPENDENT
Definition: netcdf.hpp:26
void writeTimeAxisDataBounds(const CArray< double, 1 > &data, const StdString &name, bool collective, StdSize record, bool Isroot)
Definition: onetcdf4.cpp:598
static bool isDimExisted(int ncId, const StdString &dimName)
int addDimension(const StdString &name, const StdSize size=(size_t)(-1))
Definition: onetcdf4.cpp:296
void close(void)
Definition: onetcdf4.cpp:87
static int createPar(const StdString &path, int cmode, MPI_Comm comm, MPI_Info info, int &ncId)
Create a netcdf file on a parallel file system.
void writeData(const CArray< T, ndim > &data, const StdString &name, bool collective, StdSize record, const std::vector< StdSize > *start=NULL, const std::vector< StdSize > *count=NULL)
Ecriture des données ///.
void getWriteDataInfos(const StdString &name, StdSize record, StdSize &array_size, std::vector< StdSize > &sstart, std::vector< StdSize > &scount, const std::vector< StdSize > *start, const std::vector< StdSize > *count)
Definition: onetcdf4.cpp:470
static int varParAccess(int ncid, int varid, int access)
Change access type of a variable.
static int defVarFill(int ncid, int varId, int noFill, void *fillValue)
Define variable fill parameters.
CATCH CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar *scalarDestination, CScalar *scalarSource, CReduceScalarToScalar *algo ERROR)("CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CScalar* scalarSource, CReduceScalarToScalar* algo)",<< "Operation must be defined."<< "Scalar source "<< scalarSource->getId()<< std::endl<< "Scalar destination "<< scalarDestination->getId())
bool appendMode
If true, we are appending data to an existing file.
Definition: data_output.hpp:65
Exception management.
static int inqDimName(int ncid, int dimId, StdString &dimName)
Query name of a dimension with its id.
static int getVaraType(int ncid, int varid, const StdSize *start, const StdSize *count, T *data)
Get data for a variable.
int getDimension(const StdString &dimname)
Definition: onetcdf4.cpp:143
std::size_t StdSize
Definition: xios_spl.hpp:49
bool useClassicFormat
If true, NetCDF4 will use the classic NetCDF3 format.
Definition: onetcdf4.hpp:107
void setCurrentPath(const CONetCDF4Path &path)
Mutateurs ///.
Definition: onetcdf4.cpp:281
static int inqVarDimId(int, int, int *)
Query list of dimension of a variable with its id.
void writeData_(int grpid, int varid, const std::vector< StdSize > &sstart, const std::vector< StdSize > &scount, T *data)
static int create(const StdString &path, int cmode, int &ncId)
Create a netcdf file.
void resize(int extent)
Definition: array_new.hpp:320
void resume(void)
Definition: timer.cpp:33
#define NC_COLLECTIVE
Definition: netcdf.hpp:27
bool varExist(const StdString &varname)
Definition: onetcdf4.cpp:627
StdString getUnlimitedDimensionName(void)
Definition: onetcdf4.cpp:161
int getGroup(const CONetCDF4Path &path)
Definition: onetcdf4.cpp:117
static int sync(int ncId)
Sync the file.
#define UNLIMITED_DIM
XIOS headers ///.
Definition: inetcdf4.hpp:13
static int defGrp(int parentNcid, const StdString &grpName, int &grpId)
Define a group.
static CTimer & get(std::string name)
Definition: timer.cpp:54
int addVariable(const StdString &name, nc_type type, const std::vector< StdString > &dim, int compressionLevel=0)
Definition: onetcdf4.cpp:309
static int defVarDeflate(int ncid, int varId, int compressionLevel)
Define variable compression level.
void setCompressionLevel(const StdString &varname, int compressionLevel)
Definition: onetcdf4.cpp:359
static int inqVarId(int ncid, const StdString &varName, int &varId)
Query identity of a named variable.
static int defDim(int ncid, const StdString &dimName, StdSize dimLen, int &dimId)
Define a dimension.
StdString timeCounterName
Definition: onetcdf4.hpp:129
CONetCDF4(const StdString &filename, bool append, bool useClassicFormat=false, bool useCFConvention=true, const MPI_Comm *comm=NULL, bool multifile=true, const StdString &timeCounterName="time_counter")
Constructeurs ///.
Definition: onetcdf4.cpp:15
static int inqNcId(int ncid, const StdString &grpName, int &grpId)
Query identity of a named group.
static int inqDimIds(int ncid, int &nDims, int *dimIds, int includeParents)
Query dimensions of a group.
int getUnlimitedDimension(void)
Definition: onetcdf4.cpp:153
void definition_start(void)
Definition: onetcdf4.cpp:96
static bool isVarExisted(int ncId, const StdString &varName)
Query the existence of a variable.
void definition_end(void)
Test if the file was opened in append mode.
Definition: onetcdf4.cpp:103
static int inqDimLen(int ncid, int dimId, StdSize &dimLen)
Query length of dimension with its id.
int addGroup(const StdString &name)
Definition: onetcdf4.cpp:286