PISM, A Parallel Ice Sheet Model stable 0.4.1779

src/coupler/PASDirectForcing.cc

Go to the documentation of this file.
00001 // Copyright (C) 2011 Constantine Khroulev
00002 //
00003 // This file is part of PISM.
00004 //
00005 // PISM is free software; you can redistribute it and/or modify it under the
00006 // terms of the GNU General Public License as published by the Free Software
00007 // Foundation; either version 2 of the License, or (at your option) any later
00008 // version.
00009 //
00010 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
00011 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013 // details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with PISM; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 // Implementation of surface and atmosphere models reading spatially-variable
00020 // time-dependent B.C. data from a file (-surface given and -atmosphere given).
00021 
00022 #include "PASDirectForcing.hh"
00023 
00024 PetscErrorCode PSDirectForcing::init(PISMVars &) {
00025   PetscErrorCode ierr;
00026 
00027   ierr = verbPrintf(2, grid.com,
00028                     "* Initializing the surface model reading temperature at the top of the ice\n"
00029                     "  and ice surface mass flux from a file...\n"); CHKERRQ(ierr);
00030 
00031   ierr = process_options(); CHKERRQ(ierr);
00032 
00033   ierr = set_vec_parameters("", "land_ice_surface_specific_mass_balance"); CHKERRQ(ierr);
00034 
00035   ierr = temp.create(grid, temp_name, false); CHKERRQ(ierr);
00036   ierr = smb.create(grid, smb_name, false); CHKERRQ(ierr);
00037 
00038   ierr = temp.set_attrs("climate_forcing",
00039                         "temperature of the ice at the ice surface but below firn processes",
00040                         "Kelvin", ""); CHKERRQ(ierr);
00041   ierr = smb.set_attrs("climate_forcing",
00042                        "ice-equivalent surface mass balance (accumulation/ablation) rate",
00043                        "m s-1", "land_ice_surface_specific_mass_balance"); CHKERRQ(ierr);
00044 
00045   ierr = verbPrintf(2,grid.com,
00046                     "    reading boundary conditions from %s ...\n",
00047                     filename.c_str()); CHKERRQ(ierr);
00048 
00049   ierr = temp.init(filename); CHKERRQ(ierr);
00050   ierr = smb.init(filename); CHKERRQ(ierr);
00051 
00052   return 0;
00053 }
00054 
00055 PetscErrorCode PSDirectForcing::update(PetscReal t_years, PetscReal dt_years) {
00056   PetscErrorCode ierr = update_internal(t_years, dt_years); CHKERRQ(ierr);
00057 
00058   if (enable_time_averaging) {
00059     ierr = smb.average(t, dt); CHKERRQ(ierr); 
00060     ierr = temp.average(t, dt); CHKERRQ(ierr); 
00061   } else {
00062     ierr = smb.get_record_years(t); CHKERRQ(ierr);
00063     ierr = temp.get_record_years(t); CHKERRQ(ierr);
00064   }
00065 
00066   return 0;
00067 }
00068 
00069 PetscErrorCode PSDirectForcing::ice_surface_mass_flux(IceModelVec2S &result) {
00070   PetscErrorCode ierr = smb.copy_to(result); CHKERRQ(ierr);
00071   return 0;
00072 }
00073 
00074 PetscErrorCode PSDirectForcing::ice_surface_temperature(IceModelVec2S &result) {
00075   PetscErrorCode ierr = temp.copy_to(result); CHKERRQ(ierr);
00076   return 0;
00077 }
00078 
00079 PetscErrorCode PADirectForcing::init(PISMVars &) {
00080   PetscErrorCode ierr;
00081 
00082   ierr = verbPrintf(2, grid.com,
00083                     "* Initializing the atmosphere model reading near-surface air temperature\n"
00084                     "  and ice-equivalent precipitation from a file...\n"); CHKERRQ(ierr);
00085 
00086   ierr = process_options(); CHKERRQ(ierr);
00087 
00088   ierr = set_vec_parameters("", ""); CHKERRQ(ierr);
00089 
00090   ierr = temp.create(grid, temp_name, false); CHKERRQ(ierr);
00091   ierr = smb.create(grid, smb_name, false); CHKERRQ(ierr);
00092 
00093   ierr = temp.set_attrs("climate_forcing", "near-surface air temperature",
00094                         "Kelvin", ""); CHKERRQ(ierr);
00095   ierr = smb.set_attrs("climate_forcing", "ice-equivalent precipitation rate",
00096                        "m s-1", ""); CHKERRQ(ierr);
00097 
00098   ierr = verbPrintf(2, grid.com,
00099                     "    reading boundary conditions from %s ...\n",
00100                     filename.c_str()); CHKERRQ(ierr);
00101 
00102   ierr = temp.init(filename); CHKERRQ(ierr);
00103   ierr = smb.init(filename); CHKERRQ(ierr);
00104 
00105   return 0;
00106 }
00107 
00108 PetscErrorCode PADirectForcing::update(PetscReal t_years, PetscReal dt_years) {
00109   PetscErrorCode ierr = update_internal(t_years, dt_years); CHKERRQ(ierr);
00110 
00111   if (enable_time_averaging) {
00112     ierr = smb.average(t, dt); CHKERRQ(ierr); 
00113     ierr = temp.average(t, 1.0); CHKERRQ(ierr); // compute the "mean annual" temperature
00114   } else {
00115     ierr = smb.get_record_years(t); CHKERRQ(ierr);
00116     ierr = temp.get_record_years(t); CHKERRQ(ierr);
00117   }
00118 
00119   return 0;
00120 }
00121 
00122 PetscErrorCode PADirectForcing::mean_precip(IceModelVec2S &result) {
00123   PetscErrorCode ierr = smb.copy_to(result); CHKERRQ(ierr);
00124   return 0;
00125 }
00126 
00127 PetscErrorCode PADirectForcing::mean_annual_temp(IceModelVec2S &result) {
00128   PetscErrorCode ierr = temp.copy_to(result); CHKERRQ(ierr);
00129   return 0;
00130 }
00131 
00132 PetscErrorCode PADirectForcing::temp_snapshot(IceModelVec2S &result) {
00133   PetscErrorCode ierr = temp.copy_to(result); CHKERRQ(ierr);
00134   return 0;
00135 }
00136 
00137 PetscErrorCode PADirectForcing::begin_pointwise_access() {
00138   PetscErrorCode ierr = temp.begin_access(); CHKERRQ(ierr);
00139   return 0;
00140 }
00141 
00142 PetscErrorCode PADirectForcing::end_pointwise_access() {
00143   PetscErrorCode ierr = temp.end_access(); CHKERRQ(ierr);
00144   return 0;
00145 }
00146 
00147 PetscErrorCode PADirectForcing::temp_time_series(int i, int j, int N,
00148                                                  PetscReal *ts, PetscReal *values) {
00149   PetscErrorCode ierr = temp.interp(i, j, N, ts, values); CHKERRQ(ierr);
00150   return 0;
00151 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines