FPP 1L "17 May 2001" "" "Version 3.0.0" [section 8 of 17]

.-3[LANGUAGE OVERVIEW]         .-2[DEFINITION STATEMENTS]         .-1[CONDITIONAL STATEMENTS]
Top
.+1[MACRO EXPANSION]     .+2[MESSAGE OUTPUT STATEMENTS]         .+3[OUTPUT OF fpp]


EXPRESSIONS

Expressions are recognized and evaluated in two circumstances: in the arguments of C#if, C#elseif, and C#elif, and inside the parentheses of #(...).

In expressions, primaries are Fortran integer, floating-point, logical, and character constants, and preprocessor names.

Undefined names silently evaluate to zero in arithmetic expressions, and to empty strings in string expressions.

Character strings appearing in arithmetic expressions are converted to numbers, which are zero if the string does not look like a number. Character strings appearing by themselves evaluate to themselves.

Arithmetic expressions are evaluated in floating-point arithmetic; for Boolean (Fortran logical) tests, zero is false, and non-zero is true.

The usual Fortran arithmetic operators + - * / ** are recognized, along with the C modulus operator %; x % y is Fortran's mod(x,y). This operator is rigorously defined for all arguments to be x % y = x - int(x/y)*y.

The Fortran logical and relational operators are supported, with convenient modern C-like synonyms: .and. (& and &&), .or. (| or ||), .not. (!), .eq. (==), .ne. (!=), .lt. (<), .le. (<=), .gt. (>), and .ge. (>=). Letter case in the dotted operators is not significant. Finally, the Fortran character string concatenation operator, //, is handled.

One special name, defined, is recognized, in any letter case; it may be used either in functional form, defined(name), or in prefix operator form, defined name. It evaluates to 1 if the name is defined (even if the value of the name is zero), and otherwise, to 0. Several defined operators can be used in a single expression; that is much more convenient than a series of nested conditionals using C#ifdef and C#ifndef.

The #(...) form is only recognized in a comment line, and the next line is converted to a comment (see the section MACRO EXPANSION below); the parentheses hold an expression involving Fortran constants and preprocessor names.

Examples of expressions are

C#if  defined(_OS_UNIX)  ||  defined _OS_VAXVMS  ||
  (WORDSIZE == 32)"

C     REAL A(#(MAXA**2)), B(#(MAXA % 32))

C     INTEGER BITS(#(WORDSIZE))

.-3[LANGUAGE OVERVIEW]         .-2[DEFINITION STATEMENTS]         .-1[CONDITIONAL STATEMENTS]
Top
.+1[MACRO EXPANSION]     .+2[MESSAGE OUTPUT STATEMENTS]         .+3[OUTPUT OF fpp]