PISM, A Parallel Ice Sheet Model
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
pism::Time Class Reference

Time management class. More...

#include <Time.hh>

Classes

struct  Interval
 

Public Types

typedef std::shared_ptr< TimePtr
 
typedef std::shared_ptr< const TimeConstPtr
 

Public Member Functions

 Time (MPI_Comm com, Config::ConstPtr config, const Logger &log, units::System::Ptr unit_system)
 
virtual ~Time ()=default
 
void set (double new_time)
 Sets the current time (in seconds since the reference time). More...
 
void set_start (double new_start)
 
void set_end (double new_end)
 
void step (double delta_t)
 Advance by delta_t seconds. More...
 
double current () const
 Current time, in seconds. More...
 
double start () const
 
double end () const
 
std::string calendar () const
 Returns the calendar string. More...
 
std::string run_length () const
 Returns the length of the current run, in years. More...
 
void init_calendar (const std::string &calendar)
 
std::vector< double > parse_times (const std::string &spec) const
 
std::string units_string () const
 Internal time units. More...
 
double year_fraction (double T) const
 Returns the fraction of a year passed since the last beginning of a year. Only useful in codes with a "yearly cycle" (such as the PDD model). More...
 
double day_of_the_year_to_year_fraction (unsigned int day) const
 Convert the day number to the year fraction. More...
 
double calendar_year_start (double T) const
 Returns the model time in seconds corresponding to the beginning of the year T falls into. More...
 
double increment_date (double T, double years) const
 
std::string date (double T) const
 Returns the date corresponding to time T. More...
 
double convert_time_interval (double T, const std::string &units) const
 Convert time interval from seconds to given units. Handle 'years' using the year length corresponding to the calendar. More...
 

Protected Types

enum  IntervalType { YEARLY , MONTHLY , SIMPLE }
 

Protected Member Functions

std::vector< double > parse_list (const std::string &spec) const
 
std::vector< double > parse_range (const std::string &spec) const
 
void compute_times_simple (double time_start, double delta, double time_end, std::vector< double > &result) const
 
void compute_times (double time_start, double time_end, const Interval &interval, std::vector< double > &result) const
 
Interval parse_interval_length (const std::string &spec) const
 
double years_to_seconds (double input) const
 
double seconds_to_years (double input) const
 
void init_from_file (MPI_Comm com, const std::string &filename, const Logger &log, bool set_start_time)
 Sets the time from a NetCDF file with a time dimension (-time_file). More...
 
void compute_times_monthly (std::vector< double > &result) const
 
void compute_times_yearly (std::vector< double > &result) const
 

Protected Attributes

const Config::ConstPtr m_config
 
const units::System::Ptr m_unit_system
 
units::Unit m_time_units
 
double m_year_length
 number of seconds in a year, for "mod" and "year fraction" More...
 
double m_time_in_seconds
 current time, in seconds since the reference time More...
 
double m_run_start
 run start time, in seconds since the reference time More...
 
double m_run_end
 run end tim, in seconds since the reference time More...
 
std::string m_calendar_string
 CF calendar string. More...
 
bool m_simple_calendar
 

Detailed Description

Time management class.

This is to make it possible to switch between different implementations.

For example: 365-day no-leap calendar for spinups Gregorian calendar for XX-century forcing runs

This base class implements the 365-day no-leap version.

We want to be able to count time since a particular date, so it is helpful to keep in mind that the year "1986" in this context is not the year of the Chernobyl disaster but a year 1986 years since some date.

Definition at line 54 of file Time.hh.


The documentation for this class was generated from the following files: