FIX: Incorrect Results Using a COMPLEX Array in a NAMELIST

ID: Q71186


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, version 5.0
  • Microsoft FORTRAN for 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 query words: 5.00 buglist5.00 fixlist5.10

Keywords :
Version : :5.0
Platform :
Issue type :


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