Hi Paul!
A customer sent me the following program which shows a problem with variable subscripts. He owns 5 licences of FTN95 4.80. I have tested his program with v4.91 and proofed his results. I have also checked with CVF 6.6 and IVF 9.0. They did not not accept the line b (1:2) = a (6:2) ! stride is default = 1; the extend is 0 After making this a comment, the program they created failed too. Although it appears to me that the problems are some kind of 'academic', I thought you might want to see the customer's program and have a comment. Thank you.
Kind regards,
Joerg QT software
Winapp Program Test_ArraySections
Real , Dimension (10) :: a Real , Dimension ( 2) :: b Integer :: i,k,l
Do i = 1,10 a (i) = i End Do
k = 6 l = 5
write (,) ' Results of Program Test_ArraySections' write (,) ' =====================================' write (,)
write (,) ' k = ', k write (,) ' l = ', l
! Assignment statement 1 is correct write (,) ' Assignment statement 1:'
b = 0.
b (1:2) = a (5:6)
write (,) b (1:2), ' the result should be 5 6 ',' OK' write (,)
! Assignment statement 2 should do nothing write (,) ' Assignment statement 2:'
b = 0.
b (1:2) = a (6:2) ! stride is default = 1; the extend is 0
write (,) b (1:2), ' the result should be 0 0 ',' OK' write (,)
! Assignment statement 3 should do nothing write (,) ' Assignment statement 3:'
b = 0.
b (1:2) = a (k:2) ! stride is default = 1; the extend is 0
write (,) b (1:2), ' the result should be 0 0 ',' !!!!! Error !!!!!' write (,)
! Assignment statement 4 should do nothing write (,) ' Assignment statement 4:'
b = 0.
b (1:2) = a (k:l) ! stride is default = 1; the extend is 0
write (,) b (1:2), ' the result should be 0 0 ',' !!!!! Error !!!!!' write (,)
! Assignment statement 5 should do nothing write (,) ' Assignment statement 5:'
b = 0.
b (1:2) = a (k:l:1) ! stride is = 1; the extend is 0
write (,) b (1:2), ' the result should be 0 0 ',' !!!!! Error !!!!!' write (,)
! Assignment statement 6 should be illegal write (,) ' Assignment statement 6:'
b = 0.
b (1:2) = a (k:k) ! the extend is 1
write (,) b (1:2), ' this is an illegal operation since the shapes are different' write (,) ' !!!!! Error !!!!!' write (,)
! Assignment statement 7 should be the same as 1 write (,) ' Assignment statement 7:'
b = 0.
b (1:2) = a (l:l+1)
write (,) b (1:2), ' the result should be 5 6 ',' OK' write (,)
! Assignment statement 8 write (,) ' Assignment statement 8:'
b = 0.
b (1:2) = a (k:l:-1) ! subscript triplet mechanism
write (,) b (1:2), ' the result should be 6 5 ',' OK' ! lower bound:upper bound:stride write (,)
End Program Test_ArraySections