【问题标题】:Declaring variables in in Fortran在 Fortran 中声明变量
【发布时间】:2014-03-05 11:39:18
【问题描述】:

为什么这段代码不起作用,还有什么替代方法?

module find_integers_module  
  implicit none
  contains  
  integer function function1(r) result(rnext)   
    implicit none   
    integer,intent(in) :: r     
    integer :: k = r    
    rnext = -1          
  end function function1     
end module

【问题讨论】:

    标签: fortran fortran95


    【解决方案1】:

    Fortran 标准要求integer :: k = r 中初始化的rhsconstant-expression;您可能会考虑将其视为在编译时可计算,尽管标准并非如此。

    解决方法很简单:

    integer :: k
    k = r
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-10
      • 2013-03-24
      • 2011-12-18
      相关资源
      最近更新 更多