20 #include <gsl/gsl_math.h>
22 #include "pism/coupler/AtmosphereModel.hh"
23 #include "pism/util/Time.hh"
24 #include "pism/util/error_handling.hh"
25 #include "pism/util/MaxTimestep.hh"
26 #include "pism/util/Context.hh"
29 namespace atmosphere {
34 result->set_attrs(
"climate_forcing",
"mean annual near-surface air temperature",
35 "Kelvin",
"Kelvin",
"", 0);
42 result->set_attrs(
"climate_forcing",
"precipitation rate",
43 "kg m-2 second-1",
"kg m-2 year-1",
44 "precipitation_flux", 0);
55 std::shared_ptr<AtmosphereModel> input)
98 namespace diagnostics {
109 set_attrs(
"instantaneous value of the near-surface air temperature",
111 "Kelvin",
"Kelvin", 0);
117 result->metadata(0) =
m_vars[0];
119 std::vector<double> current_time(1,
m_grid->ctx()->time()->current());
120 std::vector<double> temperature(1, 0.0);
122 model->init_timeseries(current_time);
124 model->begin_pointwise_access();
130 const int i = p.i(), j = p.j();
132 model->temp_time_series(i, j, temperature);
134 (*result)(i, j) = temperature[0];
141 model->end_pointwise_access();
156 set_attrs(
"effective mean-annual near-surface air temperature",
"",
157 "Kelvin",
"Kelvin", 0);
163 result->metadata(0) =
m_vars[0];
165 result->copy_from(
model->mean_annual_temp());
180 set_attrs(
"effective precipitation rate",
181 "precipitation_flux",
182 "kg m-2 second-1",
"kg m-2 year-1", 0);
188 result->metadata(0) =
m_vars[0];
190 result->copy_from(
model->mean_precipitation());
216 {
"air_temp_snapshot",
Diagnostic::Ptr(
new AirTemperatureSnapshot(
this))},
Makes sure that we call begin_access() and end_access() for all accessed IceModelVecs.
IceGrid::ConstPtr grid() const
DiagnosticList diagnostics() const
A class defining a common interface for most PISM sub-models.
const AtmosphereModel * model
A template derived from Diagnostic, adding a "Model".
const units::System::Ptr m_sys
the unit system
std::vector< SpatialVariableMetadata > m_vars
metadata corresponding to NetCDF variables
std::shared_ptr< Diagnostic > Ptr
IceGrid::ConstPtr m_grid
the grid
void set_attrs(const std::string &long_name, const std::string &standard_name, const std::string &units, const std::string &glaciological_units, unsigned int N=0)
A method for setting common variable attributes.
High-level PISM I/O class.
std::shared_ptr< const IceGrid > ConstPtr
std::shared_ptr< IceModelVec2S > Ptr
std::shared_ptr< IceModelVec > Ptr
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
void failed()
Indicates a failure of a parallel section.
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
virtual DiagnosticList diagnostics_impl() const
void update(const Geometry &geometry, double t, double dt)
virtual TSDiagnosticList ts_diagnostics_impl() const
const IceModelVec2S & mean_annual_temp() const
Sets result to the mean annual near-surface air temperature, in degrees Kelvin.
virtual void update_impl(const Geometry &geometry, double t, double dt)=0
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
virtual void init_timeseries_impl(const std::vector< double > &ts) const
virtual const IceModelVec2S & mean_precipitation_impl() const
void init_timeseries(const std::vector< double > &ts) const
virtual void init_impl(const Geometry &geometry)=0
virtual const IceModelVec2S & mean_annual_temp_impl() const
void begin_pointwise_access() const
void init(const Geometry &geometry)
virtual void precip_time_series_impl(int i, int j, std::vector< double > &result) const
virtual void begin_pointwise_access_impl() const
std::shared_ptr< AtmosphereModel > m_input_model
void end_pointwise_access() const
void temp_time_series(int i, int j, std::vector< double > &result) const
Sets a pre-allocated N-element array "result" to the time-series of near-surface air temperature (deg...
const IceModelVec2S & mean_precipitation() const
Sets result to the mean precipitation, in m/s ice equivalent.
AtmosphereModel(IceGrid::ConstPtr g)
virtual void end_pointwise_access_impl() const
virtual void temp_time_series_impl(int i, int j, std::vector< double > &result) const
virtual MaxTimestep max_timestep_impl(double my_t) const
std::vector< double > m_ts_times
static IceModelVec2S::Ptr allocate_precipitation(IceGrid::ConstPtr grid)
void precip_time_series(int i, int j, std::vector< double > &result) const
Sets a pre-allocated N-element array "result" to the time-series of ice-equivalent precipitation (m/s...
static IceModelVec2S::Ptr allocate_temperature(IceGrid::ConstPtr grid)
A purely virtual class defining the interface of a PISM Atmosphere Model.
AirTemperatureSnapshot(const AtmosphereModel *m)
IceModelVec::Ptr compute_impl() const
Instantaneous near-surface air temperature.
IceModelVec::Ptr compute_impl() const
AirTemperature(const AtmosphereModel *m)
Effective near-surface mean-annual air temperature.
Precipitation(const AtmosphereModel *m)
IceModelVec::Ptr compute_impl() const
Effective precipitation rate (average over time step).
#define PISM_ERROR_LOCATION
std::map< std::string, TSDiagnostic::Ptr > TSDiagnosticList
std::map< std::string, Diagnostic::Ptr > DiagnosticList
T combine(const T &a, const T &b)