24小时热门版块排行榜    

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

tider

木虫 (正式写手)

[求助] Fortran allocate 程序段编译出错求助。

以下是报出的错误:
CODE:
In file ./forces.f:393
      double precision, allocatable :: cf(:,:)                          
                                                       1
Error: Unexpected data declaration statement at (1)
In file ./forces.f:394
      allocate(cf(3,natoms),stat=error)                                 
                1
Error: Syntax error in ALLOCATE statement at (1)
In file ./forces.f:395
      integer :: vvv, kkk                                               
                1
Error: Unexpected data declaration statement at (1)
In file ./forces.f:399
            read(2013,*) (cf(vvv,kkk),kkk=1,natoms)                     
                       1
Error: Expected variable in READ statement at (1)

make: *** [forces.o] Error 1

出错的程序段如下:
c     read force from the file "force.txt"

      double precision, allocatable :: cf(:,:)
      allocate(cf(3,natoms),stat=error)
      integer :: vvv, kkk

      open (unit=2013, file='force.txt')
        do vvv=1,3
            read(2013,*) (cf(vvv,kkk),kkk=1,natoms)
        end do
      close(2013)

      do vvv=1,3
           do kkk=1,natoms
              write (*,*) cf(vvv,kkk)
           end do
      end do

总看着没错误,希望虫友指正。Thx.

[ Last edited by jjdg on 2013-2-27 at 02:54 ]
回复此楼

» 猜你喜欢

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

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

tider

木虫 (正式写手)

