PROGRAM OTSMOD C C This program reads a map file of a task and identifies C the Fortran-77 (or Fortran-4-Plus) OTS modules used C to simplify the generation of an overlayed OTS. C C To use, generate a map of the task with the /MA switch: C C TKB NL:,SY:task/MA=task C C This will create a map file which has the I.D.'s of all C the object modules. Then run this program, and give the C map file as the input file: it will search out all of C the modules which start with an I.D. of "F77" or "F4P", C sort them by name, and eliminate duplicates. C C B. Z. Lederman I.T.T. World Communications 10-SEP-82 C IMPLICIT INTEGER (A-Z) BYTE FILNAM(40), OPTNAM(40) BYTE NAME(8,200), X REAL*8 NAM8(200) BYTE RECORD(64) C EQUIVALENCE (NAM8, NAME) C C Insure the name array is clear. C DO 10 I=1,200 10 NAM8(I)=' ' C COUNT=0 C WRITE (5, 100) 100 FORMAT('$ Input file name: ') READ (5, 110, END=999) FILNAM 110 FORMAT (40A1) FILNAM(40)=0 C OPEN (UNIT=1, FILE=FILNAM, STATUS='OLD', READONLY) C C Go through the map file one record at a time. C 200 READ (1, 210, END=300, ERR=200) MAX, RECORD 210 FORMAT (Q, 64A1) C C The records we want must be at least 61 bytes long. C IF (MAX.LT.61) GOTO 200 C C Check to see if the module came from "F77" or "F4P" C IF (RECORD(59).NE.'F') GOTO 200 IF (RECORD(60).EQ.'4'.AND.RECORD(61).EQ.'P') GOTO 220 IF (RECORD(60).EQ.'7'.AND.RECORD(61).EQ.'7') GOTO 220 GOTO 200 C C Move the module name into the array. C 220 COUNT=COUNT+1 IF (COUNT.GT.200) GOTO 300 DO 230 I=1,6 230 NAME(I,COUNT)=RECORD(I+51) C C Get next record. C GOTO 200 C C All records have been read. C 300 CLOSE (UNIT=1) C C If there was no data, finish. C IF (COUNT.LE.0) GOTO 999 C C Sort the names. C This is a "SHELL" sort, and is quite fast. C C The first "jump" is the largest power of 2 (minus one) C which is less than the number of elements to be sorted. C M=1 320 IF ((2**M).GT.COUNT) GO TO 330 M=M+1 GO TO 320 330 M=M-1 M=2**M M=M-1 C 340 K=COUNT-M DO 350 J=1,K DO 360 I=J,1,-(M) C Test each byte in the name. DO 370 L=1,6 C If any byte is "LT", names must be exchanged IF (NAME(L,I+M).LT.NAME(L,I)) GOTO 380 C If any byte is "GT", names need not be exhanged. IF (NAME(L,I+M).GT.NAME(L,I)) GOTO 350 370 CONTINUE C If all bytes are equal, names are not exhanged. GOTO 350 C Exchange the two names. 380 DO 390 L=1,6 X=NAME(L,I) NAME(L,I)=NAME(L,I+M) 390 NAME(L,I+M)=X 360 CONTINUE 350 CONTINUE M=M/2 IF (M.GT.0) GO TO 340 C C Open the output file. C WRITE (5, 400) 400 FORMAT ('$ Enter output file name: ') READ (5, 110, END=999) OPTNAM OPTNAM(40)=0 OPEN (UNIT=1, FILE=OPTNAM, STATUS='NEW', CARRIAGECONTROL='LIST') C C Go through the data, write out the file names skipping duplicates. C WRITE (1, 410) FILNAM 410 FORMAT('Fortran OTS modules from ', 40A1) C C Write out the first name. WRITE (1, 420) (NAME(J,1),J=1,6) 420 FORMAT(1X, 6A1) IF (COUNT.LE.1) GOTO 500 C C For all of the rest of the names, if the name is not the C same as the previous name, print it out. REAL*8 equivalence C makes the comparisons easier. C DO 430 I=2,COUNT IF (NAM8(I).EQ.NAM8(I-1)) GOTO 430 WRITE (1, 420) (NAME(J,I), J=1,6) 430 CONTINUE C C All done. C 500 CLOSE (UNIT=1) 999 STOP END