Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Module 在Fortran 90中使用模块内部子程序_Module_Fortran_Subroutine_Intel Fortran - Fatal编程技术网

Module 在Fortran 90中使用模块内部子程序

Module 在Fortran 90中使用模块内部子程序,module,fortran,subroutine,intel-fortran,Module,Fortran,Subroutine,Intel Fortran,我有一个关于在Fortran 90中的模块内使用子程序的问题。这是我的密码 Module Multiplication Subroutine Two_times(input,output) Real :: input,output output = input * 2.0 End Subroutine Two_times End Module Program test_get_command_argu

我有一个关于在Fortran 90中的模块内使用子程序的问题。这是我的密码

    Module Multiplication
      Subroutine Two_times(input,output)
        Real :: input,output  
        output = input * 2.0  
      End Subroutine Two_times
    End Module    
    Program test_get_command_argument
      Use Multiplication: Two_times

      Real :: i,j

      i = 0.5
      Write (*,*) i

      Call  Two_times(i,j)
      Write (*,*) j

    End Program

我使用ifort编译上述代码。我收到了以下消息


    files_rev.f90(2): error #6218: This statement is positioned incorrectly and/or has syntax errors.
      Subroutine Two_times(input,output)
    --^
    files_rev.f90(4): error #6274: This statement must not appear in the specification part of a module.
        output = input * 2.0  
    ----^
    files_rev.f90(5): error #6786: This is an invalid statement; an END [MODULE] statement is required.
      End Subroutine Two_times
    --^
    files_rev.f90(5): error #6785: This name does not match the unit name.   [TWO_TIMES]
      End Subroutine Two_times
    -----------------^
    files_rev.f90(6): error #6790: This is an invalid statement; an END [PROGRAM]  statement is required.
    End Module 
    ^
    files_rev.f90(9): error #5082: Syntax error, found IDENTIFIER 'MULTIPLICATION' when expecting one of: ( : % [ . = =>
      Use Multiplication: Two_times
    ------^
    files_rev.f90(8): warning #5427: Program may contain only one main entry routine
    Program test_get_command_argument
    --------^
    compilation aborted for files_rev.f90 (code 1)


为什么我会收到#6218和#6274错误消息以及如何修复它们?

子例程
声明之前缺少一个
包含
关键字,在
使用
之后缺少一个
关键字。或者您可以删除
:两次
,以使用模块中的所有内容。因此,工作代码如下所示:

Module Multiplication
  Contains
  Subroutine Two_times(input,output)
    Real :: input,output  
    output = input * 2.0  
  End Subroutine Two_times
End Module 

Program test_get_command_argument
  Use Multiplication, Only: Two_times
  Real :: i,j

  i = 0.5
  Write (*,*) i

  Call Two_times(i,j)
  Write (*,*) j

End Program

请看一下这个答案,因为缺少
包含

谢谢。几分钟前我发现我错过了“包含”