comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Problem in reading binary file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Problem in reading binary file [message #80637] Wed, 27 June 2012 12:14
Russell Ryan is currently offline  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.
Re: Problem in reading binary file [message #80665 is a reply to message #80637] Wed, 27 June 2012 01:50 Go to previous message
hadi is currently offline  hadi
Messages: 33
Registered: June 2012
Member
On Wednesday, June 27, 2012 5:15:12 PM UTC+9, Mats Löfdahl wrote:
> Den onsdagen den 27:e juni 2012 kl. 09:48:41 UTC+2 skrev fada...@gmail.com:
>> 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
>
> You may want to read the error messages. Start with the first one:
>
> % OPENR: Error opening file. Unit: 100, File: C:\Users\fadaei\IDLWorkspace80\DEM.dat
> The system cannot find the file specified.
>
> Is the file you are trying to read actually called C:\Users\fadaei\IDLWorkspace80\DEM.dat?

Dear Mats
yes thats right.exactly
Best Hadi
Re: Problem in reading binary file [message #80666 is a reply to message #80665] Wed, 27 June 2012 01:15 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den onsdagen den 27:e juni 2012 kl. 09:48:41 UTC+2 skrev fada...@gmail.com:
> 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

You may want to read the error messages. Start with the first one:

% OPENR: Error opening file. Unit: 100, File: C:\Users\fadaei\IDLWorkspace80\DEM.dat
The system cannot find the file specified.

Is the file you are trying to read actually called C:\Users\fadaei\IDLWorkspace80\DEM.dat?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDLnetURL Object Not Loading
Next Topic: help with imdisp

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:40:12 PDT 2025

Total time taken to generate the page: 0.00547 seconds