tgrain_size_vostok.cc - 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
---
tgrain_size_vostok.cc (2219B)
---
1 /* Copyright (C) 2019 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
20 #include <algorithm> // std::min, std::max
21
22 #include "grain_size_vostok.hh"
23
24 namespace pism {
25 namespace rheology {
26
27 // age in thousands of years
28 const double grain_size_vostok::m_age[grain_size_vostok::m_N] =
29 {0.0000e+00, 5.0000e+01, 1.0000e+02, 1.2500e+02, 1.5000e+02,
30 1.5800e+02, 1.6500e+02, 1.7000e+02, 1.8000e+02, 1.8800e+02,
31 2.0000e+02, 2.2500e+02, 2.4500e+02, 2.6000e+02, 3.0000e+02,
32 3.2000e+02, 3.5000e+02, 4.0000e+02, 5.0000e+02, 6.0000e+02,
33 8.0000e+02, 1.0000e+04};
34
35 // grain size in meters
36 const double grain_size_vostok::m_grain_size[grain_size_vostok::m_N] =
37 {1.8000e-03, 2.2000e-03, 3.0000e-03, 4.0000e-03, 4.3000e-03,
38 3.0000e-03, 3.0000e-03, 4.6000e-03, 3.4000e-03, 3.3000e-03,
39 5.9000e-03, 6.2000e-03, 5.4000e-03, 6.8000e-03, 3.5000e-03,
40 6.0000e-03, 8.0000e-03, 8.3000e-03, 3.6000e-03, 3.8000e-03,
41 9.5000e-03, 1.0000e-02};
42 grain_size_vostok::grain_size_vostok() {
43 m_acc = gsl_interp_accel_alloc();
44 m_spline = gsl_spline_alloc(gsl_interp_linear, m_N);
45 gsl_spline_init(m_spline, m_age, m_grain_size, m_N);
46 }
47
48 grain_size_vostok::~grain_size_vostok() {
49 gsl_spline_free(m_spline);
50 gsl_interp_accel_free(m_acc);
51 }
52
53 double grain_size_vostok::operator()(double age) {
54 double age_ka = age / 1000.0;
55
56 age_ka = std::max(age_ka, m_age[0]);
57 age_ka = std::min(age_ka, m_age[m_N - 1]);
58
59 return gsl_spline_eval(m_spline, age_ka, m_acc);
60 }
61
62 } // end of namespace rheology
63 } // end of namespace pism