efficiency question: type versus array



Hi,

Suppose I want to allocate an array of coordinate values. I could do it in two
different ways. (Let's pretend that all compilers allow allocatable components
of derived types)

Classical method:

real(8), dimension(:,:), allocatable :: coord
allocate(coord(ndim,numpts))

! ndim = Spatial dimension
! numpts = Number of points

Modern method:

type :: point
real(8), dimension(:), allocatable :: x
end type point

type(point), dimension(:), allocatable :: coord

allocate(coord(numpts))
do i = 1,numpts
allocate(coord%x(ndim))
end do

My question is: which one will be more efficient in terms of memory access?

This probably a FAQ, but I couldn't seem to find anything.

Thanks

Ushnish

--
Ushnish Basu ubasu@xxxxxxxxxxxxxxx
+1 510 644-1906 www.ce.berkeley.edu/~ubasu
.