📄 rat
字号:
.ce 100RATFOR _ A Rational Fortran.sp 2B. W. Kernighan.spBell LaboratoriesMurray Hill, N. J. 07974.ce 0.fi.sp .de PP.sp.ti +5...PPFortran programs are hard to read, write and debug.To make program development easier,RATFOR provides a set of decent control structures:.sp.nf statement grouping completely general \fBif - else\fR statements \fBwhile\fR, \fBfor\fR and \fBdo\fR for looping \fBbreak\fR and \fBnext\fR for controlling loop exits.sp.fiand some ``syntactic sugar'':.sp.nf free form input (e.g., multiple statements/line) unobtrusive comment convention translation of >, >=, etc., into .GT., .GE., etc. ``define'' statement for symbolic parameters ``include'' statement for including source files.sp.fi.PPRATFORnot onlymakes programming in Fortran more enjoyable,but also allows structured programming, in the sense ofcoding withoutGOTO's.RATFORprograms tend to be markedly easierto write, read, and make correct than their equivalentsin standard Fortran..PPRATFORis a preprocessor,translating the input into standard Fortran constructions.RATFORprograms may readily be written so the generated Fortranis portable;program transferability is easy to achieve.RATFORis written in itself,so it is also portable..sp.PPThe grammar ofRATFOR is as follows:.nf.spprog : stat | prog statstat : \fBif\fP( condition ) stat | \fBif\fP( condition ) stat \fBelse\fP stat | \fBwhile\fP( condition ) stat | \fBfor\fP( initialization; condition; increment ) stat | \fBdo\fP do-part stat | break | next | digits stat | { prog } | anything unrecognizable.fi.spIn the grammar above,conditioncan be any legal Fortran condition like "`A .EQ. B',"i.e., anything that could appear in a legal Fortran logical IFstatement.stat is, of course, any Fortran orRATFORstatement,or any collection of these enclosed in braces..PPThewhilestatement performs a loop while some specified condition is true.The test is performed at the \fIbeginning\fR of the loop,so it ispossible to do awhilezero times,which can't be done with a FortranDO..PPTheforstatementis a somewhat generalizedwhilestatementthat allows an initialization and anincrementing step as well as a termination conditionon a loop.initializationis any single \fIFortran\fR statement, which gets done oncebefore the loop begins.incrementis any single \fIFortran\fR statement,which gets done at the end of each pass through the loop,before the test..PPforandwhileare useful forbackward loops, chaining along lists,loops that must be done zero times,and similar things which are hard to express with a DOstatement,and obscure to write out directly..PPThedostatement is like a Fortran DO,except that no label or CONTINUEis needed.The \fBdo-part\fP that follows the dokeyword has to be something that can legally go intoa Fortran DOstatement..PPAbreakcauses an immediate exit from afor,whileordoto the following statement.Thenextstatement causes an immediate transfer to theincrementpart of aforordo,and the test part of awhile.Bothbreakandnextrefer to the innermost enclosing for,whileordo..sp.br.PPStatements can be placed anywhere on a line;long statements are continued automatically.Multiple statements may appear on one line,if they are separated by semicolons.No semi-colon is needed at the end of a line,ifRATFORcan guess whether the statementends there.Lines ending with any charactersobviously a continuation, like plus or comma,are assumed to be continued on the next line.Any statement that begins with an all-numeric field isassumed to be a Fortran label,and placed in columns 1-5.PPA`#'character in a line marks the beginningof a comment;the comment is terminated by the end of a line..PPText enclosed in matching single or double quotesis converted tonH...byRATFOR,but is otherwise unaltered.Characters like `>', `>=', and `&'are translated into their longer Fortran equivalents`.GT.', `.GE',and`.AND',except within quotes..PPAny string of alphanumeric characters can be defined as a name;thereafter, whenever that name occurs in the input(delimited by non-alphanumerics)it is replaced by the rest of the definition line(comments are stripped off)..PPAn entire source file may be included by saying``include filename'' at the appropriate place.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -