next up previous contents
Next: Solution Up: Extrinsics and HPF Library Previous: Solution

 

Golf - HPF Intrinsics - curtosy of Edinburgh Parallel Computing Centre.

The purpose of this exercise is to analyse the following golf score card, using HPF Library functions.

At each hole there is an ``expected'' score, say, 3 or 4 shots which is called par. A good golfer should be able to get the ball in the hole in that number of shots.

Par    4  4  4  4  4  4  3  4  4  4  3  4  3  5  3  4  5  4
Score  5  3  4  4  4  2  3  5  6  2  5  4  3  4  4  4  7  3

The exercise consists of a number of parts -- use a different array to store the answers from each part.

  1. add distribution and alignment directives
  2. Find the running total scores of the golfer for the round.
  3. Find the running total scores for the first and second nine holes.
  4. Find the running totals for Par 3, 4 and 5 holes separately. Use three separate arrays. For each example only set the running total at the holes concerned, set other positions to zero.
  5. Enumerate the holes on which the player scored a birdie (one less than par). In other words, at the first birdied hole set to 1, then 2 for the second birdied hole and so on. The holes on which birdies were not scored should have value 0.

Use the following program skeleton (which is available by clicking here) to base your answer on.

PROGRAM golf

! Include HPF library
!
      USE hpf_library
      IMPLICIT NONE
      INTEGER, PARAMETER :: nhole=18
! Declare arrays
!
      INTEGER, DIMENSION(nhole) :: score = &
         (/5,3,4,4,4,2,3,5,6,2,5,4,3,4,4,4,7,3/)
      INTEGER, DIMENSION(nhole) :: par =   &
         (/4,4,4,4,4,4,3,4,4,4,3,4,3,5,3,4,5,4/)
      INTEGER, DIMENSION(nhole) :: rtot,rsplit,
     &                             rtot3,rtot4,rtot5,birdie
      LOGICAL, DIMENSION(nhole) :: smask,mask
      INTEGER i

! Distribute and align arrays
!
!.... 1) add directives

! Initializations
!
!.... 2) Find running total
!
!.... 3) Find running total per 9 holes
!
!.... 4) Find running total for par 3, 4 and 5 holes
!
!.... 5) Enumerate holes where a birdie was scored
!
        WRITE(*,10) par, score, rtot, rsplit,
     &             rtot3, rtot4, rtot5, birdie
 10   FORMAT(//
     & tr15,' Golf statistics using Scan routines'/
     & tr1,65(`-')/
     & `     par: `,18I3/
     & `   score: `,18I3//
     & `    rtot: `,18I3/
     & `   rtot3: `,18I3/
     & `   rtot4: `,18I3/
     & `   rtot5: `,18I3/
     & `  birdie: `,18I3/)
      END

Ignore the warnings about score and par:

PGHPF-W-0311-Non-replicated mapping for data-initialized array, score,
ignored (golf.hpf: 80)
PGHPF-W-0311-Non-replicated mapping for data-initialized array, par,
ignored (golf.hpf: 80)
  0 inform,   2 warnings,   0 severes, 0 fatal for golf

these are compiler restrictions.




next up previous contents
Next: Solution Up: Extrinsics and HPF Library Previous: Solution

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 14:10:26 GMT 1996