19.01.2015 Views

MOLPRO

MOLPRO

MOLPRO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6 PROGRAM CONTROL 34<br />

6.7.1 IF statements<br />

IF blocks have the same form as in Fortran:<br />

IF (logical expression) THEN<br />

statements<br />

ENDIF<br />

If only one statement is needed, the one-line form<br />

IF (logical expression) statement<br />

can be used, except if statement is a procedure name.<br />

ELSE and ELSE IF can be used exactly as in Fortran. IF statements may be arbitrarily nested.<br />

Jumps into IF or ELSE IF blocks are allowed. In this case no testing is performed; when an<br />

ELSE is reached, control continues after ENDIF.<br />

The logical expression may involve logical comparisons of algebraic expressions or of strings.<br />

Examples:<br />

IF(STATUS.LT.0) THEN<br />

TEXT,An error occurred, calculation stopped<br />

STOP<br />

ENDIF<br />

IF($method.eq.’HF’) then<br />

...<br />

ENDIF<br />

In the previous example the dollar and the quotes are optional:<br />

IF(METHOD.EQ.HF) then<br />

...<br />

ENDIF<br />

6.7.2 GOTO commands<br />

GOTO commands can be used to skip over parts of the input. The general form is<br />

GOTO,command,[n],[nrep]<br />

Program control skips to the |n|’th occurrence of command (Default: n = 1). command must be<br />

a keyword in the first field of an input line. If n is positive, the search is forward starting from<br />

the current position. If n is negative, search starts from the top of the input. The GOTO command<br />

is executed at most nrep times. The default for nrep is 1 if n < 0 and infinity otherwise. We<br />

recommend that GOTO commands are never used to construct loops.<br />

Alternatively, one can jump to labels using<br />

GOTO,label<br />

Since labels must be unique, the search starts always from the top of the input. It is required that<br />

the label ends with a colon.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!