作者YUNNRUWU (Ryunu)
看板Programming
标题[问题] 有关Fortran95的问题
时间Tue May 8 14:12:04 2007
我写了一个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)
1F:推 latinboy:read (*,*) 1,2,3,4 ??????? 这行..... 140.112.23.251 05/08 16:46
2F:→ latinboy:if(input=2)then -> if(input==2)then 140.112.23.251 05/08 16:47
3F:推 haoyoung:1,2,3,4是啥...没宣告140.113.224.179 05/08 18:30