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
Module 是";“意图”;是否保证在包含子例程的模块内包含子例程?_Module_Fortran_Contains_Subroutine - Fatal编程技术网

Module 是";“意图”;是否保证在包含子例程的模块内包含子例程?

Module 是";“意图”;是否保证在包含子例程的模块内包含子例程?,module,fortran,contains,subroutine,Module,Fortran,Contains,Subroutine,我想知道以下代码是否合法: module my_mod contains subroutine my_outer_sub(a) integer, intent(in) :: a call my_inner_sub() contains subroutine my_inner_sub() a=3 ! this compiles and runs! end subroutine my_inner_sub end subroutine m

我想知道以下代码是否合法:

module my_mod

contains

  subroutine my_outer_sub(a)
    integer, intent(in) :: a
    call my_inner_sub()
  contains

    subroutine my_inner_sub()
      a=3 ! this compiles and runs!
    end subroutine my_inner_sub

  end subroutine my_outer_sub

end module my_mod

我用PGI17.4编译了代码。我一直在模块子例程中使用包含的子例程,现在我想知道这个方案是否合适?

不,代码是非法的。您不能修改
意图(in)
参数。这是编译器中的错误,应向您的供应商报告

Gfortran正确地识别了它

Error: Dummy argument 'a' with INTENT(IN) in variable definition context (assignment) at (1)
英特尔Fortran也是如此

intent3.f90(11): error #6780: A dummy argument with the INTENT(IN) attribute shall not be defined nor become undefined.   [A]
      a=3 ! this compiles and runs!
------^
compilation aborted for intent3.f90 (code 1)

谢谢我修改了这个问题,我的意思是如果编译中没有错误。