我正在处理崩溃的代码。我意识到编译后的程序在释放变量时会崩溃,但我不知道如何解决它。释放声明导致崩溃
当我运行的代码,从Windows弹出似乎说:
main.exe has stopped working. Windows can check for a solution to the problem.
和编译器显示消息Process returned -1073740940 (0xC0000374) execution time : 1.171 s
娄存在的代码示例:
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
我把完整代码here作进一步调查。 我也尝试在Windows 7 x64和Windows XP x86中运行不同版本的GFortran的代码,但没有成功。
编辑:
代码正确的一端是:
...
Deallocate(u,v,p,fx,fy)
Deallocate(xd,yd)
End Subroutine PoissonCode
截至日期:
我测试了不同的编译器代码(英特尔视觉Fortran语言)和仍然没有成功。
A **系统**崩溃?如[BSOD](http://en.wikipedia.org/wiki/Blue_Screen_of_Death)?如果不是,请不要这样声称。 – user2246674
我在'deallocate'之前和之后放了'pause'语句。这让我得出结论,释放可能是崩溃的原因。 – Eleteroboltz
@HighPerformanceMark:不久前我有一个类似的问题:http://stackoverflow.com/questions/17452243/stalling-at-deallocate。 –