TECA
The Toolkit for Extreme Climate Analysis
teca_cf_interval_time_step_mapper.h
1 #ifndef teca_cf_interval_time_step_mapper_h
2 #define teca_cf_interval_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_calendar_util.h"
9 #include "teca_mpi.h"
10 
11 #include <iostream>
12 #include <sstream>
13 #include <cstring>
14 #include <cerrno>
15 #include <string>
16 #include <unordered_map>
17 #include <vector>
18 #include <memory>
19 
21 using p_teca_cf_interval_time_step_mapper = std::shared_ptr<teca_cf_interval_time_step_mapper>;
22 
23 /// NetCDF CF2 files time step mapper.
25 {
26 public:
27 
28  // allocate and return a new object
29  static p_teca_cf_interval_time_step_mapper New()
30  { return p_teca_cf_interval_time_step_mapper(new teca_cf_interval_time_step_mapper); }
31 
33 
34  // initialize based on input metadata. this is a collective call
35  // creates communicator groups for each file and creates the
36  // file layout managers for the local rank. After this call
37  // on can access file managers to create, define and write
38  // local datasets to the NetCDF files in cf format.
39  int initialize(MPI_Comm comm, long first_step, long last_step,
40  const teca_calendar_util::p_interval_iterator &it,
41  const teca_metadata &md);
42 
43  // given a time step, get the corresponding layout manager that
44  // can be used to create, define and write data to disk.
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_interval_time_step_mapper() : file_steps()
52  {}
53 
54  // remove these for convenience
57  void operator=(const teca_cf_interval_time_step_mapper&) = delete;
58  void operator=(const teca_cf_interval_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  //using teca_calendar_util::time_point;
65  //using step_bracket_t = std::pair<time_point, time_point>;
66  using step_bracket_t = std::pair<long, long>;
67  std::vector<step_bracket_t> file_steps;
68 };
69 
70 #endif
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_interval_time_step_mapper
NetCDF CF2 files time step mapper.
Definition: teca_cf_interval_time_step_mapper.h:24
teca_calendar_util.h
teca_error::TECA_EXPORT
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.