next up previous contents
Next: Extrinsic Example Continued Up: Extrinsics Previous: Extrinsic Example Continued

 

Extrinsic Example Continued

An F77_LOCAL EXTRINSIC:

 SUBROUTINE Calc_u_like(My_P_No,Siz,Tot_Proc,a,b,c)
  INTEGER A(*), B(*), C(*), My_P_No(1), Siz, Tot_Proc
C Find blocksize
  Blk_Siz    = NINT((DBLE(Siz)/DBLE(Tot_Proc))+0.5D0)
C How many elements have I got
  My_Blk_Siz = MIN(Blk_Siz,Siz-(My_P_No(1)-1)*Blk_Siz)
  My_Blk_Siz = MAX(My_Blk_Siz,0)
C Do the Calculation
  DO 100 i = 1,My_Blk_Siz
   a(i) = b(i) + c(i)
  END DO
 END

and in the calling program unit:

  REAL, DIMENSION(Siz) :: A, B = 0, C = 0
  INTEGER, DIMENSION(NUMBER_OF_PROCESSORS()) :: P_Nos
  !HPF$ PROCESSORS, &
  !HPF$  DIMENSION(NUMBER_OF_PROCESSORS()) :: P
  !HPF$ DISTRIBUTE (BLOCK) ONTO P :: A, B, C, P_Nos
    ... Interface from before goes here
  NOP   = NUMBER_OF_PROCESSORS()
  P_Nos = (/ (i, i=1,NOP) /)
  CALL Calc_u_like(P_Nos,SIZE(A),NOP,A,B,C)
 END

Now try this question gif


next up previous contents
Next: Extrinsic Example Continued Up: Extrinsics Previous: Extrinsic Example Continued

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.