C ***** This is the routine in the WaveForm Program ***** C ***** that processes the Repeat phrases in the ***** C ***** Data Section of a Timing Specification file. ***** C ***** ***** C ***** MTG WaveForm Program Rev. 20-OCT-1991 ***** SUBROUTINE Process_Repeat C ***************************************** C Define all Variables and Arrays C ***************************************** IMPLICIT NONE INCLUDE 'WaveForm_Common.INC' INTEGER*2 ChDigit(2),ChNum,CurrentChr INTEGER*4 Time_Digit(4),Time_Cell INTEGER*4 Starting_With,Through,Copied_to,Cell_Point,Got_It C ************************************************************ C Advertize that processing of a Repeat phrase will start C ************************************************************ IF ( Full_Display .EQ. 0 ) GOTO 35 WRITE ( 6, 25 ) 25 FORMAT ( //, & ' Processing a Repeat phrase will now start. ', // ) 35 CONTINUE C Test the first characters to see if they are: "Repeat Channel #" IF ( ThisLine(1) .EQ. 'R' .AND. & ThisLine(2) .EQ. 'E' .AND. & ThisLine(3) .EQ. 'P' .AND. & ThisLine(4) .EQ. 'E' .AND. & ThisLine(5) .EQ. 'A' .AND. & ThisLine(6) .EQ. 'T' .AND. & ThisLine(7) .EQ. 'C' .AND. & ThisLine(8) .EQ. 'H' .AND. & ThisLine(9) .EQ. 'A' .AND. & ThisLine(10) .EQ. 'N' .AND. & ThisLine(11) .EQ. 'N' .AND. & ThisLine(12) .EQ. 'E' .AND. & ThisLine(13) .EQ. 'L' .AND. & ThisLine(14) .EQ. '#' ) GOTO 80 C This does NOT look like the beginning of an Repeat record GOTO 900 C This DOES look like the beginning of a Repeat record. C Find the Channel Number in the beginning of the Repeat record. C Test if there are one or two digits of Channel Number. 80 IF ( ICHAR( ThisLine(15) ) .GE. '30'X .AND. & ICHAR( ThisLine(15) ) .LE. '39'X .AND. & ICHAR( ThisLine(16) ) .GE. '30'X .AND. & ICHAR( ThisLine(16) ) .LE. '39'X ) GOTO 85 IF ( ICHAR( ThisLine(15) ) .GE. '30'X .AND. & ICHAR( ThisLine(15) ) .LE. '39'X ) GOTO 87 GOTO 900 C There are TWO digits of Channel Number 85 ChDigit(1) = ( ICHAR( ThisLine(15) ) ) - '30'X ChDigit(2) = ( ICHAR( ThisLine(16) ) ) - '30'X CurrentChr = 17 IF ( ThisLine(CurrentChr) .NE. ',' ) GOTO 900 GOTO 90 C There is ONE digit of Channel Number 87 ChDigit(1) = 0 ChDigit(2) = ( ICHAR( ThisLine(15) ) ) - '30'X CurrentChr = 16 IF ( ThisLine(CurrentChr) .NE. ',' ) GOTO 900 GOTO 90 C Now put together the two digits of the Channel Number 90 ChNum = ( ChDigit(1) * 10 ) + ( ChDigit (2) ) C Now verify that the MTG Channel Number is with in range IF ( ChNum .GT. 32 ) GOTO 92 IF ( ChNum .LT. 1 ) GOTO 92 GOTO 94 92 WRITE ( 6, 93 ) 93 FORMAT ( /, ' Illegal Channel Number was found. ', / ) GOTO 900 C Now move Channels (9...16) or (17...24) or (25...32) to Channels (1...8) 94 DO WHILE ( ChNum .GT. 8 ) ChNum = ChNum - 8 END DO C Now display the Channel Number IF ( Full_Display .EQ. 0 ) GOTO 97 WRITE ( 6, 95 ) ChNum 95 FORMAT ( /, ' Channel Number to be Repeated is = ', I4 ) 97 CONTINUE C ***** Now that we have the Channel Number and the Current ***** C ***** Character pointer is positioned before the "Starting ***** C ***** _with" part of the Repeat phrase. First verify that ***** C ***** the "Starting_with" part of the phrase is next. ***** IF ( ThisLine(CurrentChr + 1) .EQ. 'S' .AND. & ThisLine(CurrentChr + 2) .EQ. 'T' .AND. & ThisLine(CurrentChr + 3) .EQ. 'A' .AND. & ThisLine(CurrentChr + 4) .EQ. 'R' .AND. & ThisLine(CurrentChr + 5) .EQ. 'T' .AND. & ThisLine(CurrentChr + 6) .EQ. 'I' .AND. & ThisLine(CurrentChr + 7) .EQ. 'N' .AND. & ThisLine(CurrentChr + 8) .EQ. 'G' .AND. & ThisLine(CurrentChr + 9) .EQ. '_' .AND. & ThisLine(CurrentChr + 10) .EQ. 'W' .AND. & ThisLine(CurrentChr + 11) .EQ. 'I' .AND. & ThisLine(CurrentChr + 12) .EQ. 'T' .AND. & ThisLine(CurrentChr + 13) .EQ. 'H' ) GOTO 110 C This does NOT look like the "Starting_with" phrase in a Repeat RECORD. GOTO 900 C This DOES look like the "Starting_with" phrase of a Repeat record. 110 CurrentChr = CurrentChr + 13 C ***** Now find the Time Cell number that follows ***** C ***** the "Starting_with" part of the Repeat phrase. ***** ASSIGN 120 TO Got_It GOTO 700 120 CONTINUE Starting_with = Time_Cell C ***** The Current Character pointer is positioned before ***** C ***** the "Through" part of the Repeat phrase. First ***** C ***** verify that the "Through" part of the phrase is next. ***** IF ( ThisLine(CurrentChr + 1) .EQ. 'T' .AND. & ThisLine(CurrentChr + 2) .EQ. 'H' .AND. & ThisLine(CurrentChr + 3) .EQ. 'R' .AND. & ThisLine(CurrentChr + 4) .EQ. 'O' .AND. & ThisLine(CurrentChr + 5) .EQ. 'U' .AND. & ThisLine(CurrentChr + 6) .EQ. 'G' .AND. & ThisLine(CurrentChr + 7) .EQ. 'H' ) GOTO 130 C This does NOT look like the "Through" phrase in a Repeat record. GOTO 900 C This DOES look like the "Through" phrase of a Repeat record. 130 CurrentChr = CurrentChr + 7 C ***** Now find the Time Cell number that follows ***** C ***** the "Through" part of the Repeat phrase. ***** ASSIGN 140 TO Got_It GOTO 700 140 CONTINUE Through = Time_Cell C ***** The Current Character pointer is positioned before ***** C ***** the "Copied_to" part of the Repeat phrase. First ***** C ***** verify that the "Copied_to" part of the phrase is next. ***** IF ( ThisLine(CurrentChr + 1) .EQ. 'C' .AND. & ThisLine(CurrentChr + 2) .EQ. 'O' .AND. & ThisLine(CurrentChr + 3) .EQ. 'P' .AND. & ThisLine(CurrentChr + 4) .EQ. 'I' .AND. & ThisLine(CurrentChr + 5) .EQ. 'E' .AND. & ThisLine(CurrentChr + 6) .EQ. 'D' .AND. & ThisLine(CurrentChr + 7) .EQ. '_' .AND. & ThisLine(CurrentChr + 8) .EQ. 'T' .AND. & ThisLine(CurrentChr + 9) .EQ. 'O' ) GOTO 150 C This does NOT look like the "Copied_to" phrase in a Repeat record. GOTO 900 C This DOES look like the "Copied_to" phrase of a Repeat record. 150 CurrentChr = CurrentChr + 9 C ***** Now find the Time Cell number that follows ***** C ***** the "Copied_to" part of the Repeat phrase. ***** ASSIGN 160 TO Got_It GOTO 700 160 CONTINUE Copied_to = Time_Cell C Now display the Time Cell Numbers of the "Starting_with", the "Through", C and the "Copied_to" parts of the Repeat phrase. IF ( Full_Display .EQ. 0 ) GOTO 180 WRITE ( 6, 173 ) Starting_with 173 FORMAT ( /, ' Time_cell Number for Starting_with is = ', I4 ) WRITE ( 6, 175 ) Through 175 FORMAT ( ' Time_cell Number for Through is = ', I4 ) WRITE ( 6, 177 ) Copied_to 177 FORMAT ( ' Time_cell Number for Copied_to is = ', I4, / ) 180 CONTINUE C ***** Now verify that the "Starting_with", the "Through", and ***** C ***** "Copied_to" Timing_Cell Numbers all have the proper ***** C ***** relative relationship. ***** IF ( Starting_with .GE. Through ) GOTO 950 IF ( Through .GE. Copied_to ) GOTO 950 IF ( ((Through - Starting_with) + Copied_to) .GT. 2047 ) & GOTO 950 C ***** Now do the operations on the Pulse_Array to implement ***** C ***** this repeat phrase. ***** DO Cell_Point=Starting_with,Through,1 Pulse_Array(ChNum,Copied_to) = Pulse_Array(ChNum,Cell_Point) Copied_to = Copied_to + 1 END DO C ***** Now return to the calling routine ****** IF ( Full_Display .EQ. 0 ) GOTO 535 WRITE ( 6, 525 ) 525 FORMAT ( /, & ' This is a normal exit from the process Repeat. ', / ) 535 CONTINUE RETURN C ***** This is the routine that can read the Time Cell number. ***** C ***** This number may be 1, 2, 3, or 4 digits long but it ***** C ***** must be in the range of 0 through 2047. ***** 700 IF ( ICHAR( ThisLine(CurrentChr + 1) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 1) ) .LE. '39'X .AND. & ICHAR( ThisLine(CurrentChr + 2) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 2) ) .LE. '39'X .AND. & ICHAR( ThisLine(CurrentChr + 3) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 3) ) .LE. '39'X .AND. & ICHAR( ThisLine(CurrentChr + 4) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 4) ) .LE. '39'X ) GOTO 754 IF ( ICHAR( ThisLine(CurrentChr + 1) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 1) ) .LE. '39'X .AND. & ICHAR( ThisLine(CurrentChr + 2) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 2) ) .LE. '39'X .AND. & ICHAR( ThisLine(CurrentChr + 3) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 3) ) .LE. '39'X ) GOTO 753 IF ( ICHAR( ThisLine(CurrentChr + 1) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 1) ) .LE. '39'X .AND. & ICHAR( ThisLine(CurrentChr + 2) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 2) ) .LE. '39'X ) GOTO 752 IF ( ICHAR( ThisLine(CurrentChr + 1) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 1) ) .LE. '39'X ) GOTO 751 GOTO 900 C There is ONE digit of Time Cell Number 751 Time_Digit(1) = 0 Time_Digit(2) = 0 Time_Digit(3) = 0 Time_Digit(4) = ( ICHAR( ThisLine(CurrentChr + 1) ) ) - '30'X CurrentChr = CurrentChr + 1 GOTO 760 C There are TWO digits of Time Cell Number 752 Time_Digit(1) = 0 Time_Digit(2) = 0 Time_Digit(3) = ( ICHAR( ThisLine(CurrentChr + 1) ) ) - '30'X Time_Digit(4) = ( ICHAR( ThisLine(CurrentChr + 2) ) ) - '30'X CurrentChr = CurrentChr + 2 GOTO 760 C There are THREE digits of Time Cell Number 753 Time_Digit(1) = 0 Time_Digit(2) = ( ICHAR( ThisLine(CurrentChr + 1) ) ) - '30'X Time_Digit(3) = ( ICHAR( ThisLine(CurrentChr + 2) ) ) - '30'X Time_Digit(4) = ( ICHAR( ThisLine(CurrentChr + 3) ) ) - '30'X CurrentChr = CurrentChr + 3 GOTO 760 C There are FOUR digits of Time Cell Number 754 Time_Digit(1) = ( ICHAR( ThisLine(CurrentChr + 1) ) ) - '30'X Time_Digit(2) = ( ICHAR( ThisLine(CurrentChr + 2) ) ) - '30'X Time_Digit(3) = ( ICHAR( ThisLine(CurrentChr + 3) ) ) - '30'X Time_Digit(4) = ( ICHAR( ThisLine(CurrentChr + 4) ) ) - '30'X CurrentChr = CurrentChr + 4 GOTO 760 C Now put together the 4 Time Digits to make the Time Cell number 760 Time_Cell = ( Time_Digit(1) * 1000 ) + $ ( Time_Digit(2) * 100 ) + $ ( Time_Digit(3) * 10 ) + $ ( Time_Digit(4) * 1 ) C Now verify that this Time Cell Number is with in range IF ( Time_Cell .GT. 2047 ) GOTO 765 IF ( Time_cell .LT. 0 ) GOTO 765 GOTO 769 765 WRITE ( 6, 767 ) 767 FORMAT ( /, ' Illegal Time Cell Number was found. ', / ) GOTO 900 769 CONTINUE GOTO Got_It C ***** This is the end of the routine that reads a 1, 2, 3, or 4 ***** C ***** digit time-cell number. ***** C *********************************************************************** C Error exit because of trouble processing a Repeat record. C *********************************************************************** 950 WRITE ( 6, 955 ) 955 FORMAT ( /, ' Error in the relative Timing_Cell Number ', /, & ' of the Starting_with, Through, or ', /, & ' Copied_to parameters in a Repeat phrase. ', /, & ' This is a fatal error. No output files. ', / ) CLOSE ( UNIT=10 ) GOTO 998 900 WRITE ( 6, 905 ) 905 FORMAT ( /, & ' Illegal syntax was found in a Repeat ', / & ' record. This is a fatal error. ', / & ' No output files will be produced. ', / ) CLOSE ( UNIT=10 ) 998 WRITE ( 6, 999 ) 999 FORMAT ( / ' MTG WaveForm Program will now exit. ', // ) STOP ' ' END