SUBROUTINE CG_DATM ( iret )
C************************************************************************
C* CG_DATM                                                              *
C*                                                                      *
C* This subroutine sets the report date/time using system and bulletin  *
C* header as input.                                                     *
C*                                                                      *
C* CG_DATM ( IRET )	       	                                        *
C*                                                                      *
C* Output parameters:                                                   *
C*	IRET            INTEGER         Return code                     *
C*				   	  0 = normal return 	        *
C*                                                                      *
C**                                                                     *
C* Log:							                *
C* R. Hollern/NCEP       6/96                                           *
C* K. Tyle/GSC		 4/97	Cleaned up				*
C* D. Kidwell/NCEP	 4/97	Added argument rarray                   *
C* D. Kidwell/NCEP	 4/97	Added initialization for ixind          *
C* R. Hollern/NCEP      10/97   Added initialization for wsped          *
C* D. Kidwell/NCEP	10/97	Changed interface, cleaned up           *
C* R. Hollern/NCEP      11/99   Added initialization for ispwds, removed*
C*                              wdgflg, gums                            *
C* R. Hollern/NCEP      11/99   Added initialization for jnprcv         *
C* R. Hollern/NCEP       3/00   Removed initialization of interface vals*
C* C. Caruso Magee/NCEP  4/00   Modifying for Coast Guard data.         *
C************************************************************************
        INCLUDE 	'GEMPRM.PRM'
        INCLUDE 	'cgcmn.cmn'
C-----------------------------------------------------------------------
        iret   = 0
C
C*      Use system year/month and bulletin day/hour/minute.
C
        irptdt(1) = nint ( rctim(2) )
        irptdt(2) = nint ( rctim(3) )
C
C*      store bulletin day as report day.
C
        CALL ST_INTG ( btime(1:2), ist1, ier )
        irptdt(3) = ist1 
        IF ( irptdt(3) .gt. 31 ) THEN
           WRITE ( UNIT = logmsg, FMT = '( I4 )' ) irptdt(3)
           CALL DC_WLOG ( 2, 'CG', 7, logmsg, ierwlg )
           iret   = -1
           RETURN
        END IF
C
C*      Check to see if system day is first day of month.  If so,
C*      then if bulletin day is from previous month (i.e. bulletin
C*      day is greater than 1) then set month back to previous month.
C
        IF ( rctim(4) .eq. 1. .and. irptdt(3) .gt. 1 ) THEN
          IF ( irptdt(2) .gt. 1) THEN
            irptdt(2) = irptdt(2) - 1 
          ELSE
            irptdt(1) = irptdt(1) - 1
            irptdt(2) = 12
          END IF
        END IF
C
C*      store bulletin hour as report hour.
C
        CALL ST_INTG ( btime(3:4), ist2, ier )
        irptdt(4) = ist2
        IF ( irptdt(4) .lt. 0 .or. irptdt(4) .gt. 23 ) THEN
           WRITE ( UNIT = logmsg, FMT = '( I4 )' ) irptdt(4)
           CALL DC_WLOG ( 2, 'CG', 8, logmsg, ierwlg )
           iret   = -1
           RETURN
        END IF
C
C*      store bulletin minute as report minute.
C
        CALL ST_INTG ( btime(5:6), ist3, ier )
        irptdt(5) = ist3 
        IF ( irptdt(5) .lt. 0 .or. irptdt(4) .gt. 59 ) THEN
           WRITE ( UNIT = logmsg, FMT = '( I4 )' ) irptdt(5)
           CALL DC_WLOG ( 2, 'CG', 9, logmsg, ierwlg )
           iret   = -1
           RETURN
        END IF

        RETURN
        END