20 #ifndef PISM_IO_HELPERS_H
21 #define PISM_IO_HELPERS_H
29 #include "pism/util/Units.hh"
33 class VariableMetadata;
34 class SpatialVariableMetadata;
55 const Grid& internal_grid,
56 const std::vector<double> &internal_z_levels);
59 const Grid& internal_grid,
60 const LocalInterpCtx &lic,
65 const Grid& grid,
const File &file,
66 unsigned int time,
double *output);
69 const Grid& grid,
const File &file,
73 const VariableMetadata &metadata);
75 void define_time(
const File &file,
const Context &ctx);
80 void append_time(
const File &file,
const Config &ctx,
double time_seconds);
81 void append_time(
const File &nc,
const std::string &name,
double time_seconds);
84 const Grid &grid,
const File &file,
88 const std::string &dimension_name,
92 const std::string &dimension_name,
93 const std::string &bounds_name,
97 const Logger &log, std::vector<double> &data);
100 size_t t_start,
const std::vector<double> &data);
103 const VariableMetadata &metadata,
104 const Logger &log, std::vector<double> &data);
107 size_t t_start,
const std::vector<double> &data);
110 std::shared_ptr<units::System> unit_system,
112 const std::string &time_name,
113 const std::string &time_units,
114 std::vector<double> ×,
115 std::vector<double> &bounds);
119 const std::string &variable_name);
121 void read_attributes(
const File &file,
const std::string &variable_name, VariableMetadata &variable);
125 void read_valid_range(
const File &file,
const std::string &name, VariableMetadata &variable);
127 bool file_exists(MPI_Comm com,
const std::string &filename);
129 void move_if_exists(MPI_Comm com,
const std::string &file_to_move,
int rank_to_use = 0);
131 void remove_if_exists(MPI_Comm com,
const std::string &file_to_remove,
int rank_to_use = 0);
std::shared_ptr< System > Ptr
void append_time(const File &file, const Config &config, double time_seconds)
Prepare a file for output.
void regrid_spatial_variable(SpatialVariableMetadata &variable, const Grid &internal_grid, const LocalInterpCtx &lic, const File &file, double *output)
Regrid from a NetCDF file into a distributed array output.
void read_spatial_variable(const SpatialVariableMetadata &variable, const Grid &grid, const File &file, unsigned int time, double *output)
Read a variable from a file into an array output.
void read_timeseries(const File &file, const VariableMetadata &metadata, const Logger &log, std::vector< double > &data)
Read a time-series variable from a NetCDF file to a vector of doubles.
void define_dimension(const File &file, unsigned long int length, const VariableMetadata &metadata)
Define a dimension and the associated coordinate variable. Set attributes.
void write_spatial_variable(const SpatialVariableMetadata &metadata, const Grid &grid, const File &file, const double *input)
Write a double array to a file.
void write_attributes(const File &file, const VariableMetadata &variable, io::Type nctype)
Write variable attributes to a NetCDF file.
void define_time_bounds(const VariableMetadata &var, const std::string &dimension_name, const std::string &bounds_name, const File &file, io::Type nctype)
void check_input_grid(const grid::InputGridInfo &input_grid, const Grid &internal_grid, const std::vector< double > &internal_z_levels)
Check that x, y, and z coordinates of the input grid are strictly increasing.
void write_time_bounds(const File &file, const VariableMetadata &metadata, size_t t_start, const std::vector< double > &data)
void read_time_info(const Logger &log, std::shared_ptr< units::System > unit_system, const File &file, const std::string &time_name, const std::string &time_units, std::vector< double > ×, std::vector< double > &bounds)
void define_spatial_variable(const SpatialVariableMetadata &metadata, const Grid &grid, const File &file, io::Type default_type)
Define a NetCDF variable corresponding to a VariableMetadata object.
void read_time_bounds(const File &file, const VariableMetadata &metadata, const Logger &log, std::vector< double > &data)
void move_if_exists(MPI_Comm com, const std::string &file_to_move, int rank_to_use)
Moves the file aside (file.nc -> file.nc~).
void read_attributes(const File &file, const std::string &variable_name, VariableMetadata &variable)
void write_timeseries(const File &file, const VariableMetadata &metadata, size_t t_start, const std::vector< double > &data)
Write a time-series data to a file.
bool file_exists(MPI_Comm com, const std::string &filename)
void remove_if_exists(MPI_Comm com, const std::string &file_to_remove, int rank_to_use)
Check if a file is present are remove it.
void read_valid_range(const File &file, const std::string &name, VariableMetadata &variable)
Read the valid range information from a file.
std::string time_dimension(units::System::Ptr unit_system, const File &file, const std::string &variable_name)
void define_time(const File &file, const Context &ctx)
Prepare a file for output.
void define_timeseries(const VariableMetadata &var, const std::string &dimension_name, const File &file, io::Type nctype)
Define a NetCDF variable corresponding to a time-series.
static std::string calendar(const File *input_file, const Config &config, const Logger &log)