efficiency question: type versus array
- From: Ushnish Basu <ubasu@xxxxxxxxxxxxxxx>
- Date: Wed, 15 Jun 2005 11:09:33 -0700
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
.
- Follow-Ups:
- Re: efficiency question: type versus array
- From: Greg Lindahl
- Re: efficiency question: type versus array
- From: Richard E Maine
- Re: efficiency question: type versus array
- Prev by Date: Re: problem with ifort intel fortran compiler
- Next by Date: Re: problem with ifort intel fortran compiler
- Previous by thread: problem with ifort intel fortran compiler
- Next by thread: Re: efficiency question: type versus array
- Index(es):
Relevant Pages
|