📄 f77
字号:
.IPIn a.B subroutineor subroutine.B entrystatement,some of the arguments may be noted by an asterisk, as in.DSsubroutine s(a, \(**, b, \(**).DEThe meaning of the ``alternate returns'' is described in section 5.2 of the Appendix..NH 1Declarations.NH 2CHARACTER Data Type.IPOne of the biggest improvements to the language is the addition of a character-string data type.Local andcommon character variables must have a length denoted by a constant expression:.DScharacter\(**17 a, b(3,4)character\(**(6+3) c.DEIf the length is omitted entirely, it is assumed equal to 1.A character string argument may have a constant length,or the length may be declared to be the same as that of the corresponding actual argument at run timeby a statement like.DScharacter\(**(\(**) a.DE(There is an intrinsic function.B lenthat returns the actual length of a character string).Character arrays and common blocks containing character variables must be packed:in an array of character variables, the first character of one element must follow the last character ofthe preceding element, without holes..NH 2IMPLICIT Statement.IPThe traditional implied declaration rules still hold:a variable whose name begins with\fBi, j, k, l, m,\fR or \fBn\fR is of type.B integer,other variables are of type.B real,unless otherwise declared.This general rule may be overridden with an.B implicitstatement:.DSimplicit real(a-c,g), complex(w-z), character\(**(17) (s).DEdeclares that variables whose name begins with an\fBa ,b, c,\fRor\fBg\fRare.B real,those beginning with\fBw, x, y,\fRor\fBz\fRare assumed.B complex,and so on.It is still poor practice to depend on implicit typing, but this statement is an industry standard..NH 2PARAMETER Statement.IPIt is now possible to give a constant a symbolic name, as in.DSparameter (x=17, y=x/3, pi=3.14159d0, s=\(fmhello\(fm).DEThe type of each parameter name is governed by the same implicit and explicit rules as for a variable.The right side of each equal sign must be a constant expression(an expression made up of constants, operators, and already defined parameters)..NH 2Array Declarations.IPArrays may now have as many as seven dimensions.(Only three were permitted in 1966).The lower bound of each dimension may be declaredto be other than 1 byusing a colon.Furthermore, an adjustable array bound may be an integer expression involving constants,arguments, and variables in.B common..DSreal a(\(mi5:3, 7, m:n), b(n+1:2\(**n).DEThe upper bound on the last dimension of an array argument may be denoted by an asteriskto indicate that the upper bound is not specified:.DSinteger a(5, \(**), b(\(**), c(0:1, \(mi2:\(**).DE.NH 2SAVE Statement.IPA poorly known rule of Fortran 66 is that local variables in a procedure do not necessarily retain their values betweeninvocations of that procedure.At any instant in the execution of a program,if a common block is declared neither in the currently executing procedurenor in any of the procedures in the chain of callers,all of the variables in that common block also become undefined.(The only exceptions are variables that have been defined in a.B datastatement and never changed).These rules permit overlay and stack implementations for the affected variables.Fortran 77 permits one to specify that certain variables and common blocks are to retain theirvalues between invocations.The declaration.DSsave a, /b/, c.DEleaves the values of the variables.B aand.B cand all of the contents of common block.B bunaffected by a return.The simple declaration.DSsave.DEhas this effect on all variables and common blocks in the procedure.A common block must be \fBsave\fRd in every procedure in which it is declared if the desired effect is to occur..NH 2INTRINSIC Statement.IPAll of the functions specified in the Standard are in a single category,``intrinsic functions'', rather than being divided into ``intrinsic'' and ``basic external'' functions.If an intrinsic function is to be passed to another procedure, it must be declared.B intrinsic.Declaring it.B external(as in Fortran 66) causes a function other than the built-in one to be passed..NH 1Expressions.NH 2Character Constants.IPCharacter string constants are marked by strings surrounded by apostrophes.If an apostrophe is to be included in a constant, it is repeated:.DS \(fmabc\(fm \(fmain\(fm\(fmt\(fm.DEThere are no null (zero-length) character strings in Fortran 77.Our compiler has two different quotation marks, `` \(fm ''' and `` " ''.(See Section 2.9 in the main text.).NH 2Concatenation.IPOne new operator has been added, character string concatenation, marked by a double slash(``//'').The result of a concatenation is the string containing the characters of the left operand followed by the characters ofthe right operand.The strings.DS \(fmab\(fm // \(fmcd\(fm \(fmabcd\(fm.DEare equal.The strings being concatenated must be of constant length in all concatenationsthat are not the right sides of assignments.(The only concatenation expressions in which acharacter string declared adjustable with a ``\(**(\(**)'' modifieror a substring denotation with nonconstant position values may appearare the right sides of assignments)..NH 2Character String Assignment.IPThe left and right sides of a character assignment may not share storage.(The assumed implementation of character assignment is to copy characters from the right to the left side.)If the left side is longer than the right, it is padded with blanks.If the left side is shorter than the right, trailing characters are discarded..NH 2Substrings.IPIt is possible to extract a substring of a character variable or character array element, using the colon notation:.DSa(i,\|j) (m:n).DEis the string of $(n-m+1)$ characters beginning at the$m sup th$ character of the character array element $a sub ij$.Results are undefined unless $m<=n$.Substrings may be used on the left sides of assignments and as procedure actual arguments..NH 2Exponentiation.IPIt is now permissible to raise real quantities to complex powers,or complex quantities to real or complex powers.(The principal part of the logarithm is used).Also, multiple exponentiation is now defined:.DSa\(**\(**b\(**\(**c = a \(**\(** (b\(**\(**c).DE.NH 2Relaxation of Restrictions.IPMixed mode expressions are now permitted.(For instance,it is permissible to combine integer and complex quantities in an expression.).IPConstant expressions are permitted where a constant is allowed,except in.B datastatements.(A constant expression is made up of explicit constants and\fBparameter\fRsand the Fortran operators,except for exponentiation to a floating-point power).An adjustable dimension may now be an integer expression involving constants,arguments, and variables inB common...IPSubscripts may now be general integer expressions;the old$c v +- c'$rules have been removed..B doloop bounds may be general integer, real, or double precision expressions.Computed.B gotoexpressions and I/O unit numbers may be general integer expressions..NH 1Executable Statements.NH 2IF-THEN-ELSE.IPAt last, theif-then-elsebranching structure has been added to Fortran.It is called a ``Block If''.A Block If begins with a statement of the form.DSif ( . . . ) then.DEand ends with an.DSend if.DEstatement.Two other new statements may appear in a Block If.There may be several.DSelse if(. . .) then.DEstatements,followed by at most one.DSelse.DEstatement.If the logical expression in the Block If statement is true, the statements following it up to thenext.B elseif,.B else,or.B endifare executed.Otherwise, the next.B elseifstatement in the group is executed.If none of the.B elseifconditions are true, control passes to the statements following the.B elsestatement, if any.(The.B elsemust follow all \fBelseif\fRs in a Block If.Of course, there may be Block Ifs embedded inside of other Block If structures).Acaseconstruct may be rendered.DSif (s .eq. \(fmab\(fm) then . . .else if (s .eq. \(fmcd\(fm) then . . .else . . .end if.DE.NH 2Alternate Returns.IPSome of the arguments of a subroutine call may be statement labels preceded by an asterisk, as in.DScall joe(j, \(**10, m, \(**2).DEA.B returnstatement may have an integer expression, such as.DSreturn k.DEIf the entry point has$n$alternate return (asterisk) argumentsand if $1<=k<=n$, the return is followed by a branch to the corresponding statement label;otherwise the usual return to the statement following the.B callis executed..NH 1Input/Output.NH 2Format Variables.IPA format may be the value of a character expression (constant or otherwise),or be stored in a character array, as in.DSwrite(6, \(fm(i5)\(fm) x.DE.NH 2END=, ERR=, and IOSTAT= Clauses.IPA.B reador.B writestatement may contain.B end=,.B err=,and.B iostat=clauses, as in.DSwrite(6, 101, err=20, iostat=a(4))read(5, 101, err=20, end=30, iostat=x).DEHere 5 and 6 are the.I unitson which the I/O is done,101 is the statement number of the associated format,20 and 30 are statement numbers,and.B aand.B xare integers.If an error occurs during I/O,control returns to the program at statement 20.If the end of the file is reached,control returns to the program at statement 30.In any case, the variable referred to inthe.B iostat=clause is given a value whenthe I/O statement finishes.(Yes, the value is assigned to the name on the right side of the equal sign.)This value is zero if all went well,negative for end of file,and some positive value for errors..NH 2Formatted I/O.NH 3Character Constants.IPCharacter constants in formats are copied literally to the output.Character constants cannot be read into..DSwrite(6,\(fm(i2,\(fm\(fm isn\(fm\(fm\(fm\(fmt \(fm\(fm,i1)\(fm) 7, 4.DEproduces.DS 7 isn\(fmt 4.DEHere the format is the character constant.DS(i2,\(fm isn\(fm\(fmt \(fm,i1).DEand the character constant.DS isn\(fmt.DEis copied into the output..NH 3Positional Editing Codes.IP.B t,.B tl,.B tr,and.B xcodescontrol where thenext character is in the record.\fBtr\fIn\fRor\fIn\fBx\fRspecifies that the next character is$n$ to the right of the current position.\fBtl\fIn\fRspecifies that the next character is$n$ to the left of the current position,allowing parts of the record to be reconsidered.\fBt\fIn\fRsays that the next character is to be characternumber $n$ in the record.(See section 3.4 in the main text.).NH 3Colon.IPA colon in the format terminates the I/O operationif there are no more data items in the I/O list,otherwise it has no effect.In the fragment.DSx=\(fm("hello", :, " there", i4)\(fmwrite(6, x) 12write(6, x).DEthe first.B writestatement prints\fBhello there 12\fR,while the second only prints\fBhello\fR..NH 3Optional Plus Signs.IPAccording to the Standard,each implementation has the option of puttingplus signs in front of non-negativenumeric output.The.B spformat code may be used to make the optional plussigns actually appear for all subsequent itemswhile the format is active.The.B ssformat code guarantees that the I/O system will notinsert the optional plus signs,and the.B sformat code restores the default behavior ofthe I/O system.(Since we never put out optional plus signs,.B ssand.B scodes have the same effect in our implementation.).NH 3Blanks on Input.IPBlanks in numeric input fields,other than leading blankswill be ignored following a.B bncode in a formatstatement,and will be treated as zeros following a.B bzcode in a format statement.The default for a unit may be changed by usingthe.B openstatement.(Blanks are ignored by default.).NH 3Unrepresentable Values.IPThe Standard requires that if a numeric itemcannot be represented in the form required by a format code,the output field must be filled with asterisks.(We think this should have been an option.).NH 3Iw.m.IPThere is a new integer output code,\fBi\fIw.m.\fRIt is the same as\fBi\fIw\fR,except that there will be at least $m$digits in the output field,including,if necessary,leading zeros.The case \fBi\fR$w.0$ is special,in that if the value being printed is 0,the output field isentirely blank.\fBi\fIw\fB.1\fRis the same as\fBi\fIw\fR..NH 3Floating Point.IPOn input, exponents may start with the letter\fBE, D, e, \fRor \fBd.\fRAll have the same meaning.On output we always use \fBe\fR.The.B eand.B dformat codes also have identical meanings.A leading zero before the decimal point in
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -