fortran - 将逻辑变量传递给 Fortran 子例程
问题描述
我有以下简单的 Fortran 代码。
program main
implicit none
call flag_test(.TRUE.)
subroutine flag_test(flag)
implicit none
logical,intent(in) :: flag
if(flag) then
print*, "flag is true"
else
print*, "flag is false"
end if
end subroutine flag_test
end program main
我想了解如何在 if 语句中传递逻辑变量。这段代码给出了以下错误:
main.F90:4:1:
subroutine flag_test(flag)
1
Error: Unclassifiable statement at (1)
main.F90:5:15:
implicit none
1
Error: Duplicate IMPLICIT NONE statement at (1)
main.F90:6:28:
logical,intent(in) :: flag
1
Error: Unexpected data declaration statement at (1)
main.F90:12:4:
end subroutine flag_test
1
Error: Expecting END PROGRAM statement at (1)
main.F90:7:9:
if(flag) then
1
Error: Symbol ‘flag’ at (1) has no IMPLICIT type
你能帮我理解我哪里出错了吗?
解决方案
推荐阅读
- macos - 如何让 Docker 在 OSX 上挂载 VM 卷
- batch-file - 如何在不关闭 cmd 窗口的情况下使该脚本在 30 分钟后重复该命令?
- excel - Excel vba for循环
- apache-spark - 如果我们在 case when 语句中使用 udf,火花会如何表现,它是否将 udf 应用于所有记录,然后应用 case 过滤器?
- c# - 使用表达式函数返回值
- xamarin - 如何在 Xamarin Forms 中使用嵌入资源字体文件中的图标
- javascript - Javascript / CSS 砌体 - 尊重列
- mysql - 如何将查询集限制为 MySQL 中的 ID 子集?
- apache-storm - Apache Storm 2.1.0 内存相关配置
- django - Django MaterializeCSS - 工作,但不确定设置 css 和 js 的正确方法?