manual   quickstart   instguide   update   basis

Next: 6.7.2 GOTO commands Up: 6.7 Branching (IF/ELSEIF/ENDIF) Previous: 6.7 Branching (IF/ELSEIF/ENDIF)   Contents   Index   PDF


6.7.1 IF statements

IF blocks have the same form as in Fortran:

IF (logical expression) THEN
statements
ENDIF

If only one statement is needed, the one-line form

IF (logical expression) statement

can be used, except if statement is a procedure name.

ELSE and ELSE IF can be used exactly as in Fortran. IF statements may be arbitrarily nested. Jumps into IF or ELSE IF blocks are allowed. In this case no testing is performed; when an ELSE is reached, control continues after ENDIF.

The logical expression may involve logical comparisons of algebraic expressions or of strings. Examples:

IF(STATUS.LT.0) THEN
TEXT,An error occurred, calculation stopped
STOP
ENDIF

IF($method.eq.'HF') then
...
ENDIF
In the previous example the dollar and the quotes are optional:
IF(METHOD.EQ.HF) then
...
ENDIF



molpro@molpro.net 2017-12-16