主题:array bounds exceed
编译的时候没提示有错误,可是运行的时候就出错了,说主要是A(i+360*(j-1))=1/2*RA(j+1)**2*pi-1/2*RA(j)**2*pi这句有问题,说array bounds exceed,可是我在子程序yi中也用到这个循环,却没出错,搞不清什么原因,哪位高手帮忙指点下,谢谢
program main
implicit none
integer::d,t,k,i,j
real::Ae,Sey,ye,Iey,Ie,E0,E
real,parameter::pi=3.1415926
real,allocatable::y(:),A(:),RA(:)
open(unit=10,file="input.txt")
open(unit=20,file="output.txt")
read(10,*)d,t
k=360*t
E0=206000
E=206000
allocate(y(k),A(k),RA(t))
call yi(d,t,k,y)
Ae=0.0
Sey=0.0
Iey=0.0
do j=1,t,1
RA(j)=(D-2*t)/2+j-1
end do
do j=1,t,1
do i=1,360,1
A(i+360*(j-1))=1/2*RA(j+1)**2*pi-1/2*RA(j)**2*pi
end do
end do
do i=1,k
Ae=Ae+E/E0*A(i)
Sey=Sey+E/E0*y(i)*A(i)
Iey=Iey+E/E0*y(i)*y(i)*A(i)
end do
ye=Sey/Ae
Ie=Iey-Sey*ye
if(Ae<=1E-4)then
write(*,*)"全截面屈服!"
stop
end if
write(20,*)Ae,ye,Iey
close(10)
close(20)
stop
end program main
subroutine yi(d,t,k,y)
implicit none
integer::d,t,k,i,j
real::y(k)
real,parameter::pi=3.1415926
do j=1,t,1
do i=1,360,1
y(i+360*(j-1))=((d-2*t)/2+j-1/2)*sin(i*pi/180-pi/360)
end do
end do
return
end subroutine yi
program main
implicit none
integer::d,t,k,i,j
real::Ae,Sey,ye,Iey,Ie,E0,E
real,parameter::pi=3.1415926
real,allocatable::y(:),A(:),RA(:)
open(unit=10,file="input.txt")
open(unit=20,file="output.txt")
read(10,*)d,t
k=360*t
E0=206000
E=206000
allocate(y(k),A(k),RA(t))
call yi(d,t,k,y)
Ae=0.0
Sey=0.0
Iey=0.0
do j=1,t,1
RA(j)=(D-2*t)/2+j-1
end do
do j=1,t,1
do i=1,360,1
A(i+360*(j-1))=1/2*RA(j+1)**2*pi-1/2*RA(j)**2*pi
end do
end do
do i=1,k
Ae=Ae+E/E0*A(i)
Sey=Sey+E/E0*y(i)*A(i)
Iey=Iey+E/E0*y(i)*y(i)*A(i)
end do
ye=Sey/Ae
Ie=Iey-Sey*ye
if(Ae<=1E-4)then
write(*,*)"全截面屈服!"
stop
end if
write(20,*)Ae,ye,Iey
close(10)
close(20)
stop
end program main
subroutine yi(d,t,k,y)
implicit none
integer::d,t,k,i,j
real::y(k)
real,parameter::pi=3.1415926
do j=1,t,1
do i=1,360,1
y(i+360*(j-1))=((d-2*t)/2+j-1/2)*sin(i*pi/180-pi/360)
end do
end do
return
end subroutine yi