PISM, A Parallel Ice Sheet Model stable 0.4.1779

src/coupler/PISMAtmosphere.hh

Go to the documentation of this file.
00001 // Copyright (C) 2008-2011 Ed Bueler, Constantine Khroulev, Ricarda Winkelmann,
00002 // Gudfinna Adalgeirsdottir and Andy Aschwanden
00003 //
00004 // This file is part of PISM.
00005 //
00006 // PISM is free software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the Free Software
00008 // Foundation; either version 2 of the License, or (at your option) any later
00009 // version.
00010 //
00011 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
00012 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00014 // details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with PISM; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #ifndef __PISMAtmosphere_hh
00021 #define __PISMAtmosphere_hh
00022 
00023 #include "PISMComponent.hh"
00024 #include "iceModelVec.hh"
00025 #include "Timeseries.hh"
00026 #include "iceModelVec2T.hh"
00027 
00028 
00031 
00033 class PISMAtmosphereModel : public PISMComponent_TS {
00034 public:
00035   PISMAtmosphereModel(IceGrid &g, const NCConfigVariable &conf)
00036     : PISMComponent_TS(g, conf) {};
00037 
00039   virtual PetscErrorCode mean_precip(IceModelVec2S &result) = 0;
00040 
00042   virtual PetscErrorCode mean_annual_temp(IceModelVec2S &result) = 0;
00043 
00044   virtual PetscErrorCode begin_pointwise_access() = 0;
00045   virtual PetscErrorCode end_pointwise_access() = 0;
00046   
00051   virtual PetscErrorCode temp_time_series(int i, int j, int N,
00052                                           PetscReal *ts, PetscReal *values) = 0;
00055   virtual PetscErrorCode temp_snapshot(IceModelVec2S &result) = 0;
00056 };
00057 
00058 
00061 class PAConstant : public PISMAtmosphereModel {
00062 public:
00063   PAConstant(IceGrid &g, const NCConfigVariable &conf)
00064     : PISMAtmosphereModel(g, conf) {};
00065   virtual PetscErrorCode init(PISMVars &vars);
00066   virtual PetscErrorCode update(PetscReal t_years, PetscReal dt_years)
00067   { t = t_years; dt = dt_years; return 0; } // do nothing
00068   virtual PetscErrorCode mean_precip(IceModelVec2S &result);
00069   virtual PetscErrorCode mean_annual_temp(IceModelVec2S &result);
00070   virtual PetscErrorCode begin_pointwise_access();
00071   virtual PetscErrorCode end_pointwise_access();
00072   virtual PetscErrorCode temp_time_series(int i, int j, int N,
00073                                           PetscReal *ts, PetscReal *values);
00074   virtual void add_vars_to_output(string keyword, set<string> &result);
00075   virtual PetscErrorCode define_variables(set<string> vars, const NCTool &nc, nc_type nctype);
00076   virtual PetscErrorCode write_variables(set<string> vars, string filename);
00077   virtual PetscErrorCode temp_snapshot(IceModelVec2S &result);
00078 protected:
00079   string input_file;
00080   IceModelVec2S precip, temperature;
00081   NCSpatialVariable airtemp_var;
00082 };
00083 
00084 
00089 class PAYearlyCycle : public PISMAtmosphereModel {
00090 public:
00091   PAYearlyCycle(IceGrid &g, const NCConfigVariable &conf)
00092     : PISMAtmosphereModel(g, conf) {}
00093   virtual PetscErrorCode init(PISMVars &vars);
00094   virtual void add_vars_to_output(string keyword, set<string> &result);
00095   virtual PetscErrorCode define_variables(set<string> vars, const NCTool &nc, nc_type nctype);
00096   virtual PetscErrorCode write_variables(set<string> vars, string filename);
00098   virtual PetscErrorCode update(PetscReal t_years, PetscReal dt_years) = 0;
00099   virtual PetscErrorCode mean_precip(IceModelVec2S &result);
00100   virtual PetscErrorCode mean_annual_temp(IceModelVec2S &result);
00101   virtual PetscErrorCode begin_pointwise_access();
00102   virtual PetscErrorCode end_pointwise_access();
00103   virtual PetscErrorCode temp_time_series(int i, int j, int N,
00104                                           PetscReal *ts, PetscReal *values);
00105   virtual PetscErrorCode temp_snapshot(IceModelVec2S &result);
00106 protected:
00107   PISMVars *variables;
00108   PetscScalar snow_temp_july_day;
00109   string reference, precip_filename;
00110   IceModelVec2S temp_ma, temp_mj, precip;
00111   NCSpatialVariable airtemp_var;
00112 };
00113 
00114 
00119 class PA_SeaRISE_Greenland : public PAYearlyCycle {
00120 public:
00121   PA_SeaRISE_Greenland(IceGrid &g, const NCConfigVariable &conf)
00122     : PAYearlyCycle(g, conf)
00123   {
00124     paleo_precipitation_correction = false;
00125     dTforcing = NULL;
00126   }
00127 
00128   virtual ~PA_SeaRISE_Greenland()
00129   {
00130     delete dTforcing;
00131   }
00132   virtual PetscErrorCode init(PISMVars &vars);
00133   virtual PetscErrorCode update(PetscReal t_years, PetscReal dt_years);
00134   virtual PetscErrorCode mean_precip(IceModelVec2S &result);
00135 protected:
00136   bool paleo_precipitation_correction;
00137   Timeseries *dTforcing;
00138   IceModelVec2S *lat, *lon, *surfelev;
00139 };
00140 
00141 class PAModifier : public Modifier<PISMAtmosphereModel>
00142 {
00143 public:
00144   PAModifier(IceGrid &g, const NCConfigVariable &conf, PISMAtmosphereModel* in)
00145     : Modifier<PISMAtmosphereModel>(g, conf, in) {}
00146   virtual ~PAModifier() {}
00147 
00148   virtual PetscErrorCode mean_precip(IceModelVec2S &result)
00149   {
00150     PetscErrorCode ierr = input_model->mean_precip(result); CHKERRQ(ierr);
00151     return 0;
00152   }
00153 
00154   virtual PetscErrorCode mean_annual_temp(IceModelVec2S &result)
00155   {
00156     PetscErrorCode ierr = input_model->mean_annual_temp(result); CHKERRQ(ierr);
00157     return 0;
00158   }
00159 
00160   virtual PetscErrorCode begin_pointwise_access()
00161   {
00162     PetscErrorCode ierr = input_model->begin_pointwise_access(); CHKERRQ(ierr);
00163     return 0;
00164   }
00165 
00166   virtual PetscErrorCode end_pointwise_access()
00167   {
00168     PetscErrorCode ierr = input_model->end_pointwise_access(); CHKERRQ(ierr);
00169     return 0;
00170   }
00171   
00172   virtual PetscErrorCode temp_time_series(int i, int j, int N,
00173                                           PetscReal *ts, PetscReal *values)
00174   {
00175     PetscErrorCode ierr = input_model->temp_time_series(i, j, N, ts, values); CHKERRQ(ierr);
00176     return 0;
00177   }
00178 
00179   virtual PetscErrorCode temp_snapshot(IceModelVec2S &result)
00180   {
00181     PetscErrorCode ierr = input_model->temp_snapshot(result); CHKERRQ(ierr);
00182     return 0;
00183   }
00184 };
00185 
00188 
00197 class PAForcing : public PAModifier {
00198 public:
00199   PAForcing(IceGrid &g, const NCConfigVariable &conf, PISMAtmosphereModel *input);
00200   virtual ~PAForcing();
00201   virtual PetscErrorCode max_timestep(PetscReal t_years, PetscReal &dt_years);
00202   virtual PetscErrorCode init(PISMVars &vars);
00203   virtual void add_vars_to_output(string keyword, set<string> &result);
00204   virtual PetscErrorCode define_variables(set<string> vars, const NCTool &nc, nc_type nctype);
00205   virtual PetscErrorCode write_variables(set<string> vars, string filename);
00206   virtual PetscErrorCode update(PetscReal t_years, PetscReal dt_years);
00207   virtual PetscErrorCode mean_precip(IceModelVec2S &result);
00208   virtual PetscErrorCode mean_annual_temp(IceModelVec2S &result); 
00209   virtual PetscErrorCode begin_pointwise_access();
00210   virtual PetscErrorCode end_pointwise_access();  
00211   virtual PetscErrorCode temp_time_series(int i, int j, int N,
00212                                           PetscReal *ts, PetscReal *values);
00213   virtual PetscErrorCode temp_snapshot(IceModelVec2S &result);
00214 protected:
00215   IceModelVec2T *temp_anomaly, *precip_anomaly;
00216   NCSpatialVariable airtemp_var;
00217 };
00218 
00219 
00220 #endif  // __PISMAtmosphere_hh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines