URI:
       tTime_Calendar.hh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
  HTML git clone git://src.adamsgaard.dk/pism
   DIR Log
   DIR Files
   DIR Refs
   DIR LICENSE
       ---
       tTime_Calendar.hh (3159B)
       ---
            1 // Copyright (C) 2012, 2013, 2014, 2015, 2017 PISM Authors
            2 //
            3 // This file is part of PISM.
            4 //
            5 // PISM is free software; you can redistribute it and/or modify it under the
            6 // terms of the GNU General Public License as published by the Free Software
            7 // Foundation; either version 3 of the License, or (at your option) any later
            8 // version.
            9 //
           10 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
           11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
           12 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
           13 // details.
           14 //
           15 // You should have received a copy of the GNU General Public License
           16 // along with PISM; if not, write to the Free Software
           17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
           18 
           19 #ifndef _PISMGREGORIANTIME_H_
           20 #define _PISMGREGORIANTIME_H_
           21 
           22 #include "Time.hh"
           23 #include "Units.hh"
           24 
           25 namespace pism {
           26 
           27 class Time_Calendar : public Time
           28 {
           29 public:
           30   Time_Calendar(MPI_Comm c, Config::ConstPtr conf,
           31                 const std::string &calendar,
           32                 units::System::Ptr units_system);
           33   virtual ~Time_Calendar();
           34 
           35   virtual void init(const Logger &log);
           36 
           37   virtual void init_from_file(const std::string &filename, const Logger &log,
           38                               bool set_start_time);
           39 
           40   virtual void init_from_input_file(const File &nc,
           41                                     const std::string &time_name,
           42                                     const Logger &log);
           43 
           44   virtual double mod(double time, unsigned int) const;
           45 
           46   virtual double year_fraction(double T) const;
           47 
           48   virtual std::string date(double T) const;
           49 
           50   virtual std::string date() const;
           51 
           52   virtual std::string start_date() const;
           53 
           54   virtual std::string end_date() const;
           55 
           56   virtual std::string units_string() const {
           57     return CF_units_string();
           58   }
           59 
           60   virtual std::string CF_units_string() const {
           61     return m_time_units.format();
           62   }
           63 
           64   virtual std::string CF_units_to_PISM_units(const std::string &input) const {
           65     return input;               // return unchanged CF units
           66   }
           67 
           68   virtual bool use_reference_date() {
           69     return true;
           70   }
           71 
           72   virtual double calendar_year_start(double T) const;
           73 
           74   virtual double increment_date(double T, int years) const;
           75 
           76 protected:
           77   virtual void compute_times(double time_start, double delta, double time_end,
           78                              const std::string &keyword,
           79                              std::vector<double> &result) const;
           80 
           81   virtual bool process_ys(double &result);
           82   virtual bool process_y(double &result);
           83   virtual bool process_ye(double &result);
           84 
           85   virtual void parse_date(const std::string &spec, double *result) const;
           86 
           87   virtual void parse_interval_length(const std::string &spec,
           88                                      std::string &keyword, double *result) const;
           89 
           90   void compute_times_monthly(std::vector<double> &result) const;
           91 
           92   void compute_times_yearly(std::vector<double> &result) const;
           93 private:
           94   MPI_Comm m_com;
           95   // Hide copy constructor / assignment operator.
           96   Time_Calendar(Time_Calendar const &);
           97   Time_Calendar & operator=(Time_Calendar const &);
           98 };
           99 
          100 
          101 } // end of namespace pism
          102 
          103 #endif /* _PISMGREGORIANTIME_H_ */