作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用 PRESENT
时遇到问题Fortran 95 的声明。目前我正在使用 Silverfrost 的 Plato 和他们的 FTN95 编译器(在“Release Win32”模式下)。我想做的是创建一个子程序SUB(a,b)
,其中 b
是一个可选变量。到目前为止一切顺利,但是当我尝试为 b
赋予新值时出现问题与 if (.NOT. present(b)) b=0
.这是代码:
module MOD
contains
subroutine SUB(a,b)
implicit none
integer :: a
integer,optional :: b
if (.NOT. present(b)) b=0
print*, a,b
end subroutine SUB
end module MOD
program TEST
use MOD
implicit none
integer :: i=2, j=1
call SUB(i,j)
call SUB(i)
call SUB(j)
end program TEST
b_aux
例如,然后使用以下代码?:
if (present(b)) then
b_aux=b
else
b_aux=0
endif
最佳答案
您不能使用不存在的变量,因此需要诸如辅助局部变量之类的方法。
关于module - 如果可选参数不存在,我们可以避免创建局部变量吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18302083/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!