source: branches/jerome/src_flexwrf_v3.1/gasdevlux.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: 2.9 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!* This file is part of FLEXPART WRF                                   *
8!*                                                                     *
9!* FLEXPART is free software: you can redistribute it and/or modify    *
10!* it under the terms of the GNU General Public License as published by*
11!* the Free Software Foundation, either version 3 of the License, or   *
12!* (at your option) any later version.                                 *
13!*                                                                     *
14!* FLEXPART is distributed in the hope that it will be useful,         *
15!* but WITHOUT ANY WARRANTY; without even the implied warranty of      *
16!* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
17!* GNU General Public License for more details.                        *
18!*                                                                     *
19!* You should have received a copy of the GNU General Public License   *
20!* along with FLEXPART.  If not, see <http://www.gnu.org/licenses/>.   *
21!***********************************************************************
22    !C--- adapted from press et al. 1992 numerial recipes in Fortran by Massimo Cassiani to jse RANLUX as uniform random number generator
23      FUNCTION gasdevlux()
24      USE luxury
25      INTEGER idum
26      REAL gasdevlux     
27      INTEGER iset
28      REAL fac,gset,rsq,v1,v2,RTEST(2)
29      SAVE iset,gset
30      DATA iset/0/
31      if (iset.eq.0) then
321      call RANLUX(RTEST,2)
33
34        v1=2.*RTEST(1)-1.
35        v2=2.*RTEST(2)-1.
36        rsq=v1**2+v2**2
37        if(rsq.ge.1..or.rsq.eq.0.)goto 1
38        fac=sqrt(-2.*log(rsq)/rsq)
39        gset=v1*fac
40        gasdevlux=v2*fac
41        iset=1
42      else
43        gasdevlux=gset
44        iset=0
45      endif
46      return
47      END
48     
49      subroutine gasdevlux2R(random1,random2)
50      USE luxury
51      INTEGER idum
52      REAL random1,random2     
53      INTEGER iset
54      REAL fac,gset,rsq,v1,v2,RTEST(2)
55     
561      call RANLUX(RTEST,2)
57
58        v1=2.*RTEST(1)-1.
59        v2=2.*RTEST(2)-1.
60        rsq=v1**2+v2**2
61        if(rsq.ge.1..or.rsq.eq.0.)goto 1
62        fac=sqrt(-2.*log(rsq)/rsq)
63        random1=v1*fac
64        random2=v2*fac
65  ! Limit the random numbers to lie within the interval -4 and +4
66  !**************************************************************
67       if (random1.lt.-4.) random1=-4.
68       if (random2.lt.-4.) random2=-4.
69       if (random1.gt.4.) random1=4.
70       if (random2.gt.4.) random2=4.
71      return
72      END
73   
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG