On Thu, 30 Oct 1997 13:16:37 +0100 Swietanowski Artur
<[log in to unmask]> wrote:
> Dear All,
>
> I'd like to initialize some constants used in a numerical algorithm
> using the HUGE and EPSILON intrinsics. However some of the constant
> data that depends on the values of those functions has to be
> calculated using other intrinsics, e.g. SQRT.
>
> I'd like to write:
> ----
> MODULE NumericConstants
> USE Kinds
> IMPLICIT NONE
>
> PUBLIC
>
> REAL(dbl) :: &
> ZeroTolDbl = SQRT( EPSILON( 1.0_dbl ) ), &
> InfDbl = SQRT( HUGE( 1.0_dbl ) )
>
> END MODULE NumericConstants
> ----
>
> It is forbidden by the standard (says my compiler) to initialize
> it like that. Instead I have to write a lot more code and check
> for the proper initializations myself. Can enyone tell me WHY????
An extremely good question! The argument was something like this.
Initialisation is done at compile time. Some vendors are loath to have the
intrinsic library available at compile time, at least the floating point part
of it. Therefore, we must ban floating point intrinsics from initialisation
expressions. A very weak argument I thought at the time, and I think it is
even worse now. Another slightly stronger argument used was that compilers
could be cross compilers, running on one machine but generating code for a
different machine where the FP arithmetic was different. In such cases the
initialisation on the compiler machine could produce different values than
would apply on the target machine. This is true but I think largely
irrelevent. Such situations will be comparitively rare and where they do the
user may need to be careful about round-off effects in initialisation, no big
deal.
Your example illustrates precisely why I have been conducting an as yet
unsuccessful campain to have these petty unnecessary restrictions removed.
WG5 are you listenning, I am not a loan voice!
--
Lawrie Schonfelder
Director, Computing Services Dept.
The University of Liverpool, UK, L69 7ZF
Phone: 44(151)794 3716, Fax: 44(151)794 3759
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|