我需要从 Fortran 程序中的文件中读取大量数据。数据的大小是可变的,所以我想动态分配数组。我的想法是创建一个读取所有数据并分配内存的子程序。该程序的简化版本是:
program main
implicit none
real*8, dimension(:,:), allocatable :: v
integer*4 n
!This subroutine will read all the data and allocate the memory
call Memory(v,n)
!From here the program will have other subroutines to make calculations
end
subroutine Memory(v,n)
implicit none
real*8, dimension(:,:), allocatable :: v
integer*4 n,i
n=5
allocate(v(n,2))
do i=1,n
v(i,1)=1.0
v(i,2)=2.0
enddo
return
end subroutine Memory
该程序给了我以下错误:
Error: Dummy argument 'v' of procedure 'memory' at (1) has an attribute that requieres an explicit interface for this procedure
这是构建此类程序的正确方法吗?如果是这样,我该如何解决错误?
谢谢。