The attached program looks terrible. However, it reflects the structure of a “real” program, where I found the problem. The problem occurs when running the program with the /Checkmate option, which I almost always use:
ftn95 Problem_Array_Section.f95 /Checkmate /underflow /Link >> comp.lis sdbg Problem_Array_Section.exe
The error message is “Attempt to call a routine with argument number two containing too few array elements”
The reason why I chose this form is because in the real problem the indices of array x (1,2,3..) in subroutine SubB correspond to indices 2,3,4 of array Data in subroutine SubA. For this transformation I need the array section as argument.
Is anything wrong with the program? Can anybody comment on this problem?
Many thanks,
Klaus Lassmann [ Winapp
Program Problem_Array_Section
Implicit None
Integer :: i, n
Real , Dimension (400) :: Result
n = 3
! Subroutine SubA calculates with the help of SubB the field Result
Call SubA ( Result, n )
! #########
Write (*,*) ' Result (1,n)= ', ( Result (i), i=1,n )
Contains
Subroutine SubA (Data, m)
Implicit None
Integer :: i
Integer , Intent (in ) :: m
Real , Dimension (m), Intent (out) :: Data
! --- This call leads to an error when compiled with /Checkmate:
Call SubB ( m, Data (1:m) )
! --- This call seems to be OK
! Call SubB ( m, Data )
Write (*,*) ' Data (1,m) = ', ( Data (i), i=1,m )
End Subroutine SubA
End Program Problem_Array_Section
! --------------------------------------------------------------------
Subroutine SubB ( k,x )
Implicit None
Integer , Intent (in ) :: k
Real , Dimension (k), Intent (out) :: x
Integer :: i
Do i = 1, k
x(i) = i**2
End Do
End Subroutine SubB
]