What Does This Fortran Statement Do?

  • Context: Fortran 
  • Thread starter Thread starter dibloff
  • Start date Start date
Click For Summary
SUMMARY

The Fortran statement in question utilizes an arithmetic IF statement, a feature prevalent in Fortran 77. The statement evaluates the expression PMAX - P(I) and directs control flow based on its result, executing the code at label 16 if the result is less than or equal to zero, which updates PMAX and ICAMAX. This type of IF statement is largely obsolete, replaced by the more modern IF/THEN/ELSE structure. Understanding this syntax is crucial for converting legacy Fortran code to Visual Basic.

PREREQUISITES
  • Understanding of Fortran 77 syntax and control structures
  • Familiarity with arithmetic IF statements in programming
  • Knowledge of Visual Basic for code conversion
  • Basic concepts of variable types, specifically REAL in Fortran
NEXT STEPS
  • Research the differences between Fortran 77 and modern Fortran standards
  • Learn about the IF/THEN/ELSE statement in Fortran
  • Study the conversion techniques from Fortran to Visual Basic
  • Explore the implications of variable types in programming languages
USEFUL FOR

This discussion is beneficial for software developers, particularly those working with legacy Fortran code, programmers transitioning to Visual Basic, and educators teaching programming concepts related to control flow and variable types.

dibloff
Messages
10
Reaction score
0
Hi Community!

I'm wondering what this Fortran statement does, per your opinion:

IF(PMAX-P(I))16,16,17
16 PMAX=P(I)
ICAMAX=I
17 CONTINUE

This was done in Fortran 77. I'm trying to convert it to VB, and I Google-d it, researched it, but it's hard to understand. The IF statement looks for PMAX-P(I) to be TRUE, which makes no sense cause the variable type for PMAX & P(I) are both REAL, therefore their difference will be REAL too, and not LOGICAL. Then there is this 16,16,17… I guess it’s checking if PMAX-P(I) is zero, if it not zero, then it’ll execute label 16, which will force their difference to be zero.
Does anybody know what 16,16,17 suppose to do? Maybe there is an hidden option for IF statement like this: IF(blablabla)>0,<0,0

Thank you

A.
 
Technology news on Phys.org


This would be hard to find with google unless you knew it is called an arithmetic if statement. http://www-linac.kek.jp/cont/langinfo/web/Fortran/docs/lrm/lrm0128.htm

This was the only type of IF statement in early versions of Fortran, but after the IF/THEN/ ELSE statement was added, it is hardly ever used.

Your example means the same as

IF (PMAX .LE. P(I)) THEN
PMAX=P(I)
ICAMAX=I
ENDIF
 


Alephzero

Thanks a lot. This makes completely perfect sense.

A.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 18 ·
Replies
18
Views
17K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
17K
Replies
11
Views
16K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K