PRB: F2414: Initializing Substrings in DATA Statements
ID: Q71313
|
The information in this article applies to:
-
Microsoft FORTRAN for MS-DOS, versions 4.0, 4.01, 4.1, 5.0, 5.1
-
Microsoft FORTRAN for OS/2, versions 4.1, 5.0, 5.1
-
Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0, 1.0a
-
Microsoft Fortran Powerstation 32 for Windows NT, version 1.0
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:
- Initializing the list of substring array elements individually
instead of using an implied-DO list in the DATA statement.
- Initializing the whole string variable instead of a substring when
using an implied-DO list in the DATA statement.
- 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:
- 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
- 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
- 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
Additional query words:
5.00 5.10 1.00
Keywords :
Version : :1.0,1.0a,4.0,4.01,4.1,5.0,5.1
Platform :
Issue type :
|