source: flexpart.git/src/re_initialize_particle.f90

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

remove tabs from files of the form src/*.f90

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