-
Notifications
You must be signed in to change notification settings - Fork 0
/
gasdevlux.f90
73 lines (68 loc) · 2.88 KB
/
gasdevlux.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
!***********************************************************************
!* Copyright 2012,2013 *
!* Jerome Brioude, Delia Arnold, Andreas Stohl, Wayne Angevine, *
!* John Burkhart, Massimo Cassiani, Adam Dingwell, Richard C Easter, Sabine Eckhardt,*
!* Stephanie Evan, Jerome D Fast, Don Morton, Ignacio Pisso, *
!* Petra Seibert, Gerard Wotawa, Caroline Forster, Harald Sodemann, *
!* This file is part of FLEXPART WRF *
!* *
!* FLEXPART is free software: you can redistribute it and/or modify *
!* it under the terms of the GNU General Public License as published by*
!* the Free Software Foundation, either version 3 of the License, or *
!* (at your option) any later version. *
!* *
!* FLEXPART is distributed in the hope that it will be useful, *
!* but WITHOUT ANY WARRANTY; without even the implied warranty of *
!* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
!* GNU General Public License for more details. *
!* *
!* You should have received a copy of the GNU General Public License *
!* along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. *
!***********************************************************************
!C--- adapted from press et al. 1992 numerial recipes in Fortran by Massimo Cassiani to jse RANLUX as uniform random number generator
FUNCTION gasdevlux()
USE luxury
INTEGER idum
REAL gasdevlux
INTEGER iset
REAL fac,gset,rsq,v1,v2,RTEST(2)
SAVE iset,gset
DATA iset/0/
if (iset.eq.0) then
1 call RANLUX(RTEST,2)
v1=2.*RTEST(1)-1.
v2=2.*RTEST(2)-1.
rsq=v1**2+v2**2
if(rsq.ge.1..or.rsq.eq.0.)goto 1
fac=sqrt(-2.*log(rsq)/rsq)
gset=v1*fac
gasdevlux=v2*fac
iset=1
else
gasdevlux=gset
iset=0
endif
return
END
subroutine gasdevlux2R(random1,random2)
USE luxury
INTEGER idum
REAL random1,random2
INTEGER iset
REAL fac,gset,rsq,v1,v2,RTEST(2)
1 call RANLUX(RTEST,2)
v1=2.*RTEST(1)-1.
v2=2.*RTEST(2)-1.
rsq=v1**2+v2**2
if(rsq.ge.1..or.rsq.eq.0.)goto 1
fac=sqrt(-2.*log(rsq)/rsq)
random1=v1*fac
random2=v2*fac
! Limit the random numbers to lie within the interval -4 and +4
!**************************************************************
if (random1.lt.-4.) random1=-4.
if (random2.lt.-4.) random2=-4.
if (random1.gt.4.) random1=4.
if (random2.gt.4.) random2=4.
return
END