13.07.2015 Views

Fortran 90/95 Programming Manual

Fortran 90/95 Programming Manual

Fortran 90/95 Programming Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>Fortran</strong> <strong>90</strong>/<strong>95</strong> <strong>Programming</strong> <strong>Manual</strong>Block if statements can be nested:[name:] if (logical expression 1) then! block 1else if (logical expression 2) then! block 2else if (logical expression 3) thenelse! block 3! block 4end if [name]Example (try to follow the logic in this example):if ( optimisation ) thenprint * , "Geometry optimisation: "if ( converged ) thenprint * , "Converged energy is ", energyelseprint * , "Energy not converged. Last value: ", energyend ifelse if (singlepoint ) thenprint * , "Single point calculation: "print * , "Energy is ", energyelseprint * , "No energy calculated."end ifIndentation is optional, but highly recommended: a consistent indentation style helps tokeep track of which if, else if, and end if belong together (i.e., have the same “if level”).Do loopsA program often needs to repeat the same statement many times. For example, you mayneed to sum all elements of an array.17

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

Saved successfully!

Ooh no, something went wrong!