CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
	SUBROUTINE WRITE_FLAG_RECORD(UNIT, YEAR, DOY, HR, MINUTE, SEC, FLAGVALUE)
C+
C 
C FUNCTIONAL DESCRIPTION:	
C 
C    This subroutine will write a single record to the output file opened to
C    the specified unit.   The record will contain the time values passed in
C    the first five parameters, with all remaining values being the flag value.
C 
C FORMAL ARGUMENTS:
C  
C     UNIT:
C	  I*4	    Fortran unit number to use in WRITE statement.
C  
C     YEAR:
C	  I*4	    Year component of time tag to be written.
C  
C     DOY:
C	  I*4	    Day of year component of time tag to be written.
C  
C     HR:
C	  I*4	    Hour component of time tag to be written.
C  
C     MINUTE:
C	  I*4	    Minute component of time tag to be written.
C  
C     SEC:
C	  I*4	    Second component of time tag to be written.
C  
C     FLAGVALUE:
C	  R*4	    Value to be written out in each column.
C  
C DESIGN:
C  
C     convert flag value to integer
C     fill arrays with flag values
C     overwrite value of FLAGS corresponding to ANGLE with 99.
C     write out flag record, alternating real and integer implied DO loops
C       since ANGLE is in first group of REALs, use implied do starting at 1
C       for first group and starting at NUM_REAL(1)+1 for subsequent groups
C  
C INTERFACE:
C
!	INTERFACE
!	  SUBROUTINE WRITE_FLAG_RECORD(UNIT, YEAR, DOY, HR, MINUTE, SEC, FLAGVALUE)
!	    INTEGER, INTENT(IN) :: UNIT, YEAR, DOY, HR, MINUTE, SEC
!	    REAL, INTENT(IN) :: FLAGVALUE
!	  END SUBROUTINE WRITE_FLAG_RECORD
!	END INTERFACE
C
C IMPLICIT INPUTS:
C
C     Contents of common block FORM, including ANGLE_INDEX, which is used to
C     control execution.
C
C IMPLICIT OUTPUTS:
C
C     None
C
C SIDE EFFECTS:
C
C     Writes a line to the output stream.
C
C COMMON BLOCKS:
C  
C     FORM		contains format to be used for WRITE statement
C
C INCLUDE FILES:
C
C     FORM.INC		defines common block FORM
C 
C This version:   1.2   14-FEB-1997
C 
C CREATED: 
C 
C	 5-FEB-1997    Lawrence Bleau
C 
C DEVELOPMENT HISTORY:
C 
C  L. BLEAU      5-FEB-1997     remove common FORM declaraction, add INCLUDE FORM.INC
C  J. PAQUETTE  14-FEB-1997     Cause ANGLE to have a flag value of 99, since -1 is a legal
C                               value for ANGLE
C  L. Bleau	11-NOV-1999	add comments
C-
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CDEC$	IDENT	'1.2'
	IMPLICIT NONE
	INTEGER*4 YEAR, DOY, HR, MINUTE, SEC, UNIT
	REAL*4 FLAGVALUE
C
	INTEGER*4 IFLAGS(50),I,N
	REAL*4 FLAGS(50)
	INCLUDE 'INC_DIR:FORM.INC'
C 
	DO I=1,50
	  FLAGS(I) = FLAGVALUE
	  IFLAGS(I) = INT(FLAGVALUE)
	ENDDO
C
C Overwrite value of FLAGS corresponding to ANGLE with 99.
C
        IF (ANGLE_INDEX .NE. 0) FLAGS(ANGLE_INDEX) = 99.0
C
C Since ANGLE is in first group of REALs, use implied do starting at 1
C for first group and starting at NUM_REAL(1)+1 for subsequent groups
C
        N = NUM_REAL(1)
	WRITE(UNIT,FMT(1:FMTLEN)) YEAR,DOY,HR,MINUTE,SEC,
	1 (FLAGS(I),I=1,NUM_REAL(1)), (IFLAGS(I),I=1,NUM_INT(1)),
	1 (FLAGS(I),I=N+1,NUM_REAL(2)+N), (IFLAGS(I),I=1,NUM_INT(2)),
	1 (FLAGS(I),I=N+1,NUM_REAL(3)+N), (IFLAGS(I),I=1,NUM_INT(3)),
	1 (FLAGS(I),I=N+1,NUM_REAL(4)+N), (IFLAGS(I),I=1,NUM_INT(4))
	RETURN
	END
