source: XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/onetcdf4_impl.hpp @ 249

Last change on this file since 249 was 249, checked in by hozdoba, 13 years ago

Ajout d'une partie d'Interface fortran pour la version 4
Ajout des sorties netcdf4 pour la version 4

File size: 2.2 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4
5#ifndef __ONETCDF4_IMPL_HPP__
6#define __ONETCDF4_IMPL_HPP__
7
8// XMLIOServer headers
9#include "xmlioserver_spl.hpp"
10
11// /////////////////////////////// Définitions ////////////////////////////// //
12
13namespace xmlioserver{
14namespace io {
15   
16   template <class DataType, std::size_t ndim>
17      void CONetCDF4::writeData(const boost::multi_array<DataType, ndim> & _data,
18                                const std::string                        & _varname,
19                                std::size_t                                _record,
20                                bool                                       _collective,
21                                const std::vector<std::size_t>           * _start,
22                                const std::vector<std::size_t>           * _count)
23   {
24      int grpid = this->getCurrentGroup();
25      int varid = this->getVariable(_varname);
26      std::size_t _array_size = 1;
27      std::vector<std::size_t> _sstart, _scount;
28     
29      if (this->comm_server && _collective)
30         CheckError(nc_var_par_access(grpid, varid, NC_COLLECTIVE));
31      if (this->comm_server && !_collective)
32         CheckError(nc_var_par_access(grpid, varid, NC_INDEPENDENT));
33     
34      this->getWriteDataInfos
35         (_varname, _record, _array_size,  _sstart, _scount, _start, _count);
36      this->writeData_(grpid, varid, _sstart, _scount, _data.data());
37   }
38
39   template <class DataType>
40      void CONetCDF4::writeAttribute
41          (const std::string           & _attname,
42           const std::vector<DataType> & _value,
43           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       this->writeAttribute_(_attname, &_value[0], _value.size(), grpid, varid);       
49   }
50   
51} // namespace io
52} // namespace xmlioserver
53
54#endif  // __ONETCDF4_IMPL_HPP__
Note: See TracBrowser for help on using the repository browser.