	SUBROUTINE PRTDSP (MAXCPL, DONE, BEGIN, PREVBG)
C
C	   Print out the d-spacings, etc., on the screen
C		MAXCPL - maximum characters per line on screen
C		DONE   - .true. if all d-sp's have been displayed,
C		         .false. otherwise
C		BEGIN  - first d-spacing to begin printing on the
C		         current screen.  Calling program MUST
C		         initialize this to 1 for first call,
C		         returned by PRTDSP as first d-sp for NEXT
C		         call.
C		PREVBG - Value of BEGIN as this routine was entered.
C		         Used by calling routine to page back.
C
C                     
C	   By: Mark Holomany     Date: 15-Oct-1876
C
C
	IMPLICIT INTEGER (A-Z)
	INTEGER  OFFSET(2)
	LOGICAL  DONE

	CHARACTER*1  TEMP
	CHARACTER*5  LGLSP
	CHARACTER*9  DISPD1, DISPD2, SPHEAD(5)
	CHARACTER*6  FMTS(4)
	REAL         SPIN, SPOUT

	COMMON /DIH/ DSPACE,INTEN,HKAYL,SUB
	CHARACTER*9  DSPACE(200)
	CHARACTER*4  INTEN(200)
	CHARACTER*22 HKAYL(200)
	INTEGER*2    SUB

D	INCLUDE 'CVTSP.CMN'
D	INCLUDE 'IORET.CMN'
D	INCLUDE 'LINEDR.CMN'
C\$INCLUDE:'CVTSP.CMN'
C\$INCLUDE:'IORET.CMN'
C\$INCLUDE:'LINEDR.CMN'

	DATA  LGLSP /'12SQD'/
	DATA  FMTS  /'(F7.3)', '(F7.3)', '(F7.5)', '(F7.5)'/
	DATA  SPHEAD /'  theta  ', ' 2-theta ', ' sin2 th ',
	1             '   Q A   ', '   d A   '/


	PREVBG = BEGIN
C
C	... Check if we're trying to start after the first screen
	IF(BEGIN .GT. 1  .AND.  DONE) BEGIN = 1

	SPTYPE = INDEX(LGLSP, ISPACG)
C
C	... Top horrizontal line
	WRITE(NOUT,1653) ULC1, (H1,K=1,9),  TT1, (H1,K=1,5),  TT1,
	1  (H1,K=1,22),  TT2,  (H1,K=1,9),  TT1, (H1,K=1,5),  TT1, 
	2  (H1,K=1,22), URC1
1653	FORMAT(' ',A,9A1, A,5A1, A,22A1, A,9A1, A,5A1, A,22A1, A)
C
C	... Write column labels
D	WRITE(NOUT,1651) V1,SPHEAD(SPTYPE),V1,V1,V2,
D	1                SPHEAD(SPTYPE),V1,V1,V1
1651	FORM AT(' ',A,A9,A,  ' Int.',A,  T27,'h k l',
	1  T41,A,  T42,A9,  T51,A,  ' Int.',A,  T66,'h k l',
	2  T80,A)

	WRITE(NOUT,1652) LT1, (H1,K=1,9), INT1, (H1,K=1,5), INT1,
	1  (H1,K=1,22), INT2, (H1,K=1,9), INT1, (H1,K=1,5), INT1, 
	2  (H1,K=1,22), RT1
1652	FORMAT(' ',A,9A1, A,5A1, A,22A1, A,9A1, A,5A1, A,22A1, A)
C
C	... Begin printing out 30 d-sp, 2 at a time
	NLINES = 0
	END = MIN0(SUB, BEGIN+14)

	DO 4050 N=BEGIN,END
	IF(NLINES.EQ.5 .OR. NLINES.EQ.10)
	1	  WRITE(NOUT,1655) V1, V1, V1, V2, V1, V1, V1
1655	FORMAT(' ',A,  T12,A,  T18,A,  T41,A,  T51,A,  T57,A,  T80,A)
C
	IF(ISPACG .EQ. 'D') THEN
	   DISPD1 = DSPACE(N)
	   DISPD2 = DSPACE(N+15)
	ELSE
	   TEMP = ' '
	   READ (DSPACE(N), '(F9.0)', ERR=100) SPIN
	   GO TO 150
100	   L = LENGTH(DSPACE(N))
	   TEMP = DSPACE(N)(L:L)
	   DSPACE(N)(L:L) = ' '
	   IF(DSPACE(N)(1:1) .EQ. '[') THEN
	      READ (DSPACE(N)(2:8), '(F7.0)') SPIN
	   ELSE
	      READ (DSPACE(N)(1:8), '(F8.0)') SPIN
	   ENDIF
	   DSPACE(N)(L:L) = TEMP

150	   CALL DSPCVT (ISPACG, CONST, SPIN, SPOUT)
	   WRITE(DISPD1(2:8), FMTS(SPTYPE)) SPOUT
	   DISPD1(9:9) = TEMP
	   DISPD1(1:1) = ' '
	   IF(DSPACE(N)(1:1) .EQ. '[') DISPD1(1:1) = '['
	   IF((N+15) .LE. SUB) THEN
	      TEMP = ' '
	      READ (DSPACE(N+15), '(F9.0)', ERR=200) SPIN
	      GO TO 250
200	      L = LENGTH(DSPACE(N+15))
	      TEMP = DSPACE(N+15)(L:L)
	      DSPACE(N+15)(L:L) = ' '
	      IF(DSPACE(N+15)(1:1) .EQ. '[') THEN
	         READ (DSPACE(N+15)(2:8), '(F7.0)') SPIN
	      ELSE
	         READ (DSPACE(N+15)(1:8), '(F8.0)') SPIN
	      ENDIF
	      DSPACE(N+15)(L:L) = TEMP

250	      CALL DSPCVT (ISPACG, CONST, SPIN, SPOUT)
	      WRITE(DISPD2(2:8), FMTS(SPTYPE)) SPOUT
	      DISPD2(9:9) = TEMP
	      DISPD2(1:1) = ' '
	      IF(DSPACE(N+15)(1:1) .EQ. '[') DISPD2(1:1) = '['
	   ENDIF
	ENDIF

	IF((N+15) .LE. SUB) THEN

	   WRITE (NOUT,1611) V1, DISPD1, V1, INTEN(N),
	2                    V1, HKAYL(N),V2, DISPD2,
	4                    V1, INTEN(N+15),V1, HKAYL(N+15), V1

1611	   FORMAT(' ',A, A,  T12,A,1X,A,  T18,A, A,  T41,A,
	1                 A,  T51,A,  1X,A,  T57,A, A,  T80,A  )

	ELSE
	   WRITE (NOUT,1612) V1, DISPD1,
	1                    V1, INTEN(N),
	2                    V1, HKAYL(N),
	3                    V2, V1, V1, V1
1612	   FORMAT(' ',A,A,  T12,A,  1X,A,  T18,A, A,  T41,A, 
	1                        T51,A,         T57,A,         T80,A  )
	ENDIF
	NLINES = NLINES + 1
4050	CONTINUE

C
C	... Bottom horrizontal line
	WRITE(NOUT,1654) LLC1, (H1,K=1,9),  BT1, (H1,K=1,5),  BT1,
	1  (H1,K=1,22),  BT2, (H1,K=1,9),  BT1, (H1,K=1,5),  BT1, 
	2  (H1,K=1,22), LRC1
1654	FORMAT(' ',A,9A1, A,5A1, A,22A1, A,9A1, A,5A1, A,22A1, A)
C                                                   
	IF(BEGIN+30 .LE. SUB) THEN
	   BEGIN = BEGIN + 30
	   DONE = .FALSE.
	ELSE
	   BEGIN = 1
	   DONE  = .TRUE.
	ENDIF

	RETURN
	END
