1 #ifndef teca_cf_time_step_mapper_h
2 #define teca_cf_time_step_mapper_h
4 #include "teca_metadata.h"
5 #include "teca_cf_layout_manager.h"
13 #include <unordered_map>
18 using p_teca_cf_time_step_mapper = std::shared_ptr<teca_cf_time_step_mapper>;
25 static p_teca_cf_time_step_mapper New()
35 int initialize(MPI_Comm comm,
long first_step,
long last_step,
39 bool initialized() {
return this->file_comms.size(); }
47 std::vector<teca_metadata> &up_reqs);
51 p_teca_cf_layout_manager get_layout_manager(
long time_step);
54 int to_stream(std::ostream &os);
64 template<
typename op_t>
65 int file_table_apply(
const op_t &op);
69 index_request_key(
""), start_time_step(0), end_time_step(-1),
70 n_files(0), n_time_steps_per_file(1)
80 int alloc_file_comms();
81 int free_file_comms();
84 int get_file_id(
long time_step,
long &file_id);
91 std::string index_initializer_key;
92 std::string index_request_key;
100 std::vector<long> block_size;
101 std::vector<long> block_start;
105 long n_time_steps_per_file;
106 std::vector<std::set<int>> file_ranks;
109 std::vector<MPI_Comm> file_comms;
112 using file_table_t = std::unordered_map<long, p_teca_cf_layout_manager>;
113 file_table_t file_table;
118 template<
typename op_t>
119 int teca_cf_time_step_mapper::file_table_apply(
const op_t &op)
121 for (
long i = 0; i < this->n_files; ++i)
123 MPI_Comm comm_i = this->file_comms[i];
124 if (comm_i != MPI_COMM_NULL)
126 if (
int ierr = op(comm, i, this->file_table[i]))