Re: derived data type extension



On May 2, 5:49 pm, rudra <bnrj.ru...@xxxxxxxxx> wrote:
  type(point), dimension(100000) :: coordinate

  type, extends(point)::latspn
   real(rdp),dimension(1,3)::spin
   end type latspn

type(latspn),dimension(100000)::corspn

So, is
there any better way to initialize the extended data type corspn from
its parent coordinate?

How about:

corspn(:)%point = coordinate
corspn(:)%spin = 1


Extended derived types have a component with the name of the parent
derived-type name. Thus for:

type t
integer :: x
end type t
type, extends(t) :: t2
end type t2
type, extends(t) :: t3
end type t3
type(t3) :: a

one can access the "x" using: a%x, a%t2%x and a%t2%t%x.

Tobias
.