Print

Print


"A foolish consistency is the hobgoblin of little minds" - Emerson

The "logical IF" kinda sneaked into Fortran through the back door: very
early versions of the language had only the "arithmetic IF": IF (logical
expression) label1, label2, label3

But Fortran IV (approximately equivalent to the 1966 ANSI standard
language) also permitted the "logical IF": IF (logical expression)
dependent statement

Usually the "dependent statement" was a GO TO, but in simple cases it
could be a non-control statement.

Fortran 77 introduced IF-THEN-ELSE which eliminated the need for IF
(...) GO TO ... , but the "simple special case" survived.

This is sorta typical of Fortran: a grand and beautiful structure is
available that could be used in all cases, but there are sometimes these
cute "quickies" that can be written more simply. Another example is the
way you can combine a lot of declarations into one.

Why be consistent, when you can be concise?

= Loren P Meissner

-----Original Message-----
From: Fortran 90 List [mailto:[log in to unmask]] On Behalf
Of Ian Chivers
Sent: Thursday, September 02, 2004 1:50 AM
To: [log in to unmask]
Subject: Style question

I'm currently writing some programs for the
next edition of our book and am converting
some fortran 66 style code to fortran 90 style.

The code has one line if statements, e.g.

 if(modulo(yyyy, 400) /= 0 .and. modulo(yyyy, 100) == 0) t = 0

 if(ddd > 59+t) dd = dd + 2 - t

 if(mm >= 1 .and. mm <= 12) return

Jane and I tend to write this type of statement as an

If then

Endif

I was curious as to what other people did with
essentially one line if statements.

cheers

Ian Chivers