TECA
The Toolkit for Extreme Climate Analysis
teca_index_executive.h
1 #ifndef teca_index_executive_h
2 #define teca_index_executive_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm_executive.h"
6 #include "teca_metadata.h"
7 #include "teca_mpi.h"
8 
9 #include <vector>
10 
11 TECA_SHARED_OBJECT_FORWARD_DECL(teca_index_executive)
12 
13 /// An executive that generates requests using a upstream or user defined index.
14 /** An extent or bounds to subset by, and list of arrays can be optionally set.
15  *
16  * metadata keys:
17  *
18  * requires:
19  *
20  * index_initializer_key -- holds the name of the key that tells how
21  * many indices are available. the named key
22  * must also be present and should contain the
23  * number of indices available
24  *
25  * index_request_key -- holds the name of the key used to request
26  * a specific index. request are generated with this
27  * name set to a specific index to be processed some
28  * upstream algorithm is expected to produce the
29  * data associated with the given index
30 */
32 {
33 public:
34  TECA_ALGORITHM_EXECUTIVE_STATIC_NEW(teca_index_executive)
35 
36  int initialize(MPI_Comm comm, const teca_metadata &md) override;
37  teca_metadata get_next_request() override;
38 
39  /// set the index to process
40  void set_index(long s);
41 
42  // Set the first time step in the series to process. The default is 0.
43  void set_start_index(long s);
44 
45  /** Set the last time step in the series to process. default is -1.
46  * negative number results in the last available time step being used.
47  */
48  void set_end_index(long s);
49 
50  /// Set the stride to process time steps at. The default is 1
51  void set_stride(long s);
52 
53  /// Set the extent to process. The default is taken from whole_extent key.
54  void set_extent(unsigned long *ext);
55 
56  /// @copydoc set_extent
57  void set_extent(const std::vector<unsigned long> &ext);
58 
59  /** Set the bounds to process. If nothing is set then extent as provided by
60  * set_extent is used.
61  */
62  void set_bounds(double *bounds);
63  void set_bounds(const std::vector<double> &bounds);
64 
65  /// Set the list of arrays to process
66  void set_arrays(const std::vector<std::string> &arrays);
67 
68 protected:
70 
71 private:
72  std::vector<teca_metadata> requests;
73  std::string index_initializer_key;
74  std::string index_request_key;
75  long start_index;
76  long end_index;
77  long stride;
78  std::vector<unsigned long> extent;
79  std::vector<double> bounds;
80  std::vector<std::string> arrays;
81 };
82 
83 #endif
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:18
teca_index_executive
An executive that generates requests using a upstream or user defined index.
Definition: teca_index_executive.h:31
teca_algorithm_executive
Base class and default implementation for executives.
Definition: teca_algorithm_executive.h:55
teca_shared_object.h