      SUBROUTINE INIT
C

C   
C     THIS ROUTINE INITIALIZES THE VARIABLES USED 
C     IN THE PROGRAM
C 
C 
      REAL IVAL,IVAL1,IVAL2,NOFF,NTDEP(64),NINST,INSCT
      DIMENSION INUM(16)
      COMMON ICRD,IPRT,IPCH,IRDR,IFIL,IMREC,IMFLE,IPFLE,IPREC,ITERM
      COMMON IMBUF(128),IPBUF(80),IN(128),ILBUF(80),IWBUF(128),IFREC
      COMMON ISBIT,ICHBT,ICHWD,NBIT,NINST,NDONT,NCOL,NROW,NOFF,IBAT 
      COMMON LODLC,IEND,NBITT,IPS,IPE,IPLEN,IPASS,IROW,LCTL,MXREC
      COMMON NPLIN,IWSEC,MSEC,IPROM,INDEX,IBITS,IBITE,LCOLS,LCOLE 
      COMMON INSCT,IVAL,IVAL1,IVAL2,MCOL,NPCNT,ICHAR,MSIZE,NWORD,ILLEN
      COMMON LMAP,LLIST,LPCH,INVRT,LHEX,LFILE,NAMEF(4),IERR,ICOL,ICNT 
      COMMON NPWID(32),NTWID(32),NPDEP(64),NTDEP,NVAL,MESSN,MESSF 
      COMMON ICHRA,ICHRB,ICHRC,ICHRD,ICHRF,ICHRN,ICHRR,ICHR0,ICHR1
      COMMON ICHRX,IBLNK,ICOMM,IAST,IDOLR,IEQUL,IMIN,IADDR(4),NUMS(16)
      DATA INUM(1),INUM(2),INUM(3),INUM(4) /1H0,1H1,1H2,1H3/
      DATA INUM(5),INUM(6),INUM(7),INUM(8) /1H4,1H5,1H6,1H7/
      DATA INUM(9),INUM(10),INUM(11),INUM(12) /1H8,1H9,1HA,1HB/
      DATA INUM(13),INUM(14),INUM(15),INUM(16) /1HC,1HD,1HE,1HF/
      DATA NCHRA,NCHRB,NCHRC,NCHRD,NCHRF /1HA,1HB,1HC,1HD,1HF/
      DATA NCHRN,NCHRR,NCHRX,NBLNK,NCOMM /1HN,1HR,1HX,1H ,1H,/
      DATA NAST,NDOLR,NEQUL,NMIN         /1H*,1H$,1H=,1H-/
C   
C   
C   
C     INITIALIZE I/O LOGICAL DEVICE NUMBERS
      ITERM = 4
      IPCH = 6
      ICRD = 1
      IPRT = 2
      IRDR = 7
      IPFLE = 0
      IFIL = 9
      IMFLE = 10
C     INITIALIZE FILE RECORD NUMBERS
      IMREC = 1 
      IPREC = 1 
      IFREC = 1 
C 
C     SET PARAMETERS FOR EQUAT ROUTINE
C     ISBIT = COMPUTER WORD SIZE (IN BITS)
C     ICHBT = NUMBER OF BITS PER CHARACTER
C     E.G. MOST MINIS = 8, 370 = 8, PDP 10 = 7, CDC 6600 = 6
      ISBIT = 16
      ICHBT = 8
      ICHWD = ISBIT/ICHBT 
C 
      NCOL = 0
      NROW = 0
      NBIT = 0
      NINST = 0 
      INSCT = 0 
      NOFF = 0
C     SET MAXIMUM COMMAND COLUMN LENGTH 
      MCOL = 72 
      MESSF = 0 
      NDONT = 0 
      IEND = 0
C     SET DISK SECTOR WORD SIZE 
      MSIZE = 64
C     SET LIST/PUNCH OUTPUT CONTROL FLAG
C     0 = LIST AND PUNCH DEVICES ARE THE SAME 
C     1 = LIST AND PUNCH DEVICES ARE DIFFERENT
      LCTL = 1
C     SET INTERACTIVE/BATCH FLAG, 0=INTERACTIVE, 1=BATCH
      IBAT = 0
      ICHRA = NCHRA 
      ICHRB = NCHRB
      ICHRC = NCHRC 
      ICHRD = NCHRD 
      ICHRF = NCHRF 
      ICHRN = NCHRN 
      ICHRR = NCHRR 
      ICHRX = NCHRX 
      ICHR0 = INUM(1) 
      ICHR1 = INUM(2) 
      IBLNK = NBLNK 
      ICOMM = NCOMM 
      IEQUL = NEQUL 
      IMIN = NMIN 
      IDOLR = NDOLR 
      IAST = NAST 
C     INITIALIZE WIDTH AND DEPTH TABLES 
      DO 100 I=1,32
      NPWID(I) = 0
100   CONTINUE
      DO 200 I=1,64
      NPDEP(I) = 0
200   CONTINUE
      DO 300 I=1,16
      NUMS(I) = INUM(I)
300   CONTINUE
      RETURN
      END
      SUBROUTINE INOUT(INDX)
C 
C 
C     THIS ROUTINE PERFORMS ALL I/O FOR THE PROGRAM EXCEPT
C     FOR THE FINAL OUTPUT LISTING.  THESE STATEMENTS MAY 
C     HAVE TO CHANGE ON SOME MACHINES PARTICULARILY FOR 
C     DISK I/O.  TWO STATEMENTS ARE SHOWN FOR EACH DISK I/O 
C     OPERATION.  A STANDARD READ OR WRITE AS USED BY IBM,DEC
C     AND SOME OTHERS, AND A CALL TO A SYSTEM ROUTINE
C     AS USED BY H.P AND SOME OTHERS (FOR INFORMATIVE PURPOSES) 
C     THE RECORD NUMBER (ASSOCIATED VARIABLE) FOR RANDOM ACCESS 
C     I/O IS PASSED INTO THE ROUTINE VIA COMMON.
C 
C 
C**************************************************************
C
C	MODIFIED BY STEP ENGINEERING FOR FUTUREDATA AMDS
C	DEVELOPMENT SYSTEM RUNNING CMDOS.
C
C		MAR. 18, 1981 -- TERRILL -- OBJECT PROGRAM
C	READ BELOW 235 AND 275 (LABELS) MAY NOT USE FORMAT
C	1000.  ERROR IN "OLD" VERSIONS OF MICROSOFT FORTRAN
C	DISK DRIVERS.
C
C**************************************************************
C
C
      REAL IVAL,IVAL1,IVAL2,NOFF,NTDEP(64),NINST,INSCT
      DIMENSION NAMEI(3),NAMEP(3) 
      COMMON ICRD,IPRT,IPCH,IRDR,IFIL,IMREC,IMFLE,IPFLE,IPREC,ITERM
      COMMON IMBUF(128),IPBUF(80),IN(128),ILBUF(80),IWBUF(128),IFREC
      COMMON ISBIT,ICHBT,ICHWD,NBIT,NINST,NDONT,NCOL,NROW,NOFF,IBAT
      COMMON LODLC,IEND,NBITT,IPS,IPE,IPLEN,IPASS,IROW,LCTL,MXREC
      COMMON NPLIN,IWSEC,MSEC,IPROM,INDEX,IBITS,IBITE,LCOLS,LCOLE
      COMMON INSCT,IVAL,IVAL1,IVAL2,MCOL,NPCNT,ICHAR,MSIZE,NWORD,ILLEN
      COMMON LMAP,LLIST,LPCH,INVRT,LHEX,LFILE,NAMEF(4),IERR,ICOL,ICNT
      COMMON NPWID(32),NTWID(32),NPDEP(64),NTDEP,NVAL,MESSN,MESSF
      COMMON ICHRA,ICHRB,ICHRC,ICHRD,ICHRF,ICHRN,ICHRR,ICHR0,ICHR1
      COMMON ICHRX,IBLNK,ICOMM,IAST,IDOLR,IEQUL,IMIN,IADDR(4),NUMS(16)
      DATA NAMEP(1),NAMEP(2),NAMEP(3) /2HOB,2HFL,2HE /
      DATA NAMEI(1),NAMEI(2),NAMEI(3) /2HIM,2HFL,2HE /
C   
C     *ENTRY PARAMETERS
C     INDX  - I/O CONTROL WORD
C             1 = READ SOURCE COMMANDS
C             2 = READ OBJECT FILE
C             3 = READ INTERMEDIATE FILE
C             4 = WRITE INTERMEDIATE FILE
C             5 = WRITE FINAL PROM OUTPUT
C             6 = DUMMY READ FOR OBJECT FILE
C     IERR  - RETURN STATUS
C             0 = VALID READ
C             1 = END OF FILE ENCOUNTERED
C   
C   
      IERR = 0
      GO TO(100,200,300,400,500,600),INDX
C   
C     READ COMMAND STATEMENTS
100   READ(ICRD,1000,END=110) (IN(I),I=1,80)
1000  FORMAT(80A1)
      GO TO 140
110   DO 120 I=1,80
      IN(I) = IBLNK
120   CONTINUE
      IERR = 1
140   ICOL = 1
C     CHECK IF COMMAND IS PRINTED
      IF(IBAT) 150,190,150
150   WRITE(IPRT,1001) (IN(I),I=1,70)
1001  FORMAT(1X,80A1)
190   RETURN
C     READ OBJECT FILE
C   
C     FOR MOST COMPUTERS THE READ STATEMENTS NEEDED
C     TO READ THE OBJECT MODULE FROM A FILE OR FROM AN
C     I/O DEVICE IS THE SAME AND THE I/O STATEMENTS AT 200 AND
C     250 ARE THE SAME.  FOR SOME COMPUTERS THE READS ARE
C     DIFFERENT AND THESE STATEMENTS MAY HAVE TO BE DIFFERENT.
C   
200   L = 65
C     READ OBJECT MODULE FROM I/O DEVICE
210   IF(NBIT-70) 220,220,230
220   L = 1
      GO TO 240
230   IF(IPFLE .EQ. 0) GO TO 235
C
C	FORTRAN READ STATEMENT (1ST RECORD WAS
C	READ IN DIFFERENTLY FROM ALL OTHERS.
C 
      READ(IRDR,1001,END=295) (IN(I),I=1,64)
      GO TO 240
C
C	SPECIAL CODE TO READ IN FIRST RECORD OF
C	A FILE -- DIFFERENT FORMAT FROM REST OF 
C	THE RECORDS UNDER SOME VERSIONS OF MICROSOFT
C	FORTRAN.  (NOT NEEDED UNDER CMDOS FORTRAN).
C
235   READ(IRDR,1001,END=295) (IN(I),I=1,64)
      IPFLE=1
240   IF(IPFLE .EQ. 0) GO TO 245
C
      READ(IRDR,1001,END=295) (IN(I),I=L,NBIT)
      GO TO 290
C
C	FIRST READ OF FILE -- WAS DIFFERENT ON
C	SOME FORTRAN VERSIONS FROM REST OF THE
C	RECORDS.  NOT DIFFERENT IN CMDOS VERSION.
C
C245   READ(IRDR,1000,END=295) (IN(I),I=L,NBIT)
C
245   READ(IRDR,1001,END=295) (IN(I),I=L,NBIT)
      IPFLE=1
      GO TO 290
C
C**************************************************************
C
C	APPARENTLY UNUSED CODE -- TERRILL
C
C     READ OBJECT MODULE FROM FILE
C250   IRDR = -IRDR
C      IF(NBIT-70) 260,260,270
C260   L = 1
C      GO TO 275
C270   READ(IRDR,1000,END=295) (IN(I),I=1,64)
C
C	END OF APPARENTLY UNUSED CODE.
C
C**************************************************************
C
C	OLD FORTRAN READ STATEMENT -- NOT THE SAME AS ALL OF
C	THE OTHERS FOR THE SYSTEM--CMDOS.
C
C275   READ(IRDR,1000,END=295) (IN(I),I=L,NBIT)
C
275   READ(IRDR,1000,END=295) (IN(I),I=L,NBIT)
C
C     CALL EXEC(14,1091,IN,128,NAMEF,IFREC)
280   IRDR = -IRDR
290   ICOL = 1
      IC = IRDR
      IF(IC .LT. 0) IC = -IC
      GO TO 296
295   IERR = 1
296   RETURN
C     READ INTERMEDIATE FILE
300   READ(IMFLE,REC=IMREC) IMBUF
C   
C     CALL EXEC(14,1091,IMBUF,128,NAMEI,IMREC)
      RETURN
C     WRITE INTERMEDIATE FILE
400   WRITE(IMFLE,REC=IMREC) IMBUF
C     CALL EXEC(15,1091,IMBUF,128,NAMEI,IMREC)
      RETURN
C     WRITE PROM OUTPUT
500   I = IPREC
      WRITE(IPCH,1001) (IPBUF(I),I=1,IPLEN)
C     CALL EXEC(15,1091,IPBUF,80,NAMEP,IPREC) 
      IPREC = I+1 
      RETURN
C     OBJECT FILE DUMMY READ
600   L = 65
      IF(IRDR) 610,240,240
610   IRDR = -IRDR
      GO TO 275 
      END
(IRDR) 610,240,240
610   IRDR = -IRDR
      GO TO 275 
      END
