2 ! *****************************COPYRIGHT****************************
6 ! Redistribution and use in source and binary
forms, with or without
7 ! modification, are permitted provided that the
8 ! following conditions are
met:
10 ! * Redistributions of source code must retain the above
11 ! copyright
notice,
this list of conditions and the following
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
22 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 ! LIMITED
TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 ! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 ! LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 ! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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.
34 ! *****************************COPYRIGHT*******************************
35 ! *****************************COPYRIGHT*******************************
38 ! Marsaglia CONG algorithm
45 ! convert to range 0-1 (32 bit only)
46 overflow_32=i2_16*i2_16
47 if ( overflow_32 .le. huge32 ) then
49 ran(irand)=ran(irand)+1
50 ran(irand)=(ran(irand))-
int(ran(irand))