i try to convert a input_file.binary in a numbers output_file.txt with a fortran (or if someone have another idea: pyton, java, c++ ...). The ascii file is a 11 rows and N columns file with only numbers (i.e.: 1e-21, 0.0, 1 .... ).
I try this post ASCii to BInary Conversion Program in java but this is a bit different respect to my idea: i want to read the binary and write an output_file.dat so i try with this fortran code:
program binary
implicit none
integer :: i, n
real, allocatable :: data(:,:)
open(20,file="input.dat",status="unknown",err=88)
n = 0
do
read(20,*,end=1)
n = n+1
end do
1 rewind(20)
allocate(data(n,11))
OPEN(10, file="output_file.txt")
do i = 1, n
read(20,*) data(i,:)
write(10,*) data(i,:)
end do
close(20)
end program binary
when i want to inspect the file with nano file.binary
the output is like that:
^@^@^@^@^@^@^@^C^@^@^A�^@^@^@^A^@^@^@^A^@^R�M0wc�6�7�^@^@^@^FA0^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@@�e^A^@^@^@^B+�^[2/[��^@^@^@^FAI�#$
I can compile the program but when i try to run it i have the follow error message:
forrtl: severe (59): list-directed I/O syntax error, unit 20, file /.../input.dat Image PC Routine Line Source ascii 0805D0AA Unknown Unknown Unknown ascii 0805B14D Unknown Unknown Unknown ascii 0804A1EA Unknown Unknown Unknown ascii 08049E67 Unknown Unknown Unknown libc.so.6 B75CF4D3 Unknown Unknown Unknown
Thanks a lot for your help.