source: trunk/libf/cosp/congvec.h @ 1

Last change on this file since 1 was 1, checked in by emillour, 14 years ago

Import initial LMDZ5

File size: 2.3 KB
Line 
1
2! *****************************COPYRIGHT****************************
3! (c) British Crown Copyright 2009, the Met Office.
4! All rights reserved.
5! 
6! Redistribution and use in source and binary forms, with or without
7! modification, are permitted provided that the
8! following conditions are met:
9! 
10!     * Redistributions of source code must retain the above
11!       copyright  notice, this list of conditions and the following
12!       disclaimer.
13!     * Redistributions in binary form must reproduce the above
14!       copyright notice, this list of conditions and the following
15!       disclaimer in the documentation and/or other materials
16!       provided with the distribution.
17!     * Neither the name of the Met Office nor the names of its
18!       contributors may be used to endorse or promote products
19!       derived from this software without specific prior written
20!       permission.
21! 
22! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26! OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
27! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
29! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
33! 
34! *****************************COPYRIGHT*******************************
35! *****************************COPYRIGHT*******************************
36
37      do irand = 1, npoints
38          ! Marsaglia CONG algorithm
39          seed(irand)=69069*seed(irand)+1234567
40          ! mod 32 bit overflow
41          seed(irand)=mod(seed(irand),2**30)   
42          ran(irand)=seed(irand)*0.931322574615479E-09
43      enddo
44
45      ! convert to range 0-1 (32 bit only)
46      overflow_32=i2_16*i2_16
47      if ( overflow_32 .le. huge32 ) then
48          do irand = 1, npoints
49              ran(irand)=ran(irand)+1
50              ran(irand)=(ran(irand))-int(ran(irand))
51          enddo
52      endif
53
54
Note: See TracBrowser for help on using the repository browser.