! ---------------------------------------- ! Example program ! Assumed-size arrays ! Warning: subroutine exceeds array bounds, ! but the compiler doesn't know it ! => program may work or not! ! ---------------------------------------- program test implicit none integer, parameter:: n=3,m=2 integer :: A(n,m) A(1,1) = 11 A(1,2) = 12 A(2,1) = 21 A(2,2) = 22 A(3,1) = 31 A(3,2) = 32 print*,' A=' write(*,99) A call output(A) print*,' A**2=' write(*,99) A 99 format(2(3i8,/)) end program test subroutine output(A) implicit none ! assumed-size array: integer,intent(inout):: A(*) print*,'A(1:10) = ',A(1:10) ! bounds are too large! A(1:10) = A(1:10)**2 ! try also what the compiler says about A = A**2 print*,'A(1:10)**2 = ',A(1:10) ! bounds are too large! end subroutine output