      SUBROUTINE ENDOCLOCK

C Routine to calculate the Endogenous clock factor
C for modification of the germination rate calculated in
C cellflux.f.  Variables are as follows: 
C
C YEARDAY = day of year 1/1 00:00 is yearday 0 (set in BCOND(7))
C GPN = normalized monthly germination potential, set in BIODAT
C DAYMM = the mid-month yearday for interpolation, also in BIODAT
C FAC = interpolation factor
C EC = the endogenous clock factor
C ENDOSCALE = value passed to cellflux.f     
C
C Program simply interpolates between monthly estimates of the
C germination potential.  Special cases are needed at the 
C beginning and end of each year.

      INCLUDE 'comdeck'
      INCLUDE 'dino.inc'

      REAL EC, FAC

      IF (YEARDAY.LT.DAYMM(1)) THEN
        FAC = ((365-DAYMM(12))+YEARDAY)/((365-DAYMM(12))+DAYMM(1))
        EC = GPN(12) + FAC*(GPN(1) - GPN(12))
      ELSE IF (YEARDAY.GE.DAYMM(12)) THEN
        FAC = (YEARDAY - DAYMM(12))/((365-DAYMM(12))+DAYMM(1))
        EC = GPN(12) + FAC*(GPN(1) - GPN(12))
      ELSE 
        DO 101 I = 1,11
          IF ((YEARDAY.GE.DAYMM(I)).AND.(YEARDAY.LT.DAYMM(I+1))) THEN
            FAC = (YEARDAY - DAYMM(I))/(DAYMM(I+1) - DAYMM(I))
            EC = GPN(I) + FAC*(GPN(I+1) - GPN(I))
          END IF
 101    CONTINUE
      END IF

      ENDOSCALE = EC
      END
