Silverfrost Forums

Welcome to our forums

Odd behaviour with automatic arrays (ftn95 express)

13 Feb 2010 7:12 #5978

I'm using ftn95 express with visual studio 2008. After testing with some previous code which compiles and runs fine with the intel compiler, i'm getting strange behaviour with the ftn95 when using debug.

The array in sub_B has undefined entries, even after being zero'd. (I'm inserting a breakpoint and putting a 'watch' on the array). Consequently any opperation i do using the array causes the debugger to abort (when \check is on). This goes away if i use allocatable or use a parameter for the array size. Is this just me doing something stupid...?

ive included the simplist example i can think of:

PROGRAM MAIN
    INTEGER M
    M=140
    CALL sub_a(M)
END PROGRAM MAIN

SUBROUTINE SUB_A(M)
    INTEGER, INTENT(in)::M
    REAL,DIMENSION(M,2)::ARRAY
    
    ARRAY=0.    

END SUBROUTINE SUB_A
14 Feb 2010 12:01 #5981

The problem is not with ftn95, but with sdbg. If you try the following program, and step through sdbg, you can see that while sdbg shows the automatic array as being undefined, ftn95 does not. As you step through the test loop, the value of N does not change. I think there is a later version of sdbg available in another post to download, which fixes this problem of viewing automatic arrays. I can't remember the post, someone else may help here.

PROGRAM MAIN 
    INTEGER M 
    M=140 
    CALL sub_a(M) 
END PROGRAM MAIN 

SUBROUTINE SUB_A(M) 
    INTEGER, INTENT(in)::M 
    REAL,DIMENSION(M,2)::ARRAY_au
   real,allocatable, dimension(:,:) :: array_al    
   integer*4 i,j, n
!
    ARRAY_au=0.    
   allocate (array_al(m,2))
!   
   array_al = 0.
   write (*,1001) array_au(3,2), array_al(3,2)
1001  format (2f10.4)
!
   n = 0
   do i = 1,140
     do j = 1,2
        if (array_au(i,j) /= 0.) then
           write (*,*) 'auto array',i,j,' = ', array_au(i,j)
           n = n+1
        end if
        if (array_al(i,j) /= 0.) then
           write (*,*) 'alloc array',i,j,' = ', array_al(i,j)
           n = n+1
        end if
     end do
   end do
END SUBROUTINE SUB_A 
14 Feb 2010 5:37 #5983

https://forums.silverfrost.com/Forum/Topic/1180

15 Feb 2010 12:01 #5989

thank you 😄

Please login to reply.