1

在第 99 行,公式gsurf(iel)给出了错误:

unclassifiable statement at (1)

编译程序时,它位于第 99 行的开头。关于如何解决这个问题的任何建议?

program gravity

implicit none
real(8) Lx,Ly,sx,sy,xsphere,ysphere,r,A,rho1,rho2,dx,G1
integer np,nel,nelx,nely,i,nnx,nny,j,counter,nsurf,iel
real(8),dimension(:),allocatable :: xcgrid
real(8),dimension(:),allocatable :: ycgrid
real(8),dimension(:),allocatable :: xgrid
real(8),dimension(:),allocatable :: ygrid
real(8),dimension(:),allocatable :: rho
real(8),dimension(:),allocatable :: xsurf
real(8),dimension(:),allocatable :: ysurf
real(8),dimension(:),allocatable :: gsurf

nnx=101.
nny=101.
Lx=100.
Ly=100.
nelx=nnx-1.
nely=nny-1.
nel=nelx*nely
np=nnx*nny
sx=Lx/nelx
sy=Ly/nely
xsphere=50.
ysphere=50.
r=12.
nsurf=7  !number of gravimeters
G1=6.6738480*10**(-11) !m^3 kg^-1 s^-2

dx=Lx/(nsurf-1.)

!==========================================================

allocate(xgrid(np))
allocate(ygrid(np))

counter=0
do i=1,nnx
    do j=1,nny
    counter=counter+1   
    xgrid(counter)=dble(i-1)*sx
    ygrid(counter)=dble(j-1)*sy
    end do
end do

call write_two_columns(np,xgrid,ygrid,'grid_init.dat')
!==========================================================

allocate(xcgrid(np))
allocate(ycgrid(np))


counter=0
do i=1,nnx-1
    do j=1,nny-1
    counter=counter+1   
    xcgrid(counter)=dble(i-1)*sx+0.5*sx
    ycgrid(counter)=dble(j-1)*sy+0.5*sy
    end do
end do

call write_two_columns(np,xcgrid,ycgrid,'gridc_init.dat')
!==========================================================

allocate(rho(nel))

rho1=3000. !kg/m^3
rho2=3200. !kg/m^3

do i=1,nel  
    if (sqrt((xsphere-xcgrid(i))**2)+((ysphere-ycgrid(i))**2)<r) then
    rho(i)=3200.
    else 
    rho(i)=3000.
    end if
end do


call write_three_columns(nel,xcgrid,ycgrid,rho,'inclusion.dat')
!==========================================================

allocate(xsurf(nsurf))
allocate(ysurf(nsurf))

do i=1,nsurf
xsurf(i)=(i-1)*dx
ysurf(i)=ly
end do

call write_two_columns(nsurf,xsurf,ysurf,'surf_init.dat')
!==========================================================

allocate(gsurf(nel))

do i=1,nsurf
xsurf(i)=(i-1)*dx
ysurf(i)=ly
    do iel=1,nel
    gsurf(iel)=2.*G1*(((rho(iel)-rho1)*(y(iel)-ygrid))/((x(iel)-xgrid)**2.+(y(iel)-ygrid))**2.)))*sx*sy
    end do
end do

call write_two_columns (nel,ysurf,xsurf,gsurf,'gravity.dat')

deallocate(xgrid)
deallocate(ygrid)
deallocate(xcgrid)
deallocate(ycgrid)
deallocate(xsurf)
deallocate(ysurf)

end program"
4

1 回答 1

3

在指定的行,我发现了以下错误(使用 编译时ifort,而不是gfortran):

  • )不平衡的括号(之前还有额外的 2 个sx*sy
  • 未声明的变量数组x
  • 未声明的变量数组y
  • 不匹配的维度(您要从单个元素中减去整个数组)ygridxgridgsurf(iel)

如果我将这些xy变量更改为xsurf/ysurfxcgrid/ycgrid并将ygrid&的索引xgrid放入,我可以在这些行上编译而不会出现错误(尽管因为我没有你的其他调用的子例程,编译器告诉我我有一些未定义的引用) .

于 2013-10-05T13:51:37.523 回答