Microsoft KB Archive/83225

= DOCERR: All Expressions Not Allowed in PARAMETER Statement =

Article ID: 83225

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q83225



SYMPTOMS
The &quot;Microsoft FORTRAN Reference&quot; for versions 5.0 and 5.1, and the &quot;Microsoft FORTRAN Language Reference&quot; 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.



CAUSE
The 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 expression

The 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 INFORMATION
The 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)) end Note 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 query words: 4.00 4.10 5.00 nofps 5.10

Keywords: KB83225

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.