      SUBROUTINE REOF12                                                   00001 
C                                                                         00002 
CC    THIS SUBROUTINE READS AN EOF MARK,                                  00003 
CC    EOF1 AND EOF2 RECORDS. VERIFIES FILE                                00004 
CC    IDENTIFIER, FILE-RET IDENTIFIER, BLOCK                              00005 
CC    AND RECORD LENGTH.                                                  00006 
C                                                                         00007 
CC    LBUFR AND DATA INITIALIZATION                                       00008 
C                                                                         00009 
      INCLUDE 'SY:BCOM.FTN'                                               00010 
      INCLUDE 'SY:FLGCM.FTN'                                              00011 
      INCLUDE 'SY:LABCM.FTN'                                              00012 
      INCLUDE 'SY:MTCOMM.FTN'                                             00013 
      INCLUDE 'SY:MTFCB.FTN'                                              00014 
C                                                                         00015 
C                                                                         00016 
      LOGICAL*1 LVOL1(80)                                                 00017 
      EQUIVALENCE (IVOL1,LVOL1)                                           00018 
      DATA NBUFER/2800/                                                   00019 
      DATA EOF1,EOF2/4HEOF1,4HEOF2/                                       00020 
C                                                                         00021 
CC    IDENTIFY ROUTINE                                                    00022 
C                                                                         00023 
      IF (DEBUG) TYPE 1                                                   00024 
1     FORMAT (' REOF12')                                                  00025 
C                                                                         00026 
CC    READ AND VERIFY EOF1 LABEL RECORD                                   00027 
C                                                                         00028 
      ASSIGN 32757 TO I32758                                              00029 
      GO TO 32758                                                         00029 
32757 CALL STRCOM (BUFR(1), EOF1, 4, IRET)                                00030 
      IF(IRET.EQ.0) GO TO 32756                                           00031 
      TYPE 3, BUFR(1)                                                     00032 
3     FORMAT (' *EOF1* RECORD NOT FOUND, FOUND INSTEAD WAS ',A4/)         00033 
      ASSIGN 32754 TO I32755                                              00034 
      GO TO 32755                                                         00034 
32754 CONTINUE                                                            00035 
C                                                                         00036 
CC    VERIFY FILE IDENTIFIER                                              00037 
C                                                                         00038 
32756 IF(.NOT.(LABFLG .EQ. 0)) GO TO 32753                                00039 
      DO 32752 I=1,17                                                     00040 
      LBDATA(I) = DDFNAM(I)                                               00040 
32752 CONTINUE                                                            00040 
32753 IF(.NOT.(LABFLG .EQ. 1)) GO TO 32751                                00042 
      DO 32750 I=1,17                                                     00043 
      LBDATA(I) = DFNAME(I)                                               00043 
32750 CONTINUE                                                            00043 
32751 CALL STRCOM (LBUFR(5),LBDATA(1),17,IRET)                            00045 
      IF(IRET.EQ.0) GO TO 32749                                           00046 
      TYPE 4, (LBDATA(L), L=1,17), (LBUFR(K), K=5,21)                     00047 
4     FORMAT (' FILE IDENTIFIER IS NOT AS EXPECTED'/                      00048 
     1 ' EXPECTED VALUE:  ',17A1,10X,' TAPE VALUE:  ',17A1/)              00049 
C                                                                         00051 
CC    VERIFY FILE-SET IDENTIFIER (VOLUME IDENTIFIER FROM VOL1 LABEL)      00052 
C                                                                         00053 
32749 CALL STRCOM (LBUFR(22),VSNLST(1),6,IRET)                            00054 
      IF(IRET.EQ.0) GO TO 32748                                           00055 
      TYPE 5, (VSNLST(L),L=1,6), (LBUFR(K),K=22,27)                       00056 
5     FORMAT (' FILE-SET IDENTIFIER IS NOT AS EXPECTED'/                  00057 
     1 ' EXPECTED VALUE:  ',6A1,10X,' TAPE VALUE:  ',6A1/)                00058 
      ASSIGN 32747 TO I32755                                              00059 
      GO TO 32755                                                         00059 
32747 CONTINUE                                                            00060 
C                                                                         00061 
CC    NOW CHECK EOF2 LABEL RECORD                                         00062 
C                                                                         00063 
32748 ASSIGN 32746 TO I32758                                              00064 
      GO TO 32758                                                         00064 
