source: XIOS/dev/XIOS_DEV_CMIP6/src/filter/file_writer_filter.cpp @ 1211

Last change on this file since 1211 was 1201, checked in by oabramkina, 4 years ago

Two server levels: merging trunk r1200 (except for non-contiguous zoom) into dev. Tested on Curie. Todo: non-contiguous zoom.

File size: 1.2 KB
Line 
1#include "file_writer_filter.hpp"
2#include "exception.hpp"
3#include "field.hpp"
4#include "utils.hpp"
5
6namespace xios
7{
8  CFileWriterFilter::CFileWriterFilter(CGarbageCollector& gc, CField* field)
9    : CInputPin(gc, 1)
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  {
19    CDataPacketPtr packet = data[0];
20
21    const bool detectMissingValue = (!field->detect_missing_value.isEmpty()
22                                      && !field->default_value.isEmpty()
23                                      && field->detect_missing_value == true);
24    if (detectMissingValue)
25    {
26      const double missingValue = field->default_value;
27      const size_t nbData = packet->data.numElements();
28      for (size_t idx = 0; idx < nbData; ++idx)
29      {
30        if (NumTraits<double>::isnan(packet->data(idx)))
31          packet->data(idx) = missingValue;
32      }
33    }
34
35    field->sendUpdateData(packet->data);
36  }
37
38  bool CFileWriterFilter::isDataExpected(const CDate& date) const
39  {
40    return true;
41  }
42} // namespace xios
Note: See TracBrowser for help on using the repository browser.