TECA
The Toolkit for Extreme Climate Analysis
teca_cf_block_time_step_mapper.h
1 #ifndef teca_cf_block_time_step_mapper_h
2 #define teca_cf_block_time_step_mapper_h
3 
4 #include "teca_config.h"
5 #include "teca_metadata.h"
6 #include "teca_cf_layout_manager.h"
7 #include "teca_cf_time_step_mapper.h"
8 #include "teca_mpi.h"
9 
10 #include <iostream>
11 #include <sstream>
12 #include <cstring>
13 #include <cerrno>
14 #include <string>
15 #include <unordered_map>
16 #include <vector>
17 #include <memory>
18 
20 using p_teca_cf_block_time_step_mapper = std::shared_ptr<teca_cf_block_time_step_mapper>;
21 
22 /// Maps time steps to files in fixed sized blocks
24 {
25 public:
26 
27  /// allocate and return a new object
28  static p_teca_cf_block_time_step_mapper New()
29  { return p_teca_cf_block_time_step_mapper(new teca_cf_block_time_step_mapper); }
30 
32 
33  /** initialize based on input metadata. this is a collective call creates
34  * communicator groups for each file and creates the file layout managers
35  * for the local rank. After this call on can access file managers to
36  * create, define and write local datasets to the NetCDF files in cf
37  * format.
38  */
39  int initialize(MPI_Comm comm, long first_step, long last_step,
40  long steps_per_file, const std::string &index_request_key);
41 
42  p_teca_cf_layout_manager get_layout_manager(long time_step) override;
44 
45  /// print a summary to the stream
46  int to_stream(std::ostream &os) override;
47 
48 protected:
49  teca_cf_block_time_step_mapper() : n_time_steps_per_file(1)
50  {}
51 
52  // remove these for convenience
55  void operator=(const teca_cf_block_time_step_mapper&) = delete;
56  void operator=(const teca_cf_block_time_step_mapper&&) = delete;
57 
58  // given a time step, get the corresponding file id
59  int get_file_id(long time_step, long &file_id);
60 
61 protected:
62  long n_time_steps_per_file;
63 };
64 
65 #endif
Maps time steps to files in fixed sized blocks.
Definition: teca_cf_block_time_step_mapper.h:24
int to_stream(std::ostream &os) override
print a summary to the stream
static p_teca_cf_block_time_step_mapper New()
allocate and return a new object
Definition: teca_cf_block_time_step_mapper.h:28
p_teca_cf_layout_manager get_layout_manager(long time_step) override
given a time step returns the associated layout manager
int initialize(MPI_Comm comm, long first_step, long last_step, long steps_per_file, const std::string &index_request_key)
Defines the interface for mapping time steps to files.
Definition: teca_cf_time_step_mapper.h:23
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
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.