Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site oddjob.UChicago.UUCP
Path: utzoo!linus!decvax!bellcore!allegra!ulysses!mhuxr!ihnp4!oddjob!paul
From: paul@oddjob.UChicago.UUCP (Paul Schinder)
Newsgroups: net.lang.f77
Subject: fixes available to 4.2BSD libF77 to comply with the ANSI standard
Message-ID: <552@oddjob.UChicago.UUCP>
Date: Sat, 22-Dec-84 02:19:49 EST
Article-I.D.: oddjob.552
Posted: Sat Dec 22 02:19:49 1984
Date-Received: Sun, 23-Dec-84 08:04:34 EST
Reply-To: paul@oddjob.UUCP (Paul Schinder)
Organization: U. Chicago: Astronomy & Astrophysics
Lines: 46

<>
If anyone is interested in changes to the 4.2 fortran library and to
/usr/lib/f77pass1 to make intrinsic functions do the proper thing (give an
error message and dump core) when passed illegal arguments, please send me
mail (after December 30, I will be gone until then).  If there is an
overwhelming response, I will post them to net.sources.

As an example, if you say

	x = sqrt(-1.)

with the current library, you will find that x = 0.  You will not be warned
that sqrt was called with an illegal value.  The fixed library would
say

	sqrt: called with argument -1.

and dump a core so you could tell where the error occured.  I have changed
sqrt, log, asin, acos, and mod to conform to the standards written out on
pages 15-28 and 15-29 of the ANSI Fortran 77 document.  I have also changed
exp to check for overflows and underflows; you may or may not want this.

These changes are very simple.  I didn't try to do anything fancy.  We have
been bothered for a long time with bogus values being silently returned from
fortran intrinsic functions when they were given illegal values of the
arguments.  Now that we have several different types of machines around, the
added portability that conforming to the standard gives us is very
important.  Besides, hidden bugs may lurk in your programs that you will
never know about otherwise.  I have found three since I made the changes.
And normal users of fortran on this machine would probably never find out
that the intrinsic functions behave this way, because, so far as I know, the
behavior of sqrt, log, etc., when given illegal arguments is only spelled
out in the manual page for the C math library.  A normal fortran user here
would probably never find out that these were the routines actually being
called by the fortran intrisic functions.

If someone out there is really brave, they could fix libm.  I didn't do that
because for all I know, something in 4.2 *depends* on this behavior from
the math routines.
-- 


				Paul Schinder
				Astronomy and Astrophysics Center
				University of Chicago
				uucp: ..!ihnp4!oddjob!paul