source: XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/inetcdf4_impl.hpp @ 229

Last change on this file since 229 was 229, checked in by hozdoba, 13 years ago
File size: 2.1 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4
5#ifndef __INETCDF4_IMPL_HPP__
6#define __INETCDF4_IMPL_HPP__
7
8/**
9 * \file    inetcdf4_impl.hpp
10 * \brief   Lecture des fichiers de données au format netCDF-4 (implémentation template).
11 * \author  Hervé Ozdoba
12 * \version 0.4
13 * \date    15 Juin 2011
14 */
15
16// XMLIOServer headers
17#include "xmlioserver_spl.hpp"
18
19// /////////////////////////////// Définitions ////////////////////////////// //
20
21namespace xmlioserver{
22namespace io {
23   
24   template <class DataType, std::size_t ndim>
25      void CINetCDF4::readData(boost::multi_array<DataType, ndim> & _data,
26                               const std::string & _varname,
27                               std::size_t _record,
28                               const std::vector<std::size_t> * _start,
29                               const std::vector<std::size_t> * _count)
30   {
31      int grpid = this->getCurrentGroup();
32      int varid = this->getVariable(_varname);
33      std::size_t _array_size = 1;
34      std::vector<std::size_t> _sstart, _scount;
35      this->getReadDataInfos
36         (_varname, _record, _array_size,  _sstart, _scount, _start, _count);
37      _data.resize(boost::extents[_array_size]);
38      this->readData_(grpid, varid, _sstart, _scount, _data.data());
39   }
40
41   template <class DataType>
42      void CINetCDF4::readAttribute
43          (const std::string & _attname, std::vector<DataType> & _value, const std::string * _varname)
44   {
45       std::pair<nc_type, std::size_t> attinfos;
46       int grpid = this->getCurrentGroup();                                 
47       int varid = (_varname != NULL) ? this->getVariable(*_varname) : NC_GLOBAL;
48       CheckError(nc_inq_att(grpid, varid, _attname.c_str(), &attinfos.first, &attinfos.second));
49       _value.resize(attinfos.second); 
50       this->readAttribute_(_attname, &_value[0], grpid, varid);
51       
52   }
53   
54} // namespace io
55} // namespace xmlioserver
56
57#endif  // __INETCDF4_IMPL_HPP__
Note: See TracBrowser for help on using the repository browser.