【发布时间】:2019-10-03 18:41:38
【问题描述】:
给定一个运行良好的简单程序,例如:
program test
implicit none
real, allocatable :: x(:)
real :: su, si
allocate(x(3))
x(:) = (/1,2,3/)
su=sum(x(:))
si=size(x(:))
end program
我尝试将其转换为带有子程序的外部模块:
module test
implicit none
real, allocatable, intent(in) :: x(:)
real, intent(out) :: su, si
contains
subroutine sumsize(x(:),su,si)
su=sum(x(:))
si=size(x(:))
end subroutine
end module
但是,我无法使用几个错误消息来编译它,我相信这些错误消息大部分是基于 x(:)、su 和 si 都不是 DUMMY 变量。
假人在哪里以及如何定义?这似乎是一个简单的形式错误。
另一个错误状态是子程序头中的垃圾,并在使用subroutine sumsize(x,su,si) 定义它时消失。为什么子程序的输入不能是向量?
通过gfortran -ffree-form -c module_test.f -o test.o 使用gfortran - gcc v. 8.3.0-6 (Debian) 编译。
【问题讨论】:
标签: module compilation fortran subroutine