SICOPOLIS V5-dev  Revision 1368
pdd_m.F90
Go to the documentation of this file.
1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 !
3 ! Module : p d d _ m
4 !
5 !> @file
6 !!
7 !! Computation of the positive degree days (PDD) with statistical temperature
8 !! fluctuations; based on semi-analytical solution by Calov and Greve (2005).
9 !!
10 !! @section Copyright
11 !!
12 !! Copyright 2009-2018 Reinhard Calov, Ralf Greve
13 !!
14 !! @section License
15 !!
16 !! This file is part of SICOPOLIS.
17 !!
18 !! SICOPOLIS is free software: you can redistribute it and/or modify
19 !! it under the terms of the GNU General Public License as published by
20 !! the Free Software Foundation, either version 3 of the License, or
21 !! (at your option) any later version.
22 !!
23 !! SICOPOLIS is distributed in the hope that it will be useful,
24 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
25 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 !! GNU General Public License for more details.
27 !!
28 !! You should have received a copy of the GNU General Public License
29 !! along with SICOPOLIS. If not, see <http://www.gnu.org/licenses/>.
30 !<
31 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32 
33 !-------------------------------------------------------------------------------
34 !> Computation of the positive degree days (PDD) with statistical temperature
35 !! fluctuations; based on semi-analytical solution by Calov and Greve (2005).
36 !<------------------------------------------------------------------------------
37 module pdd_m
38 
39  use sico_types_m
40  use sico_variables_m, only : pi
41 
42  implicit none
43 
44  private
45  public :: pdd
46 
47 contains
48 
49 !-------------------------------------------------------------------------------
50 !> Main subroutine of pdd_m:
51 !! Computation of the positive degree days (PDD) with statistical temperature
52 !! fluctuations; based on semi-analytical solution by Calov and Greve (2005).
53 !! Note that this routine uses years as time unit
54 !! (as opposed to the seconds which are usually used by SICOPOLIS).
55 !<------------------------------------------------------------------------------
56  subroutine pdd(temp_mm, s_stat, ET)
57 
58 #ifdef ALLOW_OPENAD /* OpenAD */
59  use sico_maths_m
60 #endif /* OpenAD */
61 
62  implicit none
63 
64  real(dp), dimension(12), intent(in) :: temp_mm
65  real(dp), intent(in) :: s_stat
66 
67  real(dp), intent(out) :: ET
68 
69  integer(i4b) :: n
70  real(dp) :: inv_sqrt2pi, inv_s_stat, inv_sqrt2
71  real(dp) :: pdd_sum
72 
73  real(dp), parameter :: time_year = 1.0_dp, & ! period 1 year
74  time_year_inv = 1.0_dp/time_year, &
75  d_time = 1.0_dp/12.0_dp ! time-step 1 month
76 
77 #ifdef ALLOW_OPENAD /* OpenAD */
78  real(dp) :: my_erfc_retval
79 #endif /* OpenAD */
80 
81  inv_sqrt2pi = 1.0_dp/sqrt(2.0_dp*pi)
82  inv_s_stat = 1.0_dp/s_stat
83  inv_sqrt2 = 1.0_dp/sqrt(2.0_dp)
84 
85  pdd_sum = 0.0_dp
86 
87  do n=1, 12 ! month counter
88 
89 #ifndef ALLOW_OPENAD /* Normal */
90  pdd_sum = pdd_sum &
91  + ( s_stat*inv_sqrt2pi*exp(-0.5_dp*(temp_mm(n)*inv_s_stat)**2) &
92  + 0.5_dp*temp_mm(n) &
93  *erfc(-temp_mm(n)*inv_s_stat*inv_sqrt2) ) &
94  *d_time ! positive degree days (in a * deg C)
95 #else /* OpenAD */
96  call my_erfc(-temp_mm(n)*inv_s_stat*inv_sqrt2, my_erfc_retval)
97  pdd_sum = pdd_sum &
98  + ( s_stat*inv_sqrt2pi*exp(-0.5_dp*(temp_mm(n)*inv_s_stat)**2) &
99  + 0.5_dp*temp_mm(n) &
100  *my_erfc_retval ) &
101  *d_time ! positive degree days (in a * deg C)
102 #endif /* Normal vs. OpenAD */
103 
104  end do
105 
106  et = pdd_sum*time_year_inv ! temperature excess (deg C)
107 
108  end subroutine pdd
109 
110 !-------------------------------------------------------------------------------
111 
112 end module pdd_m
113 !
Several mathematical tools used by SICOPOLIS.
Computation of the positive degree days (PDD) with statistical temperature fluctuations; based on sem...
Definition: pdd_m.F90:37
Declarations of kind types for SICOPOLIS.
real(dp), parameter pi
pi: Constant pi
subroutine, public pdd(temp_mm, s_stat, ET)
Main subroutine of pdd_m: Computation of the positive degree days (PDD) with statistical temperature ...
Definition: pdd_m.F90:57
Declarations of global variables for SICOPOLIS.