home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!gdt!ccsdhd
- From: ccsdhd@gdt.bath.ac.uk (Dennis Davis)
- Newsgroups: comp.lang.fortran
- Subject: Re: recursive I/O
- Message-ID: <1992Jul22.112743.25481@gdt.bath.ac.uk>
- Date: 22 Jul 92 11:27:43 GMT
- References: <1992Jul21.223157.2775@ccu1.aukuni.ac.nz>
- Organization: Bath University Computing Services, UK
- Lines: 37
-
- In article <1992Jul21.223157.2775@ccu1.aukuni.ac.nz> ecmtwhk@ccu1.aukuni.ac.nz (Thomas Koenig) writes:
- >Is the following legal F77? It works on the UNIX box I'm on at the
- >moment, but I can imagine trouble with architectures which do not use
- >a stack for argument passing, for example /370.
- >
- >C This assumes channels 6 and 0 are preconnected
- > PROGRAM MAIN
- > WRITE (6,*) FCN(2.3)
- > END
- > FUNCTION FCN(A)
- > IF (A.GT.2.) WRITE (0,*) 'Something horrible happened'
- > FCN = 2. - A
- > END
-
- This is illegal Fortran. See Section 12.11 of the Standard which
- states:
-
- "A function must not be referenced within an expression
- appearing anywhere in an input/output statement if such a
- reference causes an input/output statement to be executed."
-
- I'd regard your program as illegal as it stands. If the argument
- to the function were less than or equal to 2, I'd regard the
- program as legal.
-
- Writing programs which can flip-flop in and out of legality is, in
- my opinion, a rather dubious practice. Unfortunately they are all
- too easy to write. For example the two lines of code:
-
- READ (5, *) I, J, K, L, M, N
- A(I:J) = A(K:L) // A(M:N)
-
- is legal or illegal depending upon the values of the integer
- variables read in. See Section 10.4 of the Standard.
- --
- Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, United Kingdom
- D.H.Davis@bath.ac.uk ...!uunet!mcsun!ukc!gdr!D.H.Davis
-