24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 3154  |  回复: 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

木虫 (正式写手)

笑脸是   :)
2楼2013-02-26 13:23:30
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

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的回帖

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的回帖

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的回帖
相关版块跳转 我要订阅楼主 tider 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 362求调剂一志愿中国石油大学 +4 我要考大 2026-04-06 6/300 2026-04-06 14:11 by 无际的草原
[考研] 一志愿河北工业大学材料工程,初试344求专硕调剂 +6 15933906766 2026-04-05 6/300 2026-04-06 13:21 by 无际的草原
[考研] 301求调剂 +6 细胞相关蛋白 2026-04-02 10/500 2026-04-06 08:34 by jp9609
[考研] 08专硕275调剂 +5 AaAa7420 2026-04-05 5/250 2026-04-05 18:01 by jkddd
[考研] 调剂 +5 好好读书。 2026-04-01 5/250 2026-04-05 17:54 by liucky
[考研] 材料调剂 +12 一样YWY 2026-04-04 12/600 2026-04-05 08:24 by 544594351
[考研] 考研调剂 +11 小sun要好运 2026-04-04 11/550 2026-04-05 08:02 by qlm5820
[考研] 286求调剂 +3 草木不言 2026-04-04 3/150 2026-04-04 22:40 by lbsjt
[考研] 考研调剂 +5 四川王涛 2026-04-04 5/250 2026-04-04 22:18 by 啵啵啵0119
[考研] 292分,材料与化工,申请调剂 +22 程晴之 2026-04-01 26/1300 2026-04-04 22:03 by hemengdong
[考研] 368求调剂 +5 今华习 2026-04-03 7/350 2026-04-04 18:47 by imissbao
[考研] 一志愿华南师范361分,化学求调剂 +7 Nicole88888 2026-04-01 7/350 2026-04-04 18:28 by macy2011
[论文投稿] 求文献 5+3 ys879651$ 2026-04-02 3/150 2026-04-04 17:22 by bobvan
[考研] 26调剂 086003 +6 失活的细胞 2026-04-04 6/300 2026-04-04 09:50 by zhangdingwa
[考研] 一志愿重庆大学085404,总分314分,求调剂 +4 zf83hn 2026-04-03 4/200 2026-04-03 21:25 by 啵啵啵0119
[考研] 320求调剂 +5 振—TZ 2026-04-02 5/250 2026-04-03 14:42 by fxue1114
[考研] 326分求调剂 +3 于是乎呢 2026-04-01 5/250 2026-04-03 14:23 by 于是乎呢
[考研] 283求调剂 +3 jiouuu 2026-04-02 4/200 2026-04-02 14:08 by 哒哒哒呱呱呱
[考研] 354求调剂 +4 lxb598 2026-03-31 5/250 2026-04-02 09:55 by Jaylen.
[考研] 070300化学专业279调剂 +10 哈哈哈^_^ 2026-03-31 10/500 2026-03-31 23:13 by liu823948201
信息提示
请填处理意见