source: XIOS/dev/dev_trunk_omp/src/filter/file_writer_filter.cpp @ 1668

Last change on this file since 1668 was 1668, checked in by yushan, 2 years ago

MARK: branch merged with trunk @1663. static graph OK with EP

File size: 1.6 KB
Line 
1#include "file_writer_filter.hpp"
2#include "exception.hpp"
3#include "field.hpp"
4#include "utils.hpp"
5#include "workflow_graph.hpp"
6
7namespace xios
8{
9  CFileWriterFilter::CFileWriterFilter(CGarbageCollector& gc, CField* field, bool buildWorkflowGraph /* =false */)
10    : CInputPin(gc, 1)
11    , field(field)
12  {
13    if (!field)
14      ERROR("CFileWriterFilter::CFileWriterFilter(CField* field)",
15            "The field cannot be null.");
16    if (buildWorkflowGraph)
17    {
18      filterId = InvalidableObject::count;
19      InvalidableObject::count++;
20    }
21  }
22
23  void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data)
24  {
25    const bool detectMissingValue = ( !field->default_value.isEmpty() &&
26                               ( (!field->detect_missing_value.isEmpty() || field->detect_missing_value == true)
27                                 || field->hasGridMask()) );
28
29    CArray<double, 1> dataArray = (detectMissingValue) ? data[0]->data.copy() : data[0]->data;
30
31    if (detectMissingValue)
32    {
33      const double missingValue = field->default_value;
34      const size_t nbData = dataArray.numElements();
35      for (size_t idx = 0; idx < nbData; ++idx)
36      {
37        if (NumTraits<double>::isNan(dataArray(idx)))
38          dataArray(idx) = missingValue;
39      }
40    }
41
42    field->sendUpdateData(dataArray);
43  }
44
45  bool CFileWriterFilter::mustAutoTrigger() const
46  {
47    return true;
48  }
49
50  bool CFileWriterFilter::isDataExpected(const CDate& date) const
51  {
52    return true;
53  }
54
55  int CFileWriterFilter::getFilterId(void)
56  {
57    return filterId;
58  }
59
60} // namespace xios
Note: See TracBrowser for help on using the repository browser.