将逻辑变量传递给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

能否请您帮助我了解我要去哪里错了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)