Fortran could invent an "errmsg" intrinsic that is permitted to be called by
pure functions.
= Loren P Meissner
-----Original Message-----
From: [log in to unmask]
[mailto:[log in to unmask]] On Behalf Of Neil Carlson
Sent: Wednesday, May 17, 2000 5:07 PM
To: [log in to unmask]
Subject: Pure procedures and exceptions
I'm irritated by an apparent inconsistency in constraints
between user-written pure functions and intrinsic functions
which are pure. A pure function is not allowed to do any i/o
nor execute a stop statement, but many of the intrinsic
functions do exactly this (or effectively so); for example,
asin(2.0) produces an arithmetic exception, output to stdout,
and halts execution of the program (NAG compiler). How is one
supposed to write a pure function having a limited domain?
Has this issue been addressed in F2K? My only thought is to
execute something like "asin(2.0)" when the input is out-of-range
to trigger the desired abort, but it's kludgy and one needs to
watch out for compilers that are too smart (the NAG compiler
recognized sin(0.0) as 0.0, so 1.0/sin(0.0) didn't work).
Anybody have any a more elegant solution?
Thanks!
--
Neil Carlson Voice: 505-665-1220
Motorola Computational Materials Group FAX: 505-665-5757
Los Alamos National Laboratory [log in to unmask]
Mailstop B221, Los Alamos, NM 87545 [log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|