Last change
on this file since 1145 was
1119,
checked in by rlacroix, 7 years ago
|
Add the ability to check if an output field is active at the current timestep.
The "xios_field_is_active" function can now take an optional logical argument that can be used to enable this new behavior.
|
File size:
1.1 KB
|
Line | |
---|
1 | #include "file_writer_filter.hpp" |
---|
2 | #include "exception.hpp" |
---|
3 | #include "field.hpp" |
---|
4 | #include "utils.hpp" |
---|
5 | |
---|
6 | namespace 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 | bool ignoreMissingValue = (!field->detect_missing_value.isEmpty() && |
---|
20 | !field->default_value.isEmpty() && |
---|
21 | field->detect_missing_value == true); |
---|
22 | if (ignoreMissingValue) |
---|
23 | { |
---|
24 | double missingValue = field->default_value; |
---|
25 | size_t nbData = data[0]->data.numElements(); |
---|
26 | for (size_t idx = 0; idx < nbData; ++idx) |
---|
27 | { |
---|
28 | if (NumTraits<double>::isnan(data[0]->data(idx))) |
---|
29 | data[0]->data(idx) = missingValue; |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | field->sendUpdateData(data[0]->data); |
---|
34 | } |
---|
35 | |
---|
36 | bool CFileWriterFilter::isDataExpected(const CDate& date) const |
---|
37 | { |
---|
38 | return true; |
---|
39 | } |
---|
40 | } // namespace xios |
---|
Note: See
TracBrowser
for help on using the repository browser.