	subroutine tekout(length,string)
c
c ****************************************************************************
c *                                                                          *
c * This subroutine is part of the MMADS Graphics Routines, developed at CBM *
c * Branch, Physics Division, Research Directorate, Chemical Research,       *
c * Development and Engineering Center, APG, U.S. Army.                      *
c *                                                                          *
c * Author: Dr. Joseph M. Leonard                                            *
c *                                                                          *
c * Date:   3/12/87                                                          *
c *                                                                          *
c * This code has been included in the MOPAC/DRAW package.  No warranty is   *
c * expressed or implied by the author or CRDEC as to the ultimate           *
c * correctness of this code                                                 *
c *                                                                          *
c ****************************************************************************
c
c	This subroutine accepts a string from the Tek graphics library, and
c	attempts to buffer them into a string for "mass" i/o operations.  This
c	should greatly reduce the buffered-IO overhead on the VAX.
c
c	length	number of characters in <string>
c	string	the string to be appended to the internal values
c
	parameter (BUFSIZ=1020)		
	logical first_time
	data first_time/.true./	
c
	integer in_buffer
	data in_buffer/0/	
c
	character*(*) string
	integer length
	character*1020 buffer	
c
c	Check if it's a first-time call
c
	if(first_time) then
           open(unit=37,file='-stdout',status='unknown',recl=1024,
     1          form='unformatted')
	   first_time=.false.
	endif
c
c	Check that <string> fits in <buffer>
c
	if(in_buffer+length.gt.BUFSIZ) then
c
c		Dump the buffer to the terminal
c
		write(37)buffer(:in_buffer)
c900		format('+',a,$)
c
		in_buffer=0	
	endif
c
c	Add <string> to <buffer>
c
	buffer(in_buffer+1:in_buffer+length)=string(:length)
	in_buffer=in_buffer+length
c
	return
c
c	Entry to flush the buffer
c
	entry tekfls
c
	if(in_buffer.gt.0) then
		write(37)buffer(:in_buffer)
		in_buffer=0
	endif
c
	return
	end
