next up previous contents
Next: 9 Algorithmic issue to Up: Functions of thisnode Previous: Functions of thisnode

8 Algorithm

  The following algorithm implements (in Fortran) functions of thisnode.

      subroutine subtestme
      implicit none
      integer x, y
      integer p
      integer nproc0,nproc
      integer tag, uppertag, lowertag
      integer pf_GetTag
      integer m,n,f
      f(m,n) = MOD((m-1)+n,n)
c f(me) is the statement function above.
 
      nproc = numnode
      nproc0 = numnode-1
 
   
c some value to communicate
      y = 100 + me
 
c The following implements
c      x@me = y@f(me)
c hardwired for a 4-byte integer.
c
      uppertag = pf_GetTag(2*nproc+1,lowertag)
      do p = 0, nproc0
         if (f(p,nproc).EQ.p .AND. p.EQ.me) then
            x = y
         else if (f(p,nproc).EQ.me) then
            call pf_setTag(tag+me)
            call pf_snd(p,y,4) 
         endif
      enddo
 
      if (f(me,nproc).NE.me) then
        call pf_setTag(tag+f(me,nproc))
        call pf_rcv(x,4)
      endif
 
      print*,'process= ',me,' x=',x
     
      RETURN
      END


next up previous contents
Next: 9 Algorithmic issue to Up: Functions of thisnode Previous: Functions of thisnode

Terry Clark
8/2/1998