       SUBROUTINE CPMFMT(NAME,CPMFD)
C
C       CONVERSION OF CP/M FILENAME TO F80 FORMAT
C
       BYTE CUPPER,NAME(14)
       INTEGER CPMFD
C
C       CONVERT ALL LOW CHAR. TO UPPER
C
       DO 10 I=1,14
10     NAME(I)=CUPPER(NAME(I))
C
C       SET DEFAULT DRIVE TO A
C
       CPMFD=1
       K2=0
C
C       COLON IN FILENAME ?
C
       IF(NAME(2) .NE. 58) GOTO 20
       IF((NAME(1) .GE. 65) .AND. (NAME(1) .LE. 90)) CPMFD=NAME(1)-64
       K2=2
20     K1=0
       NAP=0
C       
C       STRIP FILENAME OF DRIVENAME AND PERIOD
C
       DO 40 I=1,12
       K1=K1+1
       K2=K2+1
C
C       PERIOD ?
C
       IF(NAME(K2) .NE. 46) GOTO 30
       NAP=K1
       K1=K1-1
       GOTO 40
30     NAME(K1)=NAME(K2)
40     CONTINUE
C     
C       NAP MARKS START OF EXTENSION
C
       IF(NAP .EQ. 0 .OR. NAP .EQ. 9)GOTO 75
C
C       SET EXTENSION ON RIGHT PLACE
C
       DO 60 I=1,3
       K1=12-I
       K2=NAP+3-I
60     NAME(K1)=NAME(K2)
       K1=K1-1
C
C       FILL GAP WITH BLANKS
C
       DO 70 I=K2,K1
70     NAME(I)=32
C       
C       FLUSH NAME WITH BLANKS
C
75     DO 80 I=12,14
80     NAME(I)=32
       RETURN
       END
       BYTE FUNCTION CUPPER(CHAR)
       BYTE  CHAR
       CUPPER=CHAR
       IF(CHAR .GE. 97 .AND. CHAR .LE. 122) CUPPER=CHAR-97+65
       RETURN
       END
