Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP ME!!! "open:illegal unit number "

Status
Not open for further replies.

chitina79

Programmer
Apr 19, 2007
4
IT
Hi all!!
I'm not a very good programmer...so I need same help!
I wrote a f77 code with a prinicpal program and 5 subroutines. The programm needs same input files and then after some procedures it calculates same quantities that I need to save as output file...the problem is that when I create a unit to save that quantities in the output file tha program has problem in running and it ends with :
*****
open:illegal unit number
apparent state:unit 4 namend exit
lately writing sequential formatted esternaml I0
Aborted
*****
The number 4 is related to an other output file...not that I create now...and if I changes that number the problems return with an other unit, for example an input unit number 70....I don't understand what I could do...can yuou help me?? Please!!


Thank you very much!
C.
 
What does your open statement look like?
 
I have simply written:

open(unit=13,file='namefile',status='unknown',form='formatted')
do j=1,n
write(13,0) var(j)
end do
close(unit=13)

where var(j) is the array to save.
 
Don't forget to close input unit before to reuse it (for output file, for example).
Don't use pre-opened units (for example, 1,2,5,6 are usually opened by RTL for readind/printing on default devices).
 
Yes, I know this...it's for this reason that I can't explain to me this error.
 
But
Code:
write(13,0) var(j)
is illegal construct. Zero format label?..
It's output on unit 13. Why unit 4 was in the original post?
It seems we don't see now that problem piece of code...
 
Might be an easy misspelling:

maybe you typed l3 instead of 13. The first one is 'L3' which might be an integer variable in your prog which has the value 4.

Thet's the only way I can think of, if you have l3 in your code and receive an error about a unit number being 4.

4 is an invalid unit because it is/was attributed to some i/o unit that I am no longer aware of. Some inheritance of the early years of programming.

Norbert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top