user3503704
user3503704

Reputation:

Convert Binary Data File to Text File

I have a .bin file on my hard drive. It's recl is nx*ny*4. Its dimensions are (241,121). 241 in x dimension. 121 in y dimension. How would I convert it using fortran to an ascii file that I can open and read numbers off of?

So, far I have tried

real :: g1(241,121) 
open(unit=1,file=gaugemax2010.bin',status='old',
form='unformatted',access='direct',recl=nx*ny*4) 


open(unit=5,file='g2010.txt',status='unknown', 
form='unformatted',access='direct',recl=1) 

read(1, rec=1) ((g1(i,j,),i=1,nx,j=1,ny)
write(5, rec=1) (g1(i,j,),i=1,241),h=1,121) 
end

and it has not worked

Upvotes: 0

Views: 1639

Answers (1)

Alexander Vogt
Alexander Vogt

Reputation: 18118

FORM='UNFORMATTED' opens a file for binary content. For pure text you have to specify FORM='FORMATTED'.

For more details on the OPEN statement see here: Opening Binary Files in Fortran: Status, Form, Access

Upvotes: 1

Related Questions