jjdg: 编辑内容 2013-02-27 02:55
引用回帖:
3楼: Originally posted by xujince at 2013-02-25 23:53:27
把 integer :: vvv, kkk 移到 double precision, allocatable :: cf(:,的上面

谢谢,不过这样以后还是会报错。。是同样的错误。这跟编译器的选择有关系么?
CODE:
gfortran -Ad -O -c -I. -I.  ./forces.f
In file ./forces.f:393
      integer :: vvv, kkk                                               
                                                                      1
Error: Unexpected data declaration statement at (1)
In file ./forces.f:394
      double precision, allocatable :: cf(:,:)                          
                                                                       1
Error: Unexpected data declaration statement at (1)
In file ./forces.f:395
      allocate(cf(3,natoms),stat=error)                                 
                1
Error: Syntax error in ALLOCATE statement at (1)
In file ./forces.f:399
            read(2013,*) (cf(vvv,kkk),kkk=1,natoms)                     
                       1
Error: Expected variable in READ statement at (1)
make: *** [forces.o] Error 1

[ Last edited by jjdg on 2013-2-27 at 02:55 ]
4楼2013-02-27 02:44:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 6 个回答

xujince

木虫 (正式写手)

【答案】应助回帖

★ ★
感谢参与,应助指数 +1
jjdg: 编辑内容 2013-02-27 02:54
tider: 金币+2, 谢谢提示 2013-02-27 11:33:55
把 integer :: vvv, kkk 移到
CODE:
double precision, allocatable :: cf(:,:)

的上面

[ Last edited by jjdg on 2013-2-27 at 02:54 ]
3楼2013-02-26 13:53:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

chembetsey

木虫 (小有名气)

【答案】应助回帖

★ ★ ★
感谢参与,应助指数 +1
tider: 金币+2, 谢谢提示 2013-02-27 11:34:08
jjdg: 金币+1, 辛苦了 2013-02-28 00:23:03
我怀疑编译器把代码当作固定格式的了,你把后缀名改为f90再编译试试
5楼2013-02-27 09:29:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

tider

木虫 (正式写手)

我把定义变量的语句放到整个程序最前面就没报错了,但是又出现了以下的错误,有哪位虫友知道这是什么类型的错误么?

forces.o: In function `force_':
forces.f:(.text+0x8449): undefined reference to `_gfortran_allocate64_array'
forces.f:(.text+0x89d3): undefined reference to `_gfortran_st_write'
forces.f:(.text+0x89e5): undefined reference to `_gfortran_transfer_character'
forces.f:(.text+0x89fa): undefined reference to `_gfortran_transfer_integer'
forces.f:(.text+0x8a0f): undefined reference to `_gfortran_transfer_integer'
forces.f:(.text+0x8a24): undefined reference to `_gfortran_transfer_real'
forces.f:(.text+0x8a2c): undefined reference to `_gfortran_st_write_done'
forces.f:(.text+0x941b): undefined reference to `_gfortran_st_write'
forces.f:(.text+0x9432): undefined reference to `_gfortran_transfer_character'
forces.f:(.text+0x943f): undefined reference to `_gfortran_st_write_done'
forces.f:(.text+0x9479): undefined reference to `_gfortran_st_write'
forces.f:(.text+0x9490): undefined reference to `_gfortran_transfer_character'
forces.f:(.text+0x94aa): undefined reference to `_gfortran_transfer_integer'
forces.f:(.text+0x94c1): undefined reference to `_gfortran_transfer_character'
forces.f:(.text+0x94d6): undefined reference to `_gfortran_transfer_real'
forces.f:(.text+0x94f8): undefined reference to `_gfortran_transfer_real'
forces.f:(.text+0x9505): undefined reference to `_gfortran_st_write_done'
forces.f:(.text+0x95c3): undefined reference to `_gfortran_st_open'
forces.f:(.text+0x960e): undefined reference to `_gfortran_st_read'
forces.f:(.text+0x966e): undefined reference to `_gfortran_transfer_real'
forces.f:(.text+0x9683): undefined reference to `_gfortran_st_read_done'
forces.f:(.text+0x96d2): undefined reference to `_gfortran_st_close'
forces.f:(.text+0x9738): undefined reference to `_gfortran_st_write'
forces.f:(.text+0x9779): undefined reference to `_gfortran_transfer_real'
forces.f:(.text+0x9781): undefined reference to `_gfortran_st_write_done'
forces.f:(.text+0x97bd): undefined reference to `_gfortran_deallocate'
forces.f:(.text+0x9c56): undefined reference to `_gfortran_deallocate'
6楼2013-02-27 11:36:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[硕博家园] 极限拉扯,如何抉择 +10 Isak0320 2026-10-12 14/700 2026-10-14 11:39 by thegarfield
[基金申请] 申请科研项目纯靠实力能成功吗? 200+3 David1982 2026-10-13 6/300 2026-10-14 11:14 by 北京莱茵编辑
[有机交流] OpenAI又攻克数学难题了,离AI做有机合成还有多远? +8 wangyl_123 2026-10-10 12/600 2026-10-13 20:40 by Merryya
[教师之家] 课题组会帮你通过考核么? +4 好运来~9527 2026-10-10 7/350 2026-10-13 08:41 by xli1984
[基金申请] 入职后第一次管课题组的专利缴费,对账才发现官费比别人多掏了一倍 +6 13108017953 2026-10-08 6/300 2026-10-12 20:07 by w3w3y3
[公派出国] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +5 qR2AdCWTVtkw 2026-10-09 9/450 2026-10-11 22:34 by XQNyDCa1Tk5n
[找工作] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +5 qR2AdCWTVtkw 2026-10-09 8/400 2026-10-11 22:26 by XQNyDCa1Tk5n
[考博] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +5 qR2AdCWTVtkw 2026-10-09 9/450 2026-10-11 22:15 by XQNyDCa1Tk5n
[考博] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +3 qR2AdCWTVtkw 2026-10-09 7/350 2026-10-11 22:11 by XQNyDCa1Tk5n
[教师之家] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 (EPI+-1)(金币-50) +5 qR2AdCWTVtkw 2026-10-09 10/500 2026-10-11 22:06 by XQNyDCa1Tk5n
[教师之家] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 (EPI+-1)(金币-50) +5 qR2AdCWTVtkw 2026-10-09 10/500 2026-10-11 14:25 by VOMexwnDzOFZ
[教师之家] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 (EPI+-1)(金币-50) +4 qR2AdCWTVtkw 2026-10-09 7/350 2026-10-11 14:05 by VOMexwnDzOFZ
[考研] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +5 qR2AdCWTVtkw 2026-10-09 8/400 2026-10-11 13:51 by VOMexwnDzOFZ
[硕博家园] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +5 qR2AdCWTVtkw 2026-10-09 8/400 2026-10-11 13:45 by VOMexwnDzOFZ
[找工作] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 qR2AdCWTVtkw 2026-10-09 7/350 2026-10-11 10:54 by VOMexwnDzOFZ
[找工作] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 qR2AdCWTVtkw 2026-10-09 7/350 2026-10-11 10:34 by VOMexwnDzOFZ
[考博] 招收博士生一名 +3 mandolin 2026-10-10 3/150 2026-10-11 10:21 by 不是山谷!
[公派出国] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +4 qR2AdCWTVtkw 2026-10-09 4/200 2026-10-11 03:14 by M0zrYVSAnxpE
[有机交流] 各位大佬,路线设计求助 +6 zapen 2026-10-08 8/400 2026-10-10 15:59 by zapen
[有机交流] 我应该选哪条合成路线让实验成功率高一些? +5 jing816y 2026-10-08 9/450 2026-10-10 09:05 by zapen
信息提示
请填处理意见