/[MITgcm]/MITgcm/model/src/port_rand.F
ViewVC logotype

Diff of /MITgcm/model/src/port_rand.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.7 by jmc, Tue Dec 8 21:50:35 2009 UTC revision 1.8 by jmc, Fri Aug 9 15:00:46 2013 UTC
# Line 162  C     !LOCAL VARIABLES: Line 162  C     !LOCAL VARIABLES:
162  c     seed=1618033.0d0  c     seed=1618033.0d0
163    
164  C     first generate 2 equally distributed random numbers (-1,1)  C     first generate 2 equally distributed random numbers (-1,1)
165        DO WHILE (1 .EQ. 1)        xs = 0.0
166          DO WHILE ( xs.GE.1.0 .OR. xs.EQ.0.0 )
167           x1=2.0*port_rand(seed)-1.0           x1=2.0*port_rand(seed)-1.0
168           x2=2.0*port_rand(seed)-1.0           x2=2.0*port_rand(seed)-1.0
169           xs=x1**2+x2**2           xs=x1**2+x2**2
          IF (xs .LT. 1.0 .AND. xs .NE. 0.0) THEN  
             GOTO 100  
          ENDIF  
170        ENDDO        ENDDO
  100  CONTINUE  
171    
172        t = SQRT(-2.0*LOG(xs)/xs)        t = SQRT(-2.0*LOG(xs)/xs)
173        port_rand_norm = t*x1        port_rand_norm = t*x1
174  C  
175  C     also t*x2 would be a gaussian random number and could be returned  C     also t*x2 would be a gaussian random number and could be returned
176    
177        RETURN        RETURN

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.22