fortran ***`./a.out'出错:free():下一个大小无效(正常):0x0e18b000 ***

时间:2015-10-09 20:15:17

标签: fortran

我是fortran的新人。这是我的代码:

  subroutine fft_forward(Q,ier,fftable,ffwork,nfftable,nffwork,     &
 &                       nfft1,nfft2,nfft3,nfftdim1,nfftdim2,       &
 &                       nfftdim3)
  implicit none 

  integer nfft1,nfft2,nfft3,nfftdim1,nfftdim2,nfftdim3
  integer nfftable,nffwork,ier
  double precision,dimension(nfftdim1,nfftdim2,nfftdim3):: Q
  double precision,dimension(nfftable):: fftable
  double precision,dimension(nffwork):: ffwork 

  call pubz3d(Q,ier,nfft1,nfft2,nfft3,nfftdim1,nfftdim2,nfftdim3,   &
 &            fftable,nfftable,ffwork,nffwork)
  write(6,*) 'bye'
  return
  end

我在pubz3d子例程中的不同行放了​​一些写语句,它们工作(它在子例程的最后一行打印'hi')。但子程序不返回任何值,甚至打印'再见'。

  subroutine pubz3d(Q,ier,nfft1,nfft2,nfft3,nfftdim1,nfftdim2,      &
 &                  nfftdim3,wsave,lensav,work,lenwrk)
  implicit none
  double precision,dimension(nfftdim1,nfftdim2,nfftdim3)::Q
  double precision,dimension(lensav)::wsave      
  double precision,dimension(nfft1)::r
  double precision,dimension(lenwrk)::work
  integer nfft1,nfft2,nfft3,nfftdim1,nfftdim2,nfftdim3,n
  integer lensav,lenwrk,ier
  integer i,j,k

  n = nfftdim1 * nfftdim2 *nfftdim3

  do  k = 1, nfft3
   do  j = 1, nfft2
    do  i = 1,nfft1
      r(i) = Q(i,j,k)
    continue
    call dfft1f(n,1,r,n + 1,wsave,lensav,work,lenwrk,ier)
    do  i = 1,nfft1
     Q(i,j,k) = r(i)
    continue
   continue
  continue

  do  k = 1,nfft3
   do  i = 1,nfft1
    do  j = 1,nfft2
      r(j) = Q(i,j,k)
    continue
    call dfft1f(n,1,r,n + 1,wsave,lensav,work,lenwrk,ier)
    do  j = 1,nfft2
      Q(i,j,k) = r(j)
    continue
   continue
  continue

  do  i = 1, nfft1
   do  j = 1, nfft2
    do  k = 1,nfft3
      r(k) = Q(i,j,k)
    continue
    call dfft1f(n,1,r,n + 1,wsave,lensav,work,lenwrk,ier)
    do  k = 1,nfft3
      Q(i,j,k) = r(k)
    continue
   continue
  continue
  write(6,*) 'hi'
  return
  end

跑步我

hi
*** Error in `./a.out': free(): invalid next size (normal): 0x0e5a9000 ***
Program received signal SIGABRT: Process abort signal.
Backtrace for this error:
#0  0xB760B163
#1  0xB760B800
#2  0xB77103FF
#3  0xB7710424
#4  0xB7416606
#5  0xB7419A32
#6  0xB7450E52
#7  0xB745B339
#8  0xB745BFAC
#9  0x804BD3B in pubz3d_
#10  0x804BFE4 in fft_forward_
#11  0x8055FF4 in do_pmesh_kspace_
#12  0x8054F2D in MAIN__ at main.f:?
Aborted

谢谢

1 个答案:

答案 0 :(得分:0)

您确定nfft1>nfft2nfft1>nfft3吗?您的辅助变量r的大小为nfft1,但您可以在最多nfft2nfft3的循环中使用它。如果其中任何一个大于nfft1,那么您将收到错误消息。确保r的维度足够大,以容纳所有三种循环。

如果此不是问题,请尝试使用某些数组边界检查(gfortran-fcheck=allifort-check all进行编译注意安全)。这可能会在出现问题时产生更多信息。