How can I pass a dynamically allocated array to a subroutine and get the actual bounds of this array?
I tried this:
PROGRAM MYPROG
!
IMPLICIT NONE
!
INTEGER*4, ALLOCATABLE :: I4(:)
!-----------------------------------------------------------------------
ALLOCATE(I4(10))
I4=1
!
CALL MYSUB(I4)
!
DEALLOCATE(I4)
END
!***********************************************************************
SUBROUTINE MYSUB(IARRAY)
!
IMPLICIT NONE
!
INTEGER*4 N1,N2
INTEGER*4, ALLOCATABLE :: IARRAY(:)
!-----------------------------------------------------------------------
IF(ALLOCATED(IARRAY))THEN
N1=LBOUND(IARRAY,1)
N2=UBOUND(IARRAY,1)
ENDIF
!
RETURN
END
!***********************************************************************
and I got the following compiler error:
*** Error 941: IARRAY is a dummy argument and so cannot be ALLOCATABLE
The IVF-Compiler allows this code without problems.
Detlef Pannhorst