0012.JUSTIFY0009.FILL0024.NO FLAGS CAPITALIZE0018.LEFT MARGIN 00018.AUTOPARAGRAPH0016.PARAGRAPH 00020.RIGHT MARGIN 680013.NUMBER 10037.TITLE (RSX) RATFOR DOCUMENTATION0037.SUBTITLE VERSION 21 APRIL, 198000040013A. DESIGN00040067 RATFOR attempts to retain the merits of FORTRAN (universality,0060portability, efficiency), while hiding the worst FORTRAN0074inadequacies. RATFOR is FORTRAN except for two aspects. First, since0074flow control is central to any program, regardless of the application,^^^^^^^^^^^^0079the primary task of RATFOR is to conceal this part of FORTRAN from the user0063by providing decent flow control structures. Second, it is0064possible at the same time to clean up many of the "cosmetic"0073deficiencies of FORTRAN, thus providing a language which is easier to0022read and to write.00040070 Beyond these two aspects, flow control and cosmetics, RATFOR does0074nothing about other weaknesses of FORTRAN, except that the STRING data^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0074type is added. The design philosophy which has determined what should0073be in RATFOR and what should not has been that RATFOR should not know0074much FORTRAN. Further, that RATFOR should be as machine and operating0068system independent as possible to facilitate transport of RATFOR0041programs from one machine to another.00040062 I strongly recommend "Software Tools" (Addison-Wesley) by0069Kernighan and Plauger for more detail and not a little philosophy0029on which RATFOR is based.0011.NOFILL0007 0020 David P. Sykes,0038 American Management Systems, Inc.0022 1515 Wilson Blvd.0024 Arlington, VA 222090019 (703) 841-60860009.FILL0009.PAGE000400040011.NOFILL0026B. THE RATFOR LANGUAGE00040018B.1 Statements00040020(a) DO Statement00040011Syntax:00040014 DO limits0022 RATFOR statement00040012becomes:00040020 DO label limits0025 FORTRAN statement(s)0018label CONTINUE00040009.FILL0068 The "limits" can be any Control=Initial,Final,Increment string ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0085accepted by the local FORTRAN compiler, since it is copied into the FORTRAN code 0075directly. RATFOR supplies the appropriate statement number. BREAK and0058NEXT statements may be used within "RATFOR statement".00040011.NOFILL0006 0021(b) FOR Statement00040011Syntax:00040043 FOR (initialize; condition; increment)0022 RATFOR statement0005 0012becomes:0005 0034 initialize FORTRAN statement0045 label1 IF (.NOT.(condition)) GOTO label20026 FORTRAN statement(s)0033 increment FORTRAN statement^^^^^^^^0017 GOTO label10020 label2 CONTINUE0009.FILL0064 The "initialize" statement is executed, then "condition" is0078tested, if it is true, "RATFOR statement" is executed, then "increment" is0076executed and "condition" is tested again. If "condition" is ever false,0064the loop is broken and control passes to the next statement.00040075 "Initialize" is any single FORTRAN statement, which is to be done just0066once before the loop begins; "increment" is any single FORTRAN^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0070statement to be executed at the end of each loop, before the test;0070"condition" is anything that is legal in a logical IF to the local0021FORTRAN compiler.00040067 Any of the three parts may be omitted, although the semicolons0067must remain. A null condition is treated as always true, so an0072infinite loop results. BREAK and NEXT statements are allowed within0062"RATFOR statement"; NEXT jumps immediately to "increment".00040012.NOFILL 0012Example:00040029 FOR (I=80; I > 0; I=I-1)^^^^^^^^^^^^^^^^^^0027 IF (CARD(I) != blank)0012 BREAK00040009.FILL0067Note that the IF and the statement controlled by it (BREAK) are0072considered to be a single RATFOR statement, even though not enclosed0014in braces.000400040017.TEST PAGE 180011.NOFILL0020(c) IF Statement00040011Syntax:00040019 IF (condition)0023 RATFOR statement10009 ELSE0023 RATFOR statement200040012becomes:00040038 IF (.NOT.(condition)) GOTO label10026 FORTRAN statement1(s)0016 GOTO label20019label1 CONTINUE0026 FORTRAN statement2(s)^^^^^^^^^^^^^0019label2 CONTINUE00040009.FILL0066 The ELSE part is optional. The "condition" is anything legal0075in a logical IF to the local FORTRAN compiler. If "condition" is true,0072statement1 is executed. If it is false, and there is an ELSE clause,0072statement2 is executed. IF statements can be chained to provide the0037equivalent of the CASE statement:00040017.TEST PAGE 100011.NOFILL0006 0021 IF (condition 1)0023 RATFOR statement10026 ELSE IF (condition 2)0023 RATFOR statement20026 ELSE IF (condition 3)^0023 RATFOR statement30009 ELSE0023 RATFOR statement400040006 0016.TEST PAGE 90024(d) REPEAT Statement00040011Syntax:00040011 REPEAT0022 RATFOR statement0023 UNTIL (condition)0005 0012becomes:0005 0020 label1 CONTINUE0026 FORTRAN statement(s)0039 IF (.NOT.(condition)) GOTO label10005 0009.FILL0076The "RATFOR statement" is executed, then "condition" is tested. If not0047true, "RATFOR statement" is executed again.0005 0061The UNTIL part is optional, if it is omitted, the FORTRAN0012becomes:^^^^^^^^^^0011.NOFILL0005 0020 label1 CONTINUE0026 FORTRAN statement(s)0017 GOTO label10005 0009.FILL0068Thus, the loop is infinite and must be broken in some other way.0005 0072"RATFOR statement" is always executed at least once. BREAK and NEXT0063statements are allowed within the REPEAT, with NEXT jumping0069immediately to the UNTIL (if any, otherwise, repeating the loop).0075"Condition" can be anything legal in a logical IF to the local FORTRAN 0013compiler.0011.NOFILL0017.TEST PAGE 1200040005 ^^^^^^^^^^^^^^^^^0037(e) RETURN (expression) Statement0005 0005 0011Syntax:0005 0024 RETURN (expression)0005 0012becomes:0005 0035 function = (FORTRAN statement)0011 return0005 0009.FILL0066where "function" is the name of a FORTRAN function subprogram 0040which RATFOR remembers from the last0083"FUNCTION" statement it saw (i.e.,#the one that started the function subprogram0043in which the RETURN statement appears).0006 0070The parentheses are required (and are passed to the FORTRAN code).^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0038This statement makes it very clear0062exactly what value the function is returning as its value.0082"expression" can be any valid single FORTRAN statement that the local compiler0078allows to be equated to the function's name. The normal rules for FORTRAN0072RETURNs apply: this statment is valid only within a FORTRAN function0073subprogram; it may occur several times within a function; the normal 0064RETURN without the expression may occur anywhere, as always.0011.NOFILL0005 0005 0017.TEST PAGE 140004^0023(f) WHILE Statement00040011Syntax:00040022 WHILE (condition)0022 RATFOR statement00040012becomes:00040044label1 IF (.NOT.(condition)) GOTO label20025 FORTRAN statement(s)0016 GOTO label10019label2 CONTINUE00040009.FILL0076 As long as "condition" is true (which may be never), "RATFOR statement"0063is repeated; if it is ever false (including the first time)0078the loop is broken and execution continues with the next statement. BREAK^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0079and NEXT statements are allowed within "RATFOR statement"; with NEXT going0083directly to the "condition". "Condition" can be anything legal in a logical IF0034to the local FORTRAN compiler.00040011.NOFILL0006 0016.TEST PAGE 70007 0033(g) BREAK and NEXT Statements00040011Syntax:0006 0015 BREAK and0009 NEXT00040009.FILL0071 Allowed in DO, FOR, REPEAT, and WHILE loops to either proceed with0081the next iteration, or to break out of the loop. The BREAK jumps out of only^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0059one loop, regardless of how deeply nested the BREAK is.0004000400040009.PAGE0032B.2 RATFOR Language Features00040067(a) Since symbols are clearer than the .EQ., .GT., etc. used by0079FORTRAN, RATFOR allows the use of conventional mathematical symbols, which 0044it converts into the equivalent FORTRAN.00040011.NOFILL0017.TEST PAGE 1200040023 > or >> for .GT.0023 < or << for .LT.0018 >= FOR .GE.0018 <= for .LE.0018 == for .EQ.0027 !, _^, or ~ for .NOT.0036 !=, _^=, ~=, <>, or >< for .NE.^^^^^^^0023 _\ or | for .OR.0026 _\_\ or || for .XOR.0019 _& for .AND.0021 _&_& for .EQV.0005 0009.FILL0072(b) All characters between a pound sign (_#) and the end of the line0073are treated as comments. This is equivalent to the exclamation point0074comment feature in DEC FORTRAN. The pound sign may occur in the first0073column, if desired, replacing the FORTRAN "C" in column one (which is0070not allowed in RATFOR source code). In this case, the entire line^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0075(with the "_#" replaced by a "C"), will be copied into the FORTRAN code0054as a comment (unless the /CO switch is in effect).00040065(c) If the input file(s) contain more than one program module0073(delimited by the FORTRAN "END"), each new program will be started at0076the top of a new page in the listing file (if any) and will be separated0045by a formfeed in the FORTRAN output file.00040064(d) RATFOR source code lines are automatically continued if:0019.LEFT MARGIN 160014.INDENT -2^^^^^^^^^^^^^^^^^^^0021.NO AUTOPARAGRAPH00040076 - The statement is obviously incomplete at the end of the line,0070 as in the middle of the conditional part of a FOR or IF0025 statement,00040014.INDENT -20047 - When the line ends with a comma,00040014.INDENT -20067 - When the line ends with an underline character, (the0047 underline character is deleted).00040018.LEFT MARGIN 00018.AUTOPARAGRAPH0006 0070(e) Statements may be placed anywhere on the line. By convention,^^^0077blocks of statements are usually indented three or four spaces. Multiple0068statements may appear on one line if separated by semicolons (no0073semicolon is required at the end of a statement which is on a line by0068itself). If a statement begins with an all numeric token, it is0071assumed to be a FORTRAN statement label and is placed in colums 1-50026of the FORTRAN output.00040077(f) RATFOR source lines may be up to 90 characters long. FORTRAN code is^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0079generated with a maximum line length of 72 characters. FORTRAN continuation0035lines are created if necessary.00040072(g) Any group of one or more statements (within a single program and0072a single file) can be enclosed in braces or square brackets and then0077treated as a single RATFOR statement and used anywhere a single statement0072may be used. Braces ({ }) and square brackets ([ ]) are synonymous.00040012.NOFILL 0016.TEST PAGE 70005 0012Example:00040018 IF (I == J) [0009 J=10009 I=20007 ]0004^0064causes both statements to be executed if I equals J, whereas00040016 IF (I == J)0009 J=10008 I=20009.FILL00040075causes only J=1 to be executed conditionally; I=2 would be executed in0076any case because only one statement or bracketed group of statements is 0079controlled by the IF. "RATFOR statement" in any of the examples above could0072be a bracketed group of several statements, or a single un-bracketed0014statement.0004^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0079(h) Strings in double quotes (e.g.#"foo") are converted into the equivalent0071Hollerith string (e.g.#3hfoo), since that is the only legal form in0079ANSI standard FORTRAN. Single quotes strings (e.g.#'A') are passed to the 0066FORTRAN code unchanged. Both single and double quoted strings0069are treated as single tokens; this means that symbolic constants 0066within them are not processed and that the string must be less0049then "maxtok" (currently 70) characters long.0005 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^0061 Two successive apostrophes (single quotes) are passed to0073the FORTRAN code as a single apostrophe. Therefore, in direct access0075READ/WRITE statements, use two apostrophes together (e.g.#READ(1''23)).00040071(i) Embedded blanks are significant to RATFOR because they separate0073tokens and are used to break input code down into recognizable pieces0073(along with special characters). Leading and trailing blanks are not0068significant; in particular, the indentation of blocks of code is^^^^^^^^^^^^^^0072meaningless to the pre-processor; it is for visual information only.0073The pre-processor does no formatting of the RATFOR source code on the0069RATFOR listing; you must provide indentation and other formatting0073in the source code file the way you want it to appear on the listing.00040009.PAGE00040029C. PRE-PROCESSOR FEATURES000400040071 Keywords for pre-processor features must, like language keywords, 0071appear at the beginning of a line or after a semicolon. Except for^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0073Debug and Literal lines, these features must not appear in the middle0058of RATFOR statements, nor between an IF and it's ELSE.0005 0005 0011.SKIP 10016C.1 INCLUDEs00040029 When a line of the form:00040033 INCLUDE RSXfilespecification00040078is encountered in the RATFOR source code, the specified file is opened and0072the input of source code continues from the start of that file until0071its end is reached, at which time input reverts to the next line of^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0079the original file. The INCLUDEd file may itself contain INCLUDEs; they can0080be nested three deep. The format for the file specification is the standard0082for RSX, optionally including UIC and device specifications, (the defaults are0077the user's UIC and SY:); an extension (the default is RAT), and a version0036(default is the latest version).0005 0060 If the symbol "defaultopen" is defined (in RATRSX.RAT),0058and if the include file is not found based on the file^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0061specification as given in the INCLUDE statement, then the0076defaults specified in "defaultopen" are prefixed to the specification in0083the INCLUDE and another attempt to find the file is made. However, this occurs0083only if the original specification in the INCLUDE contains neither a device nor0073a UIC. Note that the default string defined in "defaultopen" MUST be0090in double quotes; it can contain a device specification, a UIC specification, or both.0011.NOFILL0005 0012Example:0005 ^^^^^^^^^^^^^0036 DEFINE (DEFAULTOPEN="LB:[1,1]")0016 INCLUDE FOO0005 0047causes an attempt to open using "FOO.RAT".0069If that fails, another attempt to open using "LB:[1,1]FOO.RAT" 0012is made.0005 0009.FILL00040071 If you do not want the contents of the INCLUDEd file to be printed0070in the listing file, a "no-list" switch is allowed in the INCLUDE:00040037 INCLUDE/NL RSXfilespecification00040069Any INCLUDEs within the specified file will not be listed either,^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0072regardless of the switch settings of their INCLUDE lines. (Only the0035slash is actually checked for.)00040065 Statements and lines cannot be split across file boundaries;0071otherwise, the INCLUDEd code is processed just as if it had been in0028the original input file.00040066 In order to set the INCLUDEd code apart from the normal code,0071lines of code being taken from an INCLUDEd file are preceded by one0071or more asterisks on the listing (if they are listed). First level^^^^^^^^^^^^^^^^^^^^^^^^^0070INCLUDEs are preceded by one asterisk, INCLUDEs within INCLUDEs by0068two asterisks, and third level INCLUDEd code by three asterisks.00040071 The INCLUDE feature is especially handy where COMMON blocks are to0069be used by several different programs, since only one copy of the0073COMMON block and all associated declarations need be kept up to date,0073but subroutines, definitions, or any other code can be in an INCLUDEd0076file. INCLUDEs are also very useful for files containing a standard set^^^^^^^^0074of DEFINEs, which can then be INCLUDEd in a series of related programs0011easily.00040011.SKIP 20016.TEST PAGE 40035C.2 DEFINE (Symbolic Constants)00040063 The pre-processor contains a simple text-replacement macro0073capability that allows the user to create symbolic constants (similar0073to FORTRAN variables, but not limited to six characters), and specify0073a "meaning" or definition for each, which can remain in effect across0069several programs. When the RATFOR code is converted into FORTRAN^^^^^^0070code, all occurrences of symbolic constants in the RATFOR code are0078replaced by their defined equivalents in the FORTRAN code. The definition0048itself may, in turn, be a symbolic constant.0078DEFINE statements may not appear in the middle of other RATFOR statements.0012.NOFILL 0005 0016.TEST PAGE 90012Example:00040030if DEFINE (character=BYTE)0027and DEFINE (maxline=80)0006 0033then character LINE (maxline)00040050is converted into the equivalent FORTRAN code:00040019 BYTE LINE (80)0009.FILL0004^^^0068 The symbolic constant ("character" in the first line above) and0074its definition ("BYTE") must be enclosed in parentheses and separated 0040by either a comma or an equals sign.00040077 Currently, the symbolic constant and its definition can each be up to 700074characters long (their length is DEFINEd in the pre-processor) but the0049entire DEFINE statement must fit on one line.00040023 Symbolic constants0068must be single, unique alphanumberic character strings beginning^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0082with a letter; no special characters (except underline) or blanks are allowed.0071Underlines may be embedded in symbolic constants so that COBOL-like0056names can be used, e.g.#DEFINE#(DO__MONTH__END=YES).0065The definition of a symbolic constant can be another symbolic0074constant. Once a symbolic constant is defined, it cannot be redefined0056within the files processed by a single command line.0005 0016 Definitions0072can be any character string less than 70 characters long but may not^^^^^^^^^^^^^^^0078contain dollar signs. If the definition contains parentheses, they must be0019balanced pairs.00040065 The definition, either in whole or in part, can consist of a0073simple integer mathematical relationship between one or more symbolic0074constants and/or integers enclosed in less-then and greater-than signs0076(< >). Addition, subtraction, multiplication, and division are allowed.0082Evaluation of the expression is strictly left to right; there is no precedence^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0074of operators. If the expression contains previously defined symbolic 0075constants, they are replaced by their definitions prior to mathematical0076evaluation. The result of the part is included in the definition0072in place of the expression (it may be the entire definition).0073Numbers and the definitions of symbolic constants must be positive or0022negative integers.00040017.TEST PAGE 140012.NOFILL 00040021if DEFINE (foo=7)0037then DEFINE (blatz=)0004^^^^^^^^^^^^^^^^^^^^^0049makes "blatz" equal "69" and is equivalent to00040022 DEFINE (blatz=69)0011.BREAK 0007and0012.BREAK 0034 DEFINE (dumb=VERSION )00040034makes "dumb" equal "VERSION 8"0009.FILL0071 If the /SC switch is specified in the command line, a table of all0067current (as of the end of the processing for that command line)0077symbolic constants and their definitions is included in the listing file.00040072 DEFINE statements may occur anywhere in a RATFOR program, except in^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0063the middle of another RATFOR statement. Definitions remain0074in effect for the remainder of processing of the command line in which0069the file containing them occurred. Normally, all definitions are0068cleared before processing the next command line, but this can be0073prevented by specifying the /RE (RETAIN) switch in the second command0070line. A symbolic constant cannot be DEFINEd twice in files in the0075same command line (or any INCLUDEd files used by that command line), or^^^^^^^^^^^^^^^^^^^^0073a subsequent command line if the /RE switch is used, since that would0081consitute redefinition, which is not allowed. DEFINEs and MACROs can be, and0033often are, in INCLUDEd files.00040010.SKIP20014C.3 MACROs00040069 The MACRO facility is exactly like the DEFINE facility (in fact,0077the keywords are really synonymous), except that MACROs allow the passing0073of a single argument to be included in the definition at one or more 0072places at pre-processing time. The place(s) in the definition where^^0073the argument is to be inserted are specified in the definition with a0074special flag character (a dollar sign). A MACRO is distinguished from0070a simple DEFINE by the presence of at least one dollar sign in the0015definition.0076MACROs may not appear in the middle of other RATFOR statements, but may0040appear anywhere else in the program.0017.TEST PAGE 160012.NOFILL 0005 0012Example:00040022 MACRO (foo,$=$+1)00040044then foo(I) in the RATFOR code becomes0032 I=I+1 in the FORTRAN code.0004^^^^^^^^0057because each "$" in the definition is replaced by the0017argument "I".00040023if DEFINE (star=46)0033and MACRO (flag=ECOL($)=star)0006 0038then flag(7) in the RATFOR code0045becomes ECOL(7)=46 in the FORTRAN code.0004000400040060C.4 IFDEF / IFNOTDEF / ENDIFDEF (Conditional processing)00040009.FILL0067 Sections of RATFOR code (one or more lines) can be selectively0072processed into FORTRAN or ignored, depending upon the current define^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0068status of a specific symbolic constant. When "IFDEF(symbol)" is0068encountered in the RATFOR source code, a check is made to see if0071"symbol" has previously appeared in a DEFINE or MACRO statement; if0069it has, the source code up to the balancing ENDIFDEF statement is0069processed; if not, the source code is skipped until the balancing0058ENDIFDEF is found. The "IFNOTDEF(symbol)" is similar,0070except that the RATFOR source code up to the balancing ENDIFDEF is^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0058processed if "symbol" has NOT been previously defined.0006 0073 The symbolic constant can be given a null definition, if it is being0078defined only for use with the IFDEF/IFNOTDEF statements (e.g.#DEFINE(foo=)0070is sufficient). IFDEFs (and IFNOTDEFs) can be nested; if an outer0072conditional is unsatisfied, all inner conditionals are skipped, just0059like all other code within the unsatisfied conditional.00040017.TEST PAGE 100012.NOFILL 0005 0012Example:0006 0019 DEFINE (foo=3)0019 DEFINE (foo1=)^^0016 IFDEF (foo)0009 I=90020 IFNOTDEF (foo1)0010 I=720013 ENDIFDEF0013 ENDIFDEF00040009.FILL0070I=9 is processed; I=72 is ignored. Because the IFNOTDEF is nested0066within the IFDEF, if "foo" were not defined, I=72 would not be0049processed regardless of the status of "foo1".00040068 Undefined conditional code (that not processed into FORTRAN) is0074normally printed in the RATFOR source listing, but will have no source0074code line numbers on the lefthand side of the page. It can be deleted^^^^^^^^^^^^^0066from the listing entirely if a /NOIF switch is included in the0017command line.00040011.SKIP 30025C.5 Literal Lines (%)00040069 Occasionally, a line of code which must be included in a program0068is modified in some undesirable way by the pre-processor. If a 0075percent sign (%) occurs in column 1 of the RATFOR source code line, the0067entire line, except for the percent sign, will be passed to the0074FORTRAN code without ANY modification whatsoever. Don't forget enough^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0076leading blanks to put the start of the resulting FORTRAN line at or past0041column seven, as required by FORTRAN.00040011.SKIP 30023C.6 Debug Lines (?)00040068 If a question mark occurs in column one of a RATFOR source code0073line, it is considered to be a debug line and will be processed into 0072FORTRAN (minus the question mark) only if the /DE (DEBUG) switch was0034specified in the command line.00040062 Multiple levels of debug statements can be specified by a^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0066digit (1-9) in the second column (after the "?"). Debug lines0076whose level is equal to or greater than the level specified in the /DE:n0077switch are processed, but lines with a lower level are not processed into0076FORTRAN. Lines with no level specified (blank in column two) are always0072processed if the /DE switch is specified. A /DE switch with no value0043causes all debug lines to be processed.0016.TEST PAGE 60012.NOFILL 0005 0012Example:00040019 ?5 WRITE (5,1)0033 ?5 1 FORMAT (" DEBUG LINE")^00040064would be processed by specifying /DE or /DE:5 or /DE:4, etc,0054but not be processed by specifying /DE:6 or /DE:9.00040009.FILL000400040015C.7 STRINGs00040070 Since character processing frequently requires the use of strings0070(collections of characters of arbitrary length), the pre-processor0073adds the STRING data type to FORTRAN. In FORTRAN, a STRING becomes a0072character array with one character per element, plus one element for^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0071the terminator (end-of-string character, in DEC-land, a zero byte).0016.TEST PAGE 70012.NOFILL 0005 0012Example:00040023 STRING FOO "BLATZ"0011becomes0021 character FOO(6)0044 DATA FOO /1hB, 1hL, 1hA, 1hT, 1hZ, eos/00040009.FILL0069 The string must be delimited by double quotes; single quotes are0086not allowed as delimiters. Single quotes, may, however, appear within the string.0049Null strings are allowed, e.g.#STRING#FOO#"".0005 0071 Note that the STRING function requires that the symbolic constants0073"character" and "eos" be defined (usually as "BYTE" and "0") when the0073STRING keyword is first encountered; otherwise, "character" and "eos"0082will be passed to the FORTRAN code as is and upset the compiler. (The standard0038define file, DEFIN.RAT does this.)00040074 Since ANSI standard FORTRAN requires that all DATA statements must be0081grouped together and placed in the FORTRAN code after all other specification0072statements, but before any executable statements, STRING statements^^^^^^^^^^^^^^^0075must be grouped together and appear in the RATFOR source code after all0071other specification statements but before any DATA statements. The0072pre-processor holds the DATA statement parts until it has output the0070"character" statement parts for all STRINGs, then outputs the DATA0028statements as a group. 0077The pre-processor really doesn't care if STRING statements are grouped in0078this manner or not. DEC FORTRAN IV doesn't care either, but FORTRAN 4 PLUS0029and the ANSI standard do.0005 ^^^^^^^0045 Currently, there is a limit of 20 string0075specification statements with a total of 300 characters (combined total0069of the string names and the characters in the strings) in any one0070program module. (DEFINEd as 'numstr' and 'maxstr' in RATDEF.RAT).0009.PAGE0034D. PRE-PROCESSOR USE UNDER RSX00040072D.1 RATFOR is normally installed with the task name "...RAT" so that0054in can be run as an MCR task or RUN independently:00040011.NOFILL0006 0025 MCR>RAT command line0006or0019 MCR>RUN RATFOR^^^^^^^^^0021 RAT>command line00040009.FILL0074In the first example, the specified command line will be processed and0067the MCR will return; in the second example, RAT will return for0052another command line until given a CTRL/Z (EOF).00040068 Regardless of the method of running RATFOR, an indirect command0066file specification may be given by preceding it with the usual0075at sign (@). Only one level of indirect command files is allowed. The0029default extension is CMD.0004^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0047 MCR>RAT#FTN,LST,OBJ=RAT1,...,RAT6/switches00040049From left to right, the command line denotes:0011.NOFILL0005 00591. the#FORTRAN#output#file######(default extension FTN)00592. the#RATFOR#listing#file######(default extension LST)00593. the#compiler#output#file#####(default extension OBJ)00594. up#to#six#RATFOR#input#files#(default extension RAT)0005 0009.FILL0084The compiler output file will be produced if and only if the /GO switch is used.0011.NOFILL0005 0027Here are some examples:0005 ^^^^^^^^^^^^^^0030MCR>RAT#DB1:AL,AL,AL=AL/GO0072produces: AL.FTN, AL.LST, and AL.OBJ, all on DB1: (from SY:AL.RAT).0005 0027MCR>RAT#BOB,BOB,BOB=BOB0035produces: BOB.FTN and BOB.LST.0068There is no BOB.OBJ (even though it was denoted) because the /GO0023switch was omitted.0006 0029MCR>RAT#ED,ED=ED/-IN/NOSC0033produces: ED.FTN and ED.LST.0006 0033MCR>RAT#DM0:[3,3]FRED=FRED/GO0055produces: DM0:[3,3]FRED.FTN and DM0:[3,3]FRED.OBJ.0006 0023MCR>RAT#,JAY=JAY/SP0039produces (and spools) only JAY.LST.0006 0009.FILL^^^^^^^0069A special feature of the command line interpreter allows the most0069common form of command line (all default extensions, single input0066file, all output files with the same name as imput file) to be0038abbreviated to a single file name.0011.NOFILL0006 0009Thus,0006 0041MCR>RAT#MARY/GO/SP is equivalent to0006 0037MCR>RAT#MARY,MARY,MARY/SP=MARY/GO0006 0007and0006 0021MCR>RAT#DK0:NANCY0065produces: DK0:NANCY.FTN and DK0:NANCY.LST from DK0:NANCY.RAT0006 0009.FILL^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0045The default device for all files is SY0:.0006 0046The default UIC is the user's current UIC.0082If an explicit version number is specified, an explicit extension is required.0006 0062The FORTRAN output file and the listing file are optional,0037but at least one must be present.0055The compiler output file specification is optional,0048but if desired, the /GO switch must be used.0005 0069 Everything from a "!" to the end of the command line is ignored,^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0070thus trailing comments can be used either when the command line is0075input by the operator or from a indirect command file. Lines beginning0077with a ";" or a "!" in column one cause the whole line to be ignored, but0047are allowed in indirect command files only.00040070 When more then one input file is specified, they are concatenated0070into single FORTRAN output and listing files, and all command line0068switches and symbolic constant definitions are in effect for the0024entire command line.0004^^^0070 A single RATFOR input file may also contain more than one program0070module. The end of the RATFOR program module is identified by the0079FORTRAN "END" statement, and each will cause the start of a new page in the0017listing file.0005 0072 The RATFOR source listing contains the RATFOR line number, which is0070consecutive for all programs (and files) in a single command line.0067It also includes (in parentheses, on the extreme left) the line^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0080number of the FORTRAN code being generated for that RATFOR statement. These0075numbers should match (approximately) the line numbers the compiler will0077come up with for the FORTRAN code which is being generated by that RATFOR0074line. These numbers are very useful for debugging, since compiler and0072runtime errors are reported by line numbers. Almost always, you can0076find the offending code in the RATFOR listing by looking up the matching^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0075(or almost matching) line number. You should almost never have to look0026at a compiler listing.0005 0073 These numbers should be taken with a grain of salt; the relationship0080of RATFOR to FORTRAN code is neither simple nor straighforward. Many RATFOR0078statements cause several FORTRAN statements to be generated; some generate0074no FORTRAN at all; still others generate some FORTRAN now, some later.0088In general, the numbers listed correspond to the first significant FORTRAN statement^^^^^^^^^^^^^0039generated by that RATFOR statement.0080For example, an ELSE#IF generally generates a GOTO and a CONTINUE before the0083IF corresponding to the RATFOR IF. In such cases, the listed FORTRAN statement0074number is for the IF. Complex RATFOR constructs may cause some of the0083listed FORTRAN numbers to be off by 1 or 2, but the numbers always resyncronize0090after a couple of simple RATFOR statements (that can be passed directly to the FORTRAN^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0075output). The FORTRAN line numbers are correct for either DEC FORTRAN IV0075or FORTRAN 4 PLUS (which differ in the way they number IF's), depending0053on the status of symbol "decf4p" (in RATRSX.RAT).0006 0065 An index is printed at the end of the RATFOR source listing.0029It contains an entry for:0011.NOFILL0005 0060 - The start of each file specified in the command line.0065 The full file specification, including defaults is listed.0060 - Each RATFOR source code line that begins with "_#$ " ^^^^^^^^0061 in column 1-3. The whole line is listed in the index.0058 This is normally used to flag the beginning of each0034 subroutine within the file.0065 - Each INCLUDE file. The full file name, including defaults0017 is listed.0005 0009.FILL0078This index is not only very useful for finding a particular routine within0072the listing, but it is also a handy outline of the program structure0071because is shows at a glance the files, programs and includes. The^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0050index can be suppressed with the /NOIN switch.00040011.SKIP 20029D.2 Command Line Switches00040069 The following command line switches are available to control the0082actions of the pre-processor. They may be placed after any file specification0068on the command line and apply to the entire command line. Where0075appropriate, a switch can be negated by /NOsw or /-sw in the RSX style.0072For most of the switches, a default value (YES or NO) can be defined0045in RATDEF.RAT. The standard defaults are:^^^0005 0058/NODE/NOFO/NOCO/NOGO/NOHE/IF/IN/NOLC/NORE/SC/NOSP/NOVE00040006 0019.LEFT MARGIN 160021.NO AUTOPARAGRAPH0015.INDENT -160011.SKIP 10015/DE:n debug0010.BREAK0062 Causes all lines beginning with a question0067 mark in column one to be processed into FORTRAN0065 code; by default such lines are ignored. If 0060 n is specified, only debug lines with an0063 equal or higher value in column two will be^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0046 processed. DEFAULT: /NODE000400040015.INDENT -160011.SKIP 10015/FO FORTRAN0010.BREAK0059 Causes the generated FORTRAN code to be0063 included at the end of the listing file (if0060 one was specified). Each program module0059 starts a new page. Line numbers on the0057 listing agree with DEC FORTRAN or F4P0062 compiler line numbers. For this switch to^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0066 work, you must also specify an FTN output file0066 or else the pre-processor must have been built0072 with "openclose" support, so it can create a scratch0048 output file. DEFAULT: /NOFO00040006 0015.INDENT -160011.SKIP 10016/CO compress0010.BREAK0060 Causes the FORTRAN code generated by the0065 pre-processor to be compressed for faster I/O0070 by eliminating all comments and unnecessary blanks^^^0067 in the generated FORTRAN code. This makes the 0073 FORTRAN essentially unreadable and is not recommended0054 except for well debugged programs.0035 DEFAULT: /NOCO00040006 0015.INDENT -160011.SKIP 10010/GO go0010.BREAK0070 Causes the FORTRAN or F4P compiler to be spawned0073 with a command line of the form "FOO=FOO/SW", where0069 FOO is from the RATFOR command line, and /SW is^^^^^^^^^^^^^^^0072 a string of switches for the compiler which can be0078 defined in the symbol "ftnswitches". Thus, if you don't0073 want a fancy compile, this allows RATFOR to produce0073 a finished object module. This switch is available0061 only on systems which support the SPAWN0075 directive and the symbolic constant "spawnit" must be^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0085 defined (in RATRSX.RAT). RATFOR does not wait for the compiler0077 to finish, but goes on to the next command line at once0078 unless the symbol "waitforftn" is defined in RATRSX.RAT.0064 If a third output file is specified, it is0075 used on the output side of the compiler command line.0011.NOFILL0005 0012Example:0024MCR>RAT X,Y,Z=FOO/GO0017creates Z.OBJ0005 0009.FILL^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0083 If not given, the device, UIC, and name from the first output0080 file specification (for the FTN file) are used for the OBJ0035 file as well.0011.NOFILL0005 0012Example:0022MCR>RAT X,Y=FOO/GO0017creates X.OBJ0005 0009.FILL0078 The compiler is not run if there were any RATFOR errors.0063 The compiler input file is always the FTN0061 file created by RATFOR. DEFAULT: /NOGO0005 0005 0016.TEST PAGE 7^^^^^0015.INDENT -160011.SKIP 10012/HE help0010.BREAK0066 Causes a brief description of the command line0066 switches to be printed on the user's terminal.0069 The rest of the command line, if any, is ignored.0034 DEFAULT: /NOHE00040006 0015.INDENT -160011.SKIP 10021/IF ifdef listing0010.BREAK0064 Causes RATFOR source code within unsatisfied0064 conditionals (IFDEFs that are not defined or^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0065 IFNOTDEFs that are defined) to be printed in0071 the listing file. /NOIF suppresses printing of the0070 code except for the IFDEF or IFNOTDEF line itself.0032 DEFAULT: /IF00040015.INDENT -160011.SKIP 10013/IN index0010.BREAK0069 Causes the RATFOR source code index to be printed0065 at the end of the listing file. DEFAULT: /IN0006 0015.INDENT -160011.SKIP 10018/LC lower case0010.BREAK^^^^^^^^^^^^^^^^^^^^^^^^^^^0062 Causes RATFOR generated FORTRAN code to be0065 output in lower case characters (code that is0065 just transferred from the RATFOR source is in0072 upper case) making it easy to identify. In addition,0068 RATFOR comments are also converted to lower case0065 when printed on the RATFOR listing, making it0058 easier to separate comments from code.0034 DEFAULT: /NOLC00040006 ^^^^^^^^^^^^^0015.INDENT -160011.SKIP 10014/RE retain0010.BREAK0064 Causes the symbolic constant definitions (if0061 any) in effect at the end of the previous0068 command line to remain in effect for the current0071 command line. By default, any previous definitions0066 are removed at the start of each command line.0034 DEFAULT: /NORE00040005 0011.SKIP 10005 0015.INDENT -160031/SC symbolic constant table0010.BREAK^^^^^^^^^^^^^^^^^0066 Causes RATFOR to print a table of all symbolic0073 constants defined in a program (or group of programs)0073 at the end of the RATFOR source code listing (only if0074 a listing file is specified in the command line). The0068 table shows each symbol and its character string0045 definition. DEFAULT: /SC0016.TEST PAGE 90005 0011.SKIP 10006 0015.INDENT -160013/SP spool0010.BREAK^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0068 Causes the listing file, if one is specified, to0070 be spooled to the line printer. The /SP switch is0063 useful only if the listing is directed to a0070 disk file; if directed to LP: the operating system0038 convention applies0037 This switch works0069 only if the symbol "openclose" is defined in the 0050 pre-processor. DEFAULT: /NOSP00040006 0016.TEST PAGE 60015.INDENT -16^^^^^^0011.SKIP 10015/VE version0010.BREAK0072 Causes the RATFOR pre-processor to print its current0066 version identification on the user's terminal.0069 The rest of the command line, if any, is ignored.0034 DEFAULT: /NOVE00040018.LEFT MARGIN 00018.AUTOPARAGRAPH0009.PAGE00040034E. CONVENTIONS AND SUGGESTIONS00040066 While not required for proper pre-processor operation, I have0032found the following helpful:0004^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0063 Start pre-processor features (INCLUDEs, IFDEFs, IFNOTDEFs,0070ENDIFDEFs, DEFINEs, and MACROs) in column one of the RATFOR source0072code lines. Start the first level of code in column four and indent0041each logical level three more spaces.00040069 If your line printer, editor, and terminal will print lower case0068characters, make all symbolic constants lower case in the RATFOR0074source code to make them easy to distinguish from variables. The case^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0070of symbolic constants is not significant to the pre-processor, but0056lower case makes them easy to locate in the listing.00040069 If your line printer and FORTRAN compiler will handle lower case0084characters, use the /LC switch. Having the RATFOR-created FORTRAN code in lower0070case makes it easier to read and debug the FORTRAN if you have to.0072Also, having comments printed in lower case makes the RATFOR listing0019easier to read.0004^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0071 On the listing, line numbering of pre-processor feature lines will0076not be exactly correct if the keywords (IFDEF, INCLUDE, DEFINE, etc) are0076not in upper case. However, processing of such keywords will be correct0023regardless of case.0005 0066 Symbols will be added to the symbolic constant table somewhat0076more quickly if DEFINEs and MACROs are encountered in alphabetical order0021by symbolic name.00040057 A "standard" set of DEFINEs is contained in the file^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0067DEFIN.RAT and is useful for most RATFOR programs as well as the0068pre-processor itself. A shorter version, without definitions for0071lower case characters is in DEFINS.RAT. Such symbolic constants as0083EOS, YES, NO, CHARACTER, and STDOUT and macros as INCREMENT($) and DECREMENT($)0056should be standardized for all your RATFOR programs.0069 If you like the IF...THEN, ENDIF, ENDDO, etc. convention used by0088some other structured programming languages better than the brackets used by RATFOR,^^^^^^^^^^0081you can DEFINE such keywords as open and close brackets; e.g.#DEFINE(THEN=[),0020DEFINE(ENDIF=]).0071 Leave the blank out of the FORTRAN DEFINE FILE statement, so it is0062not confused with the RATFOR DEFINE; FORTRAN doesn't care.00040066 You need to be careful of some DATA statements. For example,0073DATA#foo#/"""/ or DATA#foo#/"_#"/ will both be misunderstood by the0073pre-processor. In such cases, you can protect the lines with % or use^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0072the decimal value of the character instead of the literal character.0072Note that RATFOR does not allow the DEC convention of double quotes 0062for Octal constants unless the line is protected with a %.0005 0069 The pre-processor uses a homebrew command line interpreter whose0070calling sequence and structure are based on the RT11 routine ICSI.0075Command line syntax and style are identical to the RSX conventions with0067the following limitations on switch arguments: (1) Limit of one^^^^^^^^^^^^^^^^^^^^0065argument per switch, (2) Character arguments are not allowed,0070(3) Arguments are always decimal numbers; neither "." nor "_#" are0074allowed to specify radix. The command line is converted to upper case0020before scanning.0005 0060 The pre-processor works under F4P on processors without0070floating point processors, since it generates no FPP instructions,0065provided that symbol "realcode" (in RATRSX.RAT) is undefined.0005 0066 To include an apostrophe in a string or format statement, use^^^^^^^^^^^^0077a double quoted string, e.g.#FORMAT#("here's#Johnny"). For direct access0075READs and WRITEs, use two successive apostrophes; they are converted to0061a single apostrophe in the output code, e.g.#READ#(1''1).0005 0071 When creating FORTRAN statements, the pre-processor uses statement0076numbers starting at 20000 and going upward. Therefore, you should avoid0074using statement numbers in this range. The pre-processor will issue a0063warning message if it suspects a statement number conflict.0004^^^^^^0067 Study the RATFOR code of the pre-processor itself, it provides0061some good examples of what can be done with the language.00040068 A common problem if you use FORTRAN 4 PLUS is statements in the0074generated FORTRAN that cannot be gotten to (FORTRAN IV) doesn't care).0005 0011.NOFILL0005 0012Example:0012 IF (...0014 RETURN0017 ELSE IF (...0011 ...0005 0009.FILL0077results in an unlabeled GOTO right after the RETURN. F4P is smart enough^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0073to know you can't get to the GOTO and reject it. The solution is to 0068change the ELSE IF to just an IF, which is logically equivalent.0005 0067 I find that I virtually never have to look at the FORTRAN code0063generated by RATFOR. I think the success of RATFOR depends0072considerably on the concept that the RATFOR code IS the program, NOT0031the generated FORTRAN code.0006 0066 I find the most common RATFOR language error to be improperly^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0074nested IF...IF...ELSE statements. ELSE statements always apply to the0073most recent IF that does not already have an ELSE. Thus, if you have0078an IF...IF...ELSE sequence, the ELSE applies to the second IF. That's fine0076if that's what you want, but if you want the ELSE to belong to the first0080IF, you must put brackets around the second IF to show that it is a complete0070statement by itself; the ELSE will then fall back to the first IF.0011.NOFILL0006 0012Example:^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0038 IF (statement) IF (statement) [0043 IF (statement) IF (statement)0027 statement statement0015 ]0019 ELSE ELSE0034 statement statement0005 0009.FILL0062Assuming the indentation relfects the programmer's intent 0073(ELSEing the first IF), the lefthand example is not correct, but the 0063righthand one is. Note that if the following statement were0068anything except an ELSE, both examples are equivalent, since the^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0066IF#(statement)/statement is really one RATFOR statement and is0074therefore controlled as a single unit by the first IF without the need0017for brackets.0005 0070 Note that the following RATFOR keywords are reserved and must not0051be used as variable or symbolic constant names:0011.NOFILL0005 0021IF ELSE DO FOR0024REPEAT UNTIL WHILE0030RETURN FUNCTION STOP END0015BREAK NEXT0034DEFINE INCLUDE MACRO STRING0028IFDEF IFNOTDEF ENDIFDEF0005 0009.FILL^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0070Further, these keywords must appear as single tokens preceeded and0074followed by blanks, tabs, and/or punctuation characters. The keywords0037must not contain embedded blanks.0009.PAGE0005 0052 Here are some rough timing data for version 19:0005 0071 The RATFOR input in all cases is the file RATRSX.RAT (version 19).0063It contains 800 RATFOR source lines, including 157 symbolic0059constant definitions. It produces 731 lines of FORTRAN.^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0070The data were collected on a dedicated 11/70 running RSX11/M,V3.1.0041All files were on the same RP06 disk.0005 0014.NOJUSTIFY0011.NOFILL0005 0053 ...PREPROCESSOR#BUILT#WITH#COMPILER#OPTIONS....0050 FOR FOR FOR FOR F4P0051 /CD:THR /CD:EIS /CD:EIS V2.2 V2.510042 V2.1 /OP:SPD /OP:SPD /CD:EIS0053 ASCII ASCII NOTASCII ASCII ASCII 0068----------------------------------------------------------------0016COMPILE TIME^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0065(F,F=RATRSX) :28 :27 1:300068----------------------------------------------------------------0015RATFOR TASK0061SIZE(WDS) 28,352. 30,560. 31,776. 30,720. 28,800.0068----------------------------------------------------------------0059RAT F=F 1:38 1:06 1:49 1:10 1:000068----------------------------------------------------------------0058RAT ,F=F 1:56 1:18 2:17 1:20 1:09^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0068----------------------------------------------------------------0060RAT F,F=F 2:04 1:25 2:38 1:28 1:170068----------------------------------------------------------------0063RAT F,F=F/LC 2:07 1:26 2:38 1:28 1:180068----------------------------------------------------------------0009.FILL0012.JUSTIFY0010NOTES:0005 0074 The first line is the time needed to compile the 731 lines of FORTRAN^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0087output. The second line is the size of the pre-processor task if all pre-processor0062routines are compiled with the specified compiler options.0085The last four lines are the elapsed time (m:ss) required by the pre-processor to 0077process the 800 lines of RATFOR source, given the command line specified.0076For the task sizes above, the symbols "openclose" and "spawnit" were not0075defined. See the last page for a subroutine time breakdown which shows^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0057where the (Version 19) pre-processor spends its time.0005 0074 Overlaying (in Version 20) reduces the task size given above by about00684kw. In addition, other changes save about 3kw and speed up the0027pre-processor about 8%.0005 0079 If the symbol ASCII is defined when the pre-processor itself is processed,0074the external character set (ASCII on PDP-11's) is not converted to the0077internal character set (which is ASCII). Such conversion is not required^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0076on any processor which uses ASCII as its character set, but would be on,0071say, IBM machines. Relative to the second column, the third column0052shows the overhead associated with this mapping.0056Clearly, mapping every character on input and output0072is very expensive, although the mapping routines could be speeded up0013somewhat.0009.PAGE0022F. BUILDING RATFOR0006 0080A complete set of indirect command files is provided for RSX11/M, but should^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0083work under RSX11/D as well. Under M+, D or IAS you may want to edit the compile0055and taskbuild files to create a multi-user version.0054The task build command files must be edited to use0066the correct resident libraries (if any) and device assignments0069for your system. All command files assume RATFOR and STRLIB are 0033in your current UIC, and that0081the device is XX0:, you will have to assign XX0: get your production version.00040063 The pre-processor code is in four main files. RAT1, RAT2,^^^^0069and RAT3 contain the computer-independent parts. All parts which0072may have to be changed when moving RATFOR to a different environment0031are lumped into RATRSX.RAT.0040The whole thing is designed to be as0069portable as possible without losing too much speed or capability.0082The pre-processor also needs STRLIB.RAT (string library) and ICSI.RAT (command0074line interpreter), and several COMMON block definition files which are0032INCLUDEd all over the place.0006 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0067 A variety of symbolic constants are available in RATDEF.RAT to0073configure the pre-processsor for specific environments. Also, device0073assignments for all files can be set in the task build command files.00040067 The internal character set used by the pre-processor is ASCII.0070When used on a machine whose external character set it also ASCII,0077PDP-11's, for example, much time is saved by not converting each external0078character to the equivalent internal character (which is the same anyway).^^^0078However, if RATFOR is to be used on a machine whose external character set0071is not ASCII (IBM for example), conversion to and from the internal0069character set can be provided by undefining the symbolic constant0074"ascii" in RATDEF.RAT because the internal-external conversion code is0074all conditionally pre-processed. You must edit the ODL file to include0021OUTMAP and INMAP.00040070 If defined, the symbol "decwriter" makes listing on a slow device^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0075faster by reducing the width of lines, especially the symbolic constant0018table listing.0006 0072 If symbol "strings" is undefined, the STRING data type and all code0084needed for it are deleted from the pre-processor. No ODL changes are necessary.0006 0069 The maximum nesting depth of INCLUDEs is one less then the value0082of "nfiles". If this is increased, logical unit number assingments ("stdout",0078etc) must be changed, since the input file LUNs are also the nesting level^^^^^^^^^^^^^^^^^^^^^^0045(LUN 1 being the basic source code file).0005 0074 RATDEF.RAT contains several symbols of the form "dfltXX" which define0073the default settings for most of the switches. xx is the switch name.0006 0072 The maximum length of a line of RATFOR source code input is defined0071by "maxcard"; the maximum length of a DEFINE or MACRO definition by0074"maxdef"; and the maximum length of a token (including quoted strings)0016by "maxtok".0006 0067 The maximum number of DEFINEs and MACROs allowed is defined by^^^0076"maxpts" and the total number of characters in all definitions is set by0013"maxtbl".00040068 Symbol "pagelength" can be adjusted for diferent line printers.0006 0079 If defined in RATRSX.RAT, the symbol "decf4p" configures the pre-processor0079for use with DEC F4P; if undefined, the pre-processor is configured for DEC0074FORTRAN IV. The primary difference is the statement numbering on the 0073FORTRAN code listing. It also determines which compiler is spawned by0019the /GO switch.0006 ^^^^^^^^^^^^^^^0073 The symbol "openclose" (in RATRSX.RAT and ICSI.RAT) must be defined 0078if you want support for spooling of listing files included (the default is0082still /NOSP). If "openclose" is defined, OPENs are used everwhere instead of 0071ASSIGN/FDBSET. This also allows for the odd case where you specify0069/FO without creating a FORTRAN output file (by creating a scratch0079output file). This also specifies the correct carriage control so PIP does^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0076not get confused by the FORTRAN carriage control which otherwise applies0026to the output files. 0071However, DEC's FORTRAN IV version 2.2 has a bug (feature?) and does0074not properly handle the ERR= transfer out of the OPEN statement unless0070the reason for the ERR is "no such file". Any other error, such as0080a bad device name or non-existant UIC, causes an odd address trap (error 3).0076Therefore, be advised, if you define "openclose" and use FORTRAN IV v2.2^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^0058and get odd address traps, don't panic, it's just DEC.0005 0070 Another FORTRAN IV v2.2 bug causes the compiler to print comments0075following an END statement as part of the just-finished program instead0065of part of the next program (in a file with several modules).0005 0064 The symbol "spawnit" (in RATRSX.RAT) must be defined if you0082have RSX11/M v3.2 or M PLUS and want to spawn the compiler to do the OBJ file.0075You can define a standard set of switches to be applied to the compiler^^^^^^^^^^^^^0075command line by defining symbolic constant "ftnswitches" in RATRSX.RAT.0074Note that the defined switch string must be a string in double quotes.0005 0011.NOFILL0009.PAGE00040052 THIS IS TIMING FOR SYKES' RATFOR, VERSION 19. 0033(COURTESTY OF STEVE LAZARUS).0066SINCE THIS TEST WAS RUN, SCOPY,TYPE,SPAD, AND SCOMPR HAVE BEEN0031REWRITTEN TO SPEED THEM UP.0058 PROGRAM RUN ON 01/02/80 AND FINISHED AT 09:40:45.0069 122.53 SECONDS ELAPSED TIME 7229. SAMPLES 56 ROUTINES0004^^^^^^^^^^^^^^^^^^^^^0029 STRPUT 28.94% 2092.00029 STRGET 26.75% 1934.00029 GTOK 6.47% 468.00029 SLEN 4.14% 299.00029 SCOPY 3.83% 277.00029 GETTOK 2.70% 195.00029 SEQL 2.45% 177.00029 NGETCH 2.24% 162.00029 DEFTOK 1.90% 137.00029 LOOKFR 1.87% 135.00029 SCOMPR 1.80% 130.00029 TYPE 1.69% 122.00029 OUTSTR 1.47% 106.00029 SHELL 1.34% 97.00029 .MAIN. 1.16% 84.00029 SPAD 1.13% 82.00029 SITOC 1.07% 77.0^^^^^^^^^^^^^^^^^^^0029 OUTCH 0.79% 57.00029 PRTLIN 0.73% 53.00029 LEX 0.73% 53.00029 UNFOLD 0.66% 48.00029 RATLST 0.62% 45.00029 PUTBAK 0.59% 43.00029 INDEX 0.58% 42.00029 EATUP 0.58% 42.00029 EQLS 0.54% 39.00029 GETLIN 0.48% 35.00029 PBSTR 0.41% 30.00029 PUTLIN 0.33% 24.00029 OPENI 0.26% 19.00029 ALLDIG 0.24% 17.00029 PARSE 0.24% 17.00029 STRIM 0.14% 10.00029 BALPAR 0.14% 10.0^^^^^^^^^^^^^^^^^^^0029 OUTTAB 0.12% 9.00029 RELATE 0.10% 7.00029 OTHERC 0.10% 7.00029 OUTDON 0.08% 6.00029 ADDDEF 0.06% 4.00029 FORCOD 0.06% 4.00029 LRPAR 0.06% 4.00029 UNSTAK 0.06% 4.0^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^