|
PISM, A Parallel Ice Sheet Model stable 0.4.1779
|
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 #include "PScalarForcing.hh" 00020 00022 00023 PSdTforcing::PSdTforcing(IceGrid &g, const NCConfigVariable &conf, PISMSurfaceModel* in) 00024 : PScalarForcing<PISMSurfaceModel,PSModifier>(g, conf, in) 00025 { 00026 option = "-dTforcing"; 00027 offset_name = "delta_T"; 00028 offset = new Timeseries(&grid, offset_name, "t"); 00029 offset->set_units("Celsius", ""); 00030 offset->set_dimension_units("years", ""); 00031 offset->set_attr("long_name", "ice-surface temperature offsets"); 00032 } 00033 00034 PetscErrorCode PSdTforcing::init(PISMVars &vars) { 00035 PetscErrorCode ierr; 00036 00037 ierr = input_model->init(vars); CHKERRQ(ierr); 00038 00039 ierr = verbPrintf(2, grid.com, 00040 "* Initializing ice-surface temperature forcing using scalar offsets...\n"); CHKERRQ(ierr); 00041 00042 ierr = init_internal(); CHKERRQ(ierr); 00043 00044 return 0; 00045 } 00046 00047 PetscErrorCode PSdTforcing::ice_surface_temperature(IceModelVec2S &result) { 00048 PetscErrorCode ierr = input_model->ice_surface_temperature(result); CHKERRQ(ierr); 00049 ierr = offset_data(result); CHKERRQ(ierr); 00050 return 0; 00051 } 00052 00054 00055 PAdTforcing::PAdTforcing(IceGrid &g, const NCConfigVariable &conf, PISMAtmosphereModel* in) 00056 : PScalarForcing<PISMAtmosphereModel,PAModifier>(g, conf, in) 00057 { 00058 option = "-dTforcing"; 00059 offset_name = "delta_T"; 00060 offset = new Timeseries(&grid, offset_name, "t"); 00061 offset->set_units("Celsius", ""); 00062 offset->set_dimension_units("years", ""); 00063 offset->set_attr("long_name", "near-surface air temperature offsets"); 00064 } 00065 00066 PetscErrorCode PAdTforcing::init(PISMVars &vars) { 00067 PetscErrorCode ierr; 00068 00069 ierr = input_model->init(vars); CHKERRQ(ierr); 00070 00071 ierr = verbPrintf(2, grid.com, 00072 "* Initializing near-surface air temperature forcing using scalar offsets...\n"); CHKERRQ(ierr); 00073 00074 ierr = init_internal(); CHKERRQ(ierr); 00075 00076 return 0; 00077 } 00078 00079 PetscErrorCode PAdTforcing::mean_annual_temp(IceModelVec2S &result) { 00080 PetscErrorCode ierr = input_model->mean_annual_temp(result); CHKERRQ(ierr); 00081 ierr = offset_data(result); CHKERRQ(ierr); 00082 return 0; 00083 } 00084 00085 PetscErrorCode PAdTforcing::temp_time_series(int i, int j, int N, 00086 PetscReal *ts, PetscReal *values) { 00087 PetscErrorCode ierr = input_model->temp_time_series(i, j, N, ts, values); CHKERRQ(ierr); 00088 00089 if (offset) { 00090 for (int k = 0; k < N; ++k) 00091 values[k] += (*offset)(ts[k]); 00092 } 00093 00094 return 0; 00095 } 00096 00097 PetscErrorCode PAdTforcing::temp_snapshot(IceModelVec2S &result) { 00098 PetscErrorCode ierr = input_model->temp_snapshot(result); CHKERRQ(ierr); 00099 ierr = offset_data(result); CHKERRQ(ierr); 00100 return 0; 00101 } 00102 00104 00105 POdSLforcing::POdSLforcing(IceGrid &g, const NCConfigVariable &conf, PISMOceanModel* in) 00106 : PScalarForcing<PISMOceanModel,POModifier>(g, conf, in) 00107 { 00108 option = "-dSLforcing"; 00109 offset_name = "delta_sea_level"; 00110 offset = new Timeseries(&grid, offset_name, "t"); 00111 00112 offset->set_units("m", ""); 00113 offset->set_dimension_units("years", ""); 00114 offset->set_attr("long_name", "sea level elevation offsets"); 00115 } 00116 00117 PetscErrorCode POdSLforcing::init(PISMVars &vars) { 00118 PetscErrorCode ierr; 00119 00120 ierr = input_model->init(vars); CHKERRQ(ierr); 00121 00122 ierr = verbPrintf(2, grid.com, "* Initializing sea level forcing...\n"); CHKERRQ(ierr); 00123 00124 ierr = init_internal(); CHKERRQ(ierr); 00125 00126 return 0; 00127 } 00128 00129 00130 PetscErrorCode POdSLforcing::sea_level_elevation(PetscReal &result) { 00131 PetscErrorCode ierr = input_model->sea_level_elevation(result); CHKERRQ(ierr); 00132 00133 if (offset) 00134 result += (*offset)(t + 0.5*dt); 00135 00136 return 0; 00137 }
1.7.3