Home > Archive > Fortran > March 2006 > STOP while writing
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
STOP while writing
|
|
| John Harper 2006-03-23, 10:03 pm |
| In this f95 program, STOP followed by a character constant occurs
inside a function called in a PRINT statement.
! Is STOP <non-empty string> OK in a function called in WRITE?
PRINT*,f(-2.0)
CONTAINS
REAL FUNCTION f(x)
IF(x<0)STOP ' x must not be negative in f(x)'
f = sqrt(x)
END FUNCTION f
END
NAG f95 version 5.0 aborts with a core dump at run-time, saying
STOP ' x must not be negative in f(x)' while I/O in progress
but g95 runs it OK, with the output I had expected:
x must not be negative in f(x)
Which compiler is right? (Is this recursive I/O or not?)
-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045
| |
| James Giles 2006-03-23, 10:03 pm |
| John Harper wrote:
> In this f95 program, STOP followed by a character constant occurs
> inside a function called in a PRINT statement.
>
> ! Is STOP <non-empty string> OK in a function called in WRITE?
> PRINT*,f(-2.0)
> CONTAINS
> REAL FUNCTION f(x)
> IF(x<0)STOP ' x must not be negative in f(x)'
> f = sqrt(x)
> END FUNCTION f
> END
>
> NAG f95 version 5.0 aborts with a core dump at run-time, saying
> STOP ' x must not be negative in f(x)' while I/O in progress
> but g95 runs it OK, with the output I had expected:
> x must not be negative in f(x)
>
> Which compiler is right? (Is this recursive I/O or not?)
(I won't even get into why I don't like the phrase "recursive IO".)
I'm pretty sure that the STOP statement is not considered I/O.
As a practical matter, the implementation probably does it
using the same internal operations as I/O. There may, however,
be a limitation that I can't find that applies to STOP itself....
Ah, yes. §9.11 of the F2003 standard (actually J3/04-007)
page 219 line 30:
A STOP statement shall not be executed during execution
of an input/output statement.
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
|
|
|
|
|