我想請問為什麼我的程式碼在舊版的Compaq Visual Fortran可以順利執行(作業環境是在
Win7的XP_Mode裡執行),但是我把同樣的程式碼放在微軟的Microsoft Visual Studio 的
Fortran編輯器裡卻出現兩個錯(作業系統直接在Win7),請問有人可以幫我偵錯嗎?
以下是我的程式碼
program homework01
implicit none
integer::num,i,j
real::U(20)
real::Matrix_Bij(20,20)
real::T(20)
real::Y(20)
real::b,a,G,E,pr,n,L,f,xi,xj,bij,bij1,bij2,bij3,bij4,uyi,PI,a1,a2,a3,a4,Tyy
real::ux,uy,d,zxx,zyy,zxy,r1,r2,th1,th2
real::sumux,sumuy,sumzxx,sumzxy,sumzyy
real::MATRIX_C(20)
real::MATRIX_x(20)
real::MATRIX_y(20)
real::MATRIX_xx(20)
real::MATRIX_yy(20)
real::MATRIX_xy(20)
! bij1: bij的第一部分
! bij2: bij的第二部分
! bij3: bij的第三部分
! bij4: bij的第四部分
PI=3.14159
num=20
E=10000
pr=0.3
G=0.5*(E/(1+pr))
uyi=-0.03
open(10,file='output.txt')
! L的修正
write(*,*)"L=b*f,請輸入此次的f值"
read(*,*)f
write(*,*)"請輸入此次的b值"
read(*,*)b
L=b*f
write(*,*)"請輸入此次的num值,不超過20"
read(*,*)num
write(10,*)"元素數目:",num
write(10,*)"楊氏模數:",E,"MPa"
write(10,*)"柏松比:",pr
write(10,*)"剪力模數:",G
write(10,*)"一半的基礎寬:",b,"m"
write(10,*)"元素長度 :",2*a,"m"
write(10,*)"L =",f,"*基礎寬 :",L
write(10,*)"沉陷量 :",uyi,"m"
call slove_Bij
(num,i,j,xi,xj,a,bij,bij1,bij2,bij3,bij4,pr,G,Matrix_Bij,U,uyi,L,b,a1,a2,a3,a4)
call solve (U,Matrix_Bij,T,num,uyi)
!
call compare (num,g,uyi,b,pr,Y,Tyy,xi,a,i)
!
call sum (ux,uy,zxx,zxy,zyy,uyi,r1,r2,th1,th2,y,a,d,f,b,pr,num,&
PI,G,L,T,Matrix_x,Matrix_y,Matrix_xx,Matrix_xy,Matrix_yy,sumzxx,sumzxy,sumzyy)
!
stop
end program homework01
! 解Bij subroutine1 Matrix_Bij
subroutine slove_Bij
(num,i,j,xi,xj,a,bij,bij1,bij2,bij3,bij4,pr,G,Matrix_Bij,U,uyi,L,b,a1,a2,a3,a4)
implicit none
integer::num,i,j
real::U(20)
real::Matrix_Bij(20,20)
real::T(20)
real::a,b,G,xi,xj,pr,n,L,bij,bij1,bij2,bij3,bij4,uyi,PI,E,a1,a2,a3,a4
PI=3.14159
E=10000
pr=0.3
G=0.5*(E/(1+pr))
uyi=-0.03
! 定義元素
a=b/num
write(10,*)"L :"
write(10,*)L
write(10,*)"a:"
write(10,*)a
write(10,*)"Bij :"
do I=1,num
xi=-b+(2*i-1)*a
do j=1,num
xj=-b+(2*j-1)*a
a1=abs(xi-xj+a)
a2=abs(xi-xj-a)
a3=(L-xj-a)
a4=(L-xj+a)
write(10,*)"i"
write(10,*)i
write(10,*)"j:"
write(10,*)j
write(10,*)"xi:"
write(10,*)xi
write(10,*)"xj:"
write(10,*)xj
bij1=(xi-xj+a)*log(a1)
bij2=(xi-xj-a)*log(a2)
bij3=(L-xj-a)*log(a3)
bij4=(L-xj+a)*log(a4)
bij=-((1-pr)/(PI*G))*(bij1-bij2+bij3-bij4)
Matrix_Bij(i,j)=bij
write(10,*)"Bij :"
write(10,*)bij
write(*,*)"Bij :"
write(*,*)bij
Matrix_Bij(i,j)=bij
end do
end do
! uyi
do i=1,num
U(i)=uyi
write(10,*)"uyi :"
write(10,*)U(i)
end do
return
end subroutine
! 比較理論解與數值分析 subroutine3 compare
subroutine compare (num,G,uyi,b,pr,Y,Tyy,xi,a,i)
implicit none
integer::num,i
real::Y(20)
real::Tyy
real::G,uyi,b,pr,xi,a
write(10,*)"解析解為 :"
write(*,*)"解析解為 :"
do i=1,num
a=b/num
xi=(-1)*b+(2*i-1)*a
Tyy=(((-1)*G*uyi)/((1-pr)*0.69314718))*(1/((b**2-xi**2)**0.5))
write(10,*)Tyy
write(*,*)Tyy
end do
write(*,*)"