title: Deallocate Statement Causes Crash
body: <p>I am working on a code that is crashing. I realized that the compiled program crashes when it is deallocating the variables, but I don't know how to fix it.</p>
  
  <p>When I run the code, a pop-up from Windows appears saying:</p>
  
  <p><code>main.exe has stopped working.
  Windows can check for a solution to the problem.</code></p>
  
  <p>and the compiler shows the message <code>Process returned -1073740940 (0xC0000374)   execution time : 1.171 s</code></p>
  
  <p>Bellow there is a sample of the code:</p>
  
  <pre><code>Subroutine PoissonCode()
  Use Mesh
  Implicit none
  Real(8), Allocatable :: u(:,:),v(:,:),p(:,:)
  Character(50) :: Nome
  Allocate(u(0:Imax,0:jmax),v(0:Imax,0:jmax),p(0:Imax,0:jmax),fx(0:Imax,0:jmax),fy(0:Imax,0:jmax))
  Allocate(xd(0:Imax),yd(0:Jmax))
  
  ........Code Here...............
  
  Deallocate(u,v,p,fx,fy,xd,yd)
  Deallocate(xd,yd)
  
  End Subroutine PoissonCode
  </code></pre>
  
  <p>I put the complete code <a href="https://dl.dropboxusercontent.com/u/24478877/Code.zip" rel="nofollow">here</a> for further investigation.
  I also tried to run the code with different versions of GFortran in Windows 7 x64 and Windows XP x86 with no success.</p>
  
  <p><strong>Edit:</strong> </p>
  
  <p>The correct end of the code is:</p>
  
  <pre><code>...
  
  Deallocate(u,v,p,fx,fy)
  Deallocate(xd,yd)
  
  End Subroutine PoissonCode
  </code></pre>
  
  <p><strong>Up date:</strong></p>
  
  <p>I tested the code with a different compiler (Intel Visual Fortran) and still no success.</p>