FIX: Incorrect Results Using a COMPLEX Array in a NAMELIST

Last reviewed: September 11, 1997
Article ID: Q71186
5.00 | 5.00 MS-DOS | OS/2 kbtool kbfixlist kbbuglist

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS and OS/2, version 5.0

SYMPTOMS

An application that uses a NAMELIST-directed READ statement to initialize an array of COMPLEX values generates incorrect results.

CAUSE

This error occurs when the data in the input file has one element per line.

RESOLUTION

To work around this problem, modify the data in the input file to place the data for all array elements on one line.

STATUS

Microsoft has confirmed this to be a problem in FORTRAN version 5.0 for MS-DOS and OS/2. This problem was corrected in FORTRAN version 5.1 for MS-DOS and OS/2.

MORE INFORMATION

The following code example reads the NAMELIST data file TEST.DAT.

Sample Code

C Compile options needed: None

      COMPLEX MYDATA(5)
      NAMELIST /XX/ MYDATA
      OPEN (1, FILE = 'TEST.DAT')
      READ (1, XX)
      WRITE (*, *) MYDATA
      END

NAMELIST Input File #1

&xx mydata(1) = (1.0, 2.0) mydata(2) = (3.0, 4.0) mydata(3) = (5.0, 6.0) mydata(4) = (7.0, 8.0) mydata(5) = (9.0, 10.0) /

Using NAMELIST Input File #1, the code example produces the following output.

              (1.000000,3.000000)               (5.000000,7.000000)
             (9.000000,10.000000)       (0.000000E+00,0.000000E+00)
      (0.000000E+00,0.000000E+00)

The output should be as follows.

              (1.000000,2.000000)               (3.000000,4.000000)
              (5.000000,6.000000)               (7.000000,8.000000)
             (9.000000,10.000000)

To work around this problem, rearrange the data in the input file to place all the elements on one line. The following input file demonstrates this solution.

NAMELIST Input File #2

&xx mydata = (1.0, 2.0) (3.0, 4.0) (5.0, 6.0) (7.0, 8.0) (9.0, 10.0) /

Note: A data file can contain repeat factors if the data contains more than one element with the same value. The following input file demonstrates this technique.

NAMELIST Input File #3

&xx mydata = 2*(1.0, 2.0) (3.0, 4.0) (5.0, 6.0) /


Additional reference words: 5.00 buglist5.00 fixlist5.10
KBCategory: kbtool kbfixlist kbbuglist
KBSubCategory: FLIss
Solution Type : kbfix


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: September 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.