Paste from array pointer at 2021-12-06 17:15:31I want to paste
module test
implicit none
type array_pointer
real,pointer::ptr(:)
contains
procedure,pass::init
end type array_pointer
contains
subroutine init(this,x)
class(array_pointer),intent(inout)::this
real,contiguous,target::x(:,:)
this%ptr(1:size(x))=>x
end subroutine init
end module
program main
use test
implicit none
real,target::a(3,3)
real::b(3,3)
type(array_pointer)::x(2)
a=1.0
b=2.0
!方法1
x(1)%ptr(1:9)=>a!行
!x(1)%ptr=>a !不行
!x(1)%ptr(:)=>a !不行
!方法2
call x(2)%init(b)
write(*,*)x(1)%ptr
write(*,*)x(2)%ptr
end program