[comp.lang.fortran] Bogosity in Gould FORTRAN?

lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) (05/02/89)

     I have just had a run-in with Gould FORTRAN.  Apparently, Gould
decided to OPEN files with the pointer at end of file as the default.
So if you want to READ some data, you need to do a REWIND immediately
after the OPEN.  On the two dozen or so types of computers I have run
on, never have I run into this.  Have I just been lucky?  I would
appreciate hearing from others who have been bitten by this?
     Gould says that since ANSI didn't explicitely say that the pointer
to an OPEN'd file must be at the beginning of the file, that they can
do this and still be ANSI.  Any comments?


-- 
Mike Lijewski  (H)607/277-7623 (W)607/255-0539
Cornell National Supercomputer Facility
ARPA: mjlx@cornellf.tn.cornell.edu  BITNET: mjlx@cornellf.bitnet
SMAIL:  102 E. Court St. Ithaca, NY  14850

mac@harris.cis.ksu.edu (Myron A. Calhoun) (05/02/89)

In article <7863@batcomputer.tn.cornell.edu> lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) writes:
>     I have just had a run-in with Gould FORTRAN.  Apparently, Gould
>decided to OPEN files with the pointer at end of file as the default.
 [ several lines deleted for brevity]
>     Gould says that since ANSI didn't explicitely say that the pointer
>to an OPEN'd file must be at the beginning of the file, that they can
>do this and still be ANSI.  Any comments?

The (yellow spine) UNIX Programmers Manual contains a similar statement
regarding "A Portable Fortran 77 Compiler".  Apparently this is just
another of the many things about which good programmers need to be aware.
Makes for more job security, at least!
--
Myron A. Calhoun, PhD EE, W0PBV, (913) 532-6350 (work), 539-4448 (home).
INTERNET: mac@ksuvax1.cis.ksu.edu
BITNET:   mac@ksuvax1.bitnet
UUCP:  ...{rutgers, texbell}!ksuvax1!harry!mac

ethan@esosun.UUCP (Ethan Brown) (05/02/89)

In article <7863@batcomputer.tn.cornell.edu> lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) writes:

	I have just had a run-in with Gould FORTRAN.  Apparently, Gould
   decided to OPEN files with the pointer at end of file as the default.
   So if you want to READ some data, you need to do a REWIND immediately
   after the OPEN.  On the two dozen or so types of computers I have run
   on, never have I run into this.  Have I just been lucky?  I would
   appreciate hearing from others who have been bitten by this?
	Gould says that since ANSI didn't explicitely say that the pointer
   to an OPEN'd file must be at the beginning of the file, that they can
   do this and still be ANSI.  Any comments?


Yes indeed.  I had the same unfortunate "feature" affect me when I ported
a seismic analysis code from UN*X to gould's version.  As you did, I just
went around and added rewind statements after each open.  

I will usually put a rewind statement after an open, and have had some people
remark that it's unnecessary.  Ha!  I'd sure like to know their rational
for OPENing files this way, though.

--
--Ethan Brown					...seismo!esosun!ethan
--Science Applications International Corp.
--Geophysics Division 
--

jerry@violet.berkeley.edu ( Jerry Berkman ) (05/02/89)

In article <1804@deimos.cis.ksu.edu> mac@harris.cis.ksu.edu (Myron A. Calhoun) writes:
>In article <7863@batcomputer.tn.cornell.edu> lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) writes:
>> Apparently, Gould decided to OPEN files with the pointer at end of file
>> as the default. ... Gould says that since ANSI didn't explicitly say
>> that the pointer
>>to an OPEN'd file must be at the beginning of the file, that they can
>>do this and still be ANSI.  Any comments?

The ANSI standard does not specify where a file should be opened.

>The (yellow spine) UNIX Programmers Manual contains a similar statement
>regarding "A Portable Fortran 77 Compiler".

I don't see such a statement in my manual.  BSD VAX UNIX f77 opened files
at the end until 1984, at which time it switched to opening files at the
beginning.  Some systems may still open files at the end of file.  I would
be especially careful with System V based systems.

	- Jerry Berkman, U.C. Berkeley
	  jerry@violet.berkeley.edu

brainerd@unmvax.unm.edu (Walt Brainerd) (05/02/89)

In article <7863@batcomputer.tn.cornell.edu>, lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) writes:
> 
>      I have just had a run-in with Gould FORTRAN.  Apparently, Gould
> decided to OPEN files with the pointer at end of file as the default.

Stu Feldman tried to get X3J3 to plug the hole & was not successful
for some reason, so, just to be perverse, he opened files at the end
in his orginal version of f77.  Can't imagine anybody that was writing
a compiler for commercial purposes would ever do such a thing.  Following
along like sheep, I guess!

   Walt Brainerd, Unicomp, Inc. 505/275-0800 brainerd@unmvax.unm.edu

hirchert@uxe.cso.uiuc.edu (05/04/89)

. Why the standard doesn't specify that files are read from the beginning.

  A number of systems support the concept of multi-file files (at least on
  tape) or other features in which system prepositioning is useful.  It would
  be decidedly unfriendly to force the processor to blow that preprocessing
  away (especially for output files).  [The Fortran 8x draft has a new OPEN
  option that allows you to specify whether you want to start at the beginning
  of the file, the end of the file, or where the system has left you
  positioned.]

. A possible reason why Gould is opening files at the end.

  The original f77 compiler for Unix systems did this.  It was done for a
  number of reasons.  In particular, it provides a more convenient way to
  add to the end of a sequential file than having to read through the entire
  file.  [Since Fortran 8x provides an explicit way to ask for positioning at
  the end of a file, we can hope that vendors will be smart enough to make the
  default system positioning be to the beginning of the file rather than the
  end.]

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

smryan@garth.UUCP (s m ryan) (05/06/89)

On CDC NOS, jobs have a structure like

	compile-a-program
	run-the-program
		-file-separator-
	source
	  program
	    text
		-file-separator-
	input
	  for
	    the
	      program

All of this is a single file called INPUT. On openning INPUT, the default is
not to reposition it so that it starts after the second file-separator. If files
were always rewound at open, the program would begin reading the control
statements instead of the data.

The point being, not all of the world is a Unix. A language should be as
independent of the environment as possible so that is available in many
different environments as possible.
-- 
16. `The wealth I lose becomes the bane           Steven Ryan: ingr!garth!smryan
of all who own or seek in vain.                    2400 Geng Road, Palo Alto, CA
It brings but death to Hreithmar's kin     Here have some grub. O they very fine
and joy of wealth no man shall win.'     baby worms cooked in the holy corn oil.

brainerd@unmvax.unm.edu (Walt Brainerd) (05/10/89)

In article <2820@garth.UUCP>, smryan@garth.UUCP (s m ryan) writes:
> On CDC NOS, jobs have a structure like
> 
> 	compile-a-program
> 	run-the-program
> 		-file-separator-
> 	source
> 	  program
> 	    text
> 		-file-separator-
> 	input
> 	  for
> 	    the
> 	      program
> 
> All of this is a single file called INPUT. On openning INPUT, ...

It may be a single file to you (or your system), but the standard
does not specify what a file is really, and one could argue successfully
that _the_ file (to be used for input) begins after the last
file separator.