www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - read binary file

reply Jef Andrade <geojaca bol.com.br> writes:
Hi,
I am passing of FORTRAN for D, but I have problem to read (access direct)
binary file.
In FORTRAN I make:

real*4 x,wl,alfa //declaration real numbers
OPEN(UNIT=10,FILE="file.ad",form='unformatted',access='direct',recl=len,STATUS='UNKNOWN')
//open binary file
read(10,*) x, wl, alfa //reading the numbers of file binary

Or I can read everything that will be inside of file:

do j=1,nt
    read(10,*) x(j) //vector
enddo

Can you help me please?
Regards
Jan 08 2008
parent BCS <ao pathlink.com> writes:
Reply to Jef,

 Hi,
 I am passing of FORTRAN for D, but I have problem to read (access
 direct)
 binary file.
 In FORTRAN I make:
 real*4 x,wl,alfa //declaration real numbers
 OPEN(UNIT=10,FILE="file.ad",form='unformatted',access='direct',recl=le
 n,STATUS='UNKNOWN')
 //open binary file
 read(10,*) x, wl, alfa //reading the numbers of file binary
 Or I can read everything that will be inside of file:
 
 do j=1,nt
 read(10,*) x(j) //vector
 enddo
 Can you help me please?
 Regards
If you just want to read in the whole file as an array take a look at the read function in: http://www.digitalmars.com/d/1.0/phobos/std_file.html
Jan 08 2008