I want to store a small array (patch) of data (usually 10x7) for each point
in a larger array (typically 300x500) and be able to access any of these
smaller patches quickly.
I currently have something like below. When I do some profiling, the
xpatch=opatch(i,j)%x statement always comes up as a hot spot. I'd like
to keep everything as pointers or allocatable arrays if possible so I don't
have to recompile my code if I change the size of any of the array dimensions.
Am I doing something really stupid that makes the code much slower than
it has to be, or is this a reasonable way of proceeding? I'm running
on SGI Origins and using v7.2 and 7.3 of SGI's F90 compilers.
Thanks,
Catherine
--
------------------------------------------------------------------
Catherine Moroney ph: (520) 626-5123
Institute of Atmospheric Physics fax: (520) 621-6833
University of Arizona [log in to unmask]
P.O. Box 210081, Room 542
(1118 East 4th Street)
Tucson, AZ 85721-0081
> INTEGER :: NLINE,NSMP,NLINEP,NSMPP
>
> TYPE M23_PATCH
> SEQUENCE
> REAL*4, DIMENSION(:,:),POINTER :: X
> LOGICAL :: FLAG_CALC
> LOGICAL :: FLAG_GOOD
> END TYPE M23_PATCH
>
> TYPE (M23_PATCH), DIMENSION(:,:), ALLOCATABLE :: OPATCH
> REAL, DIMENSION(:,:), ALLOCATABLE :: XPATCH
>
> ! allocate memory
>
> allocate(opatch(nsmp,nline))
> allocate(xpatch(nsmpp,nlinep))
> do iline=1,nline
> do ismp=1,nsmp
> allocate(opatch(ismp,iline)%x(nsmpp,nlinep))
> end do
> end do
>
> ! begin my big loop
>
> do iline=1,nline
> do ismp=1,nsmp
>
> <<< misc calculations >>>
>
> xpatch(:,:)=opatch(ismp,iline)%x ! this statement is expensive
>
> <<< misc calculations >>>
>
> end do
> end do
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|