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