[問題] 有關Fortran的問題

看板Programming作者 (Ryunu)時間17年前 (2007/05/08 14:12), 編輯推噓2(201)
留言3則, 2人參與, 最新討論串1/1
我寫了一個Fortran程式 但是它有錯誤 我看不太懂它指示的錯誤到底在說什麼 麻煩板上的高手幫我糾正一下 謝謝 m(_ _)m 這個程式是要利用氣體方程式PV=nRT,讓使用者可以選擇輸入的已知條件 例:P,V,n,T 求出未知的部份,還要讓使用者決定是否繼續程式 我寫的程式如下 program work real P,V,n,R,T R=0.082 3 write(*,*) "1=已知P,V,n 利用PV=nRT 求T" write(*,*) "2=已知V,n,T 利用PV=nRT 求P" write(*,*) "3=已知n,T,P 利用PV=nRT 求V" write(*,*) "4=已知T,P,V 利用PV=nRT 求n" write(*,*) "選擇要輸入的已知條件input=1,2,3,4" read (*,*) 1,2,3,4 if(input=1) then T=P*V/(n*R) write(*,*) "T=" else if(input=2) then P=n*R*T/V write(*,*) "P=" else if(input=3) then V=P*V/(R*T) write(*,*) "V=" else if(input=4) then n=P*V/(R*T) write(*,*) "n=" else end if write(*,*) "是否要繼續輸入?input=Y,N" read input if(input=Y) then GOTO 3 else if(input=N) then end if stop end work 它顯示錯誤的部份是 F95(9) : error 304 - Non-writable expression in READ statement F95(9) : error 52 - Compilation abandoned 麻煩了!!! 如果有更精簡,更好的寫法也請板上的各位多指教(我是Fortran新手) 謝謝! m(_ _)m -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.211.29.247 ※ 編輯: YUNNRUWU 來自: 218.211.29.247 (05/08 14:13)

05/08 16:46, , 1F
read (*,*) 1,2,3,4 ??????? 這行.....
05/08 16:46, 1F

05/08 16:47, , 2F
if(input=2)then -> if(input==2)then
05/08 16:47, 2F

05/08 18:30, , 3F
1,2,3,4是啥...沒宣告
05/08 18:30, 3F
文章代碼(AID): #16G1IwQ9 (Programming)