PRB: F2414: Initializing Substrings in DATA Statements (71313)



The information in this article applies to:

  • Microsoft FORTRAN Compiler for MS-DOS 4.0
  • Microsoft FORTRAN Compiler for MS-DOS 4.01
  • Microsoft FORTRAN Compiler for MS-DOS 4.1
  • Microsoft FORTRAN Compiler for MS-DOS 5.0
  • Microsoft FORTRAN Compiler for MS-DOS 5.1
  • Microsoft FORTRAN compiler for OS/2 4.1
  • Microsoft FORTRAN compiler for OS/2 5.0
  • Microsoft FORTRAN compiler for OS/2 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS 1.0
  • Microsoft FORTRAN PowerStation for MS-DOS 1.0a
  • Microsoft Fortran Powerstation 32 for Windows NT 1.0

This article was previously published under Q71313

SYMPTOMS

Using Microsoft FORTRAN to compile a program that attempts to initialize substrings using an implied-DO list in a DATA statement may result in the following error messages:
error F2414: (string name) : DATA : not array-element name warning F4400: DATA : more constants than names

CAUSE

This is not a problem with the compiler. The ANSI 77 Standard prohibits the use of implied-DO loops in DATA statements for anything but arrays. Character substrings are not considered arrays.

RESOLUTION

Possible solutions to suppress the F2414 and F4400 error messages are:

  1. Initializing the list of substring array elements individually instead of using an implied-DO list in the DATA statement.
  2. Initializing the whole string variable instead of a substring when using an implied-DO list in the DATA statement.
  3. Initializing substring array elements individually with assignment statements.

MORE INFORMATION

The following program produces the F2414 and F4400 error messages:
       character*2 a(2)
       data (a(i)(2:2),i=1,2)  /'1','2'/ 
       write(*,*) a(1)
       end
				
The following sample programs illustrate possible solutions to suppress the F2414 and F4400 error messages:

  1. Initializing the list of substring array elements individually in the DATA statement.
          character*2 a(2)
          data a(1)(2:2), a(2)(2:2)  /'1','2'/ 
          write(*,*) a(1)
          end
    						
  2. Initializing the whole string variable in the DATA statement.
          character*2 a(2)
          data (a(i),i=1,2)  /' 1',' 2'/ 
          write(*,*) a(1)
          end
    						
  3. Initializing substring array elements individually with assignment statements.
          character*2 a(2)
          a(1)(2:2) = '1'
          a(2)(2:2) = '2'
          write(*,*) a(1)
          end
    						

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:KB71313