source: XIOS/dev/dev_olga/src/io/nc4_data_input.cpp @ 1130

Last change on this file since 1130 was 967, checked in by mhnguyen, 8 years ago

Ticket 106: Reading a scalar from file

+) Add method to read scalar value
+) Modify the way to send/receive scalar (and non-distributed) data

Test
+) On Curie
+) OK

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