C----------------------------------------------------------------------
      SUBROUTINE DISPLAY(NINT,DSPACE,INT,LUNO,WAVE,IPOS,NLINE)
C Display a card in one of two formats:
C   WAVE = 0: D vs. Intensity
C   WAVE > 0: D & 2theta vs. Intensity
C NINT 		total number of peaks
C DSPACE,INT	arrays of d-spaces & intensities
C LUNO		logical unit # for output
C IPOS (input)	is the number of first peak to display
C      (output)	the number of the first undisplayed peak or 
C NLINE		number of lines to be used
      INTEGER NINT,LUNO,IPOS,NLINE
      REAL WAVE
      REAL DSPACE(*)
      INTEGER*2 INT(*) 
C----------------------------------------------------------------------
      character*7 angle(200)
      logical flag,DTOTT

      ndsint = 1 + NINT - IPOS 	
      N8 = min(NLINE,NDSINT-4*NLINE)
      N6 = min(NLINE,NDSINT-3*NLINE)
      N4 = min(NLINE,NDSINT-2*NLINE)
      N2 = min(NLINE,NDSINT-NLINE)
      N1 = min(NLINE,NDSINT)
      NST = 1 

      if (wave .EQ. 0) THEN  
C----------------------------------------------------------------------
C---------------------PRINT 2 COLS: D, INTENSITY ----------------
35	FORMAT (1X,5(F7.3,1X,I3,4X))

	DO K=nst,N8
	  I = K + IPOS - 1
	  WRITE(LUNO,35) (DSPACE(I+J),INT(I+J),j=0,4*NLINE,NLINE)
 	  NST=NST+1 
	ENDDO

	DO k=nst,N6
	  I = K + IPOS - 1
	  WRITE(LUNO,35) (DSPACE(I+J),INT(I+J),j=0,3*NLINE,NLINE)
 	  NST=NST+1 
	ENDDO

	DO k=nst,N4
	  I = K + IPOS - 1
	  WRITE(LUNO,35) (DSPACE(I+J),INT(I+J),j=0,2*NLINE,NLINE)
 	  NST=NST+1 
	ENDDO

	DO k=nst,N2
	  I = K + IPOS - 1
	  WRITE(LUNO,35) (DSPACE(I+J),INT(I+J),j=0,NLINE,NLINE)
 	  NST=NST+1 
	ENDDO

	DO k=nst,N1
	  I = K + IPOS - 1
	  WRITE(LUNO,35) DSPACE(I),INT(I)
	  NST=NST+1 
	ENDDO
	ipos = MIN(IPOS + 5*NLINE, NINT+1)
C----------------------------------------------------------------------
C----------------------------------------------------------------------
      ELSE
C----------------------------------------------------------------------
C---------------------PRINT 3 COLS: D, ANGLE, INTENSITY ----------------
	do i=1,ndsint
	  flag = DTOTT(DSPACE(I),a,WAVE)
	  if (flag) then 
	    write(angle(i),'(f7.2)') a
	  else
	    angle(i) = '  ???  '
	  endif
	enddo

44      FORMAT(1X,4(f6.3,a7,I4,2X))

	DO k=nst,N6
	  I = K + IPOS - 1
	  WRITE(LUNO,44) (DSPACE(I+J),ANGLE(I+J),INT(I+J),
	1	j=0,3*NLINE,NLINE)
 	  NST=NST+1 
	ENDDO

	DO k=nst,N4
	  I = K + IPOS - 1
	  WRITE(LUNO,44) (DSPACE(I+J),ANGLE(I+J),INT(I+J),
	1	j=0,2*NLINE,NLINE)
 	  NST=NST+1 
	ENDDO

	DO k=nst,N2
	  I = K + IPOS - 1
	  WRITE(LUNO,44) (DSPACE(I+J),ANGLE(I+J),INT(I+J),
	1	j=0,NLINE,NLINE)
 	  NST=NST+1 
	ENDDO

	DO k=nst,N1
	  I = K + IPOS - 1
	  WRITE(LUNO,44) DSPACE(I),ANGLE(I),INT(I)
 	  NST=NST+1 
	ENDDO
	ipos = MIN(IPOS + 4*NLINE, NINT+1)
C----------------------------------------------------------------------
C----------------------------------------------------------------------
      ENDIF

      RETURN
      END 
