source: XIOS/dev/branch_openmp/src/functor/accumulate.cpp @ 1482

Last change on this file since 1482 was 1482, checked in by yushan, 6 years ago

Branch EP merged with Dev_cmip6 @r1481

  • 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
  • Property svn:eol-style set to native
File size: 1.5 KB
RevLine 
[443]1#include "accumulate.hpp"
2#include "array_new.hpp"
[1018]3#include "utils.hpp"
[443]4
5namespace xios
6{
7   namespace func
8   {
9      /// ////////////////////// Définitions ////////////////////// ///
10
11      CAccumulate::CAccumulate(CArray<double,1>& doutput)
[470]12         : SuperClass(StdString("accumulate"), doutput)
[443]13      { /* Ne rien faire de plus */ }
14
[470]15      CAccumulate::CAccumulate(CArray<double,1>& doutput, double missingValue)
16         : SuperClass(StdString("accumulate"), doutput, missingValue)
17      { /* Ne rien faire de plus */ }
18
[443]19      CAccumulate::~CAccumulate(void)
20      { /* Ne rien faire de plus */ }
21
22      //---------------------------------------------------------------
23
24      void CAccumulate::apply(const CArray<double,1>& _dinput,
25                                 CArray<double,1>& _doutput)
26      {
27        if (this->nbcall == 1) _doutput=_dinput ;
[470]28        else 
29        {
30          if (hasMissingValue)
31          {
32            int i, n =_dinput.numElements() ;
33            const double * in=_dinput.dataFirst() ;
34            double* out=_doutput.dataFirst();
35            for (i=0; i<n; ++i,++in,++out) 
[1482]36              if (!NumTraits<double>::isNan(*in))
[470]37              {
[1482]38                if(!NumTraits<double>::isNan(*out)) *out  += *in;
[470]39                else *out=*in ;
40              }
41          }
42          else _doutput+=_dinput ;
43        }
[443]44      }
45     
[470]46     
[443]47      void CAccumulate::final(void)
48      {
49        this->nbcall = 0; 
50      }
51   } // namespace func
[591]52} // namespace xios
Note: See TracBrowser for help on using the repository browser.