C ***** This is the routine in the WaveForm Program ***** C ***** that processes the Up_At and the Down_At ***** C ***** phrases in the Data Section of a Timing ***** C ***** Specification file. ***** C ***** ***** C ***** MTG WaveForm Program Rev. 19-OCT-1991 ***** SUBROUTINE Process_Up_Down_At C ***************************************** C Define all Variables and Arrays C ***************************************** IMPLICIT NONE INCLUDE 'WaveForm_Common.INC' INTEGER*2 ChNum,ChDigit(2),CurrentChr,Pulse_Data INTEGER*4 Time_Cell,Time_Digit(4),Cell_Point C *********************************************************************** C Advertize that processing of an Up_At or Down_At phrase will start C *********************************************************************** IF ( Full_Display .EQ. 0 ) GOTO 35 WRITE ( 6, 25 ) 25 FORMAT ( /, & ' Processing Up_At or Down_At will now start. ' ) 35 CONTINUE C *********************************************************************** C Get the Channel Number from the beginning of the up_down_at C record and convert it from ASCII to binary. C *********************************************************************** C Test the first characters to see if they are: "Channel #" 105 IF ( ThisLine(1) .EQ. 'C' .AND. & ThisLine(2) .EQ. 'H' .AND. & ThisLine(3) .EQ. 'A' .AND. & ThisLine(4) .EQ. 'N' .AND. & ThisLine(5) .EQ. 'N' .AND. & ThisLine(6) .EQ. 'E' .AND. & ThisLine(7) .EQ. 'L' .AND. & ThisLine(8) .EQ. '#' ) GOTO 150 C This does NOT look like the beginning of an Up_Down_At record GOTO 900 C This DOES look like the beginning of an Up_Down_At record C Find the Channel Number at the beginning of the up_down_at record C Test if there are one or two digits of Channel Number. 150 IF ( ICHAR( ThisLine(9) ) .GE. '30'X .AND. & ICHAR( ThisLine(9) ) .LE. '39'X .AND. & ICHAR( ThisLine(10) ) .GE. '30'X .AND. & ICHAR( ThisLine(10) ) .LE. '39'X ) GOTO 170 IF ( ICHAR( ThisLine(9) ) .GE. '30'X .AND. & ICHAR( ThisLine(9) ) .LE. '39'X ) GOTO 180 GOTO 900 C There are TWO digits of Channel Number 170 ChDigit(1) = ( ICHAR( ThisLine(9) ) ) - '30'X ChDigit(2) = ( ICHAR( ThisLine(10) ) ) - '30'X CurrentChr = 11 IF ( ThisLine(CurrentChr) .NE. ',' ) GOTO 900 GOTO 190 C There is ONE digit of Channel Number 180 ChDigit(1) = 0 ChDigit(2) = ( ICHAR( ThisLine(9) ) ) - '30'X CurrentChr = 10 IF ( ThisLine(CurrentChr) .NE. ',' ) GOTO 900 GOTO 190 C Now put together the two digits of the Channel Number 190 ChNum = ( ChDigit(1) * 10 ) + ( ChDigit (2) ) C Now verify that the MTG Channel Number is with in range IF ( ChNum .GT. 32 ) GOTO 192 IF ( ChNum .LT. 1 ) GOTO 192 GOTO 194 192 WRITE ( 6, 193 ) 193 FORMAT ( /, ' Illegal Channel Number was found. ', / ) GOTO 900 C Now move Channels (9...16) or (17...24) or (25...32) to Channels (1...8) 194 DO WHILE ( ChNum .GT. 8 ) ChNum = ChNum - 8 END DO C Now display the Channel Number IF ( Full_Display .EQ. 0 ) GOTO 197 WRITE ( 6, 195 ) ChNum 195 FORMAT ( /, ' Channel Number = ', I4 ) 197 CONTINUE C ***** Now that we have the Channel Number and the Current ***** C ***** Character pointer is before the Up_At or Down_At ***** C ***** key word; decode the key work. ***** 200 IF ( ThisLine(CurrentChr + 1) .EQ. 'U' .AND. & ThisLine(CurrentChr + 2) .EQ. 'P' .AND. & ThisLine(CurrentChr + 3) .EQ. '_' .AND. & ThisLine(CurrentChr + 4) .EQ. 'A' .AND. & ThisLine(CurrentChr + 5) .EQ. 'T' ) GOTO 210 IF ( ThisLine(CurrentChr + 1) .EQ. 'D' .AND. & ThisLine(CurrentChr + 2) .EQ. 'O' .AND. & ThisLine(CurrentChr + 3) .EQ. 'W' .AND. & ThisLine(CurrentChr + 4) .EQ. 'N' .AND. & ThisLine(CurrentChr + 5) .EQ. '_' .AND. & ThisLine(CurrentChr + 6) .EQ. 'A' .AND. & ThisLine(CurrentChr + 7) .EQ. 'T' ) GOTO 220 GOTO 900 C This is an Up_At key word command 210 IF ( Full_Display .EQ. 0 ) GOTO 217 WRITE ( 6, 215 ) 215 FORMAT ( /, ' This is an Up_At keyword command. ' ) 217 CONTINUE Pulse_Data = 1 CurrentChr = CurrentChr + 5 GOTO 230 C This is an Down_At key word command 220 IF ( Full_Display .EQ. 0 ) GOTO 227 WRITE ( 6, 225 ) 225 FORMAT ( /, ' This is an Down_At keyword command. ' ) 227 CONTINUE Pulse_Data = 0 CurrentChr = CurrentChr + 7 GOTO 230 C ***** Now find the number of the Time Cell that follows the ***** C ***** Up-Down key word. The Time Cell number may be 1, 2, 3, or ***** C ***** digits long but it must be in the range of 0 through 2047. ***** 230 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 254 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 253 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 252 IF ( ICHAR( ThisLine(CurrentChr + 1) ) .GE. '30'X .AND. & ICHAR( ThisLine(CurrentChr + 1) ) .LE. '39'X ) GOTO 251 GOTO 900 C There is ONE digit of Time Cell Number 251 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 260 C There are TWO digits of Time Cell Number 252 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 260 C There are THREE digits of Time Cell Number 253 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 260 C There are FOUR digits of Time Cell Number 254 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 260 C Now put together the 4 Time Digits to make the Time Cell number 260 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 265 IF ( Time_cell .LT. 0 ) GOTO 265 GOTO 269 265 WRITE ( 6, 267 ) 267 FORMAT ( /, ' Illegal Time Cell Number was found. ', / ) GOTO 900 269 CONTINUE C Now display the Time Cell Number IF ( Full_Display .EQ. 0 ) GOTO 275 WRITE ( 6, 273 ) Time_Cell 273 FORMAT ( /, ' Time_cell Number = ', I4 ) 275 CONTINUE C ***** Now "Update" the Pulse Array with ***** C ***** this new timing specification. ***** DO Cell_point=Time_Cell,2047,1 Pulse_Array ( ChNum, Cell_Point ) = Pulse_Data END DO C ***** Now find out if there are more Timing Specifications ***** C ***** to process, or is this the end of the record. ***** C ***** If no more character in the record then just return. ***** C ***** If next character is a comment indicator then return. ***** C ***** If there are more charater and it is not a comment ***** C ***** then verify that it is a comma and then a key word. ***** C Are there more characters in the record? If not then return. IF ( CurrentChr .GE. NumChr ) GOTO 850 C OK, there are more characters. Is this just a comment? IF ( ThisLine(CurrentChr + 1) .EQ. ';' ) GOTO 310 IF ( ThisLine(CurrentChr + 1) .EQ. '!' ) GOTO 310 IF ( ThisLine(CurrentChr + 1) .EQ. '*' ) GOTO 310 C This does NOT look like a comment. It may be another Timing Specification GOTO 350 C This DOES look like a comment so let's return 310 IF ( Full_Display .EQ. 0 ) GOTO 320 WRITE ( 6, 315 ) 315 FORMAT ( /, ' Found a comment in an up_down_at command. ' ) 320 CONTINUE GOTO 850 C OK, there are more characters and they are not a comment so they C must be another Timing Specification or else there is an error. 350 IF ( ThisLine(CurrentChr + 1) .NE. ',' ) GOTO 900 CurrentChr = CurrentChr + 1 GOTO 200 C OK, either there are no more characters in this record or else there are C just comments left in this record, so let's return to the calling routine. 850 IF ( Full_Display .EQ. 0 ) GOTO 860 WRITE ( 6, 855 ) 855 FORMAT ( /, ' Normal exit from Up_Down_At routine. ', / ) 860 CONTINUE RETURN C *********************************************************************** C Error exit because of trouble processing and Up_Down_At record. C *********************************************************************** 900 WRITE ( 6, 905 ) 905 FORMAT ( /, & ' Illegal syntax was found in an up_at ', / & ' down_at 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