source: branches/jerome/src_flexwrf_v3.1/re_initialize_particle.f90 @ 16

Last change on this file since 16 was 16, checked in by jebri, 11 years ago

sources for flexwrf v3.1

File size: 6.3 KB
Line 
1!***********************************************************************
2!* Copyright 2012,2013                                                *
3!* Jerome Brioude, Delia Arnold, Andreas Stohl, Wayne Angevine,       *
4!* John Burkhart, Massimo Cassiani, Adam Dingwell, Richard C Easter, Sabine Eckhardt,*
5!* Stephanie Evan, Jerome D Fast, Don Morton, Ignacio Pisso,          *
6!* Petra Seibert, Gerard Wotawa, Caroline Forster, Harald Sodemann,   *
7!*                                                                     *
8!* This file is part of FLEXPART WRF                                   *
9!*                                                                     *
10!* FLEXPART is free software: you can redistribute it and/or modify    *
11!* it under the terms of the GNU General Public License as published by*
12!* the Free Software Foundation, either version 3 of the License, or   *
13!* (at your option) any later version.                                 *
14!*                                                                     *
15!* FLEXPART is distributed in the hope that it will be useful,         *
16!* but WITHOUT ANY WARRANTY; without even the implied warranty of      *
17!* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
18!* GNU General Public License for more details.                        *
19!*                                                                     *
20!* You should have received a copy of the GNU General Public License   *
21!* along with FLEXPART.  If not, see <http://www.gnu.org/licenses/>.   *
22!***********************************************************************
23                                   
24   
25    subroutine re_initialize_particle(zp,ust,wst,h,sigmaw,wp,nrand,ol)
26!                                      i   i  i   i  i    i/o  i/o
27!zp: particle position
28!ust: velocity scale
29!wst: velocity scale
30!sigmaw: vertical velcotiy standard deviation
31!wp: particle velocity
32!nrand: random number counter
33!=============== CBL skewed vertical profiles and formulation of LHH 1996 with profile of w3 from lHB 2000   ================================================================
34!=============== LHH formulation has been modified to account for variable density profiles and backward in time or forward in time simulations                             =                   
35!=============== by  Massimo Cassiani ( mc ) , NILU,  2012-2013                                                                                                             =
36!=============== this routine re-initialize particle velocity if a numerical instability in the cbl scheme met a specific condition                                         =
37!=============== (see routine cbl.f90 and Cassiani et al. 2013                                                                                                              =
38!=============== the particle velocity is extracted from the updraft and downdraft distribution as required                                                                 =
39!=============== this re-initialization si not perfectly consistent with teh well-mixed condition see Cassiani et al. 2013 for details but the error introduced is small    =
40!=============== but for the rpesent this is faste and simpler and shoudl be ok                                                                                             =         
41!============================================================================================================================================================================   
42    use par_mod, only:pi
43    use com_mod, only:ldirect,rannumb
44!    use ieee_arithmetic
45 
46    implicit none
47
48
49    real :: usurad2,usurad2p,C0,costluar4,eps
50    parameter  (usurad2=0.7071067812,usurad2p=0.3989422804,C0=2,costluar4=0.66667,eps=0.000001)
51
52    integer idum,nrand
53    real :: wp,zp,ust,wst,h,dens,ddens,sigmaw,dsigmawdz,tlw,dcas,dcas1,ran3,gasdev
54    real :: w3,w2,wpold
55    real ::  z, &   
56    skew, &
57    skew2, &
58    radw2, &
59    fluarw,fluarw2, &
60    rluarw, &
61    xluarw, &
62    aluarw, &
63    bluarw, &
64    sigmawa, &
65    sigmawb, & 
66    ath, &
67    bth, &
68    wb,wa
69    real timedir
70    real ol,transition
71    !---------------------------------------------------------------------------
72!     print*,'INSIDE INIT',zp,ust,wst,h,sigmaw,wp,nrand
73!   wpold=wp
74          nrand=nrand+1
75     dcas1=rannumb(nrand)
76     timedir=ldirect !direction of time forward (1) or backward(-1)
77    z=zp/h
78     
79     transition=1.  !comment by mc: in this version added transtion fucntion see Cassiani et al. 2013
80     if (-h/ol.lt.15) transition=((sin((((-h/ol)+10.)/10.)*pi)))/2.+0.5
81   
82     !   w2=((1.7*(z*(1.-0.7*z)*(1.-z))**(2./3.))+1.e-2)*(wst**2)
83    w2=sigmaw*sigmaw !this is correct and use hanna routine if commented it is for test reason
84    !w3=(((1.2*z*((1.-z)**(3./2.)))+eps)*wst**3) *1.5   !the 1.5 is to test with increased skeweness see also cbl.f90
85     w3=(((1.2*z*((1.-z)**(3./2.)))+eps)*wst**3) *transition !note added a transition fucntion, comemnt by mc
86    skew=w3/(w2**1.5)
87    skew2=skew*skew
88     radw2=sigmaw !sqrt(w2)
89   
90     if (skew.ne.0) then   ! the  limit must be considered explicitly to avoid NaN
91     fluarw=costluar4*skew**0.333333333333333
92    fluarw2=fluarw*fluarw
93    rluarw=(1.+fluarw2)**3.*skew2/((3.+fluarw2)**2.*fluarw2)  !-> r
94     xluarw=rluarw**0.5 !(1.+fluarw2)**1.5*skew/((3.+fluarw2)*fluarw)    !----> r^1/2
95     else       
96     fluarw=0.
97     fluarw2=0.
98     rluarw=0.       
99     xluarw=0.       
100     end if     
101     
102     aluarw=0.5*(1.-xluarw/(4.+rluarw)**0.5)
103    bluarw=1.-aluarw
104       
105     sigmawa=radw2*(bluarw/(aluarw*(1.+fluarw2)))**0.5
106     sigmawb=radw2*(aluarw/(bluarw*(1.+fluarw2)))**0.5
107
108    wa=(fluarw*sigmawa)
109    wb=(fluarw*sigmawb)
110
111   
112
113    if ((sign(1.,wp)*timedir).gt.0) then !updraft
114     
115100     wp=(dcas1*sigmawa+wa)
116      if (wp.lt.0)  then
117          nrand=nrand+1
118          dcas1=rannumb(nrand)
119          goto 100
120      end if
121     wp=wp*timedir
122    else if ((sign(1.,wp)*timedir).lt.0) then !downdraft
123101     wp=(dcas1*sigmawb-wb)
124      if (wp.gt.0)  then
125           nrand=nrand+1
126          dcas1=rannumb(nrand)
127          goto 101
128      end if
129      wp=wp*timedir
130    end if   
131!if (ieee_is_nan(wp)) print*,'PROBLEM INSIDE',dcas1,nrand,sigmawa,fluarw,sigmawb,wb,aluarw,fluarw,xluarw,zp,ust,wst,h,sigmaw,wpold,nrand
132         return
133         end
134         
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG