c c A C-program for MT19937, with initialization improved 2002/1/26. c Coded by Takuji Nishimura and Makoto Matsumoto. c c Before using, initialize the state by using init_genrand(seed) c or init_by_array(init_key, key_length). c c Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, c All rights reserved. c Copyright (C) 2005, Mutsuo Saito, c All rights reserved. c c Redistribution and use in source and binary forms, with or without c modification, are permitted provided that the following conditions c are met: c c 1. Redistributions of source code must retain the above copyright c notice, this list of conditions and the following disclaimer. c c 2. Redistributions in binary form must reproduce the above copyright c notice, this list of conditions and the following disclaimer in the c documentation and/or other materials provided with the distribution. c c 3. The names of its contributors may not be used to endorse or promote c products derived from this software without specific prior written c permission. c c THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS c "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT c LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR c A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR c CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, c EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, c PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR c PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF c LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING c NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS c SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. c c c Any feedback is very welcome. c http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html c email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) c c----------------------------------------------------------------------- c FORTRAN77 translation by Tsuyoshi TADA. (2005/12/19) c----------------------------------------------------------------------- program mttest integer genrand_int32,init(4),length,i,j double precision genrand_real2,r character*11 c(5) data init /291,564,837,1110/ data length /4/ c call init_by_array(init,length) c write(6,'(a31)')'1000 outputs of genrand_int32()' do 100 i=1,200 do 110 j=1,5 r=dble(genrand_int32()) if(r.lt.0.d0)r=r+2.d0**32 write(c(j),'(f11.0))')r c(j)(11:11)=' ' 110 continue write(6,'(5a11)')(c(j),j=1,5) 100 continue c write(6,'(/a31)')'1000 outputs of genrand_real2()' do 200 i=1,200 do 210 j=1,5 r=genrand_real2() write(c(j),'(f10.8,1h ))')r if(c(j)(1:1).eq.' ')c(j)(1:1)='0' 210 continue write(6,'(5a11)')(c(j),j=1,5) 200 continue c end