I'm going through some older code and there's a lot of .gt.'s, .lt.'s, .ne., etc. That's fine for me, but are these considered obsolescent? Should I be replacing them with <, >, /=, etc. to keep our code base up to date, or is it totally a preference thing?
2 Answers
No, they are not deemed obsolescent. It's a style preference. I will use the symbols in new code, but would never consider changing them out "just because".
In general, I am opposed to rewriting code just to keep it "up to date", as this raises a serious risk of adding bugs. "If it ain't broke, don't fix it" is my motto.
(For what it's worth, I am the convenor (chair) of the international Fortran standards committee.)

- 6,972
- 18
- 31
-
1Thanks, this is just what I was hoping to hear. Out of curiosity, what are your thoughts on goto's and computed goto's? The code works, but it becomes very difficult to work with pretty quickly when you have a lot of goto's. When I do change anything like this, I do test it, but is maintainability not a valid reason to change these types of "preferences"? – synchh Dec 05 '19 at 15:10
-
Computed GOTO is deemed obsolescent - use SELECT CASE. I would avoid GOTO as much as possible - Fortran is rich in control flow statements that are much easier to understand. Again, I don't advise rewriting code just because it uses obsolete features. But if it is a maintenance headache for you, then sure, try to redo it with modern features. Just make sure you test it thoroughly. – Steve Lionel Dec 07 '19 at 20:44
I certainly would not disagree with an authority like @SteveLionel as far as his answer goes, but would argue that .gt.
, .lt.
, etc. are stylistically obsolescent and I think that matters, although I'm sure others would disagree. For example, most python programmers would say style really matters, but I'm not sure how many Fortran programmers would agree.
In any event, probably the main advantage of writing x > 5
is that it translates to almost any other language whereas the others do not, or if they do, it might be e.g. ge
rather than .ge.
. (See here for a comparison of relational operators in several languages.) Certainly, agreement across languages in this respect is hardly a necessity, but it stills seems like a good thing overall.
Similarly, >
,<
, etc. also consistent with mathematical notation in general. Again, this is not a necessity, but seems nice.
A final advantage is that the >
, <
, etc. operators are just more readable than .gt.
, .lt.
, etc, but maybe it is possible to disagree with that.
x > 5
x .gt. 5
So I think a fairly strong case can be made for using >
instead of .gt.
in any code going forward, but whether replacing old code is worth it is obviously case dependent.

- 29,156
- 8
- 79
- 109
-
2I use the symbols in my own code, and would recommend them in any new code. But I maintain that rewriting code just for stylistic reasons is a bad idea. – Steve Lionel Dec 07 '19 at 20:45
-
FWIW I would not go into old code ONLY to change `.gt.` to `>`. But old code often involves compiler extensions not part of the Fortran standard, `goto`'s, and other bad or deprecated or obsolete things. If I'm cleaning up a bunch of those things, I'm also going to make style improvements like changing `.gt.` to `>`. But sure, leave them alone if you prefer, especially if you don't think style matters much. – JohnE Dec 08 '19 at 21:10