      SUBROUTINE WRITE8 (WBUFR,NCHR,WEOF)                                 00001 
C                                                                         00002 
C     THIS SUBROUTINE REPLACES THE CDC WRITE8 SUBROUTINE                  00003 
C     IN THE PDP ENVIRONMENT.                                             00004 
C     NAME IS NOT USED.  THE MAGTAPE IS ASSUMED.                          00005 
C     WBUFR IS THE BUFFER POINTER.                                        00006 
C     NCHR IS THE NUMBER OF BYTES IN THE BUFFER TO WRITE.                 00007 
C     WEOF IS A FLAG TO INDICATE THAT AN EOF MARK IS TO                   00008 
C     BE WRITTEN AFTER THE RECORD IS WRITTEN. 0 MEANS NO.                 00009 
C                                                                         00010 
      INCLUDE 'SY:MTFCB.FTN'                                              00011 
      INCLUDE 'SY:FLGCM.FTN'                                              00012 
      INCLUDE 'SY:HRDCOM.FTN'                                             00013 
      INCLUDE 'SY:MTCOMM.FTN'                                             00014 
        LOGICAL*1 WBUFR(1)                                                00015 
C                                                                         00016 
        INTEGER WEOF                                                      00017 
        DATA MIN/28/                                                      00018 
        DATA MAX/2048/                                                    00019 
      IF(DEBUG) TYPE 101,NCHR                                             00020 
101   FORMAT(' WRITE8. NCHR = ',I5)                                       00021 
C                                                                         00022 
      IF (NCHR .LT. MIN) GOTO 740                                         00023 
      IF (NCHR .GT. MAX) GOTO 720                                         00024 
C                                                                         00025 
C                                                                         00026 
00150 ASSIGN 32757 TO I32758                                              00027 
      GO TO 32758                                                         00027 
C                                                                         00028 
C                                                                         00029 
32757 IF (MAGERR)  GOTO 700                                               00030 
C                                                                         00031 
      KTBLK=KTBLK+1                                                       00032 
C                                                                         00033 
C                                                                         00034 
      IF (WEOF .EQ. 0) RETURN                                             00035 
C                                                                         00036 
C                                                                         00037 
      ASSIGN 32755 TO I32756                                              00038 
      GO TO 32756                                                         00038 
32755 IF (MAGERR) GOTO 700                                                00039 
        RETURN                                                            00040 
C                                                                         00041 
C                                                                         00042 
700   TYPE 701,MTSUCL,MTPNDL,MTEOFL,MTDSEL,MTIOEL,MTERRL,                 00043 
     1MTWAIT                                                              00044 
701   FORMAT(' MTSUCL=',L1,' MTPNDL=',L1,' MTEOFL=',L1,                   00045 
     1' MTDSEL=',L1,' MTIOEL=',L1,' MTERRL=',L1,' MTWAIT=',L1)            00046 
710   TYPE 711,MTIOS1,MTIOS2                                              00047 
711   FORMAT(' MTIOS1=',O16,' MTIOS2=',O16)                               00048 
      ASSIGN 32753 TO I32754                                              00049 
      GO TO 32754                                                         00049 
C                                                                         00050 
C                                                                         00051 
32753 CONTINUE                                                            00052 
720   TYPE 721,NCHR,MAX                                                   00052 
721   FORMAT(' WRITE8 REQ TOO BIG:',2I6)                                  00053 
      NCHR=MAX                                                            00054 
      GOTO 150                                                            00055 
C                                                                         00056 
C                                                                         00057 
740   TYPE 741,NCHR,MIN                                                   00058 
741   FORMAT(' WRITE8 REQ TOO SML:',2I6)                                  00059 
      NCHR=MIN                                                            00060 
      GOTO 150                                                            00061 
C                                                                         00062 
C                                                                         00063 
C     M T W R I T . F L X                                                 00064 
C                                                                         00065 
C                                                                         00066 
C     NOTE ** INCLUDE MTFCB.FTN COMMON DEFINITION                         00067 
C     MAGTAPE PROCEDURES TO WRITE A TAPE                                  00068 
C                                                                         00069 
C                                                                         00070 
32756 CONTINUE                                                            00071 
      MAGERR = .FALSE.                                                    00072 
      CALL MTEOF( MTLUN,ISTAT )                                           00073 
      IF(.NOT.( MTERRL )) GO TO 32752                                     00074 
      ASSIGN 32750 TO I32751                                              00074 
      GO TO 32751                                                         00074 
32750 CONTINUE                                                            00074 
32752 GO TO I32756                                                        00075 
C                                                                         00076 
C                                                                         00077 
32758 CONTINUE                                                            00078 
      MAGERR = .FALSE.                                                    00079 
      CALL MTWLB( MTLUN,WBUFR,NCHR,ISTAT )                                00080 
      IF(.NOT.( MTERRL )) GO TO 32749                                     00081 
      ASSIGN 32747 TO I32748                                              00081 
      GO TO 32748                                                         00081 
32747 CONTINUE                                                            00081 
32749 GO TO I32758                                                        00082 
C*******************                                                      00083 
C                                                                         00084 
C                                                                         00085 
C     ERROR HANDLERS                                                      00086 
C                                                                         00087 
C                                                                         00088 
32751 CONTINUE                                                            00089 
      CALL ERROR( TTLUN,'WRITE MAGTAPE END-OF-FILE FAILED',MTDSW,MTIOS )  00090 
      ASSIGN 32745 TO I32746                                              00091 
      GO TO 32746                                                         00091 
32745 GO TO I32751                                                        00092 
C                                                                         00093 
C                                                                         00094 
32748 CONTINUE                                                            00095 
      CALL ERROR( TTLUN,'WRITE MAGTAPE FAILED',MTDSW,MTIOS )              00096 
      ASSIGN 32744 TO I32746                                              00097 
      GO TO 32746                                                         00097 
32744 GO TO I32748                                                        00098 
C                                                                         00099 
C                                                                         00100 
32754 CONTINUE                                                            00101 
      CALL MTDET( MTLUN,ISTAT )                                           00102 
      CALL EXIT                                                           00103 
      GO TO I32754                                                        00104 
C                                                                         00105 
C                                                                         00106 
32746 CONTINUE                                                            00107 
      MAGERR = .TRUE.                                                     00108 
      GO TO I32746                                                        00109 
      END                                                                 00110 
