[comp.lang.fortran] Position after Open

cammta@taux02.UUCP (Amit Mattatia ) (10/24/88)

I will appreciate an answer to the following question:

In ANSI Fortran 77, after executing a statement such as:
	open(2, file='kuku', access='sequential', status='old')
What should be the positioning on the newly opened file? 
Should it be before the first record, or after the last record?
Or is the behavior in such cases rather "processor dependent"?
-- 
Amit Mattatia, CTP group, NSTA
National Semiconductor (Israel)
6 Maskit st.  P.O.B. 3007, Herzlia 46104, Israel   Tel. (972)52-522264
cammta%taux02@nsc.com   @{hplabs,pyramid,sun,decwrl} 

hirchert@uxe.cso.uiuc.edu (10/25/88)

Amit Mattatia(cammta@taux02.UUCP) asks:
>In ANSI Fortran 77, after executing a statement such as:
>	open(2, file='kuku', access='sequential', status='old')
>What should be the positioning on the newly opened file? 
>Should it be before the first record, or after the last record?
>Or is the behavior in such cases rather "processor dependent"?

The behavavior is not specified in X3.9-1978 (FORTRAN 77) and thus is
processor dependent.

Kurt W. Hirchert     hirchert@ncsa.uiuc.edu
National Center for Supercomputing Applications

cdb@hpclcdb.HP.COM (Carl Burch) (10/26/88)

The Fortran 77 standard doesn't say, which defaults to "processor-dependent".
I know of at least one implementation that sets the initial position to the
end, while the others I know of offhand open it at the beginning.

If we ever get the Fortran 8x standard out, one of the additions to the OPEN
statement is the POSITION= specifier, which takes a scalar character expression
that evaluate to 'ASIS', 'REWIND', or 'APPEND'.  The default is 'ASIS', which
(if the file is not previously connected) means the position is "unspecified"-
a.k.a. "processor-dependent".  This is one of the many small enhancements that
are hanging for years waiting for X3J3 to agree on a few larger items.

						- Carl Burch
						  HP Compiler Lab

jerry@violet.berkeley.edu ( Jerry Berkman ) (11/08/88)

In article <6690021@hpclcdb.HP.COM> cdb@hpclcdb.HP.COM (Carl Burch) writes:

>The Fortran 77 standard doesn't say, which defaults to "processor-dependent".
>I know of at least one implementation that sets the initial position to the
>end, while the others I know of offhand open it at the beginning.

>If we ever get the Fortran 8x standard out, one of the additions to the OPEN
>statement is the POSITION= specifier, which takes a scalar character expression
>that evaluate to 'ASIS', 'REWIND', or 'APPEND'.  The default is 'ASIS', which
>(if the file is not previously connected) means the position is "unspecified"-
>a.k.a. "processor-dependent".

The standard should specify that files are opened at the beginning.
Most users expect this, and most implementations do open files at the
beginning.  BSD f77 used to open files at the end; this confused users.
We changed it about 5(?) years ago to open files at the beginning.
No one ever complained about the change, and I no longer have to explain
this idiosyncracy to confused users.
	- Jerry Berkman, UC Berkeley,
	  jerry@violet.berkeley.edu