Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!ncar!bierstat.scd.ucar.edu!morreale From: morreale@bierstadt.scd.ucar.edu (Peter Morreale) Newsgroups: comp.lang.fortran Subject: Re: vectorization question Message-ID: <10836@ncar.ucar.edu> Date: 29 Mar 91 19:32:47 GMT References: <1991Mar29.141313.7418@ariel.unm.edu> Sender: news@ncar.ucar.edu Reply-To: morreale@bierstadt.scd.ucar.edu (Peter Morreale) Organization: Scientific Computing Division / NCAR, Boulder Co. Lines: 44 In article <1991Mar29.141313.7418@ariel.unm.edu>, prentice@triton.unm.edu (John Prentice) writes: > Consider the following loop: > > do 30 k=1,kmax > do 20 j=1,jmax > do 10 i=1,imax > a(i,j,k)=... > 10 continue > 20 continue > 30 continue > > On the Cray, only the inner most loop will vectorize. Does anyone > have a suggestion for how to collapse this loop while still using > the three dimensional array? In other words, I need a vectorized > equivalent to: > Whether or not you can collaspe the loop structure depends entirely on whether i, j, or k is used on the right hand side of the assignment. If the loop indices are not used, you could collaspe the loop as follows: DO 30 K = 1, IMAX*JMAX*KMAX A(K,1,1) = 30 CONTINUE In any event, the Cray Fortran preprocessor (fpp) can help significantly in determining whether or not the loop can collaspe. (since it *will* collaspe the loop if it can) You can still trick fpp, but it's a terrific start. I'd suggest you run the routine through fpp and see what it produces; % fpp sub.f > sub.fpp -PWM ------------------------------------------------------------------ Peter W. Morreale email: morreale@ncar.ucar.edu Nat'l Center for Atmos Research voice: (303) 497-1293 Scientific Computing Division Consulting Office ------------------------------------------------------------------