mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sun Feb 26, 2017 7:23 pm Post subject: Bug in program using SPREAD |
|
|
As far as I can see, there is nothing wrong in this test program, which uses the SPREAD intrinsic.
Code: | program ftnbug
implicit none
integer, parameter :: l = 1, m = 20, n = 3
logical :: l3v(m)
double precision :: r(m),g(m,l),dg(m,n),d5v(m,n),v(m)
integer i
l3v(1) = .TRUE.
l3v(2:20) = .FALSE.
r(1:) = 1d-3; r(2) = 63d0 ; g = 1d-4
dg(:,1) = 1d0; dg(:,2) = 2d-3; dg(:,3) = 1d-7
v = 2d-4; d5v = 0d0
where (spread(l3v,dim = 2, ncopies = n))
d5v = dg(:m,:)*( &
spread(v(:m),dim=2,ncopies=n) &
-spread(r(:m), dim = 2, ncopies = n) &
*spread(g(:m,1),dim = 2, ncopies = n) &
)
end where
write(*,'(3ES12.3)')(d5v(i,:),i=1,m)
end program
|
FTN95 8.05 with /checkmate gives a runtime error: access violation at line 14, attempt to read from location F0F0F0F4; the instruction is mov eax, [ecx+04], with ECX = F0F0F0F0.
FTN95 8.05 with /64 gives a compile time error:
Quote: | *** The test of the enclosing WHERE statement is rank 2, whereas the left hand side of this assignment is a scalar. |
The variable d5v is declared as a 2-D array, so something must have confused the compiler. |
|