Jose,
I did not look at the actual file, but from the name of the file, they are
stored as one continuous stream of binary bits. If this is the case, your
program might try to read some bits that are not a valid representation of a
real number.
I think you should read them as a streams of bytes, and divide by the
appropriate value to obtain the range [0,1]. For example, read 2 bytes and
divide by (2^16)-1 or 65535.
You might want to look at the included source file to get some idea of how it
is read.
Hope this help.
Shyan, [log in to unmask]
"Jose J. Canals-Cerda" <[log in to unmask]> wrote:
> Hello,
>
> I am interested in a fortran program that does the following things:
>
> 1.- reads from a file of random bites, for example one of
> Marsaglia random generated files
> (http://www.csis.hku.hk/internet/randomCD.html)
>
> 2.- transforms this data into real*8 random numbers within
> the
> [0,1] interval.
>
> Conceptually this does not seem hard and I am sure that somebody has
>
> faced this problem before.
>
> Using DVF6.1 I have written a simple program that reads one of
> Marsaglia files. I am not sure that I have done this correctly because I
> have never faced this problem before.
>
>
> PROGRAM random
> implicit none
> real(8) :: rreal
> integer :: n,ierror,ierror1
>
>
open(unit=1,file='c:\temp\bits.01',status='unknown',FORM='BINARY',action='read',iostat=ierror)
>
>
open(unit=2,file='c:\temp\out.dat',status='unknown',action='write',iostat=ierror1)
>
> do n = 1,10
> read(1)rreal
> write(2,*)rreal
> enddo
> END PROGRAM
>
> The result is
>
> 2.361349061791736E-199
> 8.425998214083004E+149
> -1.301095633149849E+261
> 5.166552341828369E+202
> -1.757866860529372E-276
> 7683276257476.26
> 6.581435966483412E-238
> 2.139230620717598E-264
> 2.629136211473332E+030
> 4.493242642612468E+071
>
> When I consider the option
>
> real(4) :: rreal
>
> the result is
>
> 8.1462669E+36
> 2.8769560E-25
> 4.3009742E-22
> 1.0410461E+19
> -556929.2
> -8.3743773E+32
> 4.0191015E-16
> 4.0224823E+25
> 1.5110841E-21
> -6.5888261E-35
>
> Any suggestions on how to solve this problem would be appreciated.
> Thanks in advance.
>
>
>
> Jose.
>
> -----------------------------------------------------
> Department of Economics
> University of Colorado at Boulder
> Campus Box 256
> Boulder, Colorado 80309-0256
> Phone: 3034927869
> Fax: 3034928960
> E-mail: [log in to unmask]
> web: http://stripe.Colorado.EDU/~canalsce/Home.html
> -------------------------------------------------------
>
>
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|