PISM, A Parallel Ice Sheet Model  stable v1.2 committed by Constantine Khrulev on 2020-02-11 20:24:05 -0900
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
pism::Time Class Reference

Time management class. More...

#include <Time.hh>

+ Inheritance diagram for pism::Time:

Public Types

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

Public Member Functions

 Time (Config::ConstPtr conf, const std::string &calendar, units::System::Ptr units_system)
 
virtual ~Time ()
 
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...
 
virtual void init (const Logger &log)
 Intialize using command-line options. More...
 
virtual void init_from_input_file (const File &nc, const std::string &time_name, const Logger &log)
 Set start time from a PISM input file. More...
 
void init_calendar (const std::string &calendar)
 
std::vector< doubleparse_times (const std::string &spec) const
 
virtual std::string CF_units_string () const
 Returns the CF- (and UDUNITS) compliant units string. More...
 
virtual std::string units_string () const
 Internal time units. More...
 
virtual std::string CF_units_to_PISM_units (const std::string &input) const
 
virtual double mod (double time, unsigned int period_years) const
 Returns time since the origin modulo period. More...
 
virtual 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...
 
virtual double day_of_the_year_to_day_fraction (unsigned int day) const
 Convert the day number to the year fraction. More...
 
virtual double calendar_year_start (double T) const
 Returns the model time in seconds corresponding to the beginning of the year T falls into. More...
 
virtual double increment_date (double T, int years) const
 
virtual std::string date (double T) const
 Returns the date corresponding to time T. More...
 
virtual std::string date () const
 Returns current time, in years. Only for reporting. More...
 
double current_years () const
 Returns current time, in years. Only for debugging. More...
 
virtual std::string start_date () const
 Date corresponding to the beginning of the run. More...
 
virtual std::string end_date () const
 Date corresponding to the end of the run. More...
 
virtual 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...
 
double years_to_seconds (double input) const
 
double seconds_to_years (double input) const
 

Protected Member Functions

std::vector< doubleparse_list (const std::string &spec) const
 
std::vector< doubleparse_range (const std::string &spec) const
 
void compute_times_simple (double time_start, double delta, double time_end, std::vector< double > &result) const
 
virtual bool process_ys (double &result)
 
virtual bool process_y (double &result)
 
virtual bool process_ye (double &result)
 
virtual void compute_times (double time_start, double delta, double time_end, const std::string &keyword, std::vector< double > &result) const
 
virtual void parse_date (const std::string &spec, double *result) const
 
virtual void parse_interval_length (const std::string &spec, std::string &keyword, 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...
 

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 66 of file Time.hh.


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