      INTEGER *4 FUNCTION DOY( IDAY, IMON, IYEAR )
C
C     Returns Day of Year for date in arguements ( 1 Jan => doy=1 )
      IMPLICIT UNDEFINED(A-Z)
      SAVE
      INTEGER *4 IDAY, IMON, IYEAR, LEAP, I, NDAY(12,0:1)
      DATA NDAY / 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30,
     $            0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 /
C        LEAP=0 for leap lear
      LEAP = MIN( 1, MOD( IYEAR, 4 ) )
      DOY = IDAY
      DO 100 I = 1, IMON
          DOY = DOY + NDAY(I, LEAP)
  100 CONTINUE
      RETURN
      END
