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
これは、この種のプログラムを構造化する正しい方法ですか? もしそうなら、どうすればエラーを解決できますか?
ありがとう。