      SUBROUTINE CRAM(M)
	CALL CRAMNT(M,80,1)
	RETURN
	END
	SUBROUTINE CRAMS(M,K)
	CALL CRAMNT(M,K,1)
	RETURN
	END
	SUBROUTINE CRENDNO
	CALL CRAMNT(,,2)
	RETURN
	END
	SUBROUTINE CRMDPS(M,K)
	CALL CRAMNT(M,K,3)
	RETURN
	END
	SUBROUTINE CRAMDMP(M)
	CALL CRAMNT(M,80,3)
	RETURN
	END
	SUBROUTINE CREND
	CALL CRAMNT(,,4)
	RETURN
	END
	SUBROUTINE CRAMNT(M,K,IZ)
	COMMON/PRLUN/LUN
      BYTE M(1),KHAR
C--------<M> IS AN ARRAY CONTAINING CHARACTERS LJZF.  BYTES ARE PUT
C--------INTO THE OUTPUT BUFFER UP TO THE FIRST 00B BYTE.
      BYTE LINE(120)
      DATA LINE/120*0/,ICH/0/
	GOTO (11,2,11,25)IZ
11    IDUMP=IZ/2
	ICHX=0
C--------GET THE NEXT CHARACTER OF <M>
10	ICHX=ICHX+1
	IF (ICHX.GT.K) GOTO 21
	KHAR=M(ICHX)
C--------PUT IT IN BUFFER
      IF(KHAR .EQ. 0) GO TO 21
      ICH=ICH+1
	LINE(ICH)=KHAR
	IF(ICH.GE.120) GOTO 25 
	IF((ICH.GE.72).AND.(LUN.EQ.7)) GOTO 25
      GO TO 10
C*
C--------DUMP BUFFER AND SUPPRESS LINE FEED
2	LINE(ICH+1) = 0
	CALL PROMPT (LINE,ICH)
	GOTO 27
21	IF(IDUMP.EQ. 0) RETURN 
C--------DUMP BUFFER AND GO TO NEW LINE 
25	LINE(ICH+1) = 0
	CALL PROUT(LINE,ICH)
27      DO 30 L=1,ICH 
 30   LINE(L)=0
      ICH=0
      RETURN
      END 
      SUBROUTINE CRAMF(XX,W,D)
C     XX=REAL NUMBER TO PRINT
C     W=WIDTH OF THE NUMBER
C     D=NUMBER OF PLACES TO RIGHT OF DECIMAL
	BYTE CF(10)
      INTEGER W,D
D	WRITE(1,123)XX,W,D
D123	FORMAT(G14.4,2I6)
      NEG=0
	DO 5 N=1,10
5	CF(N)="40
      X=XX
      IF(X .GE. 0) GO TO 10
      X=-XX
      NEG=1
 10   N=0 
      IF(D .EQ. 0) GO TO 30
C--------CONVERT FRACTIONAL PART TO ASCII
	I=X
	X=XX-I
      I=X*10**D+.5
      DO 20 N=1,D
      J=MOD(I,10)
	CF(N)="60+J
 20   I=I/10
	I=XX
C--------INSERT DECIMAL POINT 
      N=D+1
	CF(N)="56
C--------CONVERT INTEGRAL PART TO ASCII
 30   J=MOD(I,10)
      N=N+1
	CF(N)="60+J
      I=I/10
      IF(I .NE. 0) GO TO 30
C--------INSERT MINUS SIGN IF NEEDED
      IF(NEG .EQ. 0) GO TO 40 
      N=N+1
	CF(N)="55
C------REVERSE THE CHARACTERS BEFORE YOU AUTPUT THEM
 40	N=MAX0(N,W)
	CALL CRAMRV(CF,N)
      RETURN
      END 
      SUBROUTINE CRAMI(II,W)
	BYTE CI(10)
      INTEGER W
      I=II
      NEG=0
      IF(I .GE. 0) GO TO 10
      I=-II
      NEG=1
C--------CONVERT THE NUMBER ITSELF TO ASCII
10	DO 15 N=1,10
15	CI(N)="40
      N=0 
 20   J=MOD(I,10)
      N=N+1
	CI(N)="60+J
      I=I/10
      IF(I .NE. 0) GO TO 20
C--------INSERT MINUS SIGN IF NEEDED
 30   IF(NEG .EQ. 0) GO TO 40 
      N=N+1
	CI(N)="55
 40	IF (N .GE. W .OR. N .GE. 9) GOTO 43
	N=N+1
	CI(N)="40
	GOTO 40
43	CALL CRAMRV(CI,N)
      RETURN
      END 
	SUBROUTINE CRAMRV(CD,N)
	BYTE CD(10),CS(10)
	DO 1 I=1,N
1	CS(I)=CD(N-I+1)
	CS(N+1)=0
	CALL CRAM(CS)
	RETURN
	END
	SUBROUTINE CRAMCH(ICH,N)
	BYTE ICH
	IF (N.LE.0) RETURN
	DO 1 I=1,N
1	CALL CRAM(ICH)
	RETURN
	END
