Fortran Coder

查看: 11645|回复: 9

[子程序] 固定格式(.for)怎么调用自由格式(.f90)的子程序

[复制链接]

10

帖子

1

主题

0

精华

入门

F 币
41 元
贡献
24 点
发表于 2020-10-14 16:01:29 | 显示全部楼层 |阅读模式
各位,我现在遇到一个问题,我的主程序是for格式的(不是我写的),但是现在需要增加一个功能,我是用自由格式的f90写的:
[Fortran] 纯文本查看 复制代码
  subroutine read_force_field()
          use flexible
          implicit none

          integer*4, parameter :: ff_torsion = 10000, max_atom_type = 100, max_ligand = 500  

          integer       :: num_link(max_ligand), link(max_ligand, 10)

          integer       :: i, j, k, ios, nflag, multiplicity, num, num_atom, num_bond, id2

          integer       :: id(4), tot_multiplicity( ff_torsion, ff_torsion ), atom_id(max_ligand)

          integer       :: ligand_id(max_ligand)

          real*8        :: force_constant, phase, periodicity

          real*8        :: x0, y0, z0

          real*8        :: tot_force_constant(ff_torsion, ff_torsion), tot_phase(ff_torsion, ff_torsion )

          real*8        :: tot_periodicity(ff_torsion, ff_torsion)

          real*8        :: coordinate(3, max_ligand), charge(max_ligand)

          character*100 :: line, file_force_field, flig

          character*10  :: atom_type(max_ligand), atom(4), typ, sybyl_type

          logical       :: qqr


