24小时热门版块排行榜    

查看: 2683  |  回复: 17
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

宇天旅梦

铜虫 (小有名气)

[求助] 编一个fortran程序

需要一个fortran程序,比较简单的那种,例如f=((5x+6z)*e^(2i) )/(2x-z),其中z=(3y-1)*(x+2)

要求输出的结果是三列数据,分别对应x,y,f .并且每列有20个数。

这三组数据是要导入orgin中进行图像模拟的。
初学fortran,很多东西还不连贯。
请大师们对上面给的式子编个程序示范一下。
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

phy_yo

铁虫 (小有名气)

【答案】应助回帖

引用回帖:
3楼: Originally posted by 宇天旅梦 at 2013-08-24 22:35:22
式子中的 i 是虚数...

哦 那就把real*8改成complex*16
然后再在前面加一行parameter(i=(0,1))

[ 发自手机版 http://muchong.com/3g ]
网络错误 无法获取数据
4楼2013-08-24 23:14:52
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 18 个回答

phy_yo

铁虫 (小有名气)

【答案】应助回帖

感谢参与,应助指数 +1
open(10,file='data.dat',status='unknown')
real*8 x,y,z,x(20),y(20)
do 1 i=1,20
input (*,*)  x,y
x(i)=x
y(i)=y
1 continue
do 2 1,20
z=(3y(i)-1)*(x(i)+2)
f=((5x+6z)*e^(2i) )/(2x-z)
write(*,*) x(i),y(i),f
write(10,*) x(i),y(i),f
2 continue
pause
end
网络错误 无法获取数据
2楼2013-08-24 20:27:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

宇天旅梦

铜虫 (小有名气)

引用回帖:
2楼: Originally posted by phy_yo at 2013-08-24 20:27:45
open(10,file='data.dat',status='unknown')
real*8 x,y,z,x(20),y(20)
do 1 i=1,20
input (*,*)  x,y
x(i)=x
y(i)=y
1 continue
do 2 1,20
z=(3y(i)-1)*(x(i)+2)
f=((5x+6z)*e^(2i) )/(2x-z)
write(*,* ...

式子中的 i 是虚数
3楼2013-08-24 22:35:22
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

宇天旅梦

铜虫 (小有名气)

引用回帖:
4楼: Originally posted by phy_yo at 2013-08-24 23:14:52
哦 那就把real*8改成complex*16
然后再在前面加一行parameter(i=(0,1))
...

运行不了啊,提示有11个错。我用的是fortran90.
下面这些是显示的错误:
--------------------Configuration: Textxcx - Win32 Debug--------------------
Compiling Fortran...
C:\Users\Administrator\Desktop\Textxcx.for
C:\Users\Administrator\Desktop\Textxcx.for(6) : Error: Syntax error, found IDENTIFIER 'X' when expecting one of: ( % . = =>
      input (*,*)  x,y
-------------------^
C:\Users\Administrator\Desktop\Textxcx.for(10) : Error: Syntax error, found INTEGER_CONSTANT '20' when expecting one of: <END-OF-STATEMENT> ; <IDENTIFIER>
      do 2 1,20
-------------^
C:\Users\Administrator\Desktop\Textxcx.for(11) : Error: Syntax error, found IDENTIFIER 'Y' when expecting one of: * :: , <END-OF-STATEMENT> ; : ) (/ [ + - . ] /) ** / > // .LT. < ...
      z=(3y(i)-1)*(x(i)+2)
----------^
C:\Users\Administrator\Desktop\Textxcx.for(12) : Error: Unrecognized token '^' skipped
      f=((5x+6z)*e^(2i) )/(2x-z)
------------------^
C:\Users\Administrator\Desktop\Textxcx.for(12) : Error: Syntax error, found IDENTIFIER 'X' when expecting one of: * :: , <END-OF-STATEMENT> ; : ) (/ [ + - . ] /) ** / > // .LT. < ...
      f=((5x+6z)*e^(2i) )/(2x-z)
-----------^
C:\Users\Administrator\Desktop\Textxcx.for(3) : Error: A specification statement cannot appear in the executable section.
      parameter(i=(0,1))
------^
C:\Users\Administrator\Desktop\Textxcx.for(4) : Error: A specification statement cannot appear in the executable section.
complex*16 x,y,z,x(20),y(20)
--------^
C:\Users\Administrator\Desktop\Textxcx.for(7) : Error: This name has not been declared as an array.   [X]
      x(i)=x
------^
C:\Users\Administrator\Desktop\Textxcx.for(8) : Error: This name has not been declared as an array.   [Y]
      y(i)=y
------^
C:\Users\Administrator\Desktop\Textxcx.for(10) : Error: An unterminated block exists.
      do 2 1,20
^
C:\Users\Administrator\Desktop\Textxcx.for(10) : Error: This label is undefined.   [21]
      do 2 1,20
---------^
Error executing df.exe.

Textxcx.exe - 11 error(s), 0 warning(s)
5楼2013-08-24 23:27:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见