Re: Problem in reading binary file [message #80637] |
Wed, 27 June 2012 12:14  |
Russell Ryan
Messages: 122 Registered: May 2012
|
Senior Member |
|
|
On Wednesday, June 27, 2012 3:48:41 AM UTC-4, fada...@gmail.com wrote:
> Dear all
> I have a problem to reading a binary file that has been written by Fortran program. how I can read the binary file from fortran program. I run this command and i got this error. please see it my problem and give me solution. I am appreciating in advance. please look the program.
> infile = 'C:/Users/fadaei/IDLWorkspace80/DEM.dat' ;Input file name
> IDL>
> IDL> OPENR, iunit, infile, /GET_LUN ;Open input file
> IDL>
> IDL> n = 0 ;Make n a LONG
> IDL> m = 0 ;Make m a LONG
> IDL> READU, iunit, n, m ;Read n and m
> IDL>
> IDL> i = LONARR(n, n, n) ;Create i array
> IDL> z = FLTARR(m, m) ;Create z array
> IDL> b = BYTARR(m, m) ;Create b array
> IDL> READU, iunit, i, z, b ;Read i, z, and b
> IDL>
> IDL> FREE_LUN, iunit ;Close output file
> IDL>
> IDL> HELP, n, m, i, z, b ;Print variable info
> IDL> PRINT, z[0:3,0:3] ;Print part of z
> % OPENR: Error opening file. Unit: 100, File: C:\Users\fadaei\IDLWorkspace80\DEM.dat
> The system cannot find the file specified.
> % Error occurred at: $MAIN$
> % Execution halted at: $MAIN$
> % READU: Variable is undefined: IUNIT.
> % Error occurred at: $MAIN$
> % Execution halted at: $MAIN$
> % Array dimensions must be greater than 0.
> % Error occurred at: $MAIN$
> % Execution halted at: $MAIN$
> % Array dimensions must be greater than 0.
> % Error occurred at: $MAIN$
> % Execution halted at: $MAIN$
> % Array dimensions must be greater than 0.
> % Error occurred at: $MAIN$
> % Execution halted at: $MAIN$
> % READU: Variable is undefined: IUNIT.
> % Error occurred at: $MAIN$
> % Execution halted at: $MAIN$
> % FREE_LUN: Variable is undefined: IUNIT.
> % Error occurred at: $MAIN$
> % Execution halted at: $MAIN$
> N INT = 0
> M INT = 0
> I UNDEFINED = <Undefined>
> Z UNDEFINED = <Undefined>
> B UNDEFINED = <Undefined>
> % Variable is undefined: Z.
> % Error occurred at: $MAIN$
> % Execution halted at: $MAIN$
> best, Hadi
The first error is the only one that matters. The error is that the file C:\Users\fadaei\IDLWorkspace80\DEM.dat does not exist. You have the path and/or the name of the file incorrect.
|
|
|