1 #ifndef teca_cf_time_step_mapper_h
2 #define teca_cf_time_step_mapper_h
4 #include "teca_config.h"
5 #include "teca_metadata.h"
6 #include "teca_cf_layout_manager.h"
14 #include <unordered_map>
19 using p_teca_cf_time_step_mapper = std::shared_ptr<teca_cf_time_step_mapper>;
28 virtual bool initialized() {
return this->file_comms.size(); }
37 std::vector<teca_metadata> &up_reqs);
41 { (void) time_step;
return nullptr; }
55 std::vector<p_teca_cf_layout_manager> &managers)
58 managers.push_back(this->get_layout_manager(temporal_extent[0]));
59 return managers.back() ? 0 : -1;
74 template<
typename op_t>
75 int file_table_apply(
const op_t &op);
79 index_request_key(
""), start_time_step(0), end_time_step(-1),
91 int free_file_comms();
99 std::string index_request_key;
107 std::vector<long> block_size;
108 std::vector<long> block_start;
112 std::vector<std::set<int>> file_ranks;
118 using file_table_t = std::unordered_map<long, p_teca_cf_layout_manager>;
124 template<
typename op_t>
127 for (
long i = 0; i < this->
n_files; ++i)
130 if (comm_i != MPI_COMM_NULL)
132 if (
int ierr = op(
comm, i, this->file_table[i]))
Defines the interface for mapping time steps to files.
Definition: teca_cf_time_step_mapper.h:23
std::string index_initializer_key
pipeline control key names
Definition: teca_cf_time_step_mapper.h:98
long n_files
output files
Definition: teca_cf_time_step_mapper.h:111
std::unordered_map< long, p_teca_cf_layout_manager > file_table_t
the file table maps from a time step to a specific layout manager
Definition: teca_cf_time_step_mapper.h:118
long n_time_steps
time_steps to request by rank
Definition: teca_cf_time_step_mapper.h:106
std::vector< MPI_Comm > file_comms
per file communicators
Definition: teca_cf_time_step_mapper.h:115
MPI_Comm comm
communicator to partition into per-file communicators
Definition: teca_cf_time_step_mapper.h:95
int alloc_file_comms()
create/free the per-file communicators
virtual bool initialized()
returns true if the mapper has been successfully initialized
Definition: teca_cf_time_step_mapper.h:28
long start_time_step
user provided overrides
Definition: teca_cf_time_step_mapper.h:102
virtual int get_layout_manager(const unsigned long temporal_extent[2], std::vector< p_teca_cf_layout_manager > &managers)
Definition: teca_cf_time_step_mapper.h:54
virtual int to_stream(std::ostream &os)=0
print a summary to the stream
int file_table_apply(const op_t &op)
Definition: teca_cf_time_step_mapper.h:125
virtual p_teca_cf_layout_manager get_layout_manager(long time_step)
given a time step returns the associated layout manager
Definition: teca_cf_time_step_mapper.h:40
virtual int get_upstream_requests(teca_metadata base_req, std::vector< teca_metadata > &up_reqs)
construct requests for this rank
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.