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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unit 6 in gfortran for (*,*)?

Status
Not open for further replies.

GerritGroot

Technical User
Nov 3, 2006
291
ES
Does anyone know whether unit 6 for writing files is reserved in gfortran for writing to the screen?

I am writing to file unit 6 and get stuff from write(*,*) in my text file :-(

After not having found anything in the code, I changed the unit to UNIT=7 and the problem was gone.
 
Not sure, but I think that
unit 5 is standard input,
unit 6 is standard output,
unit 7 is standard error.
 
Normal : with most FORTRAN compilers, the unit * corresponds to 6 in WRITE statements.

If you want to avoid strange behaviors, use only unit indexes greater than 10. The unit indexes less than 10 were used in the past for specific input or output devices. For instance 5 for standard input, 6 for printers, 7 for card punch ... This behavior still continues today with recent compilers because of legacy codes.
 
Damn! I thought I already had quite some experience in fortran, but this is not mentioned anywhere. I got loads of codes starting with unit 1,2,3 etc. Never had any problem until I started with gfortran.

Thanks both!
 
Additional information :

The reserved units 4,5,6,7 have been defined by IBM a long time ago.

The units 0,1,2 are risky as well because of the UNIX meaning of "standard input","standard output" and "standard error".

All these predefined units are not defined by the FORTRAN language.

FORTRAN-77 has introduced the unit * for READ and WRITE on standard input/output devices.

FORTRAN-2003 has introduced the is_fortran_env module which provides explicitly the reserved units error_unit, input_unit, output_unit but the FORTRAN-77 * remains remains the normal way in most cases.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top