source: palm/trunk/SOURCE/init_advec.f90 @ 1346

Last change on this file since 1346 was 1346, checked in by heinze, 10 years ago

Bugfix: REAL constants provided with KIND-attribute especially in call of intrinsic function like MAX, MIN, SIGN

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1 SUBROUTINE init_advec
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later version.
9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
17! Copyright 1997-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22! Bugfix: REAL constants provided with KIND-attribute especially in call of
23! intrinsic function like MAX, MIN, SIGN
24!
25! Former revisions:
26! -----------------
27! $Id: init_advec.f90 1346 2014-03-27 13:18:20Z heinze $
28!
29! 1322 2014-03-20 16:38:49Z raasch
30! REAL constants defined as wp-kind
31!
32! 1320 2014-03-20 08:40:49Z raasch
33! ONLY-attribute added to USE-statements,
34! kind-parameters added to all INTEGER and REAL declaration statements,
35! kinds are defined in new module kinds,
36! revision history before 2012 removed,
37! comment fields (!:) to be used for variable explanations added to
38! all variable declaration statements
39!
40! 1036 2012-10-22 13:43:42Z raasch
41! code put under GPL (PALM 3.9)
42!
43! 1003 2012-09-14 14:35:53Z raasch
44! obsolete variables removed
45!
46! 1001 2012-09-13 14:08:46Z raasch
47! all actions concerning upstream-spline-method removed
48!
49! Revision 1.1  1999/02/05 09:07:38  raasch
50! Initial revision
51!
52!
53! Description:
54! ------------
55! Initialize constant coefficients and parameters for certain advection schemes.
56!------------------------------------------------------------------------------!
57
58    USE advection,                                                             &
59        ONLY:  aex, bex, dex, eex
60       
61    USE kinds
62   
63    USE control_parameters,                                                    &
64        ONLY:  scalar_advec
65
66    IMPLICIT NONE
67
68    INTEGER(iwp) ::  i          !:
69    INTEGER(iwp) ::  intervals  !:
70    INTEGER(iwp) ::  j          !:
71   
72    REAL(wp) :: delt   !:
73    REAL(wp) :: dn     !:
74    REAL(wp) :: dnneu  !:
75    REAL(wp) :: ex1    !:
76    REAL(wp) :: ex2    !:
77    REAL(wp) :: ex3    !:
78    REAL(wp) :: ex4    !:
79    REAL(wp) :: ex5    !:
80    REAL(wp) :: ex6    !:
81    REAL(wp) :: sterm  !:
82
83
84    IF ( scalar_advec == 'bc-scheme' )  THEN
85
86!
87!--    Compute exponential coefficients for the Bott-Chlond scheme
88       intervals = 1000
89       ALLOCATE( aex(intervals), bex(intervals), dex(intervals), eex(intervals) )
90
91       delt  = 1.0_wp / REAL( intervals, KIND=wp )
92       sterm = delt * 0.5
93
94       DO  i = 1, intervals
95
96          IF ( sterm > 0.5 )  THEN
97             dn = -5.0
98          ELSE
99             dn = 5.0
100          ENDIF
101
102          DO  j = 1, 15
103             ex1 = dn * EXP( -dn ) - EXP( 0.5 * dn ) + EXP( -0.5 * dn )
104             ex2 = EXP( dn ) - EXP( -dn )
105             ex3 = EXP( -dn ) * ( 1.0 - dn ) - 0.5 * EXP(  0.5 * dn ) &
106                                             - 0.5 * EXP( -0.5 * dn )
107             ex4 = EXP( dn ) + EXP( -dn )
108             ex5 = dn * sterm + ex1 / ex2
109             ex6 = sterm + ( ex3 * ex2 - ex4 * ex1 ) / ( ex2 * ex2 )
110             dnneu = dn - ex5 / ex6
111             dn  = dnneu
112          ENDDO
113
114          IF ( sterm < 0.5 )  dn = MAX(  2.95E-2_wp, dn )
115          IF ( sterm > 0.5 )  dn = MIN( -2.95E-2_wp, dn )
116          ex1 = EXP( -dn )
117          ex2 = EXP( dn ) - ex1
118          aex(i) = -ex1 / ex2
119          bex(i) = 1.0 / ex2
120          dex(i) = dn
121          eex(i) = EXP( dex(i) * 0.5 )
122          sterm = sterm + delt
123
124       ENDDO
125
126    ENDIF
127
128 END SUBROUTINE init_advec
Note: See TracBrowser for help on using the repository browser.