XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X X X 1. Adjust paper position so that dark frame on this page is X X copied centered on paper 8.5 inches wide by 11 inches X X high. X X 2. Copy all remaining pages of document in same manner. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX THERENBRUSERSGU HERENBRUSERSGUI E E G T R U DETHE NBRUS S E E NBRUSERSG H ENBRU R D H E T RENBR ERSGUI T RENBRU E ERENB E R D HEREN USERSG D HERENB I THERE RUSERS I T U ETHER BRUSER U ETHERENBR G DETHE NBRUSE G B IDETHEREN USERSGUIDETHERENBRUSERSGUIDETHERENBRUSERSG U ENBR T RENBRU R HERE SGU G DETHE NB SERSGUIDE RENBR E GUIDE ER BRUSE GU S IDETHE N USERSGUID RENB S SGUIDE E NBRUSE G R UIDET RE RUSERSGUI T REN U RSGUI TH ENBRU RS E THER RSGU ET RE R IDET USE S SGU ETHE NBRUSERSG DET R B SERSG DE ERE RU U RSGU ETH ENBRUSERS IDET N USERSG D HERE RU R ERSGU ET RENBRUSER UIDET E RUSER UI THERE RU B SERSGU E E GUIDET R RSGU ETHERE R NBRUSERSGUIDETHERENBRUSERSGUIDETHERENBRUSERSGUIDETHERENB E RUSERS IDET U H SERSGUI N R BRUSER UI THERENBR ERSGUIDET RENBR ERS IDETHERE E NBRUSE G DETHERENB SERSGUIDE ERENBR E GU H ENBRUS SG DETHEREN USERSGUID HEREN USE GUIDE T RENBRU RSGU HERE SGUI NBRUSER DET E ERENBR ERSGUIDE ER BRUSERSGU ETH ENBRUSERSGU ET D HERENB SERSGUIDE E NBRUSERSG DETH ENBRUSERSGU E ID HERE RUSERSGUI TH ENBRUSERS IDETH ENBRUSERS ID IDE ENBR IDET R UIDETH E SGU DETHERENBRUSERSGUIDETHERENBRUSERSGUIDETHERENBRUSERS IDE R ERSGUI T R IDET R GU ETHERENB SERSGU ETH ENB SERSG DE ERENBRUSE S IDETHEREN USERSG DET REN USERSG D H R UIDETHERE RUSERS IDE ERE RUSERS I THEREN E GUI R BRUSER UID HER BRUSER U E S SGUIDE E NBRUSE GUI THE NBRUSE G DETHER U RSGUID H ENBRUS SGU ETH ENBRUS S I RU RSGUI TH ENBR ERSG DET RENBR ER UIDETHERE RUS ETHE RUSE E RUSE R USERSGUIDETHERENBRUSERSGUIDETHERENBRUSERSGUIDETHE The RENBR User's Guide Donald E. Barth March 1985 Table of Contents ----- -- -------- Introduction . . . . . . . . . . . . . . . 1 Instructions for Use on the DECsystem10 Computer . . . 2 Switches Typed by User to Select Results . . . . . . 6 Input File Restrictions . . . . . . . . . . . 12 Supported Variations of Statement Structure . . . . . 17 Maintaining Logical Blocks of Statement Numbers . . . 19 Creating Logical Blocks of Statement Numbers . . . . 24 Maintaining Number Regions Keyed to Statement Types . . 25 Including NonFORTRAN Text in the Input File . . . . . 26 Statement Types Recognized by RENBR . . . . . . . 27 Appendix A: Sample Table of Contents and Listing . . . 31 Appendix B: List of Files Forming This Package . . . . 38 Appendix C: RENBR Development History . . . . . . . 43 Appendix D: Summaries Produced by the /Z Switch . . . 48 Appendix E: Instructions for the Support Programs . . . 50 Introduction ------------ RENBR is a program which can change the statement numbers in FORTRAN programs so that these numbers increase uniformly, and which can print listings of these programs. RENBR is itself written in FORTRAN. Although RENBR accepts instructions containing DECsystem10 file specifications, the routines which handle these file specifications can easily be removed or replaced if RENBR is to be used on other computers. RENBR can process programs and routines which are written in the FORTRAN-77 language, in the FORTRAN-IV language, and in some dialects of the older FORTRAN-II language. RENBR can also process programs and routines which use the FORTRAN language extensions allowed by version 7 of the DECsystem10 FORTRAN-10 compiler. RENBR will treat a character string consisting either of a leading decimal number followed by the letter H and then by the string, or else enclosed within matching apostrophes, as a single unit similar to a variable name. RENBR would recognize that the 56s and the 57s, but not the 55s, are statement numbers in either of the lines IF(A.EQ.10H)GO TO 55;)GO TO 56;GO TO 57 or IF(A.EQ.')GO TO 55;')GO TO 56;GO TO 57 where the first semicolon (the ; character) on each line is part of a character string but where the second semicolon on each line indicates that another statement follows on the same line. RENBR can also detect when a FORTRAN key word is instead being used as a variable or array name. RENBR would recognize that the variable named DO55I and the array location READ(5,10) are being assigned values in the following statements. DO 55 I=12 DO 55 I='5,10' DO 55 I=4H5,10 DO 55 I=READ(5,10) READ(5,10)=DO55I Prior to using RENBR to renumber a new version of a program, the program should be compiled without getting any serious error messages. Statement numbers in statements which are not recognized by the compiler will probably not be recognized by RENBR either. Any statement which cannot be recognized by RENBR is copied into the renumbered program without change. A program which has just been composed or revised should not be renumbered until after it has been compiled, since any statement number which is in an improperly written statement will not be correct after renumbering. When programs which are likely to contain language features which might not be recognized by RENBR are renumbered for the first time, it is best to force the new statement numbers to be completely outside the range of those originally in the program. This will cause any statement numbers in statements which RENBR leaves unchanged to reference nonexisting statements. These errors would be caught when the program is compiled the next time. If, instead, the new statement numbers were to be similar to those originally in the program, 2 The RENBR User's Guide then, after the program has been renumbered, any statement number which appears in a statement which is not recognized would likely still be the new number of a statement, although of the wrong one. The user should also verify that lines in the program do not end with necessary blank characters (sometimes call space characters), since rightmost blanks are trimmed off each line when the program is renumbered. In particular, at least 1 printing character should appear on the same line as, and to the right of, each blank character which is within a character string. If the blank character is at the right end of a string which follows a number and the letter H, then the string can remain in the H notation, but can be enclosed between parentheses, or else the string can be converted to apostrophe notation. If the blank character is in a FORMAT statement, then the string can be broken into 2 separate strings with the second string appearing after a comma and on a continuation line. The FORTRAN operating system's read routines insert extra blanks to the right of the printing characters already on each line to cause all lines to be of the same length. To decrease the lengths of the resulting files, RENBR discards all rightmost blanks on each line since it cannot distinguish between the blanks which actually appeared at the right ends of the lines in the file being processed and those which were inserted by the operating system. For example, a statement such as IF(INDEX.EQ.1)LTRBFR(INDEX)=1H could instead be written as IF(INDEX.EQ.1)LTRBFR(INDEX)=(1H ) or IF(INDEX.EQ.1)LTRBFR(INDEX)=' ' On the DECsystem10 or DECsystem20 computers, this statement could also be rewritten as IF(INDEX.EQ.1)LTRBFR(INDEX)=1H ; or IF(INDEX.EQ.1)LTRBFR(INDEX)=1H ! Instructions for Use on the DECsystem10 Computer ------------ --- --- -- --- ----------- -------- On the DECsystem10 computer, FORTRAN programs can be written either in conventional column form having the statement text in columns 7 through 72, or in tab form in which an optional left justified statement number is followed by a tab character and then by up to 66 characters of text. The tab character is a nonprinting character which advances the location of the next character to the next column beyond the next multiple of 8 columns from the left margin. RENBR can process programs written in either column or tab form, or in a mixture of these forms. The renumbered program can have whichever form is selected by the user. RENBR can also, on request, convert tab characters in comment lines into blanks filling to the tab stops. Such tab to blank conversion is often necessary when readying programs for compilation on other computer systems which do not recognize the tab character. Instructions for Use on the DECsystem10 Computer 3 RENBR can process a series of input files. Each of these input files can contain one or many main programs and routines. A program, or a routine, or even a statement, which starts at the end of one file can be continued in the next file. The files which RENBR is to process cannot contain the line sequence numbers which are used by some line oriented editors on the DECsystem10 computer. Such line sequence numbers must be removed before the file is processed, since RENBR cannot distinguish between line sequence numbers and statement numbers. On the DECsystem10 computer, line sequence numbers can be removed by selecting the /N switch when using the monitor COPY command to copy the file. When RENBR is started, it will suggest that the user type /H to obtain instructions. RENBR will then wait for the user to type a command. Each line of the command must be no longer than 80 characters, but the command can be continued onto as many subsequent lines as are necessary. In order to continue the command onto a subsequent line, the command must be split between file specifications, and either a comma or an ampersand (the & character) must be typed at the right end of the current line. A file specification cannot itself be continued in this manner since whatever is typed on the next line will start a new file specification. The command which could be typed by the user can be read from a file instead if the user types the name of this file either preceded directly by an at sign (the @ character) or followed directly by an @ character. If the command is read from a file, then the names of the input files can appear on separate lines without the use of the comma or the & character at the ends of the preceding lines. If the file is to contain several commands which are to be processed separately, then these must be separated by semicolons (the ; character). All characters to the right of an exclamation point (the ! character), to the right of an & character, or to the right of the name of the command file in the original command which was typed by the user, are ignored. The command which is typed by the user or which is read from a command file can consist of the name of the output file which is to contain the renumbered version of the program, and/or the name of the output file which is to contain the listing, followed by an equal sign (the = character) and then by a list of one or more input source files separated by commas. If both output files are specified to the left of the equal sign, then a comma should separate the names of these files, and a switch which specifies something about either the listing or the renumbering, but not about both, must appear with at least one of these file specifications. The switch, which consists of a slash and a letter sometimes followed by a number, implies whether the output file having the name with which the switch appears is to contain the renumbered program or the listing. The switch is necessary if both output files are specified, since either type of output file can be specified first. If either 1 output file or none is specified to the left of the equal sign, and if no switch which specifies something about a listing is given, then the program is renumbered instead. If neither output file is specified, then the equal sign is not necessary, and the command can start with the name of the first input source file. 4 The RENBR User's Guide A single file specification can consist of a device name followed by a colon, followed by the file name. If no device name is specified for the output listing file, then the output listing file is written to logical device LPT:. Any other file for which no device is specified is assumed to be on or to be written to logical device DSK:. The directory or path upon which the file is located can be specified before the device name, between the device name and the file name, or after the file name. The directory specification can consist of an octal project number, an octal programmer number, and a single subfile directory (SFD) name separated by commas and enclosed between left and right square brackets. If either a programmer number or an SFD name is being specified, then all items to its left must also be supplied. The user's local directory is assumed if none is specified. However, once the user has specified either a device name or a directory for an input source file, then this device name or this directory continues to be used for all subsequent input source files for which these items are not specified. Each file name can consist of up to 6 characters followed by a period and then by an extension which can consist of up to 3 characters. The file name extensions .NEW, .LPT, .FOR and .RNB are used as defaults for the resulting renumbered file, for the resulting listing file, for the original source files, and for the command file if extensions are not specified for the names of these files. If a file name is to have a null extension consisting of 3 blanks, then a period must be typed following the first part of the file name. The first part of the name of the first original source file is used as the first part of the name of either of the resulting files if the first part of the name of the resulting file is not specified. If the first part of the name of a command file is missing, then the default name RENBR is assumed. The user can specify the title which is to be shown at the top of each page of the listing by enclosing the title between apostrophes. If the title is itself to contain an apostrophe, then this apostrophe can be indicated by typing 2 apostrophes where the single apostrophe is to appear. If a title is specified to the left of the equal sign, then the file with which it is associated will contain the listing. For example, the commands DACOPY and DSK:DACOPY.NEW/I=DSK:DACOPY.FOR are identical, and would cause the program in the file named DACOPY.FOR to be renumbered with the result being placed into the file named DACOPY.NEW. The /I in this command is a switch described below which implies renumbering. The commands DACOPY'this is a title 'this is a title'DACOPY and 'this is a title'LPT:DACOPY.LPT=DSK:DACOPY.FOR Instructions for Use on the DECsystem10 Computer 5 are identical, and would cause the program in the file named DACOPY.FOR to be listed with the result being placed into the file named DACOPY.LPT, which would then be printed on device LPT:. The text appearing between the apostrophes would be placed at the top of each page in the listing. It is not necessary to include a switch in this example, since the specification of the title itself implies that a listing is desired. The commands DACOPY/I'title DACOPY'title'/I /I DACOPY'title 'title'DACOPY/I /I'title'DACOPY 'title'/I DACOPY and LPT:DACOPY.LPT'title',/I DSK:DACOPY.NEW=DSK:DACOPY.FOR are identical, and would cause the program in the file named DACOPY.FOR to be both renumbered and listed, since the specification of a title implies that a listing is desired, and the /I switch implies that renumbering is also desired. The command PRVI:.LST='title'DAHEST,DSKB:[22,56]DAHEFT.F4,DAVERB would generate a single file on device PRVI: containing a listing of the 3 files DAHEST.FOR, DAHEFT.F4 and DAVERB.FOR, the latter 2 being read from the directory [22,56] on device DSKB:. This command could also be broken into 2 lines as shown below. PRVI:.LST='title'DAHEST, DSKB:[22,56]DAHEFT.F4,DAVERB The commands @[35,56,SAMPLE] and @[35,56,SAMPLE]RENBR.RNB are identical, and would cause further instructions to be read from the file RENBR.RNB in the [35,56,SAMPLE] directory. If This file contains .FOR=ONE; .FOR=TWO;.FOR=THREE ;.FOR=FOUR ;'title'ONE TWO,THREE FOUR then the files ONE.FOR, TWO.FOR, THREE.FOR and FOUR.FOR in the user's local directory would be replaced by renumbered versions having the same names. All of the renumbered files would then be listed. Such overwriting of an original file by a renumbered version having the same name should not be done with the only copy of a source file. 6 The RENBR User's Guide Switches Typed by User to Select Results -------- ----- -- ---- -- ------ ------- Along with the names of the original and resulting files, the user can type a slash followed by a letter or a slash followed by a letter and a number to select whether renumbering or listing or both are to be performed and to modify how these operations are to be performed. The letter must immediately follow the slash, and the following number must immediately follow the letter, although a colon can appear between the letter and number. The combination of the slash, letter and optional colon and number is called a switch. Examples of all of the possible switches which can be typed by the user are shown below together with typical values for the following numbers, where allowed. /A:2 add 2 blanks to lines in DO loop or IF THEN block /B:100 base statement number is 100 /C column form statements (see /T and /U) /E:1 1 extra table of contents /F:60 form feeds every 60 lines (see /L) /G:1 gap of 1 line between each statement in listing /H help message is to be typed /I:5 increment between statement numbers is 5 /J:0:4 jump 0 lines at top and 4 at bottom of first page /K keep lines intact (see /S) /L:60:66 60 lines can be printed on pages 66 lines high /M maintain original statement numbers /M:100 modify only statement numbers of 100 or larger /M:1:9 modify only statement numbers in range 1 through 9 /P:1 page number at start of listing is to be 1 /S:9 split lines 9 characters beyond right margin /T tab form statements (see /C and /U) /U uniform left justification of statement numbers /V view listing on controlling terminal /W:8 width of tab stops is 8 /Z types array usage summary if listing is requested 'A Title' print the words A Title at top of each page Typing a title enclosed in apostrophes, or any of the switches /E, /F, /G, /J, /K, /L, /P, /S or /V, causes a listing to be produced. The default options for listings are initial page number 1, form feeds, intact long lines, single spacing, and 1 table of contents. The default number of printable lines per page is 60. The default total number of lines per page, including the blank lines used to simulate form feeds at the page boundaries if the /L switch is issued, is 66. These default values could also be selected by typing the following switches /F:60 or /L:60:66 Typing any of the switches /B, /C, /I, /M, /T or /U causes a new renumbered version of the source file to be produced. The default options for renumbering are smallest statement number 1, increment 1 and column form. Switches Typed by User to Select Results 7 The switches /A, /W and /Z do not indicate whether listing or renumbering is to be performed, and apply to the results of either listing or renumbering. The switches are described in more detail below. /A causes extra blanks to be added to the left of the text of each statement inside a DO loop or inside an IF THEN block in the renumbered file or in the listing. The actual number of blanks added to each line in such block structures is indicated by the number which follows the /A switch. When DO loops or IF THEN blocks are embedded, the range of each additional loop or block is indented further. Either /A without a following number or /A:0 implies /A:1. A /A switch appearing within a CRENBR command line (see later description of this) within a particular program or routine can for that program or routine supersede the indentation of the block structure which has been selected by the user. Shown below is an example of the application of the /A switch to a multiply embedded block structure. The unindented FORTRAN statements are shown at the left and the indented FORTRAN statements resulting from the application of /A:5 are shown at the right. A=0 A=0 IF(B.EQ.0)THEN IF(B.EQ.0)THEN C=0 C=0 IF(D.EQ.0)THEN IF(D.EQ.0)THEN E=0 E=0 END IF END IF F=0 F=0 ELSE IF(G.EQ.0)THEN ELSE IF(G.EQ.0)THEN H=0 H=0 DO WHILE(I.EQ.0) DO WHILE(I.EQ.0) J=0 J=0 END DO END DO K=0 K=0 ELSE ELSE L=0 L=0 DO 1 M=1,2 DO 1 M=1,2 N=0 N=0 1 CONTINUE 1 CONTINUE O=0 O=0 END IF END IF END END Except for the addition of the extra blanks within the range of DO loops and of IF THEN blocks, the first printing character within the statement field of a FORTRAN statement will be either in column 7 if column form is selected, or following the tab character if tab form is selected regardless of the original indentation of the first line of the statement. The original indentation of each continuation line is preserved if possible. /B sets the smallest statement number which is to appear in each program and routine after renumbering. The actual value of the smallest statement number is indicated by the number which follows the /B switch. If a /I switch is given but a /B switch is not given, then 8 The RENBR User's Guide the absolute value of the number appearing after the /I switch will be used as the smallest statement number. A /B switch appearing on a CRENBR command line (see later description of this) within a particular program or routine can for that program or routine supersede the smallest statement number selected by the user. If the /B switch is issued without a following number, and if the /I switch has not been issued, then it is assumed that the user meant to type /I:1 instead of /B. Values specified by the user's typing of the /B switch and/or the /I switch can be modified by a CRENBR command line (see later description of this) locally for the routine in which this command line appears. If a nonzero value of the lowest statement number has not been specified either by the user or by a CRENBR command line within the routine, then the value of the lowest statement number in a routine after renumbering will be the absolute value of the statement number increment used to renumber the routine. This allows the production of reasonable statement numbers even if the statement number increment, but not the smallest statement number, is specified. On the other hand, the lowest statement number can be specified by the user for all routines except for those in which it is specified internally by a CRENBR command line. /C causes the renumbered statements to have the column form. In the resulting file, the rightmost digit of each statement number will be in column 5 and the text of the initial line of each statement which is not within the range of an indented DO loop or IF THEN block will start in column 7. A digit in the range 1 through 9 will appear in column 6 of each continuation line. Although the renumbered statements are generated in column form, the original programs and routines can be in either column or tab forms, or in any mixture of these. The following 3 examples resulted from renumbering the same sequence of FORTRAN statements with the /C, /U, and /T switches respectively. Although the /U and /T switches appear to produce similar results, the /U switch causes blanks to be inserted between the statement number and the following text to force the first character of the statement to be in column 7, while the /T switch causes a single tab character to appear between the statement number and the following text. applying /C applying /U applying /T C234567890123456 C234567890123456 C234567890123456 8 DO 9 I=1,2 8 DO 9 I=1,2 8 DO 9 I=1,2 DO 9 J=1,5 DO 9 J=1,5 DO 9 J=1,5 9 IJ=IJ+ 9 IJ=IJ+ 9 IJ=IJ+ 1LOC(I,J) 1LOC(I,J) 1LOC(I,J) 10 TYPE 11,IJ 10 TYPE 11,IJ 10 TYPE 11,IJ 11 FORMAT(I5) 11 FORMAT(I5) 11 FORMAT(I5) /E causes extra tables of contents to be generated at the end of the listing. The actual number of extra tables of contents which are generated is indicated by the number which follows the /E switch. Extra tables of contents might be necessary if a long listing is to be bound as several volumes. /E without a following number or /E:0 implies /E:1. Switches Typed by User to Select Results 9 /F causes the listing to be prepared for display on a device which can eject a page of paper when a form feed character is encountered. Line feeds would not then have to be used in the listing to simulate form feeds. The pages in the listing will be separated by form feeds if the output is being sent either to device LPT (the default) or to device TTY. The character 1 (the digit one) will appear in column 1 where a form feed is needed if the listing is written to any other device. /F can be followed by the number of lines which are printable per page not including those lines skipped over automatically at the page boundaries. /F without a following number or /F:0 implies /F:60. /G causes extra blank lines to be inserted between consecutive FORTRAN statements in the listing, and between blocks of comment lines and the surrounding FORTRAN statements. The actual number of blank lines which are inserted between consecutive statements is indicated by the number which follows the /G switch. No extra blank lines are inserted between comment lines or between the continuation lines of a single statement. /G without a following number or /G:0 implies /G:1. /H types a summary of the switches which are accepted by RENBR. Any file specifications which have already been typed by the user are ignored. /I sets the increment between consecutive statement numbers in each program and routine after renumbering. The actual increment between consecutive statement numbers is indicated by the number which follows the /I switch. A negative increment, such as would be specified by /I:-1, would cause the smallest number to be at the end of the program rather than at the beginning. The smallest number will be the absolute value of the statement number increment unless /B is issued and is followed by a number which is greater than zero. Either /I without a following number or /I:0 implies /I:1. /J sets the number of extra blank lines which are to be inserted at the tops and bottoms of each page in the listing. The actual numbers of blank lines which are inserted are indicated by 2 numbers which can follow the /J switch. The first number which follows the /J switch sets the number of blank lines which are to appear in the listing at the top of the 1st page, at the bottom of the 2nd page, at the top of the 3rd page, and so on. This number can be followed by a colon and then by the number of blank lines which are to appear at the bottom of the 1st page, at the top of the 2nd page, at the bottom of the 3rd page, and so on. These blank lines could be inserted to allow top binding of unburst fanfold paper and must be included in the maximum number of printable lines specified by the number following a /F switch or by the first number following a /L switch. /J:6 or /J:6:0 would skip 6 lines at the top of the 1st page, both before and after the separation between pages 2 and 3, between pages 4 and 5, and so on. /J:0:6 or /J::6 would skip 6 lines both before and after the separation between pages 1 and 2, between pages 3 and 4, and so on. /K causes long lines to be kept intact in the listing. The /S switch can be issued instead to select the point at which long lines are to be wrapped around to give narrower listings. 10 The RENBR User's Guide /L causes the pages in the listing to be separated by counted line feeds. The /L switch can be followed by the number of lines which are printable per page not including those lines which are to be skipped over at the page boundaries by the printing of extra empty lines. This number can be followed by the total number of lines per page including those lines which are to be skipped over at the page boundaries by the printing of extra empty lines. /S:0 is assumed if a /S switch has not already been selected. If the /K switch is desired, then it must be issued after the /L switch. /L without a following number or /L:0 implies /L:60:66. /M causes only those statement numbers which are within a specified range to be renumbered. If the /M is issued without a following number, then the original statement numbers will be retained in all programs and routines which are processed. It should be noted that the /M switch without following numbers has a different meaning when included on a CRENBR command line within a program or routine being processed. If the /M switch is issued with 2 following numbers, then these numbers are the the lowest and highest original statement numbers which will be modified in all programs and routines which are processed. All original statement numbers which are either less than the first number or greater than the second number will be retained. The first number following the /M switch is assumed to be 1 if it is missing but the second number is specified. The second number is assumed to be 99999 if it is missing but the first number is specified. The /M switch could be used to identify a section of a program or routine which is to be modified and then grafted back into the original program or routine since all references within the section to statements outside the section would remain correct. If a /M switch, either with or without following numbers, is issued by the user, then all /B, /I, /M, /N and /O switches issued on CRENBR command lines within the programs and routines being processed will be ignored. /P sets the page number of the first page in the listing. The actual page number shown on the first page is indicated by the number which follows the /P switch. Issuing the /P switch with a number greater than 1 does not suppress any portion of the listing. It merely changes the numbers shown at the upper right corners of the pages. /P without a following number or /P:0 implies /P:1. /S causes long lines to be split a desired distance beyond the normal right margin of the listing. The portion of a long line which would extend beyond the right margin by more than the number of characters indicated by the number which follows the /S switch will be right justified on the following line instead. If the /S or /S:0 switch is issued, then the listing will have at most 69 characters per line (or 70 if the FORTRAN carriage control character is counted). The right margin is then 1 inch wide on 8 1/2 inch wide paper (assuming 10 characters per inch), and FORTRAN lines containing over 59 characters will be split in the listing. (In addition to the statement text, each line printed in the listing contains the carriage control character and 10 characters in the line Switches Typed by User to Select Results 11 number and margin left of the statement number field.) If wider paper is to be cut down to 8 1/2 inch width, and if the printer can print more characters, then a narrower right margin can be obtained by following the /S switch with the number of additional characters to be allowed before the line is split. If the /S is followed by a number which has a value of 69 or greater, then this number is assumed to be the maximum number of characters which can be written on a single line in the listing. Thus, /S:0 and /S:69 are equivalent. Either /S:13 or /S:82 would give the same result as /K when FORTRAN programs and/or routines are being listed, unless a /C switch has also been issued on a CRENBR command line in the program or routine being listed to cause more than 72 characters to be retained in each FORTRAN comment line. Since 120 characters are allowed in each line of a comment section introduced by either a RENBRSTART or a RENBRTITLE line (see later descriptions of these), a larger number in the range of the /S switch might be appropriate for such comment sections even if the FORTRAN statements are not too long for the listing. A portion of a listing which was generated using /S:0 is shown below. In place of a line number at the left edge of the listing, each overflow line is indicated by the number of leading blanks in parentheses if the excess text starts with a blank, or by minus signs otherwise. The page number on the top line of each page always extends to the normal right margin. The width of each line in this sample has been reduced somewhat to fit this document. SAMPLE TITLE Page 12 MAIN PROGRAM 98 48 KM=IN-1 99 IF(LINES.EQ.0)WRITE(ILPT,49)INDEX,IGROUP,NUMPRS ---- (KM), 99 1NMBTWO,LTRTWO 100 49 FORMAT(1H ,1I4,2H (,1I3,1H ,1I4,13X,1I2,2I4,2H ( 1) ,5A1) /T causes the renumbered statements to have the tab form. In the resulting file, a tab character will appear between the optional statement number and the statement text. A digit in the range 1 through 9 will appear to the immediate right of the tab character in each continuation line. Although the renumbered output is generated in tab form, the original programs and/or routines can be in either column or tab forms, or in any mixture of these. If a listing is also being generated, then the statement numbers will be left justified in the listing, but the rest of each statement will be shown in column form in the listing. /U causes the renumbered statements to have a variation of the column form. In the resulting file, the leftmost digit of each statement number will be in column 1 and the text of the initial line of each statement which is not within the range of an indented DO loop or IF THEN block will start in column 7. A digit in the range 1 through 9 will appear in column 6 of each continuation line. The only difference between the form produced when the /U is issued and that produced by the /C switch is that the statement numbers start in 12 The RENBR User's Guide column 1 when /U is issued, but end in column 5 instead when /C is issued. If all of the statement numbers were to consist of 5 digits, then the results would be identical. /V causes the listing to be typed on the controlling terminal. If the /L switch is also issued, then the user will be asked to position the paper to the next top of page before the program proceeds. /W causes tab characters in the comment lines to be converted to blank characters in the renumbered file or in the listing. The actual separation of the tab stops is indicated by the number which follows the /W switch. If a /W switch is not issued, then tab characters in comment lines are converted to blanks using a tab stop separation of 8 for the listing, but are not converted to blanks in the renumbered output. Tab characters in the text of FORTRAN statements are never converted to blanks in the renumbered file. /W without a following number or /W:0 implies /W:8. /Z types onto the controlling terminal all of the information by which each file is specified when this file is opened. If a listing has been requested, then, after the listing has been completed, the largest number of locations which were needed to store the information in the listing for any of the programs or routines is also typed onto the controlling terminal. The /Z switch is provided for use by developers of the RENBR program and is mentioned here only for completeness. The information which is displayed when the /Z switch is used is described in an appendix to this manual. Input File Restrictions ----- ---- ------------ RENBR can process programs and routines written according to either of the 1966 or 1977 standards for FORTRAN or in some dialects of the older FORTRAN-II. RENBR can also process programs and routines which use the FORTRAN language extensions allowed by the DECsystem10 F40 compiler and by version 7 of the DECsystem10 FORTRAN-10 compiler. Unrecognizable statements are copied into the renumbered output unchanged and will be correct if these statements do not reference statement numbers. RENBR can be used to produce listings of FORTRAN programs and routines which contain syntax errors. However, RENBR should not be used to renumber programs and routines until these no longer produce error messages when compiled, since RENBR is unable to correctly convert statement numbers which appear in statements having incorrectly spelled keywords or which reference missing statements. The first time that RENBR is used to renumber an existing program, the resulting renumbered program should be checked for errors since it is possible that the program uses some extension to or variant of the FORTRAN language which cannot be handled properly by RENBR. The easiest way to test whether RENBR can correctly process a program is to renumber it with the new statement numbers being outside the range of those originally in the program, then to compile the renumbered program and let the compiler report any statement numbers which are missing. If RENBR has been used repeatedly to process a program during its development, then such checking would be unnecessary, since any Input File Restrictions 13 extensions or variants would have been found and excluded while the program was being tested. RENBR cannot handle all possible programs acceptable to all possible compilers. In particular, programs which do not meet the following restrictions will not be processed correctly. 1. The input source file must not contain line sequence numbers left of the statement number field. If present, such line sequence numbers must be removed before the file is processed by RENBR. 2. Continuation lines following a comment line beginning with an initial letter C (either upper or lower case), or any of the characters *, !, / or $, are taken as a continuation of the comment and are written into the output unchanged. For this reason, comment lines can separate statements, but cannot appear within a single statement. 3. If some digits of a statement number in the text of a statement appear to the left of an exclamation point and additional digits of the same statement number appear on a following continuation line, then the exclamation point and the comment to its right will be lost when the program or routine is processed. The statement number would still be replaced by the proper new number, but the comment is considered to be part of the text of the old number and is discarded along with the digits of the old number. Similarly, if blanks appear between the digits of a statement number, then these blanks are discarded when the number is replaced. For example, the comment which appears inside the statement number 56 in the following statement GO TO 5!THIS COMMENT APPEARS INSIDE A STATEMENT NUMBER 16 would be discarded, although the statement number itself would be recognized and treated properly. The comment would be retained, however, if it is entirely outside the statement number as is the case in either of the following statements. GO TO 56!THIS COMMENT APPEARS AFTER A STATEMENT NUMBER or GO TO !THIS COMMENT APPEARS BEFORE A STATEMENT NUMBER 156 4. Statement numbers in obsolete statements, which have been changed to comment lines by the addition of the letter C, or any of the characters *, !, / or $, to the start of the statements, are left unchanged and therefore become incorrect when programs containing them are renumbered. Some compilers ignore lines which begin with certain other characters, but RENBR treats such lines as FORTRAN statements and maintains the initial characters. (See also the description of the /R switch in the CRENBR command line.) 5. All blanks which appear at the right end of the lines in a file are discarded when the contents of the file are renumbered. If character strings are specified as the number of characters 14 The RENBR User's Guide followed by the letter H and the characters of the string, then lines which end with character strings containing rightmost blanks will have these blanks removed. Therefore, unless the processed file is written onto cards, a statement such as A=1H should instead be written as A=(1H ) or A=' ' On the DECsystem10 and DECsystem20 computers, this statement could also be rewritten as A=1H ; or A=1H ! Such deletion of rightmost blanks can also occur in FORMAT statements in which character strings extend across continuation line boundaries. For example, the FORMAT statement 50 FORMAT(' THIS IS A FORMAT STATEMENT WITH A BLANK 1FOLLOWING THE FIRST APPEARANCE OF THE WORD BLANK') in which a single blank character and then the end of line characters follow the first appearance of the word BLANK, could instead be rewritten as 50 FORMAT(' THIS IS A FORMAT STATEMENT WITH A BLANK ', 1'FOLLOWING THE FIRST APPEARANCE OF THE WORD BLANK') Any character string in which a necessary blank appears at the right end of a line should be rewritten manually before the program is processed by RENBR. Of course, since many screen (or video) editors themselves discard rightmost blanks on a line, merely editing a program in which some lines contain necessary rightmost blanks could itself make the program incorrect or uncompilable. Some screen editors also convert multiple blanks to tabs, and others convert tabs to multiple blanks. If the tabs which separate the statement number fields from the text fields have been converted to blanks by the editor, then the continuation lines will no longer compile correctly, but RENBR will still treat these properly and can convert the file to either column or tab form. 6. The argument list of a function cannot contain the numbers of statements to which control is to be transfered when a RETURN statement which includes a number is executed in the function. Such alternate returns are allowed, however, from routines which are referenced by CALL statements, rather than by the inclusion of the names of the routines in expressions. These statement numbers are preceeded in the CALL statements by asterisks, dollar signs or ampersands (the *, $ or & characters, respectively), and their locations in the argument list in the first line of the routines are indicated by the same characters used alone. Input File Restrictions 15 An example of a program which would not be processed correctly by RENBR is shown below. This program asks for the user to supply 2 values, and reports the smaller of these. In this example, the SMALLR function uses an alternate return to transfer to statement 50 if the values are equal. RENBR cannot identify that SMALLR in the main program is an external function rather than an array, and so does not recognize that the *50 is a reference of a statement number. Therefore, the statement number in the argument list of the function call will not be changed if the program is renumbered. 10 TYPE 20 20 FORMAT(' NEXT 2 VALUES? ',$) ACCEPT 30,ONE,TWO 30 FORMAT(2F) A=SMALLR(*50,ONE,TWO) TYPE 40,A 40 FORMAT(' SMALLER VALUE IS',1E12.4) GO TO 10 50 TYPE 60 60 FORMAT(' VALUES ARE EQUAL') GO TO 10 END FUNCTION SMALLR(*,ONE,TWO) C RENBR(/RETURN LESSER OF 2 VALUES) IF(ONE.EQ.TWO)RETURN 1 SMALLR=ONE IF(ONE.GT.TWO)SMALLR=TWO RETURN END This restriction probably will not cause any difficulty since many FORTRAN compilers do not recognize alternate return destinations in function calls anyway, and since such alternate return destinations in function calls are not defined by the standards for the FORTRAN language. They are, however, allowed by the F40 compiler on the DECsystem10. 7. The initial line of a statement cannot be followed by more than 19 continuation lines. This means that a single statement cannot be more than 20 lines long. It also means that if a statement separation character such as the semicolon is used between statements to pack several statements on a line, and if subsequent statements are wrapped around onto continuation lines, then the right end of the final statement cannot be more than 19 continuation lines beyond the line containing the start of the first statement. 8. Unless the dimensions of the storage arrays within the RENBR program are increased, a single main program or a single routine being renumbered cannot contain more than 1000 numbered statements. (If the file is being both listed and renumbered, then the limit is 25 less.) When making a listing of a program or routine for which the sum of the number of statement numbers and the number of references of these numbers in the statements is greater than 1000, the listing of the statements will be fragmented to allow frequent emptying and reuse of the storage arrays. If a program or routine contains more than 1000 numbered statements, then the original 16 The RENBR User's Guide statement numbers will be retained when renumbering is requested. If a program or routine contains less than 1000 numbered statements, then the program or routine can be renumbered regardless of the number of references of these numbers in the statements. 9. The END statement which terminates a program or a routine must appear on a single line, although the letters of the word END can be preceded by or be separated by blanks or tabs. The END statement can have a statement number to its left and can be followed by an exclamation point and a comment to its right, but the END statement must not appear on the same line as any other statement. The input source files can contain any number of programs or routines, each with its own END statement. The first statement or comment of each of the subsequent programs or routines must start on a new line. Any statement which starts with the letters END cannot be split onto a new line between these letters and the rest of the statement. For example, an END IF or END DO or END FILE statement cannot have the word END on the first line and the rest of the statement on a continuation line. 10. If the FORTRAN compiler which was used to compile RENBR itself does not support the END= end-of-file test in READ statements, then an additional END statement should be inserted after the final program or routine in each of the files which are to be processed by RENBR. These extra END statements will not appear in the output. The extra END statement in the final source file which is processed causes a normal exit which includes printing of the table of contents. The programs and routines in the input source file would still be processed correctly even if the extra END statement is not inserted, but only a single input source file could be processed, and the listings would not include the table of contents. If the end-of-file test for READ statements is not available, then it will not be possible to have a single program or routine be split across two or more input source files, since the end of each file would have to be marked by an extra END statement. If the end-of-file test is not available, and if the list of files which are to be processed is read from a command file, rather than typed by the user directly, then the name of the final file in the list should be followed by a semicolon either to its right or on the next line. 11. RENBR cannot handle INCLUDE statements and instead copies the INCLUDE statement unchanged into the renumbered file. The INCLUDE statement names another file and causes the compiler to treat the text in this additional file as though it had appeared in the original file in place of the INCLUDE statement. Since RENBR does not process the text in the file named by the INCLUDE statement, the text in this additional file should not contain statements which bear statement numbers referenced elsewhere in the program or which could be duplicated when the rest of the program is renumbered. Likewise, the text in the file named in the INCLUDE statement should not reference statement numbers appearing in the rest of the program being renumbered. Supported Variations of Statement Structure 17 Supported Variations of Statement Structure --------- ---------- -- --------- --------- RENBR allows a tab character to appear between the statement number and the text in the first line of a statement. Use of the tab character relieves the programmer of having to type enough blanks to advance to column 7 or beyond. On a continuation line, a tab at the start of the line can be followed by a digit other than zero and then by the continuation of the text of the statement. The programmer does not have to insert exactly 5 blanks and then place the digit in column 6 as is required for the standard form of continuation lines. Regardless of whether the lines in the file which is processed by RENBR start with tabs or have the standard form, the lines in the renumbered file produced by RENBR can have the tab form or can have the standard form with the numbers being either left justified or right justified. If the FORTRAN compiler or the operating system do not support tab characters in input files, then any FORTRAN programs which contain such leading tab characters should have these tab characters converted to blanks before the programs are processed using RENBR. If the tab stops are equally spaced at least 6 characters apart, then the tabs can be converted to the appropriate number of blanks to fill to the corresponding tab stops before the file is processed using RENBR. Alternatively, each tab character in the file can be converted to 6 or more blanks before the file is processed using RENBR, since the text of an initial line must start in column 7 or beyond, and since RENBR recognizes a line which starts with 5 or more blanks and then a nonzero digit as a continuation line. RENBR allows semicolons between statements which appear on the same line and allows exclamation points before comments on the same lines as statements. These characters are recognized only when they appear within the portion of the line which can contain statement text. If more than 1 statement appears on a line, then only the first statement can bear a statement number, since the text of the next statement is assumed to start immediately after the semicolon. There cannot be more than 19 consecutive continuation lines even if these represent more than 1 statement. The END statement can bear a comment to its right, but must not appear on the same line as any other statement. The interpretation of lines in a FORTRAN program which are not comments but which have an alphabetic letter in column 1 depends upon the FORTRAN compiler which is being used. Some compilers require the letters B, D or I in column 1 to specify the type of variables appearing on that line. The DECsystem10 FORTRAN compiler allows the letter D in column 1 to indicate a debugging line, the compilation of which is optional. If the initial line of a statement starts with the letter D, then RENBR will place the letter D at the start of each continuation line of that statement regardless of whether these continuation lines themselves originally started with the letter D. If the first line of the statement does not start with the letter D, but some of the continuation lines do start with the letter D, then the appearances of the letter D at the start of the continuation lines are discarded. Whether this modification of the continuation lines can change the meaning of the program will depend upon which DECsystem10 compiler is used. When lines which start with the letter D are being ignored, the F40 compiler treats a continuation line after a line bearing the letter D in column 1 as a 18 The RENBR User's Guide continuation of a comment while the FORTRAN-10 compiler treats such a continuation line as a continuation of the previous statement. For example, on the DECsystem10, the program shown below would type the value 1 if debugging lines starting with the letter D are not compiled. The program would instead type the value 2 if debugging lines are compiled. INDEX=1 D IF(INDEX.EQ.1) D 1INDEX=2 TYPE 1,INDEX 1 FORMAT(' INDEX=',1I2) END A line beginning a new statement can have any of the forms which are described below. Where these descriptions speak of a line beginning with a character other than the letter C, it is actually meant that the character in column 1 cannot be any of the characters upper case C, lower case c, *, !, /, or $. Any of these characters in column 1 would cause the rest of the line to be treated as a comment. 1. A line beginning with 5 blanks and/or digits followed in column 6 by a blank or a zero, and then by the text of the statement. 2. A line beginning with a non-tab non-blank non-digit character other than the letter C followed by 4 blanks and/or digits followed in column 6 by a blank or a zero, and then by the text of the statement. 3. A line beginning with a tab followed by the first character of the statement which cannot be a digit. 4. A line beginning with a non-tab non-blank non-digit character other than the letter C followed by a tab followed by the first character of the statement. 5. A line beginning with a digit or digits of the statement number followed by a tab followed by the first character of the statement. 6. A line beginning with a non-tab non-blank non-digit character other than the letter C followed by the digit or digits of the statement number followed by a tab followed by the first character of the statement. The contents of typical lines which can start new statements are diagrammed below. In these illustrations, (BLANK) represents a blank, (TAB) represents a tab and (TEXT) represents the text of the statement. Of course, the text of the statement can itself begin with one or more blanks or tabs. (BLANK)(BLANK)(BLANK)(BLANK)(BLANK)(BLANK)(TEXT) (BLANK)(BLANK)(BLANK)(BLANK)(BLANK)0(TEXT) D(BLANK)(BLANK)(BLANK)(BLANK)(BLANK)(TEXT) D(BLANK)(BLANK)(BLANK)(BLANK)0(TEXT) (BLANK)(BLANK)(BLANK)22(BLANK)(TEXT) (BLANK)(BLANK)(BLANK)220(TEXT) Supported Variations of Statement Structure 19 D(BLANK)(BLANK)22(BLANK)(TEXT) D(BLANK)(BLANK)220(TEXT) 22(BLANK)(BLANK)(BLANK)(BLANK)(TEXT) 22(BLANK)(BLANK)(BLANK)0(TEXT) D22(BLANK)(BLANK)(BLANK)(TEXT) D22(BLANK)(BLANK)0(TEXT) (TAB)(TEXT) D(TAB)(TEXT) 22(TAB)(TEXT) D22(TAB)(TEXT) A continuation line can have any of the forms which are described below. Again, where these descriptions speak of a line beginning with a character other than the letter C, it is actually meant that the character in column 1 cannot be any of the characters upper case C, lower case c, *, !, /, or $. 1. A line beginning with 5 blanks followed by a non-blank non-tab non-zero character which is ignored. This is in turn followed by the continuation of the text of the statement. 2. A line beginning with a non-tab non-blank non-digit character other than the letter C followed by 4 blanks followed by a non-blank non-tab non-zero character which is ignored. This is in turn followed by the continuation of the text of the statement. 3. A line beginning with a tab (or with 5 or more blanks) followed by a non-zero digit which is ignored. This is in turn followed by the continuation of the text of the statement. 4. A line beginning with a non-tab non-blank non-digit character other than the letter C followed by a tab (or by 4 or more blanks) followed by a non-zero digit which is ignored. This is in turn followed by the continuation of the text of the statement. The following are typical continuation lines. (BLANK)(BLANK)(BLANK)(BLANK)(BLANK)2(TEXT) (BLANK)(BLANK)(BLANK)(BLANK)(BLANK)A(TEXT) D(BLANK)(BLANK)(BLANK)(BLANK)2(TEXT) D(BLANK)(BLANK)(BLANK)(BLANK)A(TEXT) (TAB)2(TEXT) D(TAB)2(TEXT) Maintaining Logical Blocks of Statement Numbers ----------- ------- ------ -- --------- ------- Some programmers select statement numbers used within a logical section of a program from a different range of values than those used elsewhere within the same program. RENBR can maintain these regions when renumbering. However, since a single normal renumbering would destroy such regions, a command line within the program is used to specify the size of the range of statement numbers in each section rather than querying the user for this information. This command line is a comment line with an * or the letter C in column 1 followed by the word RENBR and then any switches for which values are being specified. A typical 20 The RENBR User's Guide command line would be CRENBR/I:-10/B:10(NAME/SUBTITLE FOR LISTING) O 200 N 400 where slashes could appear before the single letter switches and colons could appear between the single letter switches and the following numbers. However, these slashes and colons are not required. Examples of each of the switches which can appear on the CRENBR command line are shown below, together with typical values for the following numbers, where allowed. /A:2 add 2 blanks to lines in DO loop or IF THEN block /B:100 base statement number is 100 /C:80 comment lines are 80 characters wide /I:5 increment between statement numbers is 5 /M mixed statement number regions /M:100 modify only statement numbers of 100 or larger /M:1:9 modify only statement numbers in range 1 through 9 /N:500 new groups of numbers are 1 - 499, 500 - 999 etc. /O:100 old groups of numbers are 1 - 99, 100 - 199 etc. /R= statement numbers in comment lines start with = (ONE/TWO) ONE is routine name, TWO is subtitle on each page The switches are described in more detail below. /A causes extra blanks to be added to the left of the text of each statement inside a DO loop or inside an IF THEN block in the program or routine in which it appears. These blanks are added regardless of whether the program or routine is renumbered or listed. When DO loops or IF THEN blocks are embedded, the range of each additional loop or block is indented further. The actual number of blanks added to each line is indicated by the number which follows the /A switch. If the user has specified the /A switch when RENBR was started, and the /A switch also appears on the CRENBR command line, then the value specified on the CRENBR command line will be used instead, but only in the program or routine in which it appears. The CRENBR command line containing the /A switch should be issued at the start of a program, or immediately following the first statement of a routine, since the /A switch cannot change the indentation in the listing of block structures which precede its appearance if renumbering is not being performed. /B sets the smallest statement number which is to appear in the program or routine in which it appears if the program or routine is renumbered. The actual value of the smallest statement number is indicated by the number which follows the /B switch. Normally, this would be the first statement number in the renumbered program, but if the increment between consecutive statement numbers is specified to be negative, then the smallest number will be the final statement number within the program. If the /B switch does not appear on the CRENBR command line, then the value used as the smallest statement number will be that specified by the user when RENBR was started, or will be the absolute value of the statement number increment if the user did not specify the smallest statement number when RENBR was started. Maintaining Logical Blocks of Statement Numbers 21 /C specifies that more than 72 characters are to be retained in each of the subsequent FORTRAN comment lines in the current program or routine. The number following this switch is the maximum number of characters, in addition to the 72 characters usually processed, which are to be read and written in each FORTRAN comment line. If this number has a value of 72 or greater, then this number is instead assumed to be the total number of characters which are to be retained in each FORTRAN comment line. Either a /C:8 or a /C:80 switch would cause up to 80 characters to be included in each FORTRAN comment line. The /C switch does not apply to the preceding FORTRAN comment lines or to the CRENBR command line in which it appears. Although a previous CRENBR command line could have changed the number of characters retained in the current CRENBR command line, only the first 72 characters are ever evaluated on any CRENBR command line. The maximum value which can appear with the /C switch is 120. /I specifies the statement number increment. The number following this switch will be the increment between consecutive statement numbers. If the /I switch does not appear on the CRENBR command line, then the value used as the increment will be that specified by the user when RENBR was started, or will be 1 if the user did not specify a statement number increment when RENBR was started. /M if issued without a following number, then the statement number regions which are to be maintained during renumbering can be mixed, rather than separated into logical blocks. An example of the use of the /M switch is given in a later section of this instruction manual. The /M switch must not be issued if logical blocks are to be maintained as described in this section of the manual. If the /M switch is followed by 2 numbers, then these numbers are the the lowest and highest original statement numbers which will be modified. All original statement numbers which are either less than the first number or greater than the second number will be retained. The first number following the /M switch is assumed to be 1 if it is missing but the second number is specified. The second number is assumed to be 99999 if it is missing but the first number is specified. The /M switch could be used to identify a section of a program or routine which is to be modified and then grafted back into the original program or routine since all references within the section to statements outside the section would remain correct. For example, the switch /M:100:200 or M100 200 would cause only those statement numbers which are in the range 100 through and including 200 to be renumbered. If the /M switch is followed by a single number, then the second number is assumed to have the value 99999 so that all statement numbers which are equal to or greater than the specified number will be modified. The /M switch might be used with a single number to prevent the accidental renumbering of a routine, or to allow the renumbering of only the more recent changes to a routine if an earlier version of the routine is being retained for comparison. If a number or pair of numbers follows the /M switch, then the CRENBR command line can also contain /B and /I switches to select the statement number base and increment, but /N and /O switches on the CRENBR command line will be ignored. 22 The RENBR User's Guide /N specifies the new region size. The number following this switch specifies the jump in generated statement numbers from the start of one region to the next in the renumbered program or routine. To prevent erroneous scaling of the statement numbers during a subsequent renumbering of the program or routine which contains the CRENBR command line, a /O (old region size) switch is removed when renumbering is performed if the /O switch has been preceded within the current program or routine by a /N switch, and each /N switch is converted to a /O switch. If the /N switch does not appear on any CRENBR command line in the program or routine, then the old region size as specified by the /O switch is also used as the new region size. If neither the /N switch nor the /O switch appears on any CRENBR command line in the program, then the regions of statement numbers are not preserved. /O specifies the old region size. The number following this switch specifies the jump in the original statement numbers from the start of one region to the next in the program which is being renumbered. To prevent erroneous scaling of the statement numbers during a subsequent renumbering of the program or routine which contains the CRENBR command line, a /O switch is removed when renumbering is performed if the /O switch has been preceded within the current program or routine by a /N (new region size) switch, and each /N switch is converted to a /O switch. If the /O switch does not appear on any CRENBR command line in the program or routine, then the new region size as specified by the /N switch is also used as the old region size. If neither the /N switch nor the /O switch appears on any CRENBR command line in the program, then the regions of statement numbers are not preserved. /R specifies how statement number references are to be indicated in comment lines. The first printing (neither a blank nor a tab) character following the R switch will be scanned for on all comment lines and, whenever this character is found followed by a number, then this number will be taken as a statement number reference. If a colon follows the /R switch, then colons will mark statement numbers which appear on comment lines. If renumbering is being performed, then the number marked by this character will be replaced by the new value of the referenced statement number. If a listing is being produced, then the number marked by this character will be placed into the list of statement number references with the associated line number being that of the FORTRAN statement which precedes the comment in which the number is located. If more than 1 statement number reference appears on a single comment line, then each must be preceded by the character. The character is scanned for only on lines which are indicated to be comments by the character (such as an asterisk or the letter C) which appears in column 1. Spaces and/or tabs can appear on the comment line between the key character and the following statement number but are not required. Spaces or tabs cannot appear between the digits of a single statement number on a comment line. ( specifies the routine name. The printing characters which follow the ( switch, through the end of the line, or up to the next appearance of a right parenthesis or slash character on the line, are to be used as the routine name in the table of contents, and at the upper right corners of the pages containing the listing of the routine. Only the Maintaining Logical Blocks of Statement Numbers 23 first 6 printing characters will be used if more than 6 printing characters are specified in the name. If the ( switch is not issued or does not specify a name, then the routine name will be that read from the SUBROUTINE, FUNCTION, BLOCK DATA or PROGRAM statement. The ( switch can be used to label main programs even though these would not usually have names. If a slash (the / character) appears after the ( switch or after the routine name following the ( switch, then the characters which follow the / character, through the end of the line, or to the next appearance of a matching right parenthesis on the line, will be used as the subtitle in the listing. Such a subtitle can consist of at most 44 characters and can include blanks and balanced parentheses. The subtitle is not changed if the / character does not appear after the ( switch or after the routine name following the ( switch. The subtitle will be blank if it is not specified anywhere in the program or routine. The CRENBR command line containing the ( switch should be issued at the start of a program or immediately following the first statement of a routine since the ( switch cannot change the routine name or subtitle in that portion of the listing preceding its use if renumbering is not being performed. (If renumbering is being performed, then the CRENBR command line is interpreted on the first pass through the input program, and the listing is produced on the second pass. However, if renumbering is not being performed, then the listing is produced in a single pass.) The switches can appear in any order on the CRENBR command line. Only the /I switch will accept a negative value. Although the initial * or letter C must be in column 1, blanks and tabs can appear anywhere else on the CRENBR command line except within numbers. The values specified by the CRENBR command line apply to all statement numbers within a single program or routine, but the CRENBR command line can appear anywhere in the program or routine before the terminal END statement. If multiple CRENBR command lines appear within a single program or routine, then the values which are used are the final values specified for each switch. The CRENBR command line applies only to the program or routine in which it appears. The default values of the switches (set by the user when RENBR was started) are restored for the next program or routine read. In the case of the /N and /O switches, these defaults are to not preserve regions. The CRENBR command line CRENBR I-10 B 10 O 200 N 400 would specify that original regions such as 1-199, 200-399 and 400-599 would be translated to new regions such as 1-399, 400-799 and 800-1199. The actual translation would depend on the relative placement of the original regions. To allow the insertion of new statements into a region, statement numbers which would normally be outside the region are taken as part of the surrounding region if statement numbers both before and after the insertion are within the region. If the statement number increment is positive, then this searching for the final statement number which is also within the region starts at the top of the program 24 The RENBR User's Guide and proceeds towards the bottom of the program. If the statement number increment is negative, then the searching starts at the bottom of the program and proceeds towards the top of the program instead. For example, the original program shown at the left below would be converted to the program shown at the center when renumbered. In this example, the statement number at the top of the program is 317 which is in the range 200 to 399. The final statement number which is within this same range is 285, so all of the statements located between statements 317 and 285 are also included in the first region. The next statement below the end of the first region is number 15 which is in the range 1 to 199. The final statement number which is in this same range is 99, so all of the statements located between statements 15 and 99 are also included in the second region. The bottom 2 numbers 1600 and 1622 are in the same range and form the third region. CRENBR I 10 B10 CRENBR I 10 B10 CRENBR I -10 B10 CRENBR/O:200/N:500 CRENBR/O:200/O:500 CRENBR/O:200/O:500 317 GO TO 1622 10 GO TO 1010 1010 GO TO 10 216 GO TO 1600 20 GO TO 1000 1000 GO TO 20 4260 GO TO 99 30 GO TO 540 540 GO TO 30 285 GO TO 1650 40 GO TO 530 530 GO TO 40 15 GO TO 4266 500 GO TO 520 520 GO TO 500 4200 STOP 510 STOP 510 STOP 4266 GO TO 4200 520 GO TO 510 500 GO TO 510 1650 GO TO 15 530 GO TO 500 40 GO TO 520 99 GO TO 285 540 GO TO 40 30 GO TO 530 1600 GO TO 4260 1000 GO TO 30 20 GO TO 540 1622 GO TO 216 1010 GO TO 20 10 GO TO 1000 END END END If the increment specified by the /I switch on the CRENBR command line in the original program shown at the left above were to be -10 instead, then the program shown at the right would result when the program was renumbered. Since the increment is negative, the searching for regions of statement numbers starts at the bottom of the program, rather than at the top. Here, the first range would begin at the bottom of the program with the statement numbered 1622, and would extend backward through the statement numbered 1650 which is the most distant statement having a number in the range 1600 to 1799. The second region would begin with the next statement which is numbered 4266 and extend backward through the statement numbered 4260. Creating Logical Blocks of Statement Numbers -------- ------- ------ -- --------- ------- To convert the statement numbers in a program to indicate the logical blocks in which they appear, RENBR could be run several times with the user selecting different values with the /M and /B switches to change a different range of statement numbers each time. Alternatively, all of the statement numbers can be converted in a single renumbering if new statements, which bear statement numbers outside the logical block ranges found elsewhere in the program, are inserted at the start and end of each consecutive logical region of statements to force conversion of statement numbers within these regions into consecutively higher ranges. If the CRENBR command line specifies that logical blocks of statement Creating Logical Blocks of Statement Numbers 25 numbers are to be preserved, then RENBR, when assigning new statement numbers, will terminate each logical block of statement numbers at the final statement number which is within the range defined by the first statement number of the block. If this technique is used, then there should be a temporary statement at both the start and the end of the program and 2 temporary statements between consecutive regions. Since the statements which temporarily define logical blocks should be removed during or after renumbering, these statements need not be written in legal FORTRAN. If these temporary statements consist only of statement numbers but no statement text, then RENBR will remove these statement numbers when the program or routine is renumbered. Following the renumbering, a statement number will be missing from the lower end of each region until the program is next renumbered. For example, to convert the first 2 statements in the program shown at the left below into a first region, the next 5 statements into a second region, and the rest into a third region, a CRENBR command line and numbered but otherwise empty statements could be inserted as shown in the program in the middle. Processing of the program shown in the middle would produce the program shown at the right in which the first 2 statements are now in the range 1 through 49, the second in the range 50 through 99, and the third in the range 100 through 149. Since the region size in the final program is 50, RENBR has changed the /N:50 on the CRENBR command line to be /O:50 instead. Subsequent renumbering of the final program would retain the new statement number regions and would set the first numbers in the regions to 1, 50 and 100 respectively. 1 GO TO 9 CRENBR/O:100/N:50 CRENBR/O:100/O:50 2 GO TO 8 100 2 GO TO 102 3 GO TO 7 1 GO TO 9 3 GO TO 101 4 GO TO 6 2 GO TO 8 51 GO TO 55 5 STOP 101 52 GO TO 54 6 GO TO 5 200 53 STOP 7 GO TO 4 3 GO TO 7 54 GO TO 53 8 GO TO 3 4 GO TO 6 55 GO TO 52 9 GO TO 2 5 STOP 101 GO TO 51 END 6 GO TO 5 102 GO TO 3 7 GO TO 4 END 201 300 8 GO TO 3 9 GO TO 2 301 END Maintaining Number Regions Keyed to Statement Types ----------- ------ ------- ----- -- --------- ----- Many programmers use statement number size to indicate the types of the statements with which they are associated. In particular, FORMAT statements and the statements at the ends of DO loops are often assigned large numbers. Use of the /M switch without a following number on the CRENBR command line allows the resulting mixed statement number regions to be maintained during renumbering. The new statement numbers are based on the order in which they appear within their respective regions. 26 The RENBR User's Guide The high order or leftmost digits (relative to the original region size) of the statement numbers are maintained unless an expanding region overflows into the next higher region in which case the higher region must be offset to prevent duplication of the new statement numbers. For example, the program shown at the left below would be converted to the program shown at the center when renumbered. If the increment specified by the /I switch on the CRENBR command line were to be changed to -10, then the program shown at the right would be produced instead. CRENBR/O:1000/I10/M CRENBR/O:1000/I10/M CRENBR/O:1000/I-10/M 317 GO TO 1622 10 GO TO 1020 50 GO TO 1000 216 GO TO 1600 20 GO TO 1010 40 GO TO 1010 4260 GO TO 99 4000 GO TO 50 4020 GO TO 10 285 GO TO 1650 30 GO TO 1000 30 GO TO 1020 15 GO TO 4266 40 GO TO 4020 20 GO TO 4000 4200 STOP 4010 STOP 4010 STOP 4266 GO TO 4200 4020 GO TO 4010 4000 GO TO 4010 1650 GO TO 15 1000 GO TO 40 1020 GO TO 20 99 GO TO 285 50 GO TO 30 10 GO TO 30 1600 GO TO 4260 1010 GO TO 4000 1010 GO TO 4020 1622 GO TO 216 1020 GO TO 20 1000 GO TO 40 END END END Including NonFORTRAN Text in the Input File --------- ---------- ---- -- --- ----- ---- The first line of the first input source file, and the first line following each FORTRAN END statement, are scanned for the appearance of the letters RENBRSTART anywhere on the line. The letters RENBRSTART can be preceded by any other characters and can be separated by blanks or tabs. If the letters RENBRSTART are found, then the current line and all following lines through the end of the final input source file or up to the next CRENBR command line will be treated as comment lines. The name to be associated with the current comment section, and a subtitle for the listing, can appear to the right of the letters RENBRSTART in the form in which this information could appear on a CRENBR command line. The name and subtitle will be blank in the listing if these are not specified by the RENBRSTART command line. Additional RENBRSTART command lines can appear within the comment section to force the printing of a new page with new name and new subtitle. If the comment section is terminated by a CRENBR command line, then this CRENBR command line is considered to be a part of the following FORTRAN program or routine. The ability to include comment sections within the input file allows assembly language routines, command files and data to be listed with the FORTRAN programs with which these are used. If renumbering is being performed, then the comment sections are copied into the output file unchanged. If a listing is being produced, then a line sequence number is printed beside each line within the comment section, and the comment section name and the total number of lines within the comment section are included in the table of contents, but the words and numbers appearing in the comment section are not indexed. Including NonFORTRAN Text in the Input File 27 A RENBRTITLE command line can be used for much the same purpose as a RENBRSTART command line. These 2 types of command lines are identical if encountered at the start of the first input source file or after a FORTRAN END statement. The only difference between these 2 types of command lines is that, when encountered within an already established comment section, the RENBRTITLE command line does not force the printing of a new page and, if the RENBRTITLE command line does not specify a subtitle, then the subtitle previously specified for the comment section will remain unchanged. The RENBRTITLE command line is used to enter an additional comment section name, and comment section line total, into the table of contents without starting a new page in the listing. If the storage used for the table of contents is already full, then the current table of contents will have to be printed before the new name can be added, so under these conditions even the RENBRTITLE command line would force printing of a new page after the table of contents. A typical sequence of FORTRAN programs and comment sections would be text of FORTRAN program or routine END any charactersRENBRSTART(NAME/SUBTITLE) comment section text any charactersRENBRTITLE(NAME/SUBTITLE) additional comment section text CRENBR(NAME/SUBTITLE) text of another FORTRAN program or routine END It should be noted that if the FORTRAN system does not allow end-of-file tests in READ statements, then the sequence of lines CRENBR END END must appear at the end of the input source file to force the printing of the table of contents if no other FORTRAN routines follow the comment section. Statement Types Recognized by RENBR --------- ----- ---------- -- ----- RENBR can recognize statement numbers contained in the following types of FORTRAN statements. In these examples, the number 20 has been used to represent any FORTRAN statement number and the number 10 has been used to represent a number which is not a statement number. The key words which identify these statements can also be used as variable names or as array names without causing any difficulties. The ability to handle statement numbers in other types of statements can be easily added. 28 The RENBR User's Guide ACCEPT 20 ACCEPT 20,LIST OF VARIABLES ACCEPT(FMT=20,ERR=20,END=20)LIST OF VARIABLES ACCEPT TAPE 20 ACCEPT TAPE 20,LIST OF VARIABLES ASSIGN 20 TO INTEGER VARIABLE BACKFILE(10,ERR=20) BACKFILE(UNIT=10,ERR=20) BACKSPACE(10,ERR=20) BACKSPACE(UNIT=10,ERR=20) CALL ROUTINE(OPTIONAL ARGUMENTS,*20,OPTIONAL ARGUMENTS) CALL ROUTINE(OPTIONAL ARGUMENTS,$20,OPTIONAL ARGUMENTS) CALL ROUTINE(OPTIONAL ARGUMENTS,&20,OPTIONAL ARGUMENTS) CLOSE(OPTIONAL SPECIFICATIONS,ERR=20,OPTIONALSPECIFICATIONS) DECODE(10,20,VARIABLE)LIST OF VARIABLES DECODE(10,20,VARIABLE,ERR=20)LIST OF VARIABLES DO 20 INTEGER VARIABLE=EXPRESSION,EXPRESSION DO 20,INTEGER VARIABLE=EXPRESSION,EXPRESSION DO 20 INTEGER VARIABLE=EXPRESSION,EXPRESSION,EXPRESSION DO 20,INTEGER VARIABLE=EXPRESSION,EXPRESSION,EXPRESSION ENCODE(10,20,VARIABLE)LIST OF VARIABLES ENCODE(10,20,VARIABLE,ERR=20)LIST OF VARIABLES ENDFILE(10,ERR=20) ENDFILE(UNIT=10,ERR=20) FIND(10'10,ERR=20) FIND(10#10,ERR=20) FREQUENCY 20(OPTIONAL NUMBERS), ... ,20(OPTIONAL NUMBERS) FREQUENCY 20(10,10,10),20,20(10),20(10,10) !FOR EXAMPLE GO TO 20 GO TO INTEGER VARIABLE(20, ... ,20) GO TO INTEGER VARIABLE,(20, ... ,20) GO TO (20, ... ,20)INTEGER VARIABLE GO TO (20, ... ,20),INTEGER VARIABLE IF(EXPRESSION)20,20 IF(EXPRESSION)20,20,20 IF(EXPRESSION)STATEMENT IF ACCUMULATOR OVERFLOW 20,20 IF ACCUMULATOR OVERFLOW 20,20,20 IF DIVIDE CHECK 20,20 IF DIVIDE CHECK 20,20,20 IF QUOTIENT OVERFLOW 20,20 IF QUOTIENT OVERFLOW 20,20,20 INQUIRE(OPTIONAL SPECIFICATIONS,ERR=20,OPTIONAL SPECIFICATIONS) OPEN(OPTIONAL SPECIFICATIONS,ERR=20,OPTIONAL SPECIFICATIONS) PRINT 20 PRINT 20,LIST OF VARIABLES PRINT(FMT=20,ERR=20)LIST OF VARIABLES PUNCH 20 PUNCH 20,LIST OF VARIABLES PUNCH(FMT=20,ERR=20)LIST OF VARIABLES PUNCH TAPE 20 PUNCH TAPE 20,LIST OF VARIABLES READ 20 READ(10,20) READ(10,20,END=20) READ(10,20,ERR=20) READ(10,20,ERR=20,END=20) Statement Types Recognized by RENBR 29 READ(10,20,END=20,ERR=20) READ(10,FORMAT,END=20) READ(10,FORMAT,ERR=20) READ(10,FORMAT,ERR=20,END=20) READ(10,FORMAT,END=20,ERR=20) READ(10'10,20,ERR=20,END=20) READ(10#10,20,ERR=20,END=20) READ 20,LIST OF VARIABLES READ(10,20)LIST OF VARIABLES READ(10,20,END=20)LIST OF VARIABLES READ(10,20,ERR=20)LIST OF VARIABLES READ(10,20,ERR=20,END=20)LIST OF VARIABLES READ(10,20,END=20,ERR=20)LIST OF VARIABLES READ(10,FORMAT,END=20)LIST OF VARIABLES READ(10,FORMAT,ERR=20)LIST OF VARIABLES READ(10,FORMAT,ERR=20,END=20)LIST OF VARIABLES READ(10,FORMAT,END=20,ERR=20)LIST OF VARIABLES READ(10,FMT=20,END=20,ERR=20)LIST OF VARIABLES READ(UNIT=10,FMT=20,END=20,ERR=20)LIST OF VARIABLES READ(10'10,20,ERR=20,END=20)LIST OF VARIABLES READ(10#10,20,ERR=20,END=20)LIST OF VARIABLES READ INPUT TAPE 10,20 READ INPUT TAPE 10,20,LIST OF VARIABLES REREAD 20 REREAD 20,LIST OF VARIABLES REREAD(FMT=20,END=20,ERR=20)LIST OF VARIABLES REWIND(10,ERR=20) REWIND(UNIT=10,ERR=20) SKIPFILE(10,ERR=20) SKIPFILE(UNIT=10,ERR=20) SKIPRECORD(10,ERR=20) SKIPRECORD(UNIT=10,ERR=20) TYPE 20 TYPE 20,LIST OF VARIABLES TYPE(FMT=20,ERR=20)LIST OF VARIABLES UNLOAD(10,ERR=20) UNLOAD(UNIT=10,ERR=20) WRITE 20 WRITE(10,20) WRITE(10'10,20) WRITE(10#10,20) WRITE 20,LIST OF VARIABLES WRITE(10,20)LIST OF VARIABLES WRITE(10,FMT=20,ERR=20)LIST OF VARIABLES WRITE(UNIT=10,FMT=20,ERR=20)LIST OF VARIABLES WRITE(10'10,20)LIST OF VARIABLES WRITE(10#10,20)LIST OF VARIABLES WRITE OUTPUT TAPE 10,20 WRITE OUTPUT TAPE 10,20,LIST OF VARIABLES In addition to the above, the following statement types are recognized although these do not contain statement number references. 1. DATA and FORMAT statements are recognized so that items following these keywords are not indexed. 30 The RENBR User's Guide 2. DO WHILE(expression) and END DO statements are recognized to allow optional indentation of statements within their ranges. 3. IF(expression)THEN, ELSE IF(expression)THEN, ELSE, and END IF statements are recognized to allow optional indentation of statements within their ranges. 4. BLOCK DATA, PROGRAM, SUBROUTINE, ENTRY and FUNCTION statements are recognized so that program and routine names can be obtained from these. The FORTRAN operators and delimiters shown below are recognized. This list does not include operators such as ** (exponentiation) and // (concatenation) which can be considered to be a series of shorter operators. .LT. .EQ. .GT. .AND. .OR. .EQV. .LE. .NE. .GE. .NOT. .XOR. .NEQV. ( ) = + - * / , < > # : ^ RENBR handles as a single unit any character string which either is preceded by the decimal number of characters and the letter H or else is preceded and followed by apostrophes. It is likely that no harm will result if programs containing other character string designations are renumbered. If some character other than the apostrophe is used as the delimiting character in programs or routines which are to be renumbered, then the only situation likely to give trouble will be when IF statements are used to test character data against character strings containing either left or right parentheses. RENBR was used for several years before the ability to handle character strings as single units was even added to it. Statement numbers appearing in CALL statements can be preceded either by an asterisk, by a dollar sign or by an ampersand. Appendix A: Sample Table of Contents and Listing 31 Appendix A: Sample Table of Contents and Listing -------- - ------ ----- -- -------- --- ------- RENBR can, at the user's request, produce a listing of the source programs. The listing of each separate main program or routine is begun on a new page. In the upper right corner of each page are printed both the current page number and the name of the program or routine. To the left of each non-comment statement is printed the count or sequence number of the statement within the current program or routine. If a statement must be split to keep it within the margins of the listing, then the extra characters are right justified on the next line and minus signs are placed in the statement count field if the right justified extra text does not begin with a blank character. If there is a blank at the start of the right justified extra text, then the number of initial blanks is printed within parentheses in the statement count field instead. Following the listing of the program or routine is a list of statement numbers and of the sequence numbers of the statements in which these statement numbers are referenced. If renumbering is not being performed, then this list will also include as negative numbers the sequence numbers of the numbered statements themselves. These negative numbers are not included in the list of statement number references if renumbering is being performed. If renumbering is being performed, then the array space which would be needed to store the negative numbers is used instead to store information needed to perform the renumbering. It is felt that the negative numbers do not really need to be shown if renumbering is being performed, since then the resulting statement numbers will be in order anyway, so that further assistance is not needed to locate them. After the list of statement number references is an index of all key words, variable names and constants used in the program or routine. Each of these items is accompanied by a list of the sequence numbers of the statements in which these items appear. The sequence number is negative if the equals sign operator is used in the statement to assign a value to the item. The keywords GO TO and IF are excluded from the index because they are used almost as often as the punctuation operators. Likewise, the format specifications which appear within FORMAT statements, and the list of values which are assigned by DATA statements, are not included in the index. A table of contents containing the names of the routines and programs appears at the end of the listing. The following information is also shown at the top of the table of contents. 1. The total number of FORTRAN statements which start on new lines. This number does not include statements which appear to the right of semicolons on the same line as other statements. Continuation lines and comment lines also are not included. 2. The total number of comment lines appearing within FORTRAN programs and routines. These are lines which are indicated as being comments by the character appearing in column 1. This number does not include comments which appear to the right of exclamation points in the text field. 32 The RENBR User's Guide 3. The total number of lines in comment sections which were designated by either RENBRSTART or RENBRTITLE command lines. 4. The average number of consecutive FORTRAN statements which were not separated by comment lines or by the end of programs or routines. This number is truncated down to the next lower whole number. 5. The average number of consecutive FORTRAN comment lines which were not separated by FORTRAN statements. This number is truncated down to the next lower whole number. Each program and routine name appears twice in the table of contents. The program and routine names are listed down the left side of the page sorted alphabetically by name. The program and routine names are listed down the right side of the page in the order in which they appear in the listing. The page numbers appear with the routine names in both lists. The total number of FORTRAN statements in each program and routine is also shown in the list at the right side of the page. A single page of the table of contents can contain the names and page locations of up to 28 programs or routines. If the listing contains more than 28 programs or routines, then the table of contents will be broken into separate pages which will be scattered through the listing. The program or routine names appearing in the table of contents are sorted alphabetically only among those others which appear on the same page of the table of contents. If it is desired that the program and routine names which appear on several pages be sorted alphabetically together, then the sizes of 2 arrays will have to be increased in the RENBR program. The REBIG program described elsewhere in this manual can be used to change the sizes of these arrays. Instructions for increasing the array sizes manually are also given in the BLOCK DATA routine in RENBR. A listing of one of the routines used by RENBR itself is shown on the next pages. The width of the lines in this listing have been reduced slightly (by 3 characters) to 60 characters to fit into the current document regardless of how it is formatted. The table of contents produced by RENBR when it was used to list itself is shown first. Appendix A: Sample Table of Contents and Listing 33 APPENDIX: SAMPLE TABLE OF CONTENTS AND LISTING Table of Statements 3483, Comments 3700, NonFORTRAN 0 Contents (Avg Group) 10, 11 Page Length Page DASORT SUBROUTINE 223 RENBR BLOCK DATA 47 1 RECHCK SUBROUTINE 66 RENBR MAIN PROGRAM 29 48 RECLS1 SUBROUTINE 288 RESET SUBROUTINE 90 57 RECMND SUBROUTINE 179 RECHCK SUBROUTINE 29 66 REDAT1 SUBROUTINE 277 RE1ST SUBROUTINE 283 74 REDONE SUBROUTINE 142 RE2ND SUBROUTINE 286 89 REFIL1 SUBROUTINE 245 REPLAC SUBROUTINE 467 104 REFLG1 SUBROUTINE 254 REOUT SUBROUTINE 293 126 REHLP1 SUBROUTINE 280 REDONE SUBROUTINE 70 142 REINDX SUBROUTINE 159 RENUMB SUBROUTINE 55 151 RENBR BLOCK DATA 1 REINDX SUBROUTINE 397 159 RENBR MAIN PROGRAM 48 RECMND SUBROUTINE 229 179 RENEXT SUBROUTINE 206 RETITL SUBROUTINE 201 193 RENUMB SUBROUTINE 151 RENEXT SUBROUTINE 111 206 REOPN1 SUBROUTINE 264 RETOP SUBROUTINE 36 215 REOUT SUBROUTINE 126 DASORT SUBROUTINE 46 223 REPLAC SUBROUTINE 104 REUSR1 SUBROUTINE 318 227 REPRT1 SUBROUTINE 271 REFIL1 SUBROUTINE 113 245 RESET SUBROUTINE 57 REFLG1 SUBROUTINE 120 254 RETITL SUBROUTINE 193 REOPN1 SUBROUTINE 99 264 RETMP1 SUBROUTINE 284 REPRT1 SUBROUTINE 97 271 RETOP SUBROUTINE 215 REDAT1 SUBROUTINE 10 277 REUSR1 SUBROUTINE 227 REHLP1 SUBROUTINE 23 280 RE1ST SUBROUTINE 74 RETMP1 SUBROUTINE 17 284 RE2ND SUBROUTINE 89 RECLS1 SUBROUTINE 5 288 SECND1 FUNCTION 290 SECND1 FUNCTION 12 290 34 The RENBR User's Guide APPENDIX: SAMPLE TABLE OF CONTENTS AND LISTING Page 223 SORT ROUTINE DASORT SUBROUTINE 1 SUBROUTINE DASORT(IARRAY,ILOWER,IUPPER,JARRAY) C RENBR(/SORT ROUTINE) C C DONALD BARTH, HARVARD BUSINESS SCHOOL C C REGIONS CONTAINING INITIAL ORDERING ARE SWAPPED BY C THREADING ITEMS BEING MOVED INTO NEW LOCATIONS. C C IARRAY = THE ARRAY TO BE SORTED. C ILOWER = LOWEST SUBSCRIPT OF REGION TO BE SORTED. C IUPPER = HIGHEST SUBSCRIPT OF REGION TO BE SORTED. C JARRAY = ARRAY TO BE HELD PARALLEL TO IARRAY. C 2 DIMENSION IARRAY(1),JARRAY(1) C C FIND UPPER END OF LOWER REGION TO BE SWAPPED 3 IPNTR=ILOWER 4 1 MID=IPNTR 5 IPNTR=IPNTR+1 6 2 IF(IPNTR.GT.IUPPER)GO TO 12 7 IF(IARRAY(IPNTR).GE.IARRAY(MID))GO TO 1 C C FIND LOWER END OF LOWER REGION TO BE SWAPPED 8 ITEST=IARRAY(IPNTR) 9 LOW=ILOWER 10 3 IF(ITEST.LT.IARRAY(LOW))GO TO 4 11 LOW=LOW+1 12 GO TO 3 C C FIND UPPER END OF UPPER REGION TO BE SWAPPED 13 4 JTEST=IARRAY(LOW) 14 5 MAX=IPNTR 15 IPNTR=IPNTR+1 16 IF(IPNTR.GT.IUPPER)GO TO 6 17 ITEST=IARRAY(IPNTR) 18 IF(ITEST.LT.IARRAY(MAX))GO TO 6 19 IF(ITEST.LT.JTEST)GO TO 5 C C PERFORM THE THREADED SWAP OF ORDERED REGIONS C C IF THERE WERE SEVERAL PARALLEL ARRAYS, IT MIGHT C BE CONVENIENT TO REPLACE THE FOLLOWING SECTION BY C CALLS TO THE SWAPPING ROUTINE DASWAP SIMILAR TO C C CALL DASWAP(IARRAY,LOW,MID,MAX) C CALL DASWAP(JARRAY,LOW,MID,MAX) C 20 6 ITEST=LOW-MAX-1 21 LAST=MAX 22 LOW=LOW-MID-1 23 JTEST=MAX-MID Appendix A: Sample Table of Contents and Listing 35 APPENDIX: SAMPLE TABLE OF CONTENTS AND LISTING Page 224 SORT ROUTINE DASORT SUBROUTINE 24 7 INDEX=LAST+LOW 25 IKEEP=IARRAY(LAST) 26 JKEEP=JARRAY(LAST) 27 8 ITEST=ITEST+1 28 INEW=IARRAY(INDEX) 29 JNEW=JARRAY(INDEX) 30 IARRAY(INDEX)=IKEEP 31 JARRAY(INDEX)=JKEEP 32 IKEEP=INEW 33 JKEEP=JNEW 34 IF(INDEX.GT.MID)GO TO 9 35 INDEX=INDEX+JTEST 36 GO TO 8 37 9 IF(INDEX.EQ.LAST)GO TO 10 38 INDEX=INDEX+LOW 39 GO TO 8 40 10 IF(ITEST.EQ.0)GO TO 11 41 LAST=LAST-1 42 GO TO 7 C C PREPARE TO FIND NEXT ORDERED REGION 43 11 MID=MAX 44 GO TO 2 45 12 RETURN 46 END 36 The RENBR User's Guide APPENDIX: SAMPLE TABLE OF CONTENTS AND LISTING Page 225 SORT ROUTINE DASORT SUBROUTINE Statement Number Referenced by 1 -4 7 2 -6 44 3 -10 12 4 10 -13 5 -14 19 6 16 18 -20 7 -24 42 8 -27 36 39 9 34 -37 10 37 -40 11 40 -43 12 6 -45 Appendix A: Sample Table of Contents and Listing 37 APPENDIX: SAMPLE TABLE OF CONTENTS AND LISTING Page 226 SORT ROUTINE DASORT SUBROUTINE Word Contained in DASORT 1 DIMENSION 2 END 46 IARRAY 1 2 7 8 10 13 17 18 25 28 -30 IKEEP -25 30 -32 ILOWER 1 3 9 INDEX -24 28 29 30 31 34 -35 37 -38 INEW -28 32 IPNTR -3 4 -5 6 7 8 14 -15 16 17 ITEST -8 10 -17 18 19 -20 -27 40 IUPPER 1 6 16 JARRAY 1 2 26 29 -31 JKEEP -26 31 -33 JNEW -29 33 JTEST -13 19 -23 35 LAST -21 24 25 26 37 -41 LOW -9 10 -11 13 20 -22 24 38 MAX -14 18 20 21 23 43 MID -4 7 22 23 34 -43 RETURN 45 SUBROUTINE 1 0 40 1 2 5 11 15 20 22 27 41 38 The RENBR User's Guide Appendix B: List of Files Forming This Package -------- - ---- -- ----- ------- ---- ------- The following files are needed to load the various versions of the RENBR program. REHLP1.FOR, REHLP2.FOR, etc. FORTRAN sources of the various versions of the REHELP routine which are called by the corresponding versions of RENBR to display instructions to the user. These files are produced by using the FORMAT program to process the rough drafts of the instructions in the REHLP1.RNO, REHLP2.RNO files, etc. REHLP1.RNO, REHLP2.RNO, etc. Rough drafts of the various versions of the instructions which can be displayed by some versions of RENBR. These files would be processed using the FORMAT program to produce the FORTRAN source code in the REHLP1.FOR, REHLP2.FOR files, etc. RENBRC.FOR Source of the RENBR program which internally uses character strings as defined by the FORTRAN77 standards rather than Hollerith variables. RENBRH.FOR Source of the RENBR program which internally uses Hollerith variables which were supported by FORTRAN prior to the FORTRAN77 standards. The versions of RENBR in the RENBRC.FOR and RENBRH.FOR files can both process other FORTRAN programs which are written in FORTRAN77 or prior versions of FORTRAN. The only known difference in the results obtained when using these versions on the DECsystem10 computer is in the listings, and is due to the sort order for characters specified in Hollerith or 1H notation being different than that for characters specified in CHARACTER*1 notation. This causes numbers and character strings quoted with apostrophes to appear in the indexes after other variables when RENBRH.FOR is used to produce listings, but before other variables when RENBRC.FOR is used. There should not be any differences in the resulting renumbered files. The RENBRC.FOR and RENBRH.FOR files each contain the entire program with the exception of the machine dependent routines REUSER, RETEMP and RECLOS which process the commands typed by the user and open and close all files. One of the REHELP routines to type instructions will also be needed with all but the simplest versions of the user interaction routines. RENBR1.CMD, RENBR2.CMD, etc. Command files for loading the various versions of RENBR. These versions differ in the manner in which the user specifies file names and options. These versions also differ in whether the RENBR program internally uses character strings or Hollerith variables. Appendix B: List of Files Forming This Package 39 The following command files load versions of RENBR which internally use Hollerith variables which were supported by FORTRAN prior to the FORTRAN77 standards. RENBR1.CMD loads RENBRH,REUSR1,RETMP1,REHLP1 This version for the DECsystem10 asks for commands of the form files=files/options. RENBR2.CMD loads RENBRH,REUSR2,RETMP1,REHLP2 This version asks for all options, then separately for file names. RENBR3.CMD loads RENBRH,REUSR3,RETMP1 This version asks separately for file names, and assumes standard options. RENBR4.CMD loads RENBRH,REUSR4,REHLP4 This version for the DEC VAX asks for commands of the form files=files/options. The following command files load versions of RENBR which internally use character strings as defined by the FORTRAN77 standards rather than Hollerith variables. On the DECsystem10, however, the versions loaded with these command files do not run as efficiently, since the DECsystem10 FORTRAN compiler cannot optimize programs which contain character variables. The version loaded using RENBR5.CMD typically takes 5 times longer to process files than does the optimized version loaded using RENBR1.CMD. RENBR5.CMD loads RENBRC,REUSR5,RETMP5,REHLP5 This version is similar to that loaded by RENBR1.CMD. RENBR6.CMD loads RENBRC,REUSR6,RETMP5,REHLP6 This version is similar to that loaded by RENBR2.CMD. RETMP1.FOR Sources of the RETEMP routine which opens and closes the scratch file and of the RECLOS routine which closes the output files for use on the DECsystem10. This file must be compiled and loaded together with RENBRH.FOR and either REUSR1.FOR, REUSR2.FOR or REUSR3.FOR. RETMP5.FOR Sources of the same routines as in the RETMP1.FOR file, except that those in RETMP5.FOR use character strings rather than Hollerith variables. This file must be compiled and loaded together with RENBRC.FOR and either REUSR5.FOR or REUSR6.FOR. REUSR1.FOR Sources of the REUSER routine, and of several routines which are called by REUSER, for use on the DECsystem10. This version of these routines accepts a single line command which consists of the names of the output files and associated switches, followed by an equal sign and the list of input files. This version of these routines should be compiled with the FORTRAN-10 compiler, version 5 or greater, 40 The RENBR User's Guide with optimization. The ERR= transfers will have to be removed from the OPEN statements if this version of these routines is compiled using the F40 compiler or with earlier versions of the FORTRAN-10 compiler. Before the routines in the REUSR1.FOR file can be compiled with the F40 compiler, the DATA statements which define the left and right square brackets will have to be commented out of two of these routines and be replaced by the octal notation DATA statements which are currently commented out. REUSR2.FOR Source of a simple version of the REUSER routine for use on the DECsystem10. This version of the REUSER routine accepts a single line command which consists only of switches, and then asks on subsequent lines for the names of the output and input files. This version of the REUSER routine will probably be easier to convert for use on other computer systems than that in REUSR1.FOR. REUSR3.FOR Source of a very simple version of the REUSER routine for use on the DECsystem10. This version of the REUSER routine merely asks for the output and input file names. REUSR4.FOR Sources of the REUSER routine, of the RETEMP routine, of the RECLOS routine, and of several routines which are called by REUSER, for use on the Digital Equipment Corporation VAX computer. A single line command is accepted which consists of the names of the output files and associated switches, followed by an equal sign and the list of input files. Full VAX file specifications are supported, including nodes and version numbers. Percent signs have replaced semicolons as command separators since semicolons can precede version numbers in VAX file specifications. The default filetype (or extension) for the renumbered output file has been changed to .FOR since the default version number prevents destruction of the original file. REUSR5.FOR Sources of the REUSER routine and the routines which it calls which have been converted internally to use character strings rather than Hollerith variables. This version accepts the names of the output files and associated switches, followed by an equal sign and the list of input files. It is based upon the routines in REUSR1.FOR. REUSR5.FOR must be used with the version of RENBR in RENBRC.FOR, and with the routines in RETMP5.FOR and REHLP5.FOR. REUSR6.FOR Source of the REUSER routine which has been converted internally to use character strings rather than Hollerith variables. This version accepts a single line of switches, and then asks for the names of the files individually. It is based upon the routines in REUSR2.FOR. REUSR6.FOR must be used with the version of RENBR in RENBRC.FOR, and with the routines in RETMP5.FOR and REHLP6.FOR. Appendix B: List of Files Forming This Package 41 The following files contain documentation. RENBR.DIC List of less common words which appear in this manual, and of sequences of characters which appear together in this manual but which are not words. This list can be used to customize the dictionary of a spelling verification program when processing this manual. RENBR.DOC This instruction manual. RENBR.RNO The rough form of this instruction manual. This is meant to be processed by the FROFF text processor. The following files contain support programs. REBIG.FOR FORTRAN program which can be used to change the sizes of the arrays used by RENBR to store the information which appears in the statement number table and in the index of variable names and constants. REBIG can also be used to change the maximum number of numbered statements allowed, and to change the maximum number of continuation lines allowed. RECUT.FOR FORTRAN program to split a large file containing most or all of the RENBR program into many small files each containing merely a single routine or a few closely associated routines. The RECUT program can also be used to merge the small files back into the large file. The large file can either contain the sources of only the relatively machine independent portions of RENBR, or can also contain the sources of the various versions of REUSER and RETEMP as well. REFMT.DAT Data file which can be read by REFMT to specify the current order of the items in the arrays. REFMT.FOR FORTRAN program which reorders the items in the arrays which control the recognition by RENBR of the various types of FORTRAN statements. REH2C.FOR FORTRAN program which reads the version of RENBR which internally uses Hollerith notation and produces a version which uses character strings instead. REOPR.DAT Data file which can be read by REOPR to specify the FORTRAN operators currently recognized by RENBR. REOPR.FOR FORTRAN program which constructs the DATA statements which define the arrays used by RENBR in the recognition of FORTRAN operators. 42 The RENBR User's Guide The following files contain test cases. NOTABS.GET File containing the results which are expected when RENBR is used to renumber the test cases in the NOTABS.TRY file. NOTABS.LPT File containing the results which are expected when RENBR is used to list, but not renumber, the test cases in the NOTABS.TRY file. NOTABS.TRY File containing many test cases. The programs and routines in this file are not meant to be compiled. A file identical to NOTABS.GET should result when RENBR is used to process the contents of the NOTABS.TRY file. Neither of these files contain any tab characters. The file TABS.TRY contains several cases meant to test the handling of statements written using the DECsystem10 tab form. TABS.GET File containing the results which are expected when RENBR is used to renumber the test cases in the TABS.TRY file. TABS.LPT File containing the results which are expected when RENBR is used to list, but not renumber, the test cases in the TABS.TRY file. TABS.TRY File containing several cases meant to test the handling of statements written using the DECsystem10 tab form. The programs and routines in this file are not meant to be compiled. A file identical to TABS.GET should result when RENBR is used to process the contents of the TABS.TRY file. The file NOTABS.TRY contains many other cases meant to test the handling of statements written using the standard column form. Appendix C: RENBR Development History 43 Appendix C: RENBR Development History -------- - ----- ----------- ------- RENBR is based upon a 418 statement FORTRAN program of unknown origin which was in use at Yale University in 1965 or shortly thereafter. The present version of the program consists of 10 times that many statements. The general construction of the table which drives the statement number recognition process is still based upon that in the original program. However, the statements which perform the binary search of sorted statement numbers are all that remain from the original program. The features which have been added to the program by the current author are listed below. June 1970 1. Extension. Listing of each program or routine includes statement number reference table and word reference table. March 1971 1. Extension. FORTRAN operators such as .EQ. and .LT. separate components of statements. 2. Extension. Character string following leading number and letter H or enclosed between apostrophes is treated as single component of statement. 3. Extension. Program or routine name and type are printed at upper right corner of each page of listing. 4. Extension. REFMT program reorders items in the arrays which direct the syntax recognition process. May 1971 1. Correction. DATA statement generator used by the REFMT program did not correctly handle the 2 negative numbers having largest absolute value and the largest positive number. June 1972 1. Extension. Program being renumbered can contain mixture of column form and tab form statements. Output can be selected in either form. 2. Extension. When there is a change in the number of digits in a statement number in the statement text, blanks are added or removed at the end of the line, if possible, to cause the position of following continuation lines to remain unchanged. 3. Correction. Spaces and tabs were not allowed between the number of characters and the letter H preceding a character string. July 1972 1. Correction. END statement could not be in tab form. February 1973 1. Correction. Continuation column contained non-digit characters in listing if renumbering was not being performed. 44 The RENBR User's Guide January 1975 1. Extension. Logical blocks of statement numbers can be maintained. 2. Extension. Specification of options by single characters instead of by answers to dialog questions. 3. Extension.Optional specification by the CRENBR command of the statement number increment, base and blocks to be maintained. 4. Extension. Indication in listing of names appearing on left side of equals signs. 5. Extension. Optional specification by the user of the number of lines to be printed per page in the listing. 6. Extension. Optional insertion of counted line feeds between pages of listing. 7. Extension. Optional splitting of long lines in listing. This is necessary if counted line feeds are used on a narrow width listing device. 8. Extension. Conversion of tab characters in comment lines to multiple blanks so as to fill to the proper tab stops in the listing. This allows comment lines listed by RENBR to be spaced the same as if the programs had been listed left justified. Unless otherwise specified by the W option, the width of the tab stop columns is assumed to be 8 characters. 9. Extension. Optional conversion of tab characters in comment lines to multiple blanks so as to fill to the proper tab stops in the renumbered output. Conversion of tab characters in comment lines to blanks in the renumbered output is helpful when converting programs for computer systems which do not recognize the tab character. Unless the /W switch is selected, tab characters in comment lines are left intact when copied into the renumbered output. It must be noted that tab characters within FORTRAN statements are left intact by RENBR unless such tab characters separate the digits of a statement number. 10. Extension. Optional recognition of marked statement number references in comment lines. Such marked statement numbers in comment lines are included in the table of statement number references, and can be renumbered. 11. Extension. Optional specification by the CRENBR command of the routine name and subtitle for use in the listing. 12. Extension. Optional multiple copies of table of contents. 13. Extension. Ability to include nonFORTRAN comment sections in input file. This is signalled by the letters RENBRSTART or RENBRTITLE appearing in the first line of the file or after a FORTRAN END statement. 14. Extension. ENTRY statements are included in table of contents. 15. Extension. Table of contents is ordered both serially and alphabetically. Only serial ordering was provided previously. 16. Extension. Optional insertion of blank lines between FORTRAN statements in the listing. Blank lines are not inserted between comment lines, nor between the start of a statement and its continuation lines. 17. Extension. Optional indentation of statements within the range of DO loops. Appendix C: RENBR Development History 45 January 1979 1. Extension. Optional insertion of extra empty lines into the bottom and top of consecutive pages of the listing so that fan-folded paper can be bound at the top. 2. Extension. Program name established by PROGRAM statement is used as name of a main program. 3. Extension. Semicolon can appear between pair of statements on same line. 4. Extension. Exclamation point followed by a comment can appear to the right of a statement. 5. Extension. Statements can be written in a mixture of upper and lower cases. 6. Extension. Colon can appear between letter identifying switch and the following number on CRENBR command line. 7. Extension. Numbers on CRENBR command line can have leading plus sign. 8. Extension. Single characters <, > and # are relational operators. Single character : is a subscript separator. .NEQV. is a logical operator. 9. Extension. /M switch typed by user or on CRENBR command line can be followed by values of lowest and highest statement numbers which can be changed while renumbering. 10. Extension. Instructions to RENBR program are given in form OUTPUT FILES=LIST OF INPUT FILES in which switches identify purposes of output files. 11. Extension. Optional left justification of statement numbers when column form is selected. 12. Extension. /N switch in CRENBR command line is output as /O switch. /O switch in CRENBR command line is removed if a /N switch has already been found. 13. Extension. Lower case letters appearing outside character strings are converted to upper case when indexed. 14. Extension. Optional indentation of statements within the range of IF(expression)THEN and ELSE statements. 15. Extension. To support FORTRAN77 standards, asterisk in column 1 indicates comment. 16. Extension. REOPR program constructs DATA statements which define arrays which control the recognition of operators such as +, - and .NOT. 17. Extension. /C switch on CRENBR command line can cause comment lines to be longer than 72 characters. 18. Extension. Summary of storage utilization for the listing is shown to user only if the user types the /Z switch or if one of the tables overflows. Previously, this summary was always shown to the user. 19. Extension. Programs and routines having a great many statement numbers (over 1000 with arrays dimensioned as supplied) can be processed although the old statement numbers are retained. Previously, such programs and routines could be listed, but not processed. Listings produced whenever the old statement numbers are being retained, whether due to an error being found in the first pass or to the user issuing a /M switch without following numbers, include in the tables of statement references the line numbers of the statements bearing these statement numbers. Previously, the line numbers of the statements bearing the statement numbers were included in the tables of statement number references only if the programs and routines were not being 46 The RENBR User's Guide processed. 20. Modification. Character information has been separated from numeric information in storage of index and of table of contents to ease future conversion to FORTRAN77 standards. All variables and arrays which contain a single character in each logical location which can be addressed by subscript have names beginning with the letters LTR for variables and arrays which can contain either upper or lower case, and LWR for variables and arrays which can contain only lower case and for which there are also corresponding named variables or arrays which contain only upper case. All variables and arrays which contain more than a single character in each logical location have names beginning with letters such as LA4 (for 4 characters on VAX computer) or LA5 for 5 characters on DECsystem10 computer) and are used only in the file opening and closing routines which are hardware dependent anyway. All variables and arrays which contain character information and which are needed by more than just a single routine are stored in labeled COMMON blocks which contain no numeric information. These are the only places where the letter sequences LTR, LWR, LA4 and LA5 are used in the RENBR program. 21. Modification. Main program only controls the execution of several subroutines. Previously, the main program also initialized the variables in common and read the programs and routines the first time to locate the statement numbers. The structure of the program was modified in this manner to make overlaying easier. If the program is overlaid, however, then the contents of the COMMON blocks in the REUSER routine and in the REOPEN routine which is called by some versions of the REUSER routine will have to be preserved. 22. Correction. Leading non-numeric character was not repeated on continuation lines of a statement being generated in column form. 23. Correction. Exponent is included in index with numbers written in E or D notation. Previously, signed exponents were indexed separately. March 1985 1. Correction. When a listing was being prepared with indented block structures, the leftmost characters on the first line after the removal of a level of indentation would not be placed into the index. 2. Correction. ELSE IF and END IF keywords were each indexed as 2 words if a blank appeared before the word IF. 3. Correction. Routine names were not correctly inserted into table of contents by CRENBR comment lines. If the routine already had a name, so that it was really being renamed, then the new name was not converted to upper case, was not inserted into the correct alphabetical order based upon the new name, and, if shorter than 6 characters, was right justified rather than being left justified. 4. Correction. IF statements which assigned a new value to variables having names starting with THEN caused the following lines to be indented an extra level. 5. Modification. Length of command line typed by user or read from command file changed from 72 to 80 characters. 6. Modification. GOTO and IF keywords are excluded from the indexes. 7. Conversion. Version of RENBR produced which internally uses character strings rather than Hollerith variables. Appendix C: RENBR Development History 47 8. Extension. Block structure indicated by DO WHILE and DO number WHILE statements can be shown by indentation. 9. Extension. Statement numbers in DO number WHILE statements are recognized. 10. Extension. ACCEPT, PRINT, PUNCH, OPEN, READ, REREAD, REWRITE, TYPE, WRITE and most other input/output statements accept statement numbers to right of FMT=, ERR= and END= in a list enclosed within parentheses. 11. Extension. Statement numbers in BACKFILE, BACKSPACE, ENDFILE, FIND, INQUIRE, REWIND, SKIP FILE, SKIP RECORD, and UNLOAD commands are recognized. 12. Extension. Lines starting with exclamation point, slash or dollar sign are taken as comments. Previously, only lines starting with letter C or asterisk were taken to be comments. 13. Extension. Circumflex which indicates exponentiation is treated as a FORTRAN operator. 14. Extension. REFMT program produces output file which can be used as next input file to obtain minimum number of chains of tests. 15. Extension. New program named REH2C written to convert RENBR from the use of Hollerith notation to character notation. 16. Extension. New program named REBIG written to change the sizes of arrays used by RENBR to store the information in the table of statement numbers and in the index of variable names and constants. 17. Extension. New program named RECUT written to split apart files containing all of the sources of RENBR and then to merge them back together again. 48 The RENBR User's Guide Appendix D: Summaries Produced by the /Z Switch -------- - --------- -------- -- --- -- ------ The /Z switch can be issued by the user to produce a summary of the allocation and use of the arrays needed to store the information which is included in the listings. A description of the files which are read and written is also produced as these are opened. The summary of the utilization of the array space is similar to that shown at the left below. The numbers shown in this example would be for a very large program. The information in each line is described to its right. Through Page 263 page number on final page Page Total 265 total number of pages produced Extra Number Tables 3 how often number table overflowed Extra Word Tables 9 how often word table overflowed Statement Total 4636 Comment Total 4420 Storage Summary Num 1879/ 1000(- 60) statement number references Wrd Loc21774/ 5000(-400) locations of names and words Wrd Spl 6288/ 2000(-200) spelling of names and words Tbl 35/ 28 items in table of contents The number which appears to the left of the slash in each of the last 4 lines is an estimate of the amount of space used for the program or routine which required the most space for this particular table. If the corresponding table had to be printed in the middle of the listing of a single program or routine to make room for more information, then this number is the sum of the amount used each time that the table was printed in the program or routine which required the most space. The number to the right of the slash is the actual size of the array. The number in parentheses is an estimate of the array space needed to hold 1 additional page of information, and is the amount which must remain unused at the start of each new page in the listing of the lines of the program to avoid immediate production of the corresponding table. In order to list the longest program or routine without having to print the tables before the end of the program or routine, the array space which would be needed is thus the sum of the first and third numbers on each line. The summary of the files which are opened by the program will consist of lines which are similar to those which are shown below. The file conventions in these examples are for the DECsystem10 computer. These lines are produced by the user interface routines. KND 1 ERR 0 DSK :REFMT .RNB[000123,000456,SFD ] KND 2 ERR 0 DSK :REFMT .FOR[000123,000456,SFD ] KND 3 ERR 0 DSK :REFMT .NEW[000123,000456,SFD ] KND 4 ERR 0 DSK :REFMT .LPT[000123,000456,SFD ] KND 5 ERR 0 DSK :REFMT .FOR[000123,000456,SFD ] Appendix D: Summaries Produced by the /Z Switch 49 Each of these lines contains the following items of information. KIND = describes the type of file. = 1, input command file containing list of files to be processed. = 2, first input file to be processed. Output files have not yet been opened. = 3, output renumbered file. = 4, output listing file. = 5, second or subsequent input file to be processed. All output files have already been opened. ERROR = describes whether the attempt to open the file was successful. = 0, the file was opened successfully. = 1, the file could not be opened. These first 2 items are followed by the name of the disk structure, the name of the file and the name of the account owning the file. 50 The RENBR User's Guide Appendix E: Instructions for the Support Programs -------- - ------------ --- --- ------- -------- The programs described below are provided as development and maintenance aids for RENBR. These programs recognize the particular variable and array names used within RENBR, or produce new FORTRAN statements containing such names. They should not, therefore, be used in their current form to process programs other than RENBR, although they could be modified to do so. The REBIG Program --- ----- ------- The listings produced by RENBR include tables identifying the lines which bear statement numbers and which refer to these numbers, and indexes which list the lines which contain the various variables, constants and FORTRAN reserved words. These tables are usually printed following the listing of the statements in each main program and routine. However, if the arrays used to store these lists fill before the end of the program or routine is reached, then the lists will be printed in the middle of the listing of the statements so as to release the array space for storing additional information. As supplied, RENBR can produce uninterrupted listings of individual FORTRAN main programs or individual routines containing approximately 800 lines other than comments, although this limit is highly dependent upon programming style. Storing the information for 800 lines requires 2 integer arrays containing up to 1000 values each for the statement number references, an array containing up to 2000 characters for the words and constants in the index, and an integer array of up to 5000 values for the numeric information which is to be included in the index. A table of contents consisting of the names of the main programs, routines and entry points which are included in the listing, and the page numbers on which these start, is printed at the end of the listing. The names appearing in the table of contents are shown in 2 parallel lists, the left list being sorted alphabetically, and the right list being in the order in which the programs, routines and entry points appear in the listing. As supplied, RENBR can store the information for a table of contents which contains up to 28 names and which will fit onto a single page in the listing. If the listing contains more than 28 programs, routines and entry points, then RENBR will print a table of contents containing the names of the 28 programs, routines and entry points most recently listed at each point in the listing where the next name would not fit. However, the sizes of the arrays used to store the information which is to appear in the table of contents can be increased to allow the information for a longer table of contents to be accumulated. In addition to allowing the entire table of contents to appear at the end of the listing, increasing the sizes of these arrays also allows the names to be sorted alphabetically amongst all of the names appearing in the listing, rather than just among those appearing on the same page in the table of contents. Even without changing the sizes of the arrays, RENBR can renumber any individual main program or routine containing up to 1000 numbered statements if a listing is not being produced at the same time. The sizes of 2 arrays in RENBR will have to be increased if it is to be used Appendix E: Instructions for the Support Programs 51 to either list or renumber statements continued onto more than 19 continuation lines. The sizes of 2 other arrays in RENBR will have to be increased if it is to be used to renumber main programs or routines each containing more than 1000 numbered statements. The REBIG program can be used to change the sizes of these arrays in RENBR. The REBIG program asks for the various maximum numbers of items which must be allowed for in renumbering or listing a program, and calculates the dimensions of the arrays needed by RENBR from these answers. Except for the number of items in the table of contents, these maximum numbers are for the longest single main program or routine which will be processed, and do not depend at all upon how many programs or routines happen to be in the file or files which will be processed. The REBIG program reads the original version of RENBR, and produces a new version of RENBR as a result. Either the Hollerith or the character string version of RENBR can be processed. The RENBR block data routine, main program, all of its subroutines, and the version of the REUSER routine being used, must all be processed using the same answers to the questions. To save answering the same questions several times, these can all be appended into a single file before they are processed. REBIG should not be used again to process the resulting version of RENBR, since the strings being searched for include the original array sizes. If it is later found that the array sizes must be increased further, then the original version of RENBR should be processed again. The REBIG program requests that the user supply estimates for the maximum values of the following items. Number of names in table of contents (28/560) Number of numbered statements (300/500) Number of references of numbered statements (640/1100) Letters in names of different words and constants (1800/5000) Number of different words and constants (600/1100) Total appearances of all words and constants (1400/8100) Number of lines in a single statement (20/30) The first number which appears to the right of each of the above descriptions is the value currently allowed by RENBR. The number which appears to the right of the slash is a suggested value which is large enough to handle almost any program. If the user does not supply a new value for a particular item, i.e., if the user presses the RETURN key without typing anything else first, then the current value of that item is retained. The REBIG program will report the total array space needed to handle the estimates supplied by the user, and will display each line which is changed. The RECUT Program --- ----- ------- The RECUT program can be used to split a large file containing most or all of the RENBR program into many small files each containing merely a single routine or a few closely associated routines. The RECUT program can also be used to merge the small files back into the large file. The large file can either contain the sources of only the relatively machine independent portions of RENBR, or can also contain the sources of the various version of REUSER and RETEMP as well. 52 The RENBR User's Guide The RECUT program searches for the END statements in the file or files which are processed. Each END statement must consist of 6 spaces followed by the word END in upper case, and nothing else. Any other form of the END statement will not be recognized. Some of the small files processed by the RECUT program contain several related subroutines. When processing these files, the RECUT program counts the number of END statements to determine when the next file must be started. If the number of subroutines in any of the small files is changed, then the array in the RECUT program which specifies how many END statements are in each of the small files must be changed accordingly. The REFMT Program --- ----- ------- The RENBR program recognizes statement numbers in FORTRAN statements by applying some 2 dozen different possible operations in the order which is specified by a list of numbers which indicate what operation is to be performed next depending upon whether the current operation succeeds or fails. The capability to recognize new language constructs is added by appending the numbers selecting additional operations to the end of the list, modifying the success or failure destinations in the previous portion of the list so that the new operations are performed at the correct times, and making the final operations performed by the new portion of the list transfer back into the previous portion of the list to perform subsequent operations. Such patching produces a list which is difficult for a human to verify, but which can drive the RENBR program as efficiently as a list having any other order. Portions of the list which are no longer needed become inactive when the numbers indicating transfer to them are changed so that they can no longer be reached. Since the list is highly interconnected, changing the order of the items in the list to make it more easily understood or to remove obsolete sections is difficult to perform by hand and is prone to errors. The REFMT program which is supplied with RENBR can rearrange the items in the list and the words in the glossary referenced by the list into any desired order. All of the pointers within the list are kept correct. The only restriction is that the operation which appears first in the list cannot be shifted. The REFMT program also prints a written description of the list which shows the interconnections between the operations in the list. In order to use the REFMT program, it must be loaded with the Hollerith version of the BLOCK DATA routine from RENBR, and the labeled COMMON statement in the REFMT program must be identical to that in the BLOCK DATA routine. The only items which are used from the BLOCK DATA routine are the definitions of the LTRPRS, NUMPRS, LTRABC and LWRABC arrays. The contents of the LWRPRS array are defined by the REFMT array to be parallel to those in the LTRPRS array, but the original contents of the LWRPRS array are ignored. A few other variables which appear in the COMMON statements are also used internally in the REFMT program, but these are defined within the REFMT program. Appendix E: Instructions for the Support Programs 53 When it is started, the REFMT program will ask for the user to supply the names of the 4 files which are described below. The first of these files is an input file, the remaining 3 are output files. 1. The file specifying the desired order The REFMT program will rearrange the words in the vocabulary, and the operations needed to recognize the various types of statements, into the order specified by this file. 2. The file to which the new DATA statements are to be written The original version of these DATA statements can be removed from the BLOCK DATA routine, and the new version which is written into this file can be inserted, or else this file can be referenced directly by an INCLUDE statement in the BLOCK DATA routine. 3. The file to which the next input file is to be written The contents of this file are a suggestion only. If this file is used as the input file for a subsequent run of the REFMT program but without changing the DIMENSION and DATA statements in the BLOCK DATA routine, then the DIMENSION and DATA statements produced by this subsequent run will define a list with the minimum number of connected chains of operations, and with all obsolete words and operations being discarded. If the user instead wants to have direct control over the order, then this suggested version of the next input file can be ignored or edited. 4. The file to which the listing is to be written A description of the operations in the list will be written to this file. This file can be checked to verify which tests are performed, and the order in which they are applied. The words and single characters which must be recognized during the interpretation of FORTRAN statements are stored in the LTRPRS array. The input file read by the REFMT program should start with a list of these words and single characters. Each word or single character must be left justified on a separate line. The words and single characters in the LTRPRS array will be rearranged into the order indicated by this list, and all pointers to them will be changed accordingly in the NUMPRS array which indicates what operations are performed and in what order. Any words or single characters not specified by the file will be shifted upward in the LTRPRS array above those which are specified, but will remain in their original order relative to each other in the LTRPRS array. The words and single characters specified by the input file must already appear in the LTRPRS array. Including words and single characters in the input file merely indicates the order in which they are stored in the LTRPRS array. Including them in the input file does not allow them to be recognized if they were not recognized before, and does not change the order in which they will be recognized. The list of words and single characters must be terminated by a blank line. The blank line following this section of the file is necessary even if all of words and single characters in the LTRPRS array are specified by the file. For purposes of this section of the file, the several characters which can be recognized by the operation of type 6, which takes a different branch depending upon which character appears next in the statement, are considered to form a single word. 54 The RENBR User's Guide Following the first section of the file should be a list of the original serial numbers of the operations described by the NUMPRS array in the order in which these are desired to appear. These serial numbers must appear one per line. Operations are described in the NUMPRS array by an integral number of 5 values. Most operations are in fact described by exactly 5 values. Thus, the operation specified originally in locations 46 thru 50 would be selected by the serial number 10 if each of the earlier operations are described by 5 values, since these locations would form the 10th group of values in the original contents of the NUMPRS array. A zero or a blank line terminates this section of the file. Any groups of numbers not specified will be left in their original order relative to each other. In determining the serial numbers, earlier operations which are described by more than 5 values are each considered to be a single operation. Thus, if the NUMPRS array starts with a type 1 test, then a long type 6 taking more than 5 locations, then another type 1 test, the third test will have 3 as its serial number even though it starts beyond location 11. An input file which consists only of 2 blank lines would result in the production of DIMENSION and DATA statements which are identical to those already in the BLOCK data routine. Such an input file might be used to produce a listing of the initial structure of the lists, or to obtain a new version of the input file which could then be used to more logically reorder the arrays. The REH2C Program --- ----- ------- The version of the RENBR program which is supplied in the RENBRH.FOR file reads, processes and writes Hollerith 1H arrays. Since Hollerith notation is no longer supported by the FORTRAN77 standards, the algorithms used in RENBR have been written so that they will work with character*1 arrays as well. The conversion from the version of RENBR which uses Hollerith notation to that which uses FORTRAN77 character strings only requires the insertion of several CHARACTER*1 statements into the program, and the conversion of character strings where these appear in DATA statements and FORMAT statements from Hollerith notation to apostrophe notation. These changes can be performed automatically by the REH2C program. The RENBRC.FOR file which is supplied was produced directly from the RENBRH.FOR file by the REH2C program. However, the REUSER program was extensively rewritten by hand to make better use of character strings in the OPEN statements. The REOPR Program --- ----- ------- The RENBR program recognizes the single character FORTRAN operators such as +, -, *, / and the multiple character FORTRAN operators such as .EQ. and .NOT. by testing for the characters which could appear next in the operator based upon those which have already been found, and then transferring to a different point in a controlling table depending upon whether the current test is a success or a failure. The REOPR program is used to produce the DATA statements which specify this table. The Appendix E: Instructions for the Support Programs 55 BLOCK DATA routine from RENBR does not have to be loaded with the REOPR program since the operators which are to be recognized are defined by the data file. The REOPR program reads a single input file which specifies each operator left justified on a separate line. All characters of multiple character operators such as .AND. must be specified without any separating spaces. Alphabetic characters in the input file should either be all upper case or all lower case. The input file should be terminated by an empty line if the END= end of file test in READ statements is not available. The contents of a file which could be processed by REOPR to produce the DATA statements defining the table currently used by RENBR are listed in comment lines in the BLOCK DATA routine in RENBR. The REOPR program writes the DATA statements needed to recognize the operators into an output file. If the list of operators which RENBR is to recognize is to be changed, then the contents of this file should replace the corresponding DIMENSION and DATA statements already in the BLOCK DATA routine in RENBR. The file produced by REOPR also includes comment lines describing the tests which are performed by RENBR in recognizing the operators. These comment lines are followed by DATA statements specifying each character to be matched, the location of the next character to be tested for if a match succeeds, and the location of the next character to be tested for if a match fails. All alphabetic characters appear twice in the DATA statements, regardless of their case in the input file, first in upper case and then in lower case. If it is not necessary that RENBR be able to recognize operators formed from both cases, then the entire section of code in the REOPR program which recognizes the alphabetic letters and inserts the corresponding lower case letters can be removed. The procedure which is used to produce the DATA statements is really meant for representing large arrays. Such large arrays would be split into several arrays each small enough to be specified by a single DATA statement, then these small arrays would be equivalenced with the respective portions of the original large array. Since the arrays needed to specify the FORTRAN operators are short, such equivalencing is not really necessary. The DATA statements can be changed to define the overall arrays directly, and the EQUIVALENCE statements and the DIMENSION statements for the component arrays can then be discarded.