請參考如下
program main_test
real,allocatable :: aaa(:,:,:,:)
real,allocatable :: bbb(:,:,:,:)
integer ii,jj,kk
! ii,jj,kk=.....
allocate ( aaa(ii,jj,kk,3) )
allocate ( bbb(ii,jj,kk,3) )
do i=1,kk
...
aaa(...)=...
bbb(...)=...
..
enddo
call sub_test (aaa,bbb,ii,jj,kk)
stop
end
subroutine sub_test(aaa,bbb,ii,jj,kk)
real :: aaa,bbb
integer :: ii,jj,kk
dimenstion aaa(ii,jj,kk,3)
dimenstion bbb(ii,jj,kk,3)
print*, aaa,bbb
return
end
※ 引述《zx168zx (zx168zx)》之銘言:
: 小弟想請益一下
: 如何將主程式所設定好的矩陣傳入副程式
: 小弟的矩陣是四維的
: 一開始先設定allocatable的四維可變矩陣
: allocatable :: aaa(:,:,:,:)
: allocatable :: bbb(:,:,:,:)
: