DOCERR: All Expressions Not Allowed in PARAMETER Statement

ID: Q83225


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.1, 5.0, 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0, 5.1


SYMPTOMS

The "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.


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 :
Version : :4.0,4.1,5.0,5.1
Platform :
Issue type :


Last Reviewed: November 2, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.