source: XIOS/dev/branch_openmp/src/io/nc4_data_input.cpp @ 1287

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

save modif

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