      INTEGER FUNCTION JULHR(ITIME)
      IMPLICIT NONE
C
C********************************************************************
C
C   NAME- JULHR
C
C   LANGUAGE- VS FORTRAN  TYPE- FUNCTION        COMPUTER- CRAY J916
C
C   VERSION- 1.0    DATE- 01/19/95   PROGRAMMER- LEAH WILSON (HSTX)
C   VERSION- 3.0    DATE- 06/19/97   PROGRAMMER- LEAH WILSON (HSTX)
C
C   FUNCTION- THIS FUNCTION CONVERTS A TIME, GIVEN AN ARRAY OF
C             YEAR/MONTH, DAY/HOUR, MINUTE/SECOND, INTO JULIAN HOUR.
C   VERSION- 3.0 MODIFICATIONS FOR INCLUSION INTO ATOVS.
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE      TYPE    I/O       DEFINITION
C     ---------     ----    ---       ----------
C     ITIME          INT     I        ARRAY, DIM 3, OF YEAR/MONTH,
C                                     DAY/HOUR, MINUTE/SECOND.
C
C   LOCAL PARAMTERS-
C     VARIABLE      TYPE      DESCRIPTION
C     --------      ----      -----------
C     IDAY          INT       DAY.
C     IHOUR         INT       HOUR.
C     IYEAR         INT       YEAR.
C     JDAY          INT       JULIAN DAY.
C     MINS          INT       MINUTE.
C     MONTH         INT       MONTH.
C     NUMDAY        INT       ARRAY (DIM 12) CONTAINING NUMBER OF DAYS
C                             PER MONTH IN A NON-LEAP YEAR.  SUBROUTINE
C                             JULIUS WILL HANDLE LEAP YEARS.
C
C   SUBROUTINES USED- JULIUS
C
C   FUNCTIONS USED- NONE
C
C   COMMON USED- NONE
C
C********************************************************************
      INTEGER IYEAR, MONTH, IDAY, IHOUR, MINS, JDAY
      INTEGER ITIME(3), NUMDAY(12)
      DATA NUMDAY / 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /
C
C     UNSCALE INPUT TIME INTO SEPARATE YEAR, MONTH, DAY, HOUR, MINUTE
C     COMPONENTS.
C
      IYEAR = INT(ITIME(1)/100)
      MONTH = MOD(ITIME(1),100)
      IDAY = INT(ITIME(2)/100)
      IHOUR = MOD(ITIME(2),100)
      MINS = INT(ITIME(3)/100)
      IF (MONTH.LT.1.OR.MONTH.GT.12) THEN
         print *,' In JULHR, invalid month: ',MONTH,
     +             'for ITIME ',ITIME(1),ITIME(2),ITIME(3)
         JULHR = 0
         RETURN
      END IF

C
C     ROUND TO THE NEXT HOUR IF AFTER HALF-PAST THE HOUR
C
      IF(MINS.GT.30) IHOUR = IHOUR + 1
C
C     CONVERT 24Z TO 0Z OF THE NEXT DAY
C
      IF(IHOUR.EQ.24) THEN
         IHOUR = 0
         IDAY = IDAY + 1
      ENDIF
C
C     ADJUST MONTH (EXCEPT FOR FEBRUARY) JUST IN CASE THE DAY OF THE
C     MONTH EXCEEDS THE TOTAL NUMBER OF DAYS ACTUALLY IN THAT MONTH.
C
      IF(MONTH.NE.2.AND.IDAY.GT.NUMDAY(MONTH)) THEN
         IDAY = 1
         MONTH = MONTH + 1
      ENDIF
C
C     ADJUST FOR ANY PREVIOUS ADJUSTMENTS THAT MADE IT A NEW YEAR
C
      IF(MONTH.GT.12) THEN
         MONTH = 1
         IYEAR = IYEAR + 1
      ENDIF
C
C     CONVERT TO JULIAN DAY
C
      CALL JULIUS(MONTH, IDAY, IYEAR, JDAY)
C
C     CONVERT TO JULIAN HOUR
C
      JULHR = (JDAY - 1) * 24 + IHOUR
      RETURN
      END
