	SUBROUTINE DIVCOM

C======================================================================
C
C	   Routine to divide up the comments string in CCARD into
C	   individual "cards" of at most MAXCPL characters.
C	   MAXCPL is the average maximum number of characters
C	   per photocomposed comments line.
C
C	   By: Mark Holomany, JCPDS     Date: 30-Mar-1984
C
C======================================================================
 
	IMPLICIT INTEGER (A-Z)

D	PARAMETER	(MAXCPL = 80)
C\	PARAMETER	(MAXCPL = 79)
	CHARACTER*3	PC
	LOGICAL		FINDNB

	COMMON /COMCRD/  CCARD, NUMPHC, CHPHC, CDCNT, FSTCRD, LINKCM,
	1                STCRD, NUMCD
	CHARACTER        CCARD*1760
	INTEGER          CDCNT(30), FSTCRD(30), LINKCM(20)
	INTEGER          STCRD(30)

D	INCLUDE 'IORET.CMN'
D	INCLUDE 'PDFDATA.CMN'

C\$INCLUDE:'IORET.CMN'
C\$INCLUDE:'PDFDATA.CMN'


C==>	DO 7000 I=1,CHPHC,80
C==>7000	WRITE(NOUT,34567) CCARD(I:I+79)
C==>34567	FORMAT(' ',A)

	NUMPHC = 0
	START  = 1
	COUNT  = 0
	LASTBL = 1
	FINDNB = .FALSE.

C==>	last_count = 0

	NCHAR = 0
4500	CONTINUE
C==>	type *,ccard(nchar:nchar),count-last_count,count
C==>	last_count = count

	NCHAR = NCHAR + 1
	IF(NCHAR .GT. CHPHC) GO TO 500

	IF(CCARD(NCHAR:NCHAR) .EQ. ' ') THEN
	   LASTBL = NCHAR
	   IF(FINDNB) GO TO 4500
	ENDIF

	IF(FINDNB) THEN
	   FINDNB = .FALSE.
	   START  = NCHAR
	   COUNT = 0
	ENDIF

CCCCCC REMOVED MUCH CODE HERE CCCCCCCCC

	IF(CCARD(NCHAR:NCHAR) .EQ. '|') THEN
	   IF(COUNT .EQ. 0) THEN
	      GO TO 4500
	   ELSE
	      NUMPHC = NUMPHC + 1
	      IF(NUMPHC .GT. 30) THEN
	         CALL ERRTXT ('E', 
	1          'Exceeded maximum of 30 comment cards;')
	         CALL ERRTXT ('C', 
	1          'Likely reason: string of >80 characters ' //
	2          'without blanks')
	         GO TO 8000
	      ENDIF

	      STCRD(NUMPHC) = START
	      START = NCHAR + 1
	      LASTBL = 0
C
C	      ... Could be a problem here, this statement used to read
C	      ... (COUNT .GT. 80.0) when COUNT was REAL and it counted
C	      ... characters in the empirical/heuristic manner. ???
	      IF(COUNT .GT. MAXCPL) 
	1       WRITE (*,*) CARD1(1)(73:78),' COUNT >',MAXRW
	      COUNT = 0
	      FINDNB = .TRUE.
	   ENDIF

	ELSE

	   COUNT = COUNT + 1

C	             GE ==> GT
	   IF(COUNT .GT. MAXCPL  .OR.  (NCHAR-START).GT.79 ) THEN
	      NUMPHC = NUMPHC + 1
	      IF(NUMPHC .GT. 30) THEN
	         CALL ERRTXT ('E', 
	1          'Exceeded maximum of 30 comment cards;')
	         CALL ERRTXT ('C', 
	1          'Likely reason: string of >80 characters ' //
	2          'without blanks')
	         GO TO 8000
	      ENDIF
C
C	      .. A long string of >80 chars w/o blanks will have LASTBL=0
	      IF(LASTBL .EQ. 0) LASTBL = NCHAR
	      IF(LENGTH(CCARD(START:LASTBL)) .GT. 80) 
	1       CALL SPLONG (START, LASTBL)

	      STCRD(NUMPHC) = START
	      START = LASTBL + 1
	      NCHAR = LASTBL
	      FINDNB = .TRUE.
	      LASTBL = 0
C==>	type *,'count=',count
	      COUNT = 0
	   ENDIF
	ENDIF

	GO TO 4500

500	CONTINUE
	IF(NUMPHC.LT.1 .AND. CHPHC.GT.0) THEN
	   NUMPHC = NUMPHC + 1
	   STCRD(NUMPHC) = START
	ELSE IF(STCRD(NUMPHC) .LT. CHPHC) THEN
	   NUMPHC = NUMPHC + 1
	   STCRD(NUMPHC) = START
	ENDIF
	IF(STCRD(NUMPHC) .GT. CHPHC) NUMPHC = NUMPHC - 1

8000	CONTINUE
9000	RETURN
	END
