mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Thu Jun 04, 2015 2:45 pm Post subject: FTN95 bug: array valued functions in expressions |
|
|
FTN95 7.1 has problems processing expressions that contain array constructors and functions that return arrays. Some of these problems surfaced in a recent thread ( http://forums.silverfrost.com/viewtopic.php?t=3095 ), and here is a simple reproducer.
Code: | program getdiag
implicit none
real matrix(2,2),d4(4)
!
matrix=reshape((/ 2.,4.,5.,3. /),(/2,2/))
d4 = (/ 1.0, diagf(matrix), 4.0 /) ! FTN95 bug here
print*,d4
contains
function diagf(A)
real :: A(2,2),diagf(2)
diagf = (/ A(1,1), A(2,2) /)
return
end function
end program
|
The compiler says
Code: | 0006) d4 = (/ 1.0, diagf(matrix), 4.0 /) ! FTN95 bug here
*** Non-conformant array shapes in first rank of an array expression (4 and 3)
|
which suggests that it does not recognize that diagf() is of size 2, not 1.
If the array constructor is used in an I/O list, compilation goes through, but the resulting program attempts to read from address zero.
Code: | program getdiag
implicit none
real matrix(2,2)
!
matrix=reshape((/ 2.,4.,5.,3. /),(/2,2/))
print *, (/ 1.0, diagf(matrix), 4.0 /) ! FTN95 bug here
contains
function diagf(A)
real :: A(2,2),diagf(2)
diagf = (/ A(1,1), A(2,2) /)
return
end function
end program
|
[P.S. 6/15/2015]Same bugs also present in FTN95-7.20.
Last edited by mecej4 on Mon Jun 15, 2015 10:58 pm; edited 2 times in total |
|