20 #ifndef PISM_UTILITIES_H
21 #define PISM_UTILITIES_H
38 double floatation_level,
39 double rho_ice,
double rho_water,
double g);
44 # define __attribute__(x)
52 const std::string &separator,
53 const std::string &suffix);
62 bool ends_with(
const std::string &str,
const std::string &suffix);
67 std::string
join(
const std::vector<std::string> &strings,
const std::string &separator);
69 std::vector<std::string>
split(
const std::string &input,
char separator);
71 std::set<std::string>
set_split(
const std::string &input,
char separator);
73 std::string
set_join(
const std::set<std::string> &input,
const std::string& separator);
78 bool member(
const std::string &
string,
const std::set<std::string> &set);
97 for (
const auto &element : b) {
98 result.insert(element);
108 double vector_min(
const std::vector<double> &input);
110 double vector_max(
const std::vector<double> &input);
113 void GlobalReduce(MPI_Comm comm,
double *local,
double *result,
int count, MPI_Op op);
117 void GlobalMin(MPI_Comm comm,
double *local,
double *result,
int count);
119 void GlobalMax(MPI_Comm comm,
double *local,
double *result,
int count);
121 void GlobalMax(MPI_Comm comm,
int *local,
int *result,
int count);
123 void GlobalSum(MPI_Comm comm,
double *local,
double *result,
int count);
125 void GlobalSum(MPI_Comm comm,
int *local,
int *result,
int count);
127 double GlobalMin(MPI_Comm comm,
double local);
129 double GlobalMax(MPI_Comm comm,
double local);
131 double GlobalSum(MPI_Comm comm,
double local);
133 unsigned int GlobalSum(MPI_Comm comm,
unsigned int input);
143 uint64_t
fletcher64(const uint32_t *data,
size_t len);
146 const std::vector<
double> &data,
150 const std::vector<
double> &data,
154 const std::vector<
int> &data,
double max(const array::Scalar &input)
Finds maximum over all the values in an array::Scalar object. Ignores ghosts.
double min(const array::Scalar &input)
Finds minimum over all the values in an array::Scalar object. Ignores ghosts.
double get_time(MPI_Comm comm)
bool is_increasing(const std::vector< double > &a)
Checks if a vector of doubles is strictly increasing.
double parse_number(const std::string &input)
double average_water_column_pressure(double ice_thickness, double bed, double floatation_level, double rho_ice, double rho_water, double g)
double wall_clock_hours(MPI_Comm com, double start_time)
Return time since the beginning of the run, in hours.
static double start_time(const Config &config, const Logger &log, const File *file, const std::string &reference_date, const std::string &calendar, const units::Unit &time_units)
void print_checksum(MPI_Comm com, const std::vector< double > &data, const char *label)
bool ends_with(const std::string &str, const std::string &suffix)
Returns true if str ends with suffix and false otherwise.
void GlobalMax(MPI_Comm comm, double *local, double *result, int count)
std::string set_join(const std::set< std::string > &input, const std::string &separator)
std::string printf(const char *format,...)
void print_vector(MPI_Comm com, const std::vector< double > &data, const char *label)
uint64_t fletcher64(const uint32_t *data, size_t length)
void validate_format_string(const std::string &format)
std::set< std::string > set_split(const std::string &input, char separator)
Transform a separator-separated list (a string) into a set of strings.
double vector_min(const std::vector< double > &input)
std::string string_strip(const std::string &input)
std::string filename_add_suffix(const std::string &filename, const std::string &separator, const std::string &suffix)
Adds a suffix to a filename.
std::string timestamp(MPI_Comm com)
Creates a time-stamp used for the history NetCDF attribute.
bool member(const std::string &string, const std::set< std::string > &set)
void GlobalMin(MPI_Comm comm, double *local, double *result, int count)
std::string args_string()
Uses argc and argv to create the string with current PISM command-line arguments.
T combine(const T &a, const T &b)
long int parse_integer(const std::string &input)
std::string join(const std::vector< std::string > &strings, const std::string &separator)
Concatenate strings, inserting separator between elements.
void GlobalSum(MPI_Comm comm, double *local, double *result, int count)
std::string username_prefix(MPI_Comm com)
Creates a string with the user name, hostname and the time-stamp (for history strings).
void GlobalReduce(MPI_Comm comm, double *local, double *result, int count, MPI_Op op)
std::string replace_character(const std::string &input, char from, char to)
double vector_max(const std::vector< double > &input)
std::vector< std::string > split(const std::string &input, char separator)
Transform a separator-separated list (a string) into a vector of strings.