PROGRAM ItDependsOnTheDummyArgument
!
!  IanH  Feb 12, 2014
!
	  IMPLICIT NONE

	  INTEGER :: array(10,5)
	  integer*8 :: loc_array

	  array = 0
	  loc_array = LOC (array(3,:))
 

	  ! If a temporary is created for a call, then the LOC of the dummy argument

	  ! will be different from the LOC of the actual argument.
	  PRINT "('In main program, LOC(array(3,:)) is ',T45,I10)", LOC(array(3,:))

	  CALL AssumedShape(array(3,:))

	  CALL ExplicitShape(array(3,:), SIZE(array, 2))

	  CALL AssumedSize(array(3,:))

	CONTAINS

	  SUBROUTINE AssumedShape(arg)

	    INTEGER, INTENT(IN) :: arg(:)
	    integer i

	    PRINT "(/'In DeferredShape, LOC(arg) is ',T45,2I10)", LOC(arg), LOC(arg)-loc_array
	    write (*,*) '  Spacing=', (loc(arg(i))-loc(arg(i-1)), i=2,size(arg))

	  END SUBROUTINE AssumedShape

	 

	  SUBROUTINE ExplicitShape(arg, n)

	    INTEGER, INTENT(IN) :: n
	    INTEGER, INTENT(IN) :: arg(n)
      integer i

	    PRINT "(/'In ExplicitShape, LOC(arg) is ',T45,2I10)", LOC(arg), LOC(arg)-loc_array
      write (*,*) '  Spacing=', (loc(arg(i))-loc(arg(i-1)), i=2,size(arg))

	  END SUBROUTINE ExplicitShape

	 

	  SUBROUTINE AssumedSize(arg)

	    INTEGER, INTENT(IN) :: arg(*)
      integer i
      
	    PRINT "(/'In AssumedSize, LOC(arg) is ',T45,2I10)", LOC(arg), LOC(arg)-loc_array
      write (*,*) '  Spacing=', (loc(arg(i))-loc(arg(i-1)), i=2,5)

	  END SUBROUTINE AssumedSize

	END PROGRAM ItDependsOnTheDummyArgument

