PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
SeariseGreenland.cc
Go to the documentation of this file.
1 // Copyright (C) 2008-2018, 2022, 2023 Ed Bueler, Constantine Khroulev, Ricarda Winkelmann,
2 // Gudfinna Adalgeirsdottir and Andy Aschwanden
3 //
4 // This file is part of PISM.
5 //
6 // PISM is free software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3 of the License, or (at your option) any later
9 // version.
10 //
11 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with PISM; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 // Implementation of the atmosphere model using constant-in-time precipitation
21 // and a cosine yearly cycle for near-surface air temperatures.
22 
23 // This includes the SeaRISE Greenland parameterization.
24 
25 #include "pism/coupler/atmosphere/SeariseGreenland.hh"
26 #include "pism/geometry/Geometry.hh"
27 #include "pism/util/ConfigInterface.hh"
28 #include "pism/util/Grid.hh"
29 #include "pism/util/MaxTimestep.hh"
30 #include "pism/util/error_handling.hh"
31 
32 namespace pism {
33 namespace atmosphere {
34 
35 ///// SeaRISEGreenland
36 
37 SeaRISEGreenland::SeaRISEGreenland(std::shared_ptr<const Grid> g)
38  : YearlyCycle(g) {
39  // empty
40 }
41 
43 }
44 
45 void SeaRISEGreenland::init_impl(const Geometry &geometry) {
46 
47  m_log->message(2,
48  "* Initializing SeaRISE-Greenland atmosphere model based on the Fausto et al (2009)\n"
49  " air temperature parameterization and using stored time-independent precipitation...\n");
50 
51  m_reference =
52  "R. S. Fausto, A. P. Ahlstrom, D. V. As, C. E. Boggild, and S. J. Johnsen, 2009. "
53  "A new present-day temperature parameterization for Greenland. J. Glaciol. 55 (189), 95-105.";
54 
55  auto precip_file = m_config->get_string("atmosphere.searise_greenland.file");
56 
57  if (not precip_file.empty()) {
58  m_log->message(2,
59  " * Reading precipitation from '%s'...\n",
60  precip_file.c_str());
61 
62  YearlyCycle::init_internal(precip_file,
63  true, /* do regrid */
64  0 /* start (irrelevant) */);
65  } else {
66  YearlyCycle::init_impl(geometry);
67  }
68 }
69 
70 void SeaRISEGreenland::precip_time_series_impl(int i, int j, std::vector<double> &result) const {
71 
72  for (unsigned int k = 0; k < m_ts_times.size(); k++) {
73  result[k] = m_precipitation(i,j);
74  }
75 }
76 
78  (void) t;
79  return MaxTimestep("atmosphere searise_greenland");
80 }
81 
82 //! \brief Updates mean annual and mean summer (July) near-surface air temperatures.
83 //! Note that the precipitation rate is time-independent and does not need
84 //! to be updated.
85 void SeaRISEGreenland::update_impl(const Geometry &geometry, double t, double dt) {
86  (void) t;
87  (void) dt;
88 
89  const double
90  d_ma = m_config->get_number("atmosphere.fausto_air_temp.d_ma"), // K
91  gamma_ma = m_config->get_number("atmosphere.fausto_air_temp.gamma_ma"), // K m-1
92  c_ma = m_config->get_number("atmosphere.fausto_air_temp.c_ma"), // K (degN)-1
93  kappa_ma = m_config->get_number("atmosphere.fausto_air_temp.kappa_ma"), // K (degW)-1
94  d_mj = m_config->get_number("atmosphere.fausto_air_temp.d_mj"), // SAME UNITS as for _ma ...
95  gamma_mj = m_config->get_number("atmosphere.fausto_air_temp.gamma_mj"),
96  c_mj = m_config->get_number("atmosphere.fausto_air_temp.c_mj"),
97  kappa_mj = m_config->get_number("atmosphere.fausto_air_temp.kappa_mj");
98 
99 
100  // initialize pointers to fields the parameterization depends on:
101  const array::Scalar
102  &h = geometry.ice_surface_elevation,
103  &lat_degN = geometry.latitude,
104  &lon_degE = geometry.longitude;
105 
106  if (lat_degN.metadata().has_attribute("missing_at_bootstrap")) {
107  throw RuntimeError(PISM_ERROR_LOCATION, "latitude variable was missing at bootstrap;\n"
108  "SeaRISE-Greenland atmosphere model depends on latitude and would return nonsense!");
109  }
110 
111  if (lon_degE.metadata().has_attribute("missing_at_bootstrap")) {
112  throw RuntimeError(PISM_ERROR_LOCATION, "longitude variable was missing at bootstrap;\n"
113  "SeaRISE-Greenland atmosphere model depends on longitude and would return nonsense!");
114  }
115 
116  array::AccessScope list{&h, &lat_degN, &lon_degE, &m_air_temp_mean_annual, &m_air_temp_mean_summer};
117 
118  for (auto p = m_grid->points(); p; p.next()) {
119  const int i = p.i(), j = p.j();
120  m_air_temp_mean_annual(i,j) = d_ma + gamma_ma * h(i,j) + c_ma * lat_degN(i,j) + kappa_ma * (-lon_degE(i,j));
121  m_air_temp_mean_summer(i,j) = d_mj + gamma_mj * h(i,j) + c_mj * lat_degN(i,j) + kappa_mj * (-lon_degE(i,j));
122  }
123 }
124 
125 } // end of namespace atmosphere
126 } // end of namespace pism
const Config::ConstPtr m_config
configuration database used by this component
Definition: Component.hh:158
const Logger::ConstPtr m_log
logger (for easy access)
Definition: Component.hh:162
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition: Component.hh:156
array::Scalar2 ice_surface_elevation
Definition: Geometry.hh:57
array::Scalar longitude
Definition: Geometry.hh:42
array::Scalar latitude
Definition: Geometry.hh:41
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
Definition: MaxTimestep.hh:31
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition: Array.hh:65
std::vector< double > m_ts_times
virtual void init_impl(const Geometry &geometry)
Reads in the precipitation data from the input file.
virtual MaxTimestep max_timestep_impl(double t) const
virtual void precip_time_series_impl(int i, int j, std::vector< double > &values) const
SeaRISEGreenland(std::shared_ptr< const Grid > g)
virtual void update_impl(const Geometry &geometry, double t, double dt)
Updates mean annual and mean summer (July) near-surface air temperatures. Note that the precipitation...
array::Scalar m_air_temp_mean_summer
Definition: YearlyCycle.hh:63
void init_internal(const std::string &input_filename, bool regrid, unsigned int start)
Read precipitation data from a given file.
Definition: YearlyCycle.cc:73
virtual void init_impl(const Geometry &geometry)
Reads in the precipitation data from the input file.
Definition: YearlyCycle.cc:65
array::Scalar m_air_temp_mean_annual
Definition: YearlyCycle.hh:63
#define PISM_ERROR_LOCATION
static const double g
Definition: exactTestP.cc:36
static const double k
Definition: exactTestP.cc:42