[問題] 不同的編輯軟體出來結果不同?

作者: Kira76 (王牌投手)   2012-12-10 16:51:35
我想請問為什麼我的程式碼在舊版的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(*,*)"
作者: gilocustom   2012-02-10 16:58:00
錯誤訊息是?
作者: mk650   2012-02-10 18:11:00
call副程式(參數),(參數)跳到下一行了,移回就可以執行如果你不是這個錯誤那就不解了,因為沒細看程式碼.如果是這個錯誤,那這個程式複製貼上繳出真輕鬆!執行為L=b*f,請輸入此次的f值,輸入三個值可得計算結果我覺得是IVF設定問題,不是程式問題.請貼上圖片或說明,這樣才比較好debug我在想這是作業吧,拿去問助教應該很快就解決了.你的程式是正確的,但IVF你可能不熟,有些小地方需要微調一下就可以執行

Links booklink

Contact Us: admin [ a t ] ucptt.com