forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

False subscript error detected

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Fri Aug 07, 2020 1:54 pm    Post subject: False subscript error detected Reply with quote

I had occasion to compile a program that used Lapack/BLAS routines, and needed to compile the needed BLAS routines with /check. FTN95 detects a subscript error in a situation where (I think) that it should not. In order to make the error easy to investigate, I have constructed a short reproducer.

The test program takes a 4 X 4 matrix C, and copies rows 2-4 and columns 2-4 into a 3 X 3 matrix D.

Code:
program xsubmat
implicit none
real C(4,4),D(3,3)
integer i,j,ldc,ldd,m,n
!test of copying C(2:4,2:4) into D, with subscript checking
do i=1,4
   do j=1,4
      C(i,j)=10*j+i
   end do
end do
ldc=4; ldd=3; m=3; n=3
call sub(C(2,2),ldc,D,ldd,m,n)
print 10,(D(i,:),i=1,m)
10 format(3F6.0)
end program

subroutine sub(C,ldc,D,ldd,m,n)
implicit none
integer i,ldc,ldd,m,n
real C(ldc,*),D(ldd,*)
do i=1,m
   D(1:n,i)=C(1:n,i)
end do
return
end subroutine


The Fortran 95 standard, section 12.4.1.1, says:
Quote:
Except when a procedure reference is elemental (12.7), each element of an array-valued actual argument or of a sequence in a sequence association (12.4.1.4) is associated with the element of the dummy array that has the same position in array element order (6.2.2.2).
My inference is that it should be OK to copy the sequence starting with C(2,2), which has 11 elements, 9 of which I wish to put into D.

In the debugger, after entering the subroutine, the variable list shows the effective dimensions of C in the subroutine as 4 X 2. It is debatable what it should show. However, there is no subscript error in the array copy. Please tell me if you do or do not agree.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Aug 07, 2020 5:03 pm    Post subject: Reply with quote

mecej4

Can you clarify please. Is this an error in FTN95 alone or does it also concern the debugger?
Back to top
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Fri Aug 07, 2020 5:47 pm    Post subject: Reply with quote

Paul, I think that it is more an FTN95 issue. I ran the test program with NAG and Lahey compilers with their checking flags turned on, and there were no subscript errors reported. The Lapack code has been widely used for decades, and it would be unusual for the Lapack sources to retain subscript errors after such a long time.

Running the test program (compiled with /check) from the command line causes a subscript error to be reported, but it is not clear which variable/subscript was the cause. I had suggested some time ago that in such cases it would be helpful if the particular variable and subscript names were given in the error message, rather than just the line number.

I used the debugger only to see which subscript/array variable was being flagged as accessed outside its proper ranges.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Aug 08, 2020 7:50 am    Post subject: Reply with quote

Thank you. I have made a note of this.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Aug 10, 2020 10:22 am    Post subject: Reply with quote

This has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group