然后报错内容就是:
kreadff.f90(11): error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( * ) , . % + - [ : . ** / // .LT. < .LE. <= .EQ. == .NE. ...
          integer       :: id(4), tot_multiplicity( ff_torsion, ff_torsion ), atom_id(max_ligand)
-------------------------------------------------------------------------------------------------^
kreadff.f90(41): error #6404: This name does not have a type, and must have an explicit type.   [TOT_PHASE]
          tot_phase          = -1.0
----------^
kreadff.f90(106): error #6410: This name has not been declared as an array or a function.   [TOT_PHASE]
                  tot_phase(i, j)            = phase
------------------^
kreadff.f90(126): error #6404: This name does not have a type, and must have an explicit type.   [NUM_ATOM]
          num_atom = 0
----------^
kreadff.f90(127): error #6404: This name does not have a type, and must have an explicit type.   [NUM_BOND]
          num_bond = 0
----------^
kreadff.f90(190): error #6404: This name does not have a type, and must have an explicit type.   [ATOM_ID]
          atom_id = 0
----------^
kreadff.f90(194): error #6404: This name does not have a type, and must have an explicit type.   [SYBYL_TYPE]
              sybyl_type = atom_type(i)
--------------^
kreadff.f90(194): error #6303: The assignment operation or the binary expression operation is invalid for the data types of the two operands.   [ATOM_TYPE]
              sybyl_type = atom_type(i)
---------------------------^
kreadff.f90(207): error #6404: This name does not have a type, and must have an explicit type.   [ID2]
                              id2 = 1
------------------------------^
kreadff.f90(217): error #6410: This name has not been declared as an array or a function.   [ATOM_ID]
                      atom_id(i) = id2
----------------------^
kreadff.f90(224): error #6410: This name has not been declared as an array or a function.   [ATOM_ID]
                  atom_id(i) = 5
------------------^
kreadff.f90(7): error #6279: A specification expression object must be a dummy argument, a COMMON block object, or an object accessible through host or use association   [MAX_LIGAND]
          integer       :: num_link(max_ligand), link(max_ligand, 10)
------------------------------------^
kreadff.f90(11): error #6279: A specification expression object must be a dummy argument, a COMMON block object, or an object accessible through host or use association   [FF_TORSI]
          integer       :: id(4), tot_multiplicity( ff_torsion, ff_torsion ), atom_id(max_ligand)
----------------------------------------------------------------^
kreadff.f90(7): error #6404: This name does not have a type, and must have an explicit type.   [MAX_LIGAND]
          integer       :: num_link(max_ligand), link(max_ligand, 10)
------------------------------------^
kreadff.f90(11): error #6404: This name does not have a type, and must have an explicit type.   [FF_TORSI]
          integer       :: id(4), tot_multiplicity( ff_torsion, ff_torsion ), atom_id(max_ligand)
----------------------------------------------------------------^
compilation aborted for CovaDock.for (code 1)


有没有大神教教怎么办,谢谢各位了!

10

帖子

1

主题

0

精华

入门

F 币
41 元
贡献
24 点
 楼主| 发表于 2020-10-14 16:34:39 | 显示全部楼层
[Fortran] 纯文本查看 复制代码
     subroutine read_force_field()
          use flexible
          implicit none

          integer*4, parameter :: ff_torsion = 10000, max_atom_type = 100, max_ligand = 500  

          integer       :: num_link(max_ligand), link(max_ligand, 10)

          integer       :: i, j, k, ios, nflag, multiplicity, num, num_atom, num_bond, id2

          integer       :: id(4), tot_multiplicity( ff_torsion, ff_torsion ), atom_id(max_ligand)

          integer       :: ligand_id(max_ligand)

          real*8        :: force_constant, phase, periodicity

          real*8        :: x0, y0, z0

          real*8        :: tot_force_constant(ff_torsion, ff_torsion), tot_phase(ff_torsion, ff_torsion )

          real*8        :: tot_periodicity(ff_torsion, ff_torsion)

          real*8        :: coordinate(3, max_ligand), charge(max_ligand)

          character*100 :: line, file_force_field, flig

          character*10  :: atom_type(max_ligand), atom(4), typ, sybyl_type

          logical       :: qqr

790

帖子

2

主题

0

精华

大宗师

F 币
3765 元
贡献
2255 点
发表于 2020-10-14 17:09:54 | 显示全部楼层
模块flexible有问题

1948

帖子

12

主题

5

精华

论坛跑堂

臭石头雪球

F 币
1298 元
贡献
547 点

美女勋章热心勋章星光勋章新人勋章贡献勋章管理勋章帅哥勋章爱心勋章规矩勋章元老勋章水王勋章

发表于 2020-10-14 17:32:56 | 显示全部楼层
报错先看第一个错误提示,后面的先不管。

10

帖子

1

主题

0

精华

入门

F 币
41 元
贡献
24 点
 楼主| 发表于 2020-10-14 18:20:33 | 显示全部楼层
li913 发表于 2020-10-14 17:09
模块flexible有问题

[Fortran] 纯文本查看 复制代码
  41       module flexible
  42
  43         parameter(max_flex=50000,ntrace_max = 1000,ncycle_max=50)
  44
  45         integer ncycle,ntors,noh,nzma_atom
  46
  47         integer,allocatable :: cycle_atom(:,:),label(:)
  48         integer,allocatable :: path(:),torsion(:)
  49         real,allocatable :: coor_zm(:,:),coor_car(:,:)
  50         real,allocatable :: temp_car(:,:)
  51         real,allocatable :: loh(:,:),init_zm(:,:),dis_lig(:,:)
  52         integer trace(ntrace_max),cycle_size(ncycle_max)
  53         integer temp_cycle(ntrace_max)
  54
  55
  56
  57       end module flexible

10

帖子

1

主题

0

精华

入门

F 币
41 元
贡献
24 点
 楼主| 发表于 2020-10-14 18:21:45 | 显示全部楼层
li913 发表于 2020-10-14 17:09
模块flexible有问题

[Fortran] 纯文本查看 复制代码
 11       allocate( cycle_atom(ncycle_max,nlig) )
 12       allocate( torsion(nlig*nlig) )
 13       allocate( loh(nlig,3) )
 14       allocate( path(nlig) )
 15       allocate( label(nlig) )
 16

 33       allocate( coor_zm(max_flex, ntors) )
 34       allocate( coor_car(max_flex, nlig) )
 35       allocate( init_zm(nlig, 8) )
 36       allocate( temp_car(nlig, 3) )
 37       allocate( dis_lig(nlig, nlig) )

10

帖子

1

主题

0

精华

入门

F 币
41 元
贡献
24 点
 楼主| 发表于 2020-10-14 18:22:34 | 显示全部楼层
li913 发表于 2020-10-14 17:09
模块flexible有问题

flexible应该没问题,因为不添加这个子程序,我在其他的主程序里面跑是一点问题都没有的

10

帖子

1

主题

0

精华

入门

F 币
41 元
贡献
24 点
 楼主| 发表于 2020-10-14 18:24:03 | 显示全部楼层
fcode 发表于 2020-10-14 17:32
报错先看第一个错误提示,后面的先不管。

那这个第一个错误:
kreadff.f90(11): error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( * ) , . % + - [ : . ** / // .LT. < .LE. <= .EQ. == .NE. ...
          integer       :: id(4), tot_multiplicity( ff_torsion, ff_torsion ), atom_id(max_ligand)
是什么意思呢

10

帖子

1

主题

0

精华

入门

F 币
41 元
贡献
24 点
 楼主| 发表于 2020-10-14 19:09:55 | 显示全部楼层
谢谢大家了,我打算把自由格式重写成固定格式了。

81

帖子

0

主题

0

精华

专家

F 币
471 元
贡献
232 点

规矩勋章新人勋章元老勋章

QQ
发表于 2020-10-14 22:21:13 | 显示全部楼层
固定格式应该用 *.for 或 *.f 作为扩展名,自由格式应该用 *.f90 作为扩展名。
同一个源代码文件,只能是一种格式。
固定格式和自由格式混合使用,应该使用多个源代码文件。而不能混写在一个源代码文件中(也不能自由格式include固定格式,或固定格式include自由格式)
彼岸,有永恒的守候...
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-3-29 17:07

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表