Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

IVF-CVF difference wrt data statements

mkummert
Beginner
765 Views
Hi,

IVF seems to handle successive data statements differently from CVF. The program here below illustrates that:

program Test

implicit none
integer :: i
real(8) :: array(3)
data array/3*-999/
data array(1)/11/

write(*,*) (array(i),i=1,3)

end program Test

The results are:
in CVF 11 -999 -999
in IVF -999 -999 -999

I assume successive data statements for the same array are just a bad idea, but is there a way to obtain the CVF result with IVF?

Thanks,

Michal

Message Edited by mkummert on 05-05-2004 03:40 PM

0 Kudos
3 Replies
Steven_L_Intel1
Employee
765 Views
The program is illegal. You're not allowed to initialize the same element more than once. If it "worked" in CVF it was by coincidence, not design.
0 Kudos
durisinm
Novice
765 Views

In the section describing the DATA statement my DVF and IVF language reference manuals both state that a variable can be initialized only once in an executable program. What you're observing with CVF is probably nonstandard behavior and could be a bug. I wouldn't trust any workaround to duplicate that behavior in IVF--if it even exists. It could change at any time in the future.

The better option is to change your code. One possibility is to change data array/3*-999/ to data array/11, 2*-999/, although I recommend using data array/11.d0, 2*-999.d0/ since array is the real(8) type.

Mike

0 Kudos
mkummert
Beginner
765 Views
Thank you both for your answers.

DATA statements like :
DATA array/11.d0,2*999.d0, etc.
would be hard to read in the real program (big arrays with only a few spots reassigned) so I just used an initialization routine that is easy to read.

sblionel wrote:
The program is illegal. ...



I will report the programmer to the competent authorities ;-)

Michal
0 Kudos
Reply