小编use*_*099的帖子

Fortran 是否在编译时解析可选参数并显示语句?

在没有任何结果的搜索之后,我想问你一个关于包含可选参数的子例程以及编译器如何处理它们(运行时/编译时)的问题。考虑以下示例程序。

  module CONTAINS_ABC

  contains

  subroutine ABC( a, b, c)

  implicit none

  real, intent(in)           :: a
  real, intent(in), optional :: b, c

  if( present(b) )then ! PATH_B
     write(*,*) 'Provide c'
  else if( present(c) )then "! PATH_C
     write(*,*) 'Provide b'
  end if

  ! Do all the computations with a, b and c 

  end subroutine ABC

  end module CONTAINS_ABC


  program CALL_ABC

  use CONTAINS_ABC

  real :: aa, bb, cc


  call ABC( a = aa, b=bb )

  call ABC( a = aa, c=cc )


  end …
Run Code Online (Sandbox Code Playgroud)

fortran runtime compile-time optional fortran90

4
推荐指数
1
解决办法
386
查看次数

标签 统计

compile-time ×1

fortran ×1

fortran90 ×1

optional ×1

runtime ×1