Fortran程序属性冲突

时间:2016-04-07 21:47:51

标签: gcc compiler-errors fortran gfortran

我不确定为什么编译器抱怨"过程属性与意图属性冲突"因为我指定了所有参数的意图。这似乎是我写的几乎所有其他例程。这是第一个模块:

  module char_mod
  implicit none
  private
  public :: char,init
  interface init;      module procedure init_char;        end interface
  interface init;      module procedure init_copy;        end interface
  type char
    character(len=1) :: c
  end type
  contains
  subroutine init_char(CH,c)
    implicit none
    type(char),intent(inout) :: CH
    character(len=1),intent(in) :: c
    CH%c = c
  end subroutine
  subroutine init_copy(a,b)
    implicit none
    type(char),intent(inout) :: a
    type(char),intent(in) :: b
    a%c = b%c
  end subroutine
  end module

编译好。但我还有第二个基于此的模块:

  module varStr_mod
  use char_mod
  implicit none
  private
  public :: varStr,init
  interface init;      module procedure init_size;        end interface
  interface init;      module procedure init_string;      end interface
  type varStr
    type(char),dimension(:),allocatable :: s ! string
    integer :: n                             ! string length
  end type
  contains
  subroutine init_size(VS,n)
    implicit none
    type(varStr),intent(inout) :: VS
    integer,intent(in) :: n
    if (n.lt.1) stop 'Error: string must be of size > 1 in varStr.f90'
    if (allocated(VS%s)) deallocate(VS%s)
    allocate(VS%s(n))
    VS%n = n
  end subroutine
  subroutine init_string(VS,s)
    implicit none
    type(varStr),intent(inout) :: VS
    character(len=*),intent(in) :: s
    integer :: i,n
    n = len(s)
    call init(VS,n)
    do i=1,n
      call init(VS%s(i),s(i))
    enddo
  end subroutine
  end module

我收到的编译错误是:

 subroutine init_string(VS,s)
                           1
 PROCEDURE attribute conflicts with INTENT attribute in 's' at (1)

非常感谢任何帮助。

0 个答案:

没有答案