24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 3155  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料与化工专硕306分找合适调剂 +6 沧海轻舟e 2026-04-06 6/300 2026-04-06 10:02 by lqwchd
[考研] 308求调剂 +4 maverick^_^ 2026-04-03 4/200 2026-04-05 19:08 by 蓝云思雨
[考研] 348求调剂 +6 wukira 2026-04-04 6/300 2026-04-05 18:11 by 猪会飞
[考研] 288求调剂,一志愿华南理工大学071005 +6 ioodiiij 2026-04-04 6/300 2026-04-05 10:09 by guoweigw
[考研] 085602调剂 初试总分335 +12 19123253302 2026-04-04 12/600 2026-04-05 08:08 by 544594351
[考研] 一志愿北京化工大学,初试成绩350求调剂 +9 沿岸?贝壳 2026-04-04 14/700 2026-04-05 01:09 by 沿岸?贝壳
[考研] 材料与化工306分找调剂 +12 沧海轻舟e 2026-04-03 13/650 2026-04-04 23:45 by lqwchd
[考研] 能动调剂326专硕 +4 wan112233 2026-04-04 4/200 2026-04-04 22:47 by yu221
[考研] 342求调剂 +3 Liang7111 2026-04-04 5/250 2026-04-04 19:47 by dongzh2009
[考研] 一志愿北京科技大学材料工程085601,求调剂 +17 cdyw 2026-04-02 18/900 2026-04-04 11:14 by w_xuqing
[考研] 326分求调剂 +3 于是乎呢 2026-04-01 5/250 2026-04-03 14:23 by 于是乎呢
[考研] 求调剂 +3 usbdndj 2026-04-03 3/150 2026-04-03 14:10 by dxiaoxin
[考研] 专硕 351 086100 也是考的材科基 本科也是材料 +8 202451007219 2026-04-02 8/400 2026-04-03 09:50 by 蓝云思雨
[考研] 326求调剂 +3 9ahye 2026-04-02 4/200 2026-04-03 08:43 by Jaylen.
[考研] 282求调剂 +13 呼吸都是减肥 2026-04-01 13/650 2026-04-02 14:10 by baoball
[考研] 085601一志愿中山大学深圳材料工程330求调剂 +8 pipiver 2026-03-30 8/400 2026-04-02 12:01 by ms629
[考研] 266分,一志愿电气工程,本科材料,求材料专业调剂 +10 哇呼哼呼哼 2026-04-01 11/550 2026-04-02 11:31 by lnilvy
[考研] 材料调剂 +12 一样YWY 2026-04-01 12/600 2026-04-02 09:15 by olim
[考研] 0855机械初试280求调剂 +3 kazenotori 2026-03-31 3/150 2026-04-01 10:08 by JourneyLucky
[考研] 一志愿北京科技大学085601材料工程英一数二初试总分335求调剂 +5 双马尾痞老板2 2026-03-31 5/250 2026-04-01 09:04 by oooqiao
信息提示
请填处理意见