DOCERR: All Expressions Not Allowed in PARAMETER Statement

Last reviewed: July 18, 1995
Article ID: Q83225
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 5.0 and 5.1
  • Microsoft FORTRAN for OS/2, versions 5.0 and 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 reference words: 4.00 4.10 5.00 5.10
KBCategory: kbprg kbdocerr
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 18, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.