title: Index of array out of range
body: <p>I am confused how Fortran handle the situation if the index for referencing an element of an array is actually out of its supposed range. </p>
  
  <p>Here is a simple code to illustrate the problem:</p>
  
  <pre><code>PROGRAM test_matrix_out
  
  USE mod_writearray
  
  IMPLICIT NONE
  INTEGER :: i,j,m,n
  REAL    :: k
  REAL, Dimension(:,:),ALLOCATABLE :: A
  
  m = 3
  n = 4
  ALLOCATE(A(m,n))
  
  k = 1
  
  DO i=1,m
      DO j=1,n
          A(i,j)=k
          k=k+1
      ENDDO
  ENDDO
  
  CALL writearray(A)
  WRITE(*,*)
  WRITE(*,*) A(1,:)
  WRITE(*,*)
  WRITE(*,*) A(2,:)
  WRITE(*,*)
  WRITE(*,*) A(0,:)
  WRITE(*,*)
  WRITE(*,*) A(4,:)
  WRITE(*,*)
  WRITE(*,*) A(5,:)
  WRITE(*,*)
  WRITE(*,*) A(100,:)
  WRITE(*,*)
  WRITE(*,*) A(:,1)
  WRITE(*,*)
  WRITE(*,*) A(:,2)
  WRITE(*,*)
  WRITE(*,*) A(:,0)
  WRITE(*,*)
  WRITE(*,*) A(:,4)
  WRITE(*,*)
  WRITE(*,*) A(:,5)
  WRITE(*,*)
  WRITE(*,*) A(:,100)
  
  
  DEALLOCATE(A)
  
  END PROGRAM test_matrix_out
  </code></pre>
  
  <p>It gives me the following result:</p>
  
  <pre><code>   1.000000       2.000000       3.000000       4.000000
  
     5.000000       6.000000       7.000000       8.000000
  
    0.0000000E+00   9.000000       10.00000       11.00000
  
     2.000000       3.000000       4.000000      0.0000000E+00
  
     6.000000       7.000000       8.000000      0.0000000E+00
  
    0.0000000E+00  0.0000000E+00  0.0000000E+00  0.0000000E+00
  
     1.000000       5.000000       9.000000
  
     2.000000       6.000000       10.00000
  
   -1.0097448E-28  8.9776148E-39  0.0000000E+00
  
     4.000000       8.000000       12.00000
  
    0.0000000E+00  0.0000000E+00  0.0000000E+00
  
   -3.3631163E-44  1.4293244E-43  0.0000000E+00
  </code></pre>
  
  <p>Why does this happen?</p>