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.
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.