Ignore:
Timestamp:
02/13/12 19:35:25 (12 years ago)
Author:
ymipsl
Message:

nouvelle version de developpement de xios

  • nouvelle interface fortran
  • recodage complet de la couche de communication
  • et bien d'autres choses...

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/common/src/array_impl.hpp

    r219 r300  
    33 
    44#include "array_mac.hpp" 
     5#include "buffer_in.hpp" 
     6#include "buffer_out.hpp" 
    57 
    68namespace xmlioserver 
     
    1618   { /* Ne rien faire de plus */ } 
    1719 
     20   template <typename ValueType, StdSize NumDims, typename Allocator> 
     21       CArray<ValueType, NumDims, Allocator>::CArray() 
     22            : boost::multi_array<ValueType, NumDims, Allocator> 
     23                  (getExtentNull<NumDims>(), boost::fortran_storage_order()) 
     24   { /* Ne rien faire de plus */ } 
     25    
    1826   template <typename ValueType, StdSize NumDims, typename Allocator> 
    1927      template <typename ExtentList> 
     
    3341                                const CArray<ValueType, NumDims, Allocator> & array) 
    3442   { 
    35       os << (array.data()[0]) << "(" << array.shape()[0]; 
     43      os << "CArray (" ; 
    3644      for (StdSize i = 1; i < array.num_dimensions(); i++) 
    3745         os << ", " << array.shape()[i]; 
    38       os << ")" << (array.data()[array.num_elements()-1]); 
     46      os << ") = " ;  
     47      for (StdSize i = 0; i < array.num_elements(); i++) os << (array.data()[i])<<"  "; 
    3948      return (os); 
    4049   } 
     
    108117      is.read (reinterpret_cast<char*>(this->data()), nelem * sizeof(ValueType)); 
    109118   } 
     119   
     120    template <typename ValueType, StdSize NumDims, typename Allocator> 
     121    size_t CArray<ValueType, NumDims, Allocator>::getSize(void) const 
     122   { 
     123      typedef boost::multi_array_types::size_type LSize; 
     124      LSize nelem = this->num_elements(); 
     125      LSize ndim  = this->num_dimensions(); 
     126      const LSize * shape = this->shape(); 
     127      const ValueType * data = this->data(); 
     128      size_t ret ; 
     129      ret=sizeof(ndim) ; 
     130      for (LSize i = 0; i < ndim; i++ ) ret+=sizeof(shape[i]) ; 
     131      ret+=sizeof(nelem) ; 
     132      ret+=sizeof(ValueType)*nelem ; 
     133      return ret ; 
     134   } 
     135 
     136   template <typename ValueType, StdSize NumDims, typename Allocator> 
     137   bool CArray<ValueType, NumDims, Allocator>::toBuffer(CBufferOut& buffer) const 
     138   { 
     139      typedef boost::multi_array_types::size_type LSize; 
     140 
     141      LSize nelem = this->num_elements(); 
     142      LSize ndim  = this->num_dimensions(); 
     143      const LSize* shape = this->shape(); 
     144      const ValueType* data = this->data(); 
     145      bool ret ; 
     146       
     147      ret=buffer.put(ndim) ; 
     148      for (LSize i = 0; i < ndim; i++ ) ret&=buffer.put(shape[i]) ; 
     149      ret&=buffer.put(nelem) ; 
     150      ret&=buffer.put(data,nelem) ; 
     151      return ret ; 
     152  } 
     153 
     154   template <typename ValueType, StdSize NumDims, typename Allocator> 
     155   bool CArray<ValueType, NumDims, Allocator>::fromBuffer(CBufferIn& buffer) 
     156   { 
     157      typedef boost::multi_array_types::size_type LSize; 
     158      LSize ndim = 0, nelem = 0, temp = 0; 
     159      std::vector<LSize> shape; 
     160      bool ret ; 
     161       
     162      ret=buffer.get(ndim) ; 
     163      for (LSize i = 0; i < ndim; i++ ) 
     164      { 
     165         ret&=buffer.get(temp) ; 
     166         shape.push_back(temp); 
     167      } 
     168      this->resize(shape); 
     169      ret&=buffer.get(nelem) ; 
     170      ret&=buffer.get(this->data(),nelem) ; 
     171      return ret ; 
     172   } 
     173    
    110174 
    111175   ///--------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.