我可以在fortran模块中声明intent变量吗?

won*_*jun 0 fortran

我可以在fortran模块中声明intent变量吗?我想制作可以称为其他子程序的通用模块

module fmod
real b
integer n, i
integer, dimension(6), intent(inout) :: indata1
real, dimension(7,8), intent(inout) :: indata2
end module fmod

subroutine temp_f(indata1, indata2)
use fmod

do i=1,8
   print *, indata4(i)
end do

end
Run Code Online (Sandbox Code Playgroud)

M. *_* B. 7

不,意图是子程序参数,而不是模块变量.模块变量通常可供"使用"它们的任何实体使用.您可以将它们声明为"私有",这将阻止它们在模块外部的可见性.也许您正在考虑将模块作为包含文件,该文件复制源代码行以进行复制的编译.这不是模块的概念......它是一个独立的源代码实体.

虽然它不在语言标准之内,但许多Fortran编译器支持从第一列开始通过"#include"使用包含文件.有些编译器使用文件类型"F90"(大写).与其他人一样,您必须使用编译器选项来运行C风格的预处理器.这种使用会降低您的代码可移植性的风险很小.