1 #ifndef teca_cf_layout_manager_h
2 #define teca_cf_layout_manager_h
4 #include "teca_config.h"
5 #include "teca_metadata.h"
7 #include "teca_array_collection.h"
17 using p_teca_cf_layout_manager = std::shared_ptr<teca_cf_layout_manager>;
27 static p_teca_cf_layout_manager
New(MPI_Comm comm,
28 long file_id,
long first_index,
long n_indices)
30 return p_teca_cf_layout_manager(
32 first_index, n_indices));
36 int create(
const std::string &file_name,
const std::string &date_format,
37 const teca_metadata &md_in,
int mode_flags,
int use_unlimited_dim,
int stride);
60 const std::vector<std::string> &point_arrays,
61 const std::vector<std::string> &info_arrays,
62 int collective_buffer,
int compression_level,
63 bool move_vars_to_root);
67 const const_p_teca_array_collection &point_arrays,
68 const const_p_teca_array_collection &info_arrays);
82 int write(
const unsigned long extent[6],
83 const unsigned long temporal_extent[2],
84 const const_p_teca_array_collection &point_arrays,
85 const const_p_teca_array_collection &info_arrays,
89 int close() {
return this->handle.close(); }
92 bool opened() {
return bool(this->handle); }
95 bool defined() {
return this->n_dims > 0; }
101 return this->n_written == this->n_indices;
108 int to_stream(std::ostream &os);
112 first_index(-1), n_indices(-1), n_written(0), n_dims(0),
117 long fid,
long first_id,
long n_ids) : comm(fcomm), file_id(fid),
118 first_index(first_id), n_indices(n_ids), n_written(0), n_dims(0),
134 std::string file_name;
145 int use_unlimited_dim;
149 unsigned long whole_extent[6];
153 var_def_t() : parent_id(0), var_id(0), type_code(0), active_dims{0,0,0,0} {}
155 var_def_t(
int pid,
int aid,
unsigned int atc,
const std::array<int,4> &ada) :
156 parent_id(pid), var_id(aid), type_code(atc), active_dims(ada) {}
158 var_def_t(
int pid,
int aid,
unsigned int atc) :
159 parent_id(pid), var_id(aid), type_code(atc), active_dims{0,0,0,0} {}
163 unsigned int type_code;
164 std::array<int,4> active_dims;
167 std::map<std::string, var_def_t> var_def;
168 std::string t_variable;
Puts data on disk using NetCDF CF2 conventions.
Definition: teca_cf_layout_manager.h:21
int define(const teca_metadata &md, unsigned long *whole_extent, const std::vector< std::string > &point_arrays, const std::vector< std::string > &info_arrays, int collective_buffer, int compression_level, bool move_vars_to_root)
int write(long index, const const_p_teca_array_collection &point_arrays, const const_p_teca_array_collection &info_arrays)
writes the collection of arrays to the NetCDF file in the correct spot.
int create(const std::string &file_name, const std::string &date_format, const teca_metadata &md_in, int mode_flags, int use_unlimited_dim, int stride)
creates the NetCDF file. This is an MPI collective call.
int write(const unsigned long extent[6], const unsigned long temporal_extent[2], const const_p_teca_array_collection &point_arrays, const const_p_teca_array_collection &info_arrays, int stride)
A RAII class for managing NETCDF files. The file is kept open while the object exists.
Definition: teca_netcdf_util.h:133
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.
auto New(size_t n_elem, teca_variant_array::allocator alloc=teca_variant_array::allocator::malloc)
Definition: teca_variant_array_util.h:269
Definition: teca_cf_layout_manager.h:152
std::shared_ptr< teca_variant_array > p_teca_variant_array
Definition: teca_variant_array.h:27