
CD-Section: Miscellaneous Routines
C This section describes some routines which are basically for internal use
C but may also be called by the user if desired.
CD-end

C LAST UPDATE:
C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C*************************
C**       LRL_HCF       **
C*************************
C
CD-Routine: Highest Common Factor of Two Numbers - LRL_HCF
C This routine, based on code by I.J. Clifton, returns the highest common
C factor of two integers.
CD-end
CD-Fortran:
      INTEGER FUNCTION  LRL_HCF (II,JJ)
CD-end
      INCLUDE 'implicit_none.finc'
C
C Purpose: To calculate h.c.f. of 2 integers
C
C Author:  Based on code from GENLAUE by Clifton et al.
C
C Arguments:
C
      INTEGER    II
      INTEGER    JJ
CD-Parameters: 
C II    i (R)   First integer
C JJ    i (R)   Second integer
C
C       Returns the highest common factor of the two integers
C
CD-end
C
C====== LOCALS:
C
      INTEGER    I, J, ISAV, K
C
C------------------------------------------------------------------------------
C
      I = II
      J = JJ
      IF (I.EQ.J) THEN
         LRL_HCF = I
         RETURN
      END IF

      IF (I.LT.J) THEN
         ISAV = I
         I = J
         J = ISAV
      END IF

      IF (J.EQ.0) THEN
         LRL_HCF = I
         RETURN
      END IF

 20   K = MOD(I,J)

      IF (K.EQ.0) THEN
         LRL_HCF = J
         RETURN
      END IF

      I = J
      J = K
      GO TO 20

      END
