source: flexpart.git/src/re_initialize_particle.f90 @ 3481cc1

10.4.1_peseiGFS_025bugfixes+enhancementsdevrelease-10release-10.4.1scaling-bug
Last change on this file since 3481cc1 was 3481cc1, checked in by Ignacio Pisso <ip@…>, 4 years ago

move license from headers to a different file

  • Property mode set to 100644
File size: 3.1 KB
Line 
1subroutine re_initialize_particle(zp,ust,wst,h,sigmaw,wp,nrand,ol)
2!                                      i   i  i   i  i    io  io    i
3!=============== CBL skewed vertical profiles and formulation of LHH 1996 with profile of w3 from lHB 2000                                       ======
4!=============== LHH formulation has been modified to account for variable density profiles and backward in time or forward in time simulations  ======           
5!=============== this routine re-initiaalize particle velocity if a numerical instability in the cbl scheme generated a NaN value                ======
6!=============== the particle velocity is extracted from the updraft and downdraft distribution as required                                      ======
7!=============== the re-initialization si not perfect see e.g. Cassiani et al(2015) BLM                                                          ======
8!======================================================================================================================================================   
9!======================================================================================================================================================   
10  use par_mod, only:pi
11  use com_mod, only:ldirect,rannumb
12
13  implicit none
14
15
16  real :: usurad2,usurad2p,C0,costluar4,eps
17  parameter  (usurad2=0.7071067812,usurad2p=0.3989422804,C0=2,costluar4=0.66667,eps=0.000001)
18
19  integer idum,nrand
20  real :: wp,zp,ust,wst,h,dens,ddens,sigmaw,dsigmawdz,tlw,dcas,dcas1 !,ran3,gasdev
21  real :: w3,w2
22  real ::  z, &   
23       skew, &
24       skew2, &
25       radw2, &
26       fluarw,fluarw2, &
27       rluarw, &
28       xluarw, &
29       aluarw, &
30       bluarw, &
31       sigmawa, &
32       sigmawb, & 
33       ath, &
34       bth, &
35       wb,wa
36  real timedir
37  real ol,transition
38
39!--------------------------------------------------------------------------- 
40!timedir direction of time forward (1) or backward(-1)
41  nrand=nrand+1
42  dcas1=rannumb(nrand)
43  timedir=ldirect
44  z=zp/h
45  transition=1.
46
47  if (-h/ol.lt.15) transition=((sin((((-h/ol)+10.)/10.)*pi)))/2.+0.5
48
49  w2=sigmaw*sigmaw 
50  w3=(((1.2*z*((1.-z)**(3./2.)))+eps)*wst**3)*transition
51  skew=w3/(w2**1.5)
52  skew2=skew*skew
53  radw2=sqrt(w2) !sigmaw
54
55  fluarw=costluar4*skew**0.333333333333333
56  fluarw2=fluarw*fluarw
57  rluarw=(1.+fluarw2)**3.*skew2/((3.+fluarw2)**2.*fluarw2)  !-> r
58  xluarw=rluarw**0.5 !(1.+fluarw2)**1.5*skew/((3.+fluarw2)*fluarw)    !----> r^1/2
59
60  aluarw=0.5*(1.-xluarw/(4.+rluarw)**0.5)
61  bluarw=1.-aluarw
62
63  sigmawa=radw2*(bluarw/(aluarw*(1.+fluarw2)))**0.5
64  sigmawb=radw2*(aluarw/(bluarw*(1.+fluarw2)))**0.5
65
66  wa=(fluarw*sigmawa)
67  wb=(fluarw*sigmawb)
68
69
70
71  if ((sign(1.,wp)*timedir).gt.0) then !updraft   
72100 wp=(dcas1*sigmawa+wa)
73    if (wp.lt.0)  then
74      nrand=nrand+1
75      dcas1=rannumb(nrand)
76      goto 100
77    end if
78    wp=wp*timedir
79  else if ((sign(1.,wp)*timedir).lt.0) then !downdraft   
80101 wp=(dcas1*sigmawb-wb)
81    if (wp.gt.0)  then
82      nrand=nrand+1
83      dcas1=rannumb(nrand)
84      goto 101
85    end if
86    wp=wp*timedir
87  end if
88
89  return
90end subroutine re_initialize_particle
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG