24小时热门版块排行榜    

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

红叶cq

木虫 (小有名气)

[求助] fortran程序在ubuntu上的运行 已有2人参与

本人刚开始接触fortran,在fortran教程中找了一个程序尝试运行。我用editplus编写程序,保存为.f格式,文件名为hello
放到linux系统下,输入命令gfortran hello.f -o hello.o  ,运行结果出现错误,希望各位大神能帮帮我。
运行结果如下:                                                                     编写的程序如下:
hello.f:1.1:                                                                                                             program ex05
                                                                                                                             implicit none
program ex05                                                                                                       real p
1                                                                                                                          parameter(p=3.1415926)
Error: Non-numeric character in statement label at (1)                                           write(*,*) sin(p/6)
hello.f:1.1:                                                                                                             end

program ex05                                                            
1
Error: Unclassifiable statement at (1)
hello.f:2.1:

implicit none                                                           
1
Error: Non-numeric character in statement label at (1)
hello.f:2.1:

implicit none                                                           
1
Error: Unclassifiable statement at (1)
hello.f:3.1:

real p                                                                  
1
Error: Non-numeric character in statement label at (1)
hello.f:3.1:

real p                                                                  
1
Error: Unclassifiable statement at (1)
hello.f:4.1:

parameter(p=3.1415926)                                                  
1
Error: Non-numeric character in statement label at (1)
hello.f:4.1:

parameter(p=3.1415926)                                                  
1
Error: Unclassifiable statement at (1)
hello.f:5.1:

write(*,*) sin(p/6)                                                     
1
Error: Non-numeric character in statement label at (1)
hello.f:5.1:

write(*,*) sin(p/6)                                                     
1
Error: Unclassifiable statement at (1)
hello.f:6.1:

end                                                                     
1
Error: Non-numeric character in statement label at (1)
hello.f:6.1:

end                                                                     
1
Error: Unclassifiable statement at (1)
回复此楼

» 猜你喜欢

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

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

红叶cq

木虫 (小有名气)

引用回帖:
5楼: Originally posted by pippi6 at 2015-01-14 03:23:12
real p
parameter(p=3.1415926)
这两个语句ok,f90 是支持的。事实上,f90/95 兼容 f77。风格没有好坏,自己习惯就好。...

问题已解决,非常感谢!
8楼2015-01-14 16:33:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 9 个回答

baobiao007

木虫 (职业作家)

中国特色

【答案】应助回帖

感谢参与,应助指数 +1
不要用这么老土的Fortran 77风格语法写。。。。。。。。。。。。因为gfortran编译器不支持了。。。。。。。。。应该写成 real, parameter :: p = 3.1415926
我同意叔本华的观点,人们投身艺术和科学领域的强烈愿望之一就是逃离痛苦、残酷和枯燥无味的现实生活,逃离自己飘忽不定的七情六欲的桎梏。--爱因斯坦
2楼2015-01-13 22:26:13
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

qchem

铁杆木虫 (著名写手)


【答案】应助回帖

★ ★ ★ ★ ★
感谢参与,应助指数 +1
红叶cq: 金币+5, ★★★★★最佳答案, 谢谢您的回答,我知道问题出在哪里了,非常感谢! 2015-01-14 16:35:56
应该用code模式贴出完整的程序,你现在这个太乱了,看不明白。

文件后缀应该用f90,而不是f。

[ 发自小木虫客户端 ]
3楼2015-01-13 22:28:01
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

baobiao007

木虫 (职业作家)

中国特色

现在 fortran2003标准都出来很久了,那些该死的Fortran 77语法都该扔到垃圾桶里去了。。。。。。。。你可以看懂他们,但自己写代码的时候都应该遵循 fortran 90/95 甚至2003标准来写
我同意叔本华的观点,人们投身艺术和科学领域的强烈愿望之一就是逃离痛苦、残酷和枯燥无味的现实生活,逃离自己飘忽不定的七情六欲的桎梏。--爱因斯坦
4楼2015-01-13 22:28:15
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 综述论文作为代表作会不会影响评审专家的印象分? +10 yufeiwaner 2026-08-09 11/550 2026-08-10 18:47 by yufeiwaner
[基金申请] FileCode能看出啥? +6 要乐观耀哥 2026-08-10 12/600 2026-08-10 18:37 by wmfsnow
[基金申请] 关于代码变化问题,想知道的进来 +17 且听虎啸 2026-08-07 24/1200 2026-08-10 18:35 by zhangduo2008
[基金申请] 静等基金结果 +5 gjjjzhong 2026-08-10 16/800 2026-08-10 17:19 by Tide man
[基金申请] 关于Filecode分析方法 +3 majunge000 2026-08-10 3/150 2026-08-10 15:46 by lch2012
[基金申请] 国自然结果 +4 Vierhys 2026-08-10 8/400 2026-08-10 15:06 by Vierhys
[基金申请] 应该是93bebmhtak前后十一个字符比较关键 +14 Lanmanbaby 2026-08-09 22/1100 2026-08-10 14:57 by wwncly
[基金申请] 奇怪,两个人的filecode固定段从头到尾一模一样 +4 布布和一二 2026-08-10 4/200 2026-08-10 14:50 by 医学老男孩
[基金申请] 2026国自然放榜时间 +9 布布和一二 2026-08-08 9/450 2026-08-10 11:22 by xxxx2020
[基金申请] 这样的filecode谁见过 +11 布布和一二 2026-08-08 22/1100 2026-08-10 11:10 by wmfsnow
[基金申请] fileCode有新解读? +10 Tide man 2026-08-08 18/900 2026-08-09 12:55 by 仁砚薪传
[基金申请] 关于豆爷回答的JTJC与%2F数量 +5 yang182083 2026-08-06 7/350 2026-08-08 18:29 by zhanghaozhu
[基金申请] 基金中了 +14 laoda193707 2026-08-06 14/700 2026-08-08 00:23 by 实验小白ha
[基金申请] 关于filecode +4 布布和一二 2026-08-07 7/350 2026-08-07 22:55 by zhanghaozhu
[基金申请] 娱乐 +6 Tide man 2026-08-03 6/300 2026-08-07 22:40 by 铁帽子农民
[基金申请] 化学口download_prp&fileCode的固定段好像这几天一直没变,有变的大神么? +3 Tide man 2026-08-07 4/200 2026-08-07 22:39 by Tide man
[基金申请] 听说今天filecode变了 +24 布布和一二 2026-08-06 47/2350 2026-08-07 16:02 by zhiyanjiang
[基金申请] filecode +14 等待解的谜 2026-08-06 19/950 2026-08-07 12:20 by wlwhappy
[基金申请] filecode +8 布布和一二 2026-08-06 11/550 2026-08-06 20:41 by tangpu318
[基金申请] 求各位大神看下 100+6 hpkpkpkp 2026-08-05 33/1650 2026-08-06 14:49 by zhiyanjiang
信息提示
请填处理意见