停止释放 [英] Stalling at deallocate

查看:172
本文介绍了停止释放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的2D水电码在下面的子程序(它计算y方向流量)期间停顿:

  ALLOCATE(W1d( 1:my,nFields),q1d(nFields),& 
Wl(1:my,nFields),Wr(1:my,nFields))

PRINT *,Main loop
DO i = 1,mx
DO j = 1,my
q1d(1)= qVar(i,j,1,iRho)
q1d(2)= qVar (i,j,1,iE)
q1d(3)= qVar(i,j,1,Ivy)
q1d(4)= qVar(i,j,1,ivx)
CALL Cons2Prim(q1d(:),W1d(j,:))
ENDDO

CALL lr_states(grid,W1d,dt,dy,Wl,Wr,dir)

DO j = 1,my
Flux(i,j,:) = hllc_flux(wl(j,:),wr(j,:))
ENDDO

DO j = 1,my
CALL Prim2Cons(Wl(j,:),Ul(i,j,:))
CALL Prim2Cons(Wr(j,:),Ur(i,j ,:))
ENDDO
ENDDO
PRINT *,释放

DEALLOCATE(W1d,q1d,Wl,Wr)
PRINT *,返回

我将 DEALLOCATE 语句分隔为4个独立状态并发现无论哪个二维数组首先出现, W1d wl wr ,是失速的原因。忽略 DEALLOCATE 语句(在返回主页时会产生一个自动释放)也会导致停顿。 x方向flux的子程序具有相同的数组,在这个子程序之前被调用,并且没有任何问题解除分配。

有什么建议?



编辑这是在Fedora 18上运行,并使用英特尔Fortran 2013.3进行编译。它是一个并行化的代码,但是我为了测试/调试的目的在一个处理器上运行它。

解决方案

事情又突然开始重新开始工作。其中两个我不相信可以做到,但第三个可能。我所做的更改:


  • 我的界限是 i j 循环定义略有不同,所以我在两次方向扫描之间统一了

  • 我运行 make clean code>和 make

  • 我添加了 --check bounds --check pointers --check uninit 标志到Makefile



我认为前两个没有做任何事情。上面代码中的变量 grid 是一个包含 qVar 的边界的2x2数组;在x-sweep中,我已经定义了 mx = grid(1,2) - grid(1,1)+ 1 ,类似于 my ,但grid(1,1) 1,所以它确实没有太大的区别。上面第二项我已经做了至少3次。



但是最后一个我尝试过一次,它又开始工作了。我不知道如何修复它,所以如果有人知道,请告诉我!

My 2D hydro code stalls during the following subroutine (which computes the y-direction flux):

 ALLOCATE(W1d(1:my,nFields),q1d(nFields),&
           Wl(1:my,nFields),Wr(1:my,nFields))

 PRINT *,"Main loop"
 DO i=1,mx
    DO j=1,my
       q1d(1) = qVar(i,j,1,iRho)
       q1d(2) = qVar(i,j,1,  iE)
       q1d(3) = qVar(i,j,1, ivy)
       q1d(4) = qVar(i,j,1, ivx)
       CALL Cons2Prim(q1d(:), W1d(j,:))
    ENDDO

    CALL lr_states(grid, W1d, dt, dy, Wl, Wr, dir)

    DO j=1,my
       Flux(i,j,:) = hllc_flux(wl(j,:), wr(j,:))
    ENDDO

    DO j=1,my
       CALL Prim2Cons(Wl(j,:),Ul(i,j,:))
       CALL Prim2Cons(Wr(j,:),Ur(i,j,:))
    ENDDO
 ENDDO
 PRINT *,"Deallocating"

 DEALLOCATE(W1d,q1d,Wl,Wr)
 PRINT *,"Returning"

I separated the DEALLOCATE statement into 4 separate statements and found that whichever 2D array would come first, W1d, wl, or wr, was the cause of the stall. Ignoring the DEALLOCATE statement (which should produce an automatic deallocate when going back to the main) also causes a stall. The subroutine for the x-direction flux has the same arrays, is called before this subroutine, and has no problems deallocating them.

Any suggestions?

EDIT This is run on Fedora 18 and compiled with Intel Fortran 2013.3. It is a parallelized code, but I am running it on a single processor for testing/debugging purposes.

解决方案

I did three different things and it suddenly started working again. Two of them I do not believe could have done it, while it is possible the third did it. The changes I made:

  • I did have the bounds of i and j loops defined slightly differently, so I made it uniform between the two directional sweeps
  • I ran make clean and make
  • I added -check bounds -check pointers -check uninit flags to the Makefile

I think the first two did not really do anything. The variable grid in the code above is a 2x2 array that contains the bounds of qVar; in the x-sweep I had defined mx = grid(1,2) - grid(1,1) + 1, similarly for my, but grid(1,1) is 1, so it really does not do much different. The second item above I had done at least 3 times.

But the last one I tried once and it started working again. I do not know how that could have fixed it, so if someone does know, please tell me!

这篇关于停止释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