ahafigure 发表于 2020-10-14 16:01:29

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

各位,我现在遇到一个问题,我的主程序是for格式的(不是我写的),但是现在需要增加一个功能,我是用自由格式的f90写的:
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          = -1.0
----------^
kreadff.f90(106): error #6410: This name has not been declared as an array or a function.   
                  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 = 0
----------^
kreadff.f90(127): error #6404: This name does not have a type, and must have an explicit type.   
          num_bond = 0
----------^
kreadff.f90(190): error #6404: This name does not have a type, and must have an explicit type.   
          atom_id = 0
----------^
kreadff.f90(194): error #6404: This name does not have a type, and must have an explicit 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.   
            sybyl_type = atom_type(i)
---------------------------^
kreadff.f90(207): error #6404: This name does not have a type, and must have an explicit type.   
                              id2 = 1
------------------------------^
kreadff.f90(217): error #6410: This name has not been declared as an array or a function.   
                      atom_id(i) = id2
----------------------^
kreadff.f90(224): error #6410: This name has not been declared as an array or a function.   
                  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   
          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   
          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.   
          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.   
          integer       :: id(4), tot_multiplicity( ff_torsion, ff_torsion ), atom_id(max_ligand)
----------------------------------------------------------------^
compilation aborted for CovaDock.for (code 1)


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

ahafigure 发表于 2020-10-14 16:34:39

   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

li913 发表于 2020-10-14 17:09:54

模块flexible有问题

fcode 发表于 2020-10-14 17:32:56

报错先看第一个错误提示,后面的先不管。

ahafigure 发表于 2020-10-14 18:20:33

li913 发表于 2020-10-14 17:09
模块flexible有问题

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

ahafigure 发表于 2020-10-14 18:21:45

li913 发表于 2020-10-14 17:09
模块flexible有问题

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) )

ahafigure 发表于 2020-10-14 18:22:34

li913 发表于 2020-10-14 17:09
模块flexible有问题

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

ahafigure 发表于 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)
是什么意思呢

ahafigure 发表于 2020-10-14 19:09:55

谢谢大家了,我打算把自由格式重写成固定格式了。

青衣巷 发表于 2020-10-14 22:21:13

固定格式应该用 *.for 或 *.f 作为扩展名,自由格式应该用 *.f90 作为扩展名。
同一个源代码文件,只能是一种格式。
固定格式和自由格式混合使用,应该使用多个源代码文件。而不能混写在一个源代码文件中(也不能自由格式include固定格式,或固定格式include自由格式)
页: [1]
查看完整版本: 固定格式(.for)怎么调用自由格式(.f90)的子程序