Re: Automatic allocation of an available file unit
- From: Paul Van Delst <Paul.vanDelst@xxxxxxxx>
- Date: Fri, 31 Mar 2006 10:33:08 -0500
Joe Krahn wrote:
I noticed that J3 is (finally) implementing automatic file unit allocation:
http://j3-fortran.org/doc/year/06/06-138r2.txt
I see that the plan is to use negative unit numbers for automatically assigned units. It seems to me that there would be fewer conflicts by using positive numbers starting at some number higher than the old compiler limits, an therefore unlikely to conflict with old code using constant unit numbers.
That's just my 2 cents.
I have been strictly avoiding constant unit numbers for a long time, using a function that returns a free UNIT, found by a simple INQUIRE loop, which also returns the unit number in an optional argument, so you can do an open statement like this:
open(unit=file_unit(data_unit), ...)
read(data_unit,...)
Doesn't everyone do something like this? :o) Although I tend towards the:
fileid=get_lun()
open(fileid, ....)
read(fileid, ....)
method.
But, if you do the above doesn't it mean that you don't really care what the actual unit value is? All you care is that it's valid to use for file I/O, right? So what does it matter if it's negative? From the link you gave, if the NEWUNIT= specifier is used, you'd do something like:
open(file='myfile.name',newunit=fileid, ....)
read(fileid, ....)
Same dog, different leg AFAICT.
cheers,
paulv
--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
.
- Follow-Ups:
- Re: Automatic allocation of an available file unit
- From: beliavsky
- Re: Automatic allocation of an available file unit
- References:
- Automatic allocation of an available file unit
- From: Joe Krahn
- Automatic allocation of an available file unit
- Prev by Date: Re: fortran code for 'cp' / subroutine file_copy
- Next by Date: Re: O/T: Patenting a computational scheme?
- Previous by thread: Re: Automatic allocation of an available file unit
- Next by thread: Re: Automatic allocation of an available file unit
- Index(es):
Relevant Pages
|