source: XIOS/dev/branch_openmp/src/filter/file_writer_filter.cpp @ 1460

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

branch_openmp merged with XIOS_DEV_CMIP6@1459

File size: 1.3 KB
RevLine 
[638]1#include "file_writer_filter.hpp"
2#include "exception.hpp"
3#include "field.hpp"
[1018]4#include "utils.hpp"
[638]5
6namespace xios
7{
[639]8  CFileWriterFilter::CFileWriterFilter(CGarbageCollector& gc, CField* field)
9    : CInputPin(gc, 1)
[638]10    , field(field)
11  {
12    if (!field)
13      ERROR("CFileWriterFilter::CFileWriterFilter(CField* field)",
14            "The field cannot be null.");
15  }
16
17  void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data)
18  {
[1205]19    const bool detectMissingValue = (!field->detect_missing_value.isEmpty()
20                                      && !field->default_value.isEmpty()
21                                      && field->detect_missing_value == true);
[1328]22
23    CArray<double, 1> dataArray = (detectMissingValue) ? data[0]->data.copy() : data[0]->data;
24
[1205]25    if (detectMissingValue)
[1018]26    {
[1205]27      const double missingValue = field->default_value;
[1328]28      const size_t nbData = dataArray.numElements();
[1018]29      for (size_t idx = 0; idx < nbData; ++idx)
30      {
[1328]31        if (NumTraits<double>::isnan(dataArray(idx)))
32          dataArray(idx) = missingValue;
[1018]33      }
[1205]34    }
[1018]35
[1328]36    field->sendUpdateData(dataArray);
[638]37  }
[1119]38
[1460]39  bool CFileWriterFilter::mustAutoTrigger() const
40  {
41    return true;
42  }
43
[1119]44  bool CFileWriterFilter::isDataExpected(const CDate& date) const
45  {
46    return true;
47  }
[638]48} // namespace xios
Note: See TracBrowser for help on using the repository browser.