Changeset 1119 for XIOS/trunk/src


Ignore:
Timestamp:
05/05/17 08:58:33 (7 years ago)
Author:
rlacroix
Message:

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.

Location:
XIOS/trunk/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/filter/file_writer_filter.cpp

    r1018 r1119  
    3333    field->sendUpdateData(data[0]->data); 
    3434  } 
     35 
     36  bool CFileWriterFilter::isDataExpected(const CDate& date) const 
     37  { 
     38    return true; 
     39  } 
    3540} // namespace xios 
  • XIOS/trunk/src/filter/file_writer_filter.hpp

    r639 r1119  
    2323      CFileWriterFilter(CGarbageCollector& gc, CField* field); 
    2424 
     25      /*! 
     26       * Tests whether data is expected for the specified date. 
     27       * 
     28       * \param date the date associated to the data 
     29       */ 
     30      bool virtual isDataExpected(const CDate& date) const; 
     31 
    2532    protected: 
    2633      /*! 
  • XIOS/trunk/src/filter/filter.cpp

    r1006 r1119  
    4040    return (CInputPin::canBeTriggered() || COutputPin::canBeTriggered()); 
    4141  } 
     42 
     43  bool CFilter::isDataExpected(const CDate& date) const 
     44  { 
     45    return COutputPin::isDataExpected(date); 
     46  } 
    4247} // namespace xios 
  • XIOS/trunk/src/filter/filter.hpp

    r1006 r1119  
    4848      bool virtual canBeTriggered() const; 
    4949 
     50      /*! 
     51       * Tests whether data is expected for the specified date. 
     52       * 
     53       * \param date the date associated to the data 
     54       */ 
     55      bool virtual isDataExpected(const CDate& date) const; 
     56 
    5057    protected: 
    5158      IFilterEngine* engine; //!< The filter engine, might be the filter itself 
  • XIOS/trunk/src/filter/input_pin.hpp

    r1006 r1119  
    6060 
    6161      /*! 
     62       * Tests whether data is expected for the specified date. 
     63       * 
     64       * \param date the date associated to the data 
     65       */ 
     66      bool virtual isDataExpected(const CDate& date) const = 0; 
     67 
     68      /*! 
    6269       * Removes all pending packets which are older than the specified timestamp. 
    6370       * 
  • XIOS/trunk/src/filter/output_pin.cpp

    r1006 r1119  
    7373  } 
    7474 
     75  bool COutputPin::isDataExpected(const CDate& date) const 
     76  { 
     77    std::vector<std::pair<boost::shared_ptr<CInputPin>, size_t> >::const_iterator it, itEnd; 
     78    for (it = outputs.begin(), itEnd = outputs.end(); it != itEnd; ++it) 
     79    { 
     80      if (it->first->isDataExpected(date)) 
     81        return true; 
     82    } 
     83 
     84    return false; 
     85  } 
     86 
    7587  void COutputPin::invalidate(Time timestamp) 
    7688  { 
  • XIOS/trunk/src/filter/output_pin.hpp

    r1006 r1119  
    4646 
    4747      /*! 
     48       * Tests whether data is expected for the specified date. 
     49       * 
     50       * \param date the date associated to the data 
     51       */ 
     52      bool virtual isDataExpected(const CDate& date) const; 
     53 
     54      /*! 
    4855       * Removes all pending packets which are older than the specified timestamp. 
    4956       * 
  • XIOS/trunk/src/filter/store_filter.cpp

    r1029 r1119  
    8181  } 
    8282 
     83  bool CStoreFilter::isDataExpected(const CDate& date) const 
     84  { 
     85    return true; 
     86  } 
     87 
    8388  void CStoreFilter::invalidate(Time timestamp) 
    8489  { 
  • XIOS/trunk/src/filter/store_filter.hpp

    r1006 r1119  
    5050 
    5151      /*! 
     52       * Tests whether data is expected for the specified date. 
     53       * 
     54       * \param date the date associated to the data 
     55       */ 
     56      bool virtual isDataExpected(const CDate& date) const; 
     57 
     58      /*! 
    5259       * Removes all pending packets which are older than the specified timestamp. 
    5360       * 
  • XIOS/trunk/src/filter/temporal_filter.cpp

    r1018 r1119  
    7575    return packet; 
    7676  } 
     77 
     78  bool CTemporalFilter::isDataExpected(const CDate& date) const 
     79  { 
     80    return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date + samplingFreq > nextOperationDate); 
     81  } 
    7782} // namespace xios 
  • XIOS/trunk/src/filter/temporal_filter.hpp

    r643 r1119  
    4040      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
    4141 
     42      /*! 
     43       * Tests whether data is expected for the specified date. 
     44       * 
     45       * \param date the date associated to the data 
     46       */ 
     47      bool virtual isDataExpected(const CDate& date) const; 
     48 
    4249    private: 
    4350      boost::scoped_ptr<func::CFunctor> functor; //!< The functor corresponding to the temporal operation 
  • XIOS/trunk/src/interface/c/icfield.cpp

    r943 r1119  
    7676// -----------------------------------------------------------------------------------------------------    
    7777 
    78   void cxios_field_is_active (XFieldPtr field_hdl, bool* ret) 
     78  void cxios_field_is_active (XFieldPtr field_hdl, bool at_current_timestep, bool* ret) 
    7979  { 
    8080    CTimer::get("XIOS").resume() ; 
    81     *ret = field_hdl->isActive(); 
     81    *ret = field_hdl->isActive(at_current_timestep); 
    8282    CTimer::get("XIOS").suspend() ; 
    8383  } 
  • XIOS/trunk/src/interface/fortran/field_interface.f90

    r943 r1119  
    1818      END SUBROUTINE cxios_field_valid_id 
    1919 
    20       SUBROUTINE cxios_field_is_active(field_hdl, ret) BIND(C) 
     20      SUBROUTINE cxios_field_is_active(field_hdl, at_current_timestep, ret) BIND(C) 
    2121         USE ISO_C_BINDING 
    2222         INTEGER  (kind = C_INTPTR_T), VALUE        :: field_hdl 
     23         LOGICAL  (kind = C_BOOL), VALUE            :: at_current_timestep 
    2324         LOGICAL  (kind = C_BOOL)                   :: ret 
    2425      END SUBROUTINE cxios_field_is_active 
  • XIOS/trunk/src/interface/fortran/ifield.F90

    r943 r1119  
    142142   END FUNCTION  xios(is_valid_fieldgroup) 
    143143    
    144   LOGICAL FUNCTION xios(field_is_active_id(field_id)) 
     144  LOGICAL FUNCTION xios(field_is_active_id)(field_id, at_current_timestep_arg) 
    145145      IMPLICIT NONE 
    146       CHARACTER(len  = *)    , INTENT(IN) :: field_id 
    147       LOGICAL  (kind = 1)                 :: val 
    148       TYPE(txios(field))                 :: field_hdl 
    149        
     146      CHARACTER(len  = *) , INTENT(IN) :: field_id 
     147      LOGICAL, OPTIONAL   , INTENT(IN) :: at_current_timestep_arg 
     148      TYPE(txios(field))               :: field_hdl 
     149 
    150150      CALL xios(get_field_handle)(field_id,field_hdl) 
    151       xios(field_is_active_id)=xios(field_is_active_hdl(field_hdl)) 
     151      xios(field_is_active_id) = xios(field_is_active_hdl)(field_hdl, at_current_timestep_arg) 
    152152 
    153    END FUNCTION  xios(field_is_active_id) 
    154     
    155     
    156    LOGICAL FUNCTION xios(field_is_active_hdl(field_hdl)) 
     153   END FUNCTION xios(field_is_active_id) 
     154 
     155   LOGICAL FUNCTION xios(field_is_active_hdl)(field_hdl, at_current_timestep_arg) 
    157156      IMPLICIT NONE 
    158       TYPE(txios(field)),INTENT(IN)       :: field_hdl 
    159       LOGICAL  (kind = 1)                 :: ret 
    160        
    161       CALL cxios_field_is_active(field_hdl%daddr, ret); 
     157      TYPE(txios(field)) , INTENT(IN) :: field_hdl 
     158      LOGICAL, OPTIONAL  , INTENT(IN) :: at_current_timestep_arg 
     159      LOGICAL(kind = C_BOOL)          :: at_current_timestep 
     160      LOGICAL(kind = C_BOOL)          :: ret 
     161 
     162      IF (PRESENT(at_current_timestep_arg)) THEN 
     163         at_current_timestep = at_current_timestep_arg 
     164      ELSE 
     165         at_current_timestep = .FALSE. 
     166      ENDIF 
     167 
     168      CALL cxios_field_is_active(field_hdl%daddr, at_current_timestep, ret); 
    162169      xios(field_is_active_hdl) = ret 
    163170       
    164    END FUNCTION  xios(field_is_active_hdl)  
     171   END FUNCTION xios(field_is_active_hdl) 
    165172  
    166  
    167173END MODULE IFIELD 
  • XIOS/trunk/src/node/field.cpp

    r1018 r1119  
    518518   //---------------------------------------------------------------- 
    519519 
    520    bool CField::isActive(void) const 
    521    { 
    522       return (instantDataFilter != NULL); 
     520   bool CField::isActive(bool atCurrentTimestep /*= false*/) const 
     521   { 
     522      if (atCurrentTimestep && clientSourceFilter) 
     523        return clientSourceFilter->isDataExpected(CContext::getCurrent()->getCalendar()->getCurrentDate()); 
     524      else 
     525        return (instantDataFilter != NULL); 
    523526   } 
    524527 
  • XIOS/trunk/src/node/field.hpp

    r1017 r1119  
    9797 
    9898       public: 
    99          bool isActive(void) const; 
     99         bool isActive(bool atCurrentTimestep = false) const; 
    100100         bool hasOutputFile; 
    101101 
Note: See TracChangeset for help on using the changeset viewer.