source: XIOS/dev/branch_yushan_merged/src/io/nc4_data_input.cpp @ 1138

Last change on this file since 1138 was 1138, checked in by yushan, 7 years ago

test_remap back to work. No thread for now

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 22.6 KB
Line 
1#include "nc4_data_input.hpp"
2
3#include "context.hpp"
4#include "context_server.hpp"
5#include "context_client.hpp"
6#include "domain.hpp"
7#include "axis.hpp"
8#include "scalar.hpp"
9
10// mpi.hpp
11
12namespace xios
13{
14  CNc4DataInput::CNc4DataInput(const StdString& filename, ::MPI_Comm comm_file, bool multifile, bool isCollective /*= true*/, const StdString& timeCounterName /*= "time_counter"*/)
15    : SuperClass()
16    , SuperClassWriter(filename, &comm_file, multifile, timeCounterName)
17    , comm_file(comm_file)
18    , filename(filename)
19    , isCollective(isCollective)
20    , readMetaDataDomains_(), readValueDomains_()
21    , readMetaDataAxis_(), readValueAxis_()
22    , readMetaDataScalar_(), readValueScalar_()
23  {
24    SuperClass::type = multifile ? MULTI_FILE : ONE_FILE;
25  }
26
27  CNc4DataInput::~CNc4DataInput(void)
28  { /* Nothing more to do */ }
29
30  StdSize CNc4DataInput::getFieldNbRecords_(CField* field)
31  {
32    StdString fieldId = field->getFieldOutputName();
33
34    if (SuperClassWriter::isTemporal(fieldId))
35    {
36//      return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getUnlimitedDimensionName()];
37      return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getTimeCounterName()];
38    }
39
40    return 1;
41  }
42
43  void CNc4DataInput::readFieldData_(CField* field)
44  {
45    CContext* context = CContext::getCurrent();
46    CContextServer* server = context->server;
47
48    CGrid* grid = field->grid;
49
50    if (!grid->doGridHaveDataToWrite())
51      if (SuperClass::type==MULTI_FILE || !isCollective) return;
52
53    StdString fieldId = field->getFieldOutputName();
54
55    CArray<double,1> fieldData(grid->getWrittenDataSize());
56    if (!field->default_value.isEmpty()) fieldData = field->default_value;
57
58    switch (SuperClass::type)
59    {
60      case MULTI_FILE:
61        SuperClassWriter::getData(fieldData, fieldId, isCollective, (field->getNStep() - 1)%field->nstepMax );
62        break;
63      case ONE_FILE:
64      {
65/*
66        std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();
67        std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();
68        std::vector<int> nZoomSizeServer  = grid->getDistributionServer()->getZoomSizeServer();
69
70        int ssize = nZoomBeginGlobal.size();
71
72        std::vector<StdSize> start(ssize);
73        std::vector<StdSize> count(ssize);
74
75        for (int i = 0; i < ssize; ++i)
76        {
77          start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1];
78          count[i] = nZoomSizeServer[ssize - i - 1];
79        }
80*/
81
82        std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();
83        std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();
84        std::vector<int> nZoomSizeServer  = grid->getDistributionServer()->getZoomSizeServer();
85
86        std::vector<StdSize> start, count;
87
88        CArray<int,1> axisDomainOrder = grid->axis_domain_order;
89        std::vector<StdString> domainList = grid->getDomainList();
90        std::vector<StdString> axisList   = grid->getAxisList();
91        int numElement = axisDomainOrder.numElements();
92        int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1;
93        int idx = nZoomBeginGlobal.size() - 1;
94
95        start.reserve(nZoomBeginGlobal.size());
96        count.reserve(nZoomBeginGlobal.size());
97
98        for (int i = numElement - 1; i >= 0; --i)
99        {
100          if (2 == axisDomainOrder(i))
101          {
102            CDomain* domain = CDomain::get(domainList[idxDomain]);
103            if ((domain->type) != CDomain::type_attr::unstructured)
104            {
105              start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
106              count.push_back(nZoomSizeServer[idx]);
107            }
108            --idx ;
109            start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
110            count.push_back(nZoomSizeServer[idx]);
111            --idx ;
112            --idxDomain;
113          }
114          else if (1 == axisDomainOrder(i))
115          {
116            start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
117            count.push_back(nZoomSizeServer[idx]);
118            --idx;
119          }
120          else
121          {
122            if (1 == axisDomainOrder.numElements())
123            {
124              start.push_back(0);
125              count.push_back(1);
126            }
127            --idx;
128          }
129        }
130
131        SuperClassWriter::getData(fieldData, fieldId, isCollective, (field->getNStep() - 1)%field->nstepMax, &start, &count);
132        break;
133      }
134    }
135
136    field->inputField(fieldData);
137
138    if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty())
139    {
140      double scaleFactor = 1.0, addOffset = 0.0;
141      if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor;
142      if (!field->add_offset.isEmpty()) addOffset = field->add_offset;
143      field->invertScaleFactorAddOffset(scaleFactor, addOffset);
144    }
145  }
146
147  void CNc4DataInput::readFieldAttributes_(CField* field, bool readAttributeValues)
148  {
149    StdString fieldId = field->getFieldOutputName();
150
151    CGrid* grid = field->grid;
152
153    std::vector<CDomain*> domainP = grid->getDomains();
154    std::vector<CAxis*> axisP = grid->getAxis();
155    std::vector<CScalar*> scalarP = grid->getScalars();
156    int gridDim = domainP.size() * 2 + axisP.size();
157
158    // Nothing to do with scalar without timestep
159    if ((0 == gridDim) && (!SuperClassWriter::isTemporal(fieldId))) 
160      return;
161
162    // Verify the compatibility of dimension of declared grid and real grid in file
163    int realGridDim = 1;
164    bool isUnstructuredGrid = SuperClassWriter::isUnstructured(fieldId);
165    std::map<StdString, StdSize> dimSizeMap = SuperClassWriter::getDimensions(&fieldId);
166    std::list<StdString> dimList = SuperClassWriter::getDimensionsList(&fieldId);
167
168    realGridDim = SuperClassWriter::isTemporal(fieldId) ? dimSizeMap.size() - 1 : dimSizeMap.size();
169    if (isUnstructuredGrid) ++realGridDim;
170
171    if (gridDim != realGridDim)
172       ERROR("CNc4DataInput::readFieldAttributes_(CField* field, bool readAttributeValues)",
173        << "Field '" << fieldId << "' has incorrect dimension " << std::endl
174        << "Verify dimension of grid defined by 'grid_ref' or 'domain_ref'/'axis_ref' and dimension of grid in read file.");
175
176    // Remove unlimited dimension from the map, we dont need it anymore
177    if (SuperClassWriter::isTemporal(fieldId))
178    {
179      dimSizeMap.erase(SuperClassWriter::getUnlimitedDimensionName());
180      dimList.pop_front() ;  // assume time dimension is first
181    }
182
183    std::list<std::pair<StdString, StdSize> > listDimSize;
184/*
185    for (std::map<StdString, StdSize>::const_iterator itMap = dimSizeMap.begin(); itMap != dimSizeMap.end(); ++itMap)
186      listDimSize.push_front(*itMap);
187*/
188    for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it)
189      listDimSize.push_front(*dimSizeMap.find(*it));
190
191    // Now process domain and axis
192    CArray<int,1> axisDomainOrder = grid->axis_domain_order;
193    int numElement = domainP.size() + axisP.size() + scalarP.size();
194    int elementPosition = 0;
195    int idxDomain = 0, idxAxis = 0, idxScalar = 0;
196
197    std::pair<std::set<StdString>::iterator,bool> it;
198    for (int i = 0; i < numElement; ++i)
199    {
200      if(2 == axisDomainOrder(i))
201      {
202        if (readAttributeValues)
203        {
204           it = readValueDomains_.insert(domainP[idxDomain]->getId());
205           if (it.second) readDomainAttributeValueFromFile(domainP[idxDomain], listDimSize, elementPosition, fieldId);
206        }
207        else
208        {
209          it = readMetaDataDomains_.insert(domainP[idxDomain]->getId());
210          if (it.second) readDomainAttributesFromFile(domainP[idxDomain], listDimSize, elementPosition, fieldId);
211        }
212        ++idxDomain;
213        if (isUnstructuredGrid) ++elementPosition;
214        else elementPosition += 2;
215      }
216      else if (1 == axisDomainOrder(i))
217      {
218        if (readAttributeValues)
219        {
220          it = readValueAxis_.insert(axisP[idxAxis]->getId());
221          if (it.second) readAxisAttributeValueFromFile(axisP[idxAxis], listDimSize, elementPosition, fieldId);
222        }
223        else
224        {
225          it = readMetaDataAxis_.insert(axisP[idxAxis]->getId());
226          if (it.second) readAxisAttributesFromFile(axisP[idxAxis], listDimSize, elementPosition, fieldId);
227        }
228        ++idxAxis;
229        ++elementPosition;
230      }
231      else
232      {
233        if (readAttributeValues)
234        {
235          it = readValueScalar_.insert(scalarP[idxScalar]->getId());
236          if (it.second) readScalarAttributeValueFromFile(scalarP[idxScalar], listDimSize, elementPosition, fieldId);
237        }
238        else
239        {
240          it = readMetaDataScalar_.insert(scalarP[idxScalar]->getId());
241          if (it.second) readScalarAttributesFromFile(scalarP[idxScalar], listDimSize, elementPosition, fieldId);
242        }
243        ++idxScalar;
244        ++elementPosition;
245      }
246    }
247  }
248
249  /*!
250    Read attributes of a domain from a file
251    \param [in] domain domain whose attributes are read from the file
252    \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file
253    \param [in] emelentPosition position of domain in grid
254    \param [in] fieldId id (or name) associated with the grid
255  */
256  void CNc4DataInput::readDomainAttributeValueFromFile(CDomain* domain, std::list<std::pair<StdString, StdSize> >& dimSizeMap,
257                                                       int elementPosition, const StdString& fieldId)
258  {
259    // There are some optional attributes of a domain to retrieve from file    // + lon lat?
260    std::list<std::pair<StdString, StdSize> >::const_iterator itMapNi = dimSizeMap.begin(), itMapNj,
261                                                              iteMap  = dimSizeMap.end();
262
263    for (int i = 0; i < elementPosition; ++i, ++itMapNi) {}
264    itMapNj = itMapNi; ++itMapNj;
265
266    if ((CDomain::type_attr::rectilinear == domain->type))
267    {
268      // Ok, try to read some f.. attributes such as longitude and latitude
269      bool hasLat = SuperClassWriter::hasVariable(itMapNj->first);
270      if (hasLat)
271      {
272        domain->latvalue_rectilinear_read_from_file.resize(itMapNj->second);
273        std::vector<StdSize> nBeginLat(1, 0), nSizeLat(1, itMapNj->second);
274        readFieldVariableValue(domain->latvalue_rectilinear_read_from_file, itMapNj->first, nBeginLat, nSizeLat, true);
275      }
276
277      bool hasLon = SuperClassWriter::hasVariable(itMapNi->first);
278      if (hasLon)
279      {
280        domain->lonvalue_rectilinear_read_from_file.resize(itMapNi->second);
281        std::vector<StdSize> nBeginLon(1, 0), nSizeLon(1, itMapNi->second);
282        readFieldVariableValue(domain->lonvalue_rectilinear_read_from_file, itMapNi->first, nBeginLon, nSizeLon, true);
283      }     
284    }
285    else if ((CDomain::type_attr::curvilinear == domain->type))
286    {
287      int ni = domain->ni;
288      int nj = domain->nj;
289      std::vector<StdSize> nBeginLatLon(2), nSizeLatLon(2);
290      nBeginLatLon[0] = 0; nBeginLatLon[1] = 0;
291      nSizeLatLon[0]  = domain->nj_glo.getValue(); nSizeLatLon[1] = domain->ni_glo.getValue();
292
293      StdString latName = this->getLatCoordName(fieldId);
294      if (SuperClassWriter::hasVariable(latName))
295      {
296        domain->latvalue_curvilinear_read_from_file.resize(domain->ni_glo,domain->nj_glo);
297        readFieldVariableValue(domain->latvalue_curvilinear_read_from_file, latName, nBeginLatLon, nSizeLatLon);
298      }
299      StdString lonName = this->getLonCoordName(fieldId);
300      if (SuperClassWriter::hasVariable(lonName))
301      {
302        domain->lonvalue_curvilinear_read_from_file.resize(domain->ni_glo,domain->nj_glo);
303        readFieldVariableValue(domain->lonvalue_curvilinear_read_from_file, lonName, nBeginLatLon, nSizeLatLon);
304      }
305
306      StdString boundsLatName = this->getBoundsId(latName);
307      StdString boundsLonName = this->getBoundsId(lonName);
308
309      int nbVertex = this->getNbVertex(fieldId);
310      if (!domain->nvertex.isEmpty() && (domain->nvertex != nbVertex))
311      {
312        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)",
313          << "The domain " << domain->getDomainOutputName()
314          << " has nvertex read from file " << this->filename << " and nvertex provided from model"
315          << " are not coherent. They should be the same." << std::endl
316          << " nvertex read from file: "<< nbVertex
317          << " nvertex from model: "<< domain->nvertex << std::endl);
318      } 
319
320      if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName)) 
321        domain->nvertex.setValue(nbVertex);
322
323      std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3);
324      nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->nj_glo.getValue();
325      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = domain->nj_glo.getValue();
326      nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex;
327
328      if (SuperClassWriter::hasVariable(boundsLatName))
329      {
330        domain->bounds_latvalue_curvilinear_read_from_file.resize(nbVertex,domain->ni_glo,domain->nj_glo);
331        readFieldVariableValue(domain->bounds_latvalue_curvilinear_read_from_file, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon);
332
333      }
334      if (SuperClassWriter::hasVariable(boundsLonName)) 
335      {
336        domain->bounds_lonvalue_curvilinear_read_from_file.resize(nbVertex,domain->ni_glo,domain->nj_glo);
337        readFieldVariableValue(domain->bounds_lonvalue_curvilinear_read_from_file, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon);
338      }     
339    }
340    else if ((CDomain::type_attr::unstructured == domain->type))// || (this->isUnstructured(fieldId)))
341    {
342      std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0);
343      nSizeLatLon[0]  = domain->ni_glo.getValue();
344      CArray<double,1> globalLonLat(domain->ni_glo.getValue());
345
346      StdString latName = this->getLatCoordName(fieldId);
347      if (SuperClassWriter::hasVariable(latName))
348      {
349        domain->latvalue_unstructured_read_from_file.resize(domain->ni_glo);
350        readFieldVariableValue(domain->latvalue_unstructured_read_from_file, latName, nBeginLatLon, nSizeLatLon); 
351      }
352
353      StdString lonName = this->getLonCoordName(fieldId);
354      if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare(""))
355      {
356        // readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon);
357        domain->lonvalue_unstructured_read_from_file.resize(domain->ni_glo);
358        readFieldVariableValue(domain->lonvalue_unstructured_read_from_file, lonName, nBeginLatLon, nSizeLatLon);
359      }
360
361      StdString boundsLatName = this->getBoundsId(latName);
362      StdString boundsLonName = this->getBoundsId(lonName);
363
364      int nbVertex = this->getNbVertex(fieldId);
365      if (!domain->nvertex.isEmpty() && (domain->nvertex != nbVertex))
366      {
367        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)",
368          << "The domain " << domain->getDomainOutputName()
369          << " has nvertex read from file " << this->filename << " and nvertex provided from model"
370          << " are not coherent. They should be the same." << std::endl
371          << " nvertex read from file: "<< nbVertex
372          << " nvertex from model: "<< domain->nvertex << std::endl);
373      } 
374     
375      if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName)) 
376        domain->nvertex.setValue(nbVertex);
377
378      std::vector<StdSize> nBeginBndsLatLon(2), nSizeBndsLatLon(2);
379      nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->ni_glo.getValue();
380      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex;
381
382      if (SuperClassWriter::hasVariable(boundsLatName)) 
383      {
384        domain->bounds_latvalue_unstructured_read_from_file.resize(nSizeBndsLatLon[1], nSizeBndsLatLon[0]);
385        readFieldVariableValue(domain->bounds_latvalue_unstructured_read_from_file, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon);
386      }
387
388      if (SuperClassWriter::hasVariable(boundsLonName)) 
389      {
390        domain->bounds_lonvalue_unstructured_read_from_file.resize(nSizeBndsLatLon[1], nSizeBndsLatLon[0]);
391        readFieldVariableValue(domain->bounds_lonvalue_unstructured_read_from_file, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon);
392      }     
393    }
394    domain->fillInLonLat();
395  }
396
397  /*!
398    Read attribute value of a domain from a file
399    \param [in] domain domain whose attributes are read from the file
400    \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file
401    \param [in] emelentPosition position of domain in grid
402    \param [in] fieldId id (or name) associated with the grid
403  */
404  void CNc4DataInput::readDomainAttributesFromFile(CDomain* domain, std::list<std::pair<StdString, StdSize> >& dimSizeMap,
405                                                   int elementPosition, const StdString& fieldId)
406  {
407    // There are some mandatory attributes of a domain to retrieve from file
408    // + ni_glo, nj_glo
409    std::list<std::pair<StdString, StdSize> >::const_iterator itMapNi = dimSizeMap.begin(), itMapNj,
410                                                              iteMap  = dimSizeMap.end();
411    for (int i = 0; i < elementPosition; ++i, ++itMapNi) {}
412    itMapNj = itMapNi; ++itMapNj;
413
414    if (this->isRectilinear(fieldId) || this->isCurvilinear(fieldId))
415    {
416      if (!domain->nj_glo.isEmpty() && (domain->nj_glo != itMapNj->second))
417      {
418        ERROR("void CNc4DataInput::readDomainAttributesFromFile(...)",
419          << "The domain " << domain->getDomainOutputName()
420          << " has nj_glo read from file " << this->filename << " and nj_glo provided from model"
421          << " are not coherent. They should be the same." << std::endl
422          << " nj_glo read from file: "<< itMapNj->second
423          << " nj_glo from model: "<< domain->nj_glo << std::endl);
424      } 
425      domain->nj_glo.setValue(itMapNj->second);
426
427      if (!domain->ni_glo.isEmpty() && (domain->ni_glo != itMapNi->second))
428      {
429        ERROR("void CNc4DataInput::readDomainAttributesFromFile(...)",
430          << "The domain " << domain->getDomainOutputName()
431          << " has ni_glo read from file " << this->filename << " and ni_glo provided from model"
432          << " are not coherent. They should be the same." << std::endl
433          << " ni_glo read from file: "<< itMapNi->second
434          << " ni_glo from model: "<< domain->ni_glo << std::endl);
435      } 
436      domain->ni_glo.setValue(itMapNi->second);
437    }
438    else if (this->isUnstructured(fieldId))
439    {
440      domain->nj_glo.setValue(1);
441
442      if (!domain->ni_glo.isEmpty() && (domain->ni_glo != itMapNi->second))
443      {
444        ERROR("void CNc4DataInput::readDomainAttributesFromFile(...)",
445          << "The domain " << domain->getDomainOutputName()
446          << " has ni_glo read from file " << this->filename << " and ni_glo provided from model"
447          << " are not coherent. They should be the same." << std::endl
448          << " ni_glo read from file: "<< itMapNi->second
449          << " ni_glo from model: "<< domain->ni_glo << std::endl);
450      }       
451      domain->ni_glo.setValue(itMapNi->second);
452    }
453  }
454
455  /*!
456    Read attributes of an axis from a file
457    \param [in] axis axis whose attributes are read from the file
458    \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file
459    \param [in] emelentPosition position of axis in grid
460    \param [in] fieldId id (or name) associated with the grid
461  */
462  void CNc4DataInput::readAxisAttributesFromFile(CAxis* axis, std::list<std::pair<StdString, StdSize> >& dimSizeMap,
463                                                 int elementPosition, const StdString& fieldId)
464  {
465    std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(),
466                                                              iteMap = dimSizeMap.end();
467    for (int i = 0; i < elementPosition; ++i, ++itMapN) {}
468
469    if (!axis->n_glo.isEmpty() && (axis->n_glo != itMapN->second))
470    {
471      ERROR("void CNc4DataInput::readAxisAttributesFromFile(...)",
472        << "The axis " << axis->getAxisOutputName()
473        << " has n_glo read from file " << this->filename << " and n_glo provided from model"
474        << " are not coherent. They should be the same." << std::endl
475        << " n_glo read from file: "<< itMapN->second
476        << " n_glo from model: "<< axis->n_glo << std::endl);
477    }   
478    axis->n_glo.setValue(itMapN->second);
479  }
480
481  /*!
482    Read attribute value of an axis from a file
483    \param [in] axis axis whose attributes are read from the file
484    \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file
485    \param [in] emelentPosition position of axis in grid
486    \param [in] fieldId id (or name) associated with the grid
487  */
488  void CNc4DataInput::readAxisAttributeValueFromFile(CAxis* axis, std::list<std::pair<StdString, StdSize> >& dimSizeMap,
489                                                    int elementPosition, const StdString& fieldId)
490  {
491    std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(),
492                                                              iteMap = dimSizeMap.end();
493    for (int i = 0; i < elementPosition; ++i, ++itMapN) {}
494
495    { // Read axis value
496      std::vector<StdSize> nBegin(1, 0), nSize(1, itMapN->second);
497      CArray<double,1> readAxisValue(itMapN->second);
498      readFieldVariableValue(readAxisValue, itMapN->first, nBegin, nSize, true);
499      int begin = 0, n = itMapN->second;
500      if (!axis->begin.isEmpty()) begin = axis->begin.getValue();
501      if (!axis->n.isEmpty()) n = axis->n.getValue();
502      axis->value.resize(n);
503      for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i);
504    }
505  }
506
507  /*!
508    Read attributes of a scalar from a file
509    \param [in] scalar scalar whose attributes are read from the file
510    \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file
511    \param [in] emelentPosition position of scalar in grid
512    \param [in] fieldId id (or name) associated with the grid
513  */
514  void CNc4DataInput::readScalarAttributesFromFile(CScalar* scalar, std::list<std::pair<StdString, StdSize> >& dimSizeMap,
515                                                  int elementPosition, const StdString& fieldId)
516  {
517    /*Nothing to do */
518  }
519
520  /*!
521    Read attribute value of an axis from a file
522    \param [in] axis axis whose attributes are read from the file
523    \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file
524    \param [in] emelentPosition position of axis in grid
525    \param [in] fieldId id (or name) associated with the grid
526  */
527  void CNc4DataInput::readScalarAttributeValueFromFile(CScalar* scalar, std::list<std::pair<StdString, StdSize> >& dimSizeMap,
528                                                      int elementPosition, const StdString& fieldId)
529  {
530    /*Nothing to do */
531  }
532
533  void CNc4DataInput::closeFile_(void)
534  {
535    SuperClassWriter::close();
536  }
537} // namespace xios
Note: See TracBrowser for help on using the repository browser.