New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
average.cpp in vendors/XIOS/current/src/functor – NEMO

source: vendors/XIOS/current/src/functor/average.cpp @ 9295

Last change on this file since 9295 was 3428, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

File size: 1.3 KB
Line 
1#include "average.hpp"
2
3namespace xios
4{
5   namespace func
6   {
7      /// ////////////////////// Définitions ////////////////////// ///
8
9      CAverage::CAverage(DoubleArray doutput)
10         : SuperClass(StdString("average"), doutput)
11      { /* Ne rien faire de plus */ }
12
13      CAverage::~CAverage(void)
14      { /* Ne rien faire de plus */ }
15
16      //---------------------------------------------------------------
17
18      void CAverage::apply(const DoubleArray _dinput,
19                                 DoubleArray _doutput)
20      {
21         const double * it1  = _dinput->data(),
22                      * end1 = _dinput->data() + _dinput->num_elements(); 
23               double * it   = _doutput->data();
24         if (this->nbcall == 1)
25              for (; it1 != end1; it1++, it++) *it  = *it1;
26         else for (; it1 != end1; it1++, it++) *it += *it1;               
27      }
28     
29      void CAverage::final(void)
30      {
31          double * it1  = this->getDataOutput()->data(),
32                 * end1 = this->getDataOutput()->data() + this->getDataOutput()->num_elements();
33          for (; it1 != end1; it1++) *it1 /= this->nbcall;
34          this->nbcall = 0;                                                   
35      }
36   } // namespace func
37} // namespace xmlioserver
Note: See TracBrowser for help on using the repository browser.