DOCERR: All Expressions Not Allowed in PARAMETER StatementLast reviewed: July 18, 1995Article ID: Q83225 |
The information in this article applies to:
SYMPTOMSThe "Microsoft FORTRAN Reference" for versions 5.0 and 5.1, and the "Microsoft FORTRAN Language Reference" for versions 4.0 and 4.1, describe the PARAMETER statement in the following manner:
PARAMETER (name=expression [[,name=expression]]...)This implies that you can uses expressions in PARAMETER statements. However, only a constant expression can be used. The FORTRAN PowerStation Language Help correctly indicates that only constant expressions may be used in the PARAMETER statement.
CAUSEThe ANSI FORTRAN Standard (X3.9-1978) describes the PARAMETER statement as follows (Section 8.6):
PARAMETER (p=e [,p=e]...) where: p is a symbolic name e is a constant expressionThe standard goes on to define a constant expression as an expression made up of primitive constants (numbers or prior PARAMETER values) and arithmetic or logical operators. This is not the same as the definition of an expression. The FORTRAN 5.1 reference manual, page 30, describes an expression as follows:
An expression is a formula for computing a value. Expressions consist of operands and operators. The operands can be function references, variables, structure elements, constants, or other expressions.This implies that functions can be used in PARAMETER statements in Microsoft FORTRAN. This is incorrect: Microsoft FORTRAN adheres to the ANSI standard and permits constant expressions only in PARAMETER statements.
MORE INFORMATIONThe following program will fail to compile, and the following error is produced:
error F2349: X : PARAMETER : nonconstant expression Sample Code
parameter(x=cos(1.0)) parameter(y=float(1)) endNote that no error is flagged on the second PARAMETER statement even though the intrinsic function FLOAT() is used. Type conversions are applied automatically in PARAMETER statements and use of type conversion intrinsic functions is allowed. Some other intrinsic functions, such as TINY, PRECISION, and the logical functions LGE(), LGT(), LLE(), and LLT(), are allowed also.
|
Additional reference words: 4.00 4.10 5.00 5.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |