Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

syntax question

3 views
Skip to first unread message

Patrick F. McGehearty

unread,
Jan 20, 2000, 3:00:00 AM1/20/00
to
In article <3887C14C...@kw.igs.net>,
Robert T Couture <rtco...@kw.igs.net> wrote:
>I'm transcribing some Fortran code and I came across the following
>statement
>
>IF (EPS) 24,26,27
>
>
>
>EPS is a double percision variable, and 24 , 26, and 27 are valid line
>numbers
>
>But 24,26,27 all have goto statments as there last line....
>
>If someone could tell me what it does, it would make my life much
>easier.
>

This statement is an arithmetic if.
If EPS < 0.0 then control will transfer to 24
If EPS = 0.0 then control will transfer to 26
If EPS > 0.0 then control will transfer to 27

This archaic feature is so poorly thought off in modern Fortran programming
practice that it is often not even mentioned in introductory classes.
I'll allow others to discuss why and give the historical reason why
it is in the language at all. Not recommended for new code. I recommend
adding a comment describing the intent if you are maintaining old code.

- Patrick McGehearty

Robert T Couture

unread,
Jan 21, 2000, 3:00:00 AM1/21/00
to

Nick N. Yasko

unread,
Jan 21, 2000, 3:00:00 AM1/21/00
to

Robert T Couture <rtco...@kw.igs.net> сообщил в новостях
следующее:3887C14C...@kw.igs.net...

> I'm transcribing some Fortran code and I came across the following
> statement
>
> IF (EPS) 24,26,27
>
It is old ariphmetic IF statement. You can see this as:
IF ( EPS < 0 ) THEN
GO TO 24
ELSEIF(EPS>0) THEN
GOTO 27
ELSE
GOTO 26
END IF
I hope your life will be much easier.!

horationelson

unread,
Jan 23, 2000, 3:00:00 AM1/23/00
to
Like many prehistoric bits of FORTRAN, this "arithmetic IF" appears
many times in old code. My first FORTRAN was an an IBM 1130: logical IF
wasn't possible on that.

On ICL 1900 and 2900 series computers, there was a variant ... here's
and example:

IF (RES) 25, 0, 0

Statement number 0 meant "on the next line"

Sometimes it is useful to know where one is going in the case of an
expression evaluating to neg, zero or pos, simply because the zero
result does come up remarkably often!

In this sort of code:

P = result of some computation
R = anyvalue / P

then something like

P =
IF (P) 100, 1600, 100
100 R = anyvalue / P

traps the inevitable overflow. When used like this, 1600 was the
statement of the error handling code.

Whether or not you hate this sort of thing : GOTOs, ASSIGNED GOTOs and
COMPUTED GOTOs, tolerate them or love them really depends on whether
you like to know where you are going before you arrive!


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!


Tim Prince

unread,
Jan 24, 2000, 3:00:00 AM1/24/00
to
>On ICL 1900 and 2900 series computers, there was a variant ... here's
>and example:
>
>IF (RES) 25, 0, 0
>
>Statement number 0 meant "on the next line"

Similarly, GE625 Fortran and its successors used a null statement number to
designate "no branch." Even when the arithmetic IF was syntactically
equivalent to a more modern style of conditional GOTO, it saved a branch, so it
seemed that the optimizer intentionally favored archaic and non-standard code.
Seems I've made that comment about much more recent compilers.
Tim Prince
tpr...@computer.org

0 new messages