Using Fortran
On this page:
When writing code fragments in Fortran, you need to follow these guidelines:
-
In general, you can use free-form syntax. You can enter more than one statement on a line if you separate the statements with semi-colons (;). However, you cannot continue a statement onto more than one line.
-
You can use GOTO, GO TO, ENDIF, and END IF statements; Although ELSEIF statements aren’t allowed, you can use ELSE IF statements.
-
Syntax is free-form. No column rules apply.
-
The space character is significant and is sometimes required. (Some Fortran 77 compilers ignore all space characters.) For example:
|
Valid |
Invalid |
|
DO 100 I=1,10 |
DO100I=1,10 |
|
CALL RINGBELL |
CALL RING BELL |
|
X .EQ. 1 |
X.EQ.1 |
You can use the following data types and declarations in a Fortran expression:
-
You can use the INTEGER, REAL, DOUBLE PRECISION, and COMPLEX data types.
-
You can’t define or declare variables that have implied or derived data types.
-
You can only use simple declarations. You can’t use a COMMON, BLOCK DATA, EQUIVALENCE, STRUCTURE, RECORD, UNION, or array declaration.
-
You can refer to variables of any type in the target program.
-
TotalView assumes that integer (kind=n) is an n-byte integer.
Fortran Statements
You can use the Fortran language statements:
-
You can use assignment, CALL (to subroutines, functions, and all intrinsic functions except CHARACTER functions in the target program), CONTINUE, DO, GOTO, IF (including block IF, ENDIF, ELSE, and ELSE IF), and RETURN (but not alternate return) statements.
-
If you enter a comment in an expression, precede the comment with an exclamation point (!).
-
You can use array sections within expressions. For more information, see “Array Slices and Array Sections” on page 289.
-
A GOTO statement can refer to a line number in your program. This line number is the number that appears in the Source Pane. For example, the following GOTO statement branches to source line number 432:
GOTO $432;You must use a dollar sign ($) before the line number so that TotalView knows that you’re referring to a source line number rather than a statement label.
You cannot branch to a label within your program. You can instead branch to a TotalView line number.
-
The following expression operators are not supported: CHARACTER operators and the .EQV., .NEQV., and .XOR. logical operators.
-
You can’t use subroutine function and entry definitions.
-
You can’t use Fortran 90 pointer assignment (the => operator).
-
You can’t call Fortran 90 functions that require assumed shape array arguments.
Fortran Intrinsics
TotalView supports some Fortran intrinsics. You can use these supported intrinsics as elements in expressions. The classification of these intrinsics into groups is that contained within Chapter 13 of the Fortran 95 Handbook, by Jeanne C. Adams, et al., published by the MIT Press.
TotalView does not support the evaluation of expressions involving complex variables (other than as the arguments for real or aimag). In addition, we do not support function versions. For example, you cannot use dcos (the double-precision version of cos).
The supported intrinsics are:
-
Bit Computation functions: btest, iand, ibclr, ibset, ieor, ior, and not.
-
Conversion, Null and Transfer functions: achar, aimag, char, dble, iachar, ichar, int, and real.
-
Inquiry and Numeric Manipulation Functions: bit_size.
-
Numeric Computation functions: acos, asin, atan, atan2, ceiling, cos, cosh, exp, floor, log, log10, pow, sin, sinh, sqrt, tan, and tanh.
Complex arguments to these functions are not supported. In addition, on MacIntosh and AIX, the log10, ceiling, and floor intrinsics are not supported.
The following are not supported:
-
Array functions
-
Character computation functions.
-
Intrinsic subroutines
If you statically link your program, you can only use intrinsics that are linked into your code. In addition, if your operating system is Mac OS X, AIX, or Linux/Power, you can only use math intrinsics in expressions if you directly linked them into your program. The ** operator uses the pow function. Consequently, it too must either be used within your program or directly linked. In addition, ceiling and log10 are not supported on these three platforms.