Xref: utzoo comp.lang.fortran:4406 comp.parallel:2011 Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!know!sdd.hp.com!wuarchive!emory!hubcap!booker%network From: booker%network@ucsd.edu (Booker bense) Newsgroups: comp.lang.fortran,comp.parallel Subject: Re: Parallel Fortran question Message-ID: <12251@hubcap.clemson.edu> Date: 13 Dec 90 21:02:20 GMT Sender: fpst@hubcap.clemson.edu Followup-To: comp.lang.fortran Organization: San Diego Supercomputer Center @ UCSD Lines: 76 Approved: parallel@hubcap.clemson.edu In article <12191@hubcap.clemson.edu> john%ghostwheel.unm.edu@ariel.unm.edu (John Prentice) writes: >I want to code the following for a shared memory parallel system: > > program yuppie >c >c loop over subroutine >c > integer n,nmax > parameter (nmax=10) > real hippie(nmax) > do 10 n=1,nmax > call yippie (hippie(n)) > . > call yippie (hippie(n)) > . > 10 continue > end > subroutine yippie (hippie) > real hippie > logical first > save first > data first /.true./ >c > if (first) then > . > [initializations] > . > first=.false. > endif > . > end > >When yippie gets called the first time, it does some initializations. >Subsequent calls for the same loop iteration should not repeat the >initialization however (assume I am parallelizing the loop in the main >routine). The way I wrote yippie works fine on a non-shared memory >machine, but not on a shared memory system. This is because the save >statement causes yippie to always save first to the same memory location, >no matter which processor is being used. On the Cray, you could use task >common to save the value of first, but there is no way to initialize task >common (that I know of). Any suggestions? Thanks. > - A better way to do this for a shared memory machine is to put first into the arguements for the subroutine. i.e. do 10 n=1,nmax first = .true. call yippie (hippie(n),first) first = .false. . . . call yippie (hippie(n),first) . . . 10 continue And make first a local ( or non-shared or private ) variable. If you are using the CRI autotasking directives, something like CMIC$ DO ALL SHARED( hippie ) PRIVATE(first,n) I'm assuming that you need first = true for each n ,i.e. first means first call in the do loop. I quess you said this didn't you. -Booker C. Bense /* benseb@grumpy.sdsc.edu */