Ignore:
Timestamp:
09/05/17 16:49:13 (3 years ago)
Author:
oabramkina
Message:

Fixing a bug in case of activated missing values. If nan values are replaced by default values or vice versa data package (or data) is copied.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/filter/file_writer_filter.cpp

    r1201 r1251  
    1717  void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    1818  { 
    19     CDataPacketPtr packet = data[0]; 
    20  
    2119    const bool detectMissingValue = (!field->detect_missing_value.isEmpty() 
    2220                                      && !field->default_value.isEmpty() 
    2321                                      && field->detect_missing_value == true); 
     22 
     23    CArray<double, 1> dataArray = (detectMissingValue) ? data[0]->data.copy() : data[0]->data; 
     24 
    2425    if (detectMissingValue) 
    2526    { 
    2627      const double missingValue = field->default_value; 
    27       const size_t nbData = packet->data.numElements(); 
     28      const size_t nbData = dataArray.numElements(); 
    2829      for (size_t idx = 0; idx < nbData; ++idx) 
    2930      { 
    30         if (NumTraits<double>::isnan(packet->data(idx))) 
    31           packet->data(idx) = missingValue; 
     31        if (NumTraits<double>::isnan(dataArray(idx))) 
     32          dataArray(idx) = missingValue; 
    3233      } 
    3334    } 
    3435 
    35     field->sendUpdateData(packet->data); 
     36    field->sendUpdateData(dataArray); 
    3637  } 
    3738 
Note: See TracChangeset for help on using the changeset viewer.