(j3.2006) (SC22WG5.5352) [ukfortran] From a colleague

Van Snyder Van.Snyder
Mon Oct 27 23:04:21 EDT 2014

The problem illustrates that Fortran codes have extremely long lives.
The codes containing arithmetic IF were written before IEEE arithmetic
existed.  They were developed and supported on a shoestring for more
than thirty years, and then support was discontinued entirely in 1996.
My colleague is the sole proprietor of this software.  It will almost
certainly be left to anybody who is still using this software to
retrofit the arithmetic IF statements to something else, including
detecting NaN.

We have five pages of processor dependencies.  Can we keep arithmetic
IF, and define the result when <expr> is NaN to be processor dependent?

I agree arithmetic IF shouldn't be used NOW, but giving the advice that
"you should never use it" requires the owner of fifty-year-old code
(that works extremely well) to have a time machine to return to 1966 and
advise against it.

On Tue, 2014-10-28 at 09:56 +0900, Malcolm Cohen wrote:
> This discussion seems to be continuing on the J3 list, but for everyone else...
> >My colleague wrote:
> >
> >        I've just learned that at least some compilers will no longer
> >        support the arithmetic IF statement.
> Since that is currently standard-conforming, such a compiler is also not 
> standard-conforming.  Compilers that ignore the standard are (rather obviously) 
> not going to be affected by whatever *we* decide!
> >  The reason being that
> >        there is no good  answer as to what this statement should do if
> >        the value in question is a NaN.
> I suspect your colleague is labouring under a misapprehension.
> There is, indeed, no good answer as to what this statement should do if the 
> value in question is a NaN.  Which is why you should remove it from your 
> program.  And why it should be removed from the standard.
> That does not mean that any compiler will actually rip out its support for the 
> (broken!) feature.
> >  And here I thought that
> >        compiler writers would continue to support all the old features
> >        out of self interest.  But here there seems to be no good
> >        answer.
> Compilers will "support" it, but you should never use it.
> >This colleague has "only" about 170,000 lines of Fortran 77
> Right, and arithmetic IF is a Fortran 66 feature that is redundant with Fortran 
> 77, therefore we are talking 2014-1978 = it has been obsolete for 36 years and 
> formally marked as obsolescent for 2014-1991=23 years.
> I don't see why the standard should support broken features that were obsolete 
> for virtually the entire working lifetime of all current programmers.
> Anyway, if NaN's are not an issue (either because you've proved some difficult 
> mathematical theorems about your code, you have some sophisticated error 
> handling mechanism, you are running with the Invalid Exception trap enabled, or 
> you don't care if the bridge falls down/plane falls out of the sky), it is 
> trivial to replace arithmetic IF with newer alternatives.
> After all, if you continue to use arithmetic IF, that's what the compiler is 
> effectively going to do "under the covers".  There are no single machine 
> instructions that branch to three different labels depending on a floating-point 
> value.  Of course this means that NaN will do different (and maybe impossible) 
> things on different machines or with different compiler options.  Now THAT would 
> be a problem!  At least if you replace it with 1-3 logical IF+GOTO yourself it 
> will do the same thing.
> > code to
> >support.  He's a semi-retired proprietor of a small business, with no
> >staff other than himself to revise his codes so as not to use Arithmetic
> >IF.
> If he doesn't know what his code should do with a NaN, I don't see how it is any 
> fault of the language or the compiler!
> >Was it really wise, and especially was it necessary, to delete
> >Arithemtic IF?
> Yes, and yes.
> Cheers,

More information about the J3 mailing list