mecej4
Joined: 31 Oct 2006 Posts: 1888
|
Posted: Tue Jul 12, 2022 4:38 am Post subject: Error in assigning value to an array section |
|
|
The following test program shows an assignment being made to an array section using a subscript triplet.
Code: | program arraybug
implicit none
logical prms(13)
integer kpm,PrimeNum,Rescnt,maxprms
integer i,j,k
!
prms = .true.
kpm = 12; maxprms=13; Rescnt=8; PrimeNum = 7
i =13; j = maxprms
prms( i:j:PrimeNum*Rescnt) = .false.
print '(13L3)',prms ! prms(13) incorrectly displayed as .T.
k = PrimeNum*Rescnt
prms(i:j:k) = .false.
print '(13L3)',prms ! prms(13) now displayed as .F.
end program |
When the third part of the triplet is present as a variable, there is no problem. However, when an expression is used instead for this third part, an error occurs, as the following output (any version of FTN95, with or without /64) shows:
Code: |
T T T T T T T T T T T T T
T T T T T T T T T T T T F
|
|
|