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

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

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


Revision 1.2 - (hide annotations) (download)
Fri Feb 2 21:04:48 2001 UTC (23 years, 4 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint40pre3, checkpoint40pre1, checkpoint40pre7, checkpoint40pre6, checkpoint40pre9, checkpoint40pre8, checkpoint38, checkpoint40pre2, checkpoint40pre4, pre38tag1, c37_adj, pre38-close, checkpoint39, checkpoint37, checkpoint36, checkpoint35, checkpoint40pre5, checkpoint40
Branch point for: pre38
Changes since 1.1: +82 -0 lines
Merged changes from branch "branch-atmos-merge" into MAIN (checkpoint34)
 - substantial modifications to algorithm sequence (dynamics.F)
 - packaged OBCS, Shapiro filter, Zonal filter, Atmospheric Physics

1 adcroft 1.2 C $Header: /u/gcmpack/models/MITgcmUV/model/src/Attic/port_rand.F,v 1.1.2.1 2001/01/25 18:44:07 adcroft Exp $
2     C $Name: branch-atmos-merge-freeze $
3    
4     C Portable random number generator
5    
6     #undef _USE_INTEGERS
7    
8     ! ==============================================================================
9     real*8 function port_rand()
10     implicit none
11     integer nff
12     parameter(nff=55)
13     #ifdef _USE_INTEGERS
14     integer mbig,mseed,mZ
15     #else
16     real*8 mbig,mseed,mz
17     #endif
18     real*8 fac
19     #ifdef _USE_INTEGERS
20     parameter (mbig=1000000000,mseed=161803398,mz=0,fac=1./mbig)
21     #else
22     parameter (mbig=4000000.,mseed=1618033.,mz=0.,fac=1./mbig)
23     #endif
24     integer i,ii,inext,inextp,k,idum
25     parameter(idum=-2)
26     #ifdef _USE_INTEGERS
27     integer mj,mk,ma(nff)
28     #else
29     real*8 mj,mk,ma(nff)
30     #endif
31     logical firstCall
32     save firstCall,inext,inextp,ma
33     data firstCall /.true./
34     ! ------------------------------------------------------------------------------
35     if(firstCall)then
36     firstCall=.false.
37     mj=mseed-iabs(idum)
38     mj=mod(mj,mbig)
39     ma(nff)=mj
40     mk=1
41     do i=1,nff-1
42     ii=mod(21*i,nff)
43     ma(ii)=mk
44     mk=mj-mk
45     if(mk.lt.mz)mk=mk+mbig
46     mj=ma(ii)
47     enddo
48     do k=1,4
49     do i=1,nff
50     ma(i)=ma(i)-ma(1+mod(i+30,nff))
51     if(ma(i).lt.MZ)ma(i)=ma(i)+mbig
52     enddo
53     enddo
54     inext=0
55     inextp=31
56     endif
57     inext=mod(inext,nff)+1
58     inextp=mod(inextp,nff)+1
59     mj=ma(inext)-ma(inextp)
60     if(mj.lt.MZ)mj=mj+mbig
61     ma(inext)=mj
62     port_rand=mj*fac
63     return
64     ! ------------------------------------------------------------------------------
65     end
66     ! ==============================================================================
67    
68     ! ==============================================================================
69     subroutine port_ranarr(n,arr)
70     implicit none
71     integer n,i
72     real arr(n)
73     real*8 port_rand
74     ! ------------------------------------------------------------------------------
75     do i=1,n
76     arr(i)=port_rand()
77     enddo
78    
79     return
80     ! ------------------------------------------------------------------------------
81     end
82     ! ==============================================================================

  ViewVC Help
Powered by ViewVC 1.1.22