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 teca_metadata &md);
41 
42  /** given a time step, get the corresponding layout manager that can be
43  * used to create, define and write data to disk.
44  */
45  p_teca_cf_layout_manager get_layout_manager(long time_step) override;
46 
47  /// print a summary to the stream
48  int to_stream(std::ostream &os) override;
49 
50 protected:
51  teca_cf_block_time_step_mapper() : n_time_steps_per_file(1)
52  {}
53 
54  // remove these for convenience
57  void operator=(const teca_cf_block_time_step_mapper&) = delete;
58  void operator=(const teca_cf_block_time_step_mapper&&) = delete;
59 
60  // given a time step, get the corresponding file id
61  int get_file_id(long time_step, long &file_id);
62 
63 protected:
64  long n_time_steps_per_file;
65 };
66 
67 #endif
teca_cf_block_time_step_mapper
Maps time steps to files in fixed sized blocks.
Definition: teca_cf_block_time_step_mapper.h:23
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:21
teca_cf_time_step_mapper
Defines the interface for mapping time steps to files.
Definition: teca_cf_time_step_mapper.h:22
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:28
teca_error::TECA_EXPORT
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.