主题:数组越界,跪求大大帮忙,
废话不多说,上传程序吧,
program input
c----------------------------------------------------------------------
c Subroutine for loading or generating initial particle information
c x-- coordinates of particles [out]
c vx-- velocities of particles [out]
c mass-- mass of particles [out]
c rho-- dnesities of particles [out]
c p-- pressure of particles [out]
c u-- internal energy of particles [out]
c itype-- types of particles [out]
c hsml-- smoothing lengths of particles [out]
c ntotal-- total particle number [out]
implicit none
include 'param.inc'
integer itype(maxn), ntotal
double precision x(dim, maxn), vx(dim, maxn), mass(maxn),
& p(maxn), u(maxn), hsml(maxn), rho(maxn)
integer i, d,im
c load initial particle information from external disk file
call shear_cavity(x, vx, mass, rho, p, u,
& itype, hsml, ntotal)
end
subroutine shear_cavity(x, vx, mass, rho, p, u,
& itype, hsml, ntotal)
c----------------------------------------------------------------------
c This subroutine is used to generate initial data for the
c 2 d shear driven cavity probem with Re = 1
c x-- coordinates of particles [out]
c vx-- velocities of particles [out]
c mass-- mass of particles [out]
c rho-- dnesities of particles [out]
c p-- pressure of particles [out]
c u-- internal energy of particles [out]
c itype-- types of particles [out]
c =2 water
c h-- smoothing lengths of particles [out]
c ntotal-- total particle number [out]
implicit none
include 'param.inc'
integer itype(maxn), ntotal
double precision x(dim, maxn), vx(dim, maxn), mass(maxn),
& rho(maxn), p(maxn), u(maxn), hsml(maxn)
integer i, j, d, m, n, mp, np, k
double precision xl, yl, dx, dy
c Giving mass and smoothing length as well as other data.
m = 41
n = 41
mp = m-1
np = n-1
ntotal = mp * np
xl = 1.e-3
yl = 1.e-3
dx = xl/mp
dy = yl/np
do i = 1, mp
do j = 1, np
k = j + (i-1)*np
x(1, k) = (i-1)*dx + dx/2.
x(2, k) = (j-1)*dy + dy/2.
enddo
enddo
do i = 1, mp*np
vx(1, i) = 0.
vx(2, i) = 0.
rho (i) = 1000.
mass(i) = dx*dy*rho(i)
p(i)= 0.
u(i)=357.1
itype(i) = 2
hsml(i) = dx
enddo
end
居然报错 x(2, k) = (j-1)*dy + dy/2. 这行是数组越界了
我看了没问题啊,这里不是只要行循环时变量i和j在限定范围就可以了吗,谢谢帮忙,
program input
c----------------------------------------------------------------------
c Subroutine for loading or generating initial particle information
c x-- coordinates of particles [out]
c vx-- velocities of particles [out]
c mass-- mass of particles [out]
c rho-- dnesities of particles [out]
c p-- pressure of particles [out]
c u-- internal energy of particles [out]
c itype-- types of particles [out]
c hsml-- smoothing lengths of particles [out]
c ntotal-- total particle number [out]
implicit none
include 'param.inc'
integer itype(maxn), ntotal
double precision x(dim, maxn), vx(dim, maxn), mass(maxn),
& p(maxn), u(maxn), hsml(maxn), rho(maxn)
integer i, d,im
c load initial particle information from external disk file
call shear_cavity(x, vx, mass, rho, p, u,
& itype, hsml, ntotal)
end
subroutine shear_cavity(x, vx, mass, rho, p, u,
& itype, hsml, ntotal)
c----------------------------------------------------------------------
c This subroutine is used to generate initial data for the
c 2 d shear driven cavity probem with Re = 1
c x-- coordinates of particles [out]
c vx-- velocities of particles [out]
c mass-- mass of particles [out]
c rho-- dnesities of particles [out]
c p-- pressure of particles [out]
c u-- internal energy of particles [out]
c itype-- types of particles [out]
c =2 water
c h-- smoothing lengths of particles [out]
c ntotal-- total particle number [out]
implicit none
include 'param.inc'
integer itype(maxn), ntotal
double precision x(dim, maxn), vx(dim, maxn), mass(maxn),
& rho(maxn), p(maxn), u(maxn), hsml(maxn)
integer i, j, d, m, n, mp, np, k
double precision xl, yl, dx, dy
c Giving mass and smoothing length as well as other data.
m = 41
n = 41
mp = m-1
np = n-1
ntotal = mp * np
xl = 1.e-3
yl = 1.e-3
dx = xl/mp
dy = yl/np
do i = 1, mp
do j = 1, np
k = j + (i-1)*np
x(1, k) = (i-1)*dx + dx/2.
x(2, k) = (j-1)*dy + dy/2.
enddo
enddo
do i = 1, mp*np
vx(1, i) = 0.
vx(2, i) = 0.
rho (i) = 1000.
mass(i) = dx*dy*rho(i)
p(i)= 0.
u(i)=357.1
itype(i) = 2
hsml(i) = dx
enddo
end
居然报错 x(2, k) = (j-1)*dy + dy/2. 这行是数组越界了
我看了没问题啊,这里不是只要行循环时变量i和j在限定范围就可以了吗,谢谢帮忙,