C                                                                         00065 
CC    VERIFY EOF2 RECORD                                                  00066 
C                                                                         00067 
32746 CALL STRCOM (BUFR(1),EOF2,4,IRET)                                   00068 
      IF(IRET.EQ.0) GO TO 32745                                           00069 
      TYPE 6, BUFR(1)                                                     00070 
6     FORMAT (' *EOF2* RECORD NOT FOUND, FOUND INSTEAD WAS ',A4/)         00071 
      ASSIGN 32744 TO I32755                                              00072 
      GO TO 32755                                                         00072 
32744 CONTINUE                                                            00073 
C                                                                         00074 
CC    OBTAIN BLOCK LENGTH                                                 00075 
C                                                                         00076 
32745 DECODE (5,7,LBUFR(6)) IBLOCL                                        00077 
7     FORMAT (I5)                                                         00078 
      IF(IBLOCL.LE.2046) GO TO 32743                                      00079 
      TYPE 8, IBLOCL                                                      00080 
8     FORMAT (' BLOCK LENGTH = ',I5,' (SHOULD BE .LE. 2046)'/)            00081 
C                                                                         00083 
CC    OBTAIN RECORD LENGTH                                                00084 
C                                                                         00085 
32743 DECODE (5,7,LBUFR(11)) IRECL                                        00086 
      IF(IRECL.LE.2046) GO TO 32742                                       00087 
      TYPE 9, IRECL                                                       00088 
9     FORMAT (' RECORD LENGTH = ',I5,' (SHOULD BE .LE. 2046)'/)           00089 
C                                                                         00091 
CC    READ EOF MARK                                                       00092 
C                                                                         00093 
32742 ASSIGN 32741 TO I32758                                              00094 
      GO TO 32758                                                         00094 
32741 IF(MAGEND) GO TO 32740                                              00095 
      MAGEND = .FALSE.                                                    00096 
      TYPE 10                                                             00097 
10    FORMAT (' NO EOF MARK AFTER EOF2')                                  00098 
      ASSIGN 32739 TO I32755                                              00099 
      GO TO 32755                                                         00099 
32739 CONTINUE                                                            00100 
32740 LABFLG = 1                                                          00101 
      RETURN                                                              00102 
32758 CONTINUE                                                            00103 
      ASSIGN 32737 TO I32738                                              00103 
      GO TO 32738                                                         00103 
32737 GO TO I32758                                                        00103 
32738 CONTINUE                                                            00104 
      MAGERR = .FALSE.                                                    00105 
      NBUFER=2800                                                         00106 
      CALL MTRLB(MTLUN,LBUFR,NBUFER,ISTAT)                                00107 
      IF(.NOT.(ISTAT.EQ.0)) GO TO 32736                                   00108 
      MAGEND = .FALSE.                                                    00109 
      NBUFER = MTIOS(2)                                                   00110 
32736 IF(.NOT.(ISTAT.EQ.1)) GO TO 32735                                   00112 
      ASSIGN 32733 TO I32734                                              00112 
      GO TO 32734                                                         00112 
32733 CONTINUE                                                            00112 
32735 IF(.NOT.(ISTAT.EQ.2)) GO TO 32732                                   00113 
      IF(.NOT.(MTIOS(1).NE.MTEOFS)) GO TO 32730                           00114 
      ASSIGN 32729 TO I32734                                              00114 
      GO TO 32734                                                         00114 
32729 GO TO 32731                                                         00114 
32730 MAGEND = .TRUE.                                                     00115 
32731 CONTINUE                                                            00116 
32732 GO TO I32738                                                        00117 
32734 CONTINUE                                                            00118 
      CALL ERROR (TTLUN,'READ MAGTAPE FAILED',MTDSW,MTIOS)                00119 
      ASSIGN 32727 TO I32728                                              00120 
      GO TO 32728                                                         00120 
32727 GO TO I32734                                                        00121 
32728 CONTINUE                                                            00122 
      MAGERR = .TRUE.                                                     00123 
      GO TO I32728                                                        00124 
32755 CONTINUE                                                            00125 
      IABORT = 1                                                          00126 
      IF (IABORT .EQ. 1) STOP                                             00127 
      GO TO I32755                                                        00128 
      END                                                                 00129 
