1
我要創建哪些鏈接到另一個一維數組指針的二維數組:有沒有辦法讓指針數組切片?
module class_GridUnit;use iso_fortran_env
implicit none
type,public :: CGridUnit
integer(int8)::index
endtype CGridUnit
type,public :: CGridLink
type(CGridUnit),pointer::L
endtype CGridLink
type(CGridUnit),target,allocatable,dimension(:)::gDATA
type(CGridLink),allocatable,dimension(:,:)::gLink
endmodule class_GridUnit
program tt
use class_GridUnit
integer::ix1=5,iy1=5,i1=20
integer(int8),dimension(2,2)::c=0
allocate (gLink(ix1,iy1))
forall(ix=1:ix1,iy=1:iy1)
gLink(ix,iy)%L=>null()
endforall
allocate (gDATA(20))
i0=0; do ix=1,ix1; do iy=1,iy1 ; i0=i0+1
if(i0<=20)then
gLink(ix,iy)%L=>gDATA(i0)
gLink(ix,iy)%L%index=i0
endif
enddo; enddo
forall(ix=1:2,iy=1:2) c(ix,iy)=gLink(ix,iy)%L%index
print *, c
end
FORALL工作正常,但是當我試圖使切片我得到:
c(1:2,1:2)=gLink(1:2,1:2)%L%index
1
Error: Component to the right of a part reference with nonzero rank must not have the POINTER attribute at (1)
所以,我的問題 - 有沒有辦法做到這一點?