📄 f77
字号:
.B eoutputwithout a scale factor is optional with theimplementation.(We do not print it.)There is a\fBg\fIw.d\fRformat code which is the same as\fBe\fIw.d\fRand\fBf\fIw.d\fRon input,but which chooses.B for.B eformats for output depending.on the size of the number and of $d$..NH 3``A'' Format Code.IPA codes are used for character values.\fBa\fIw\fRuse a field width of $w$,while a plain.B auses the length of the character item..NH 2Standard Units.IPThere are default formatted input and output units.The statement.DSread 10, a, b.DEreads from the standard unit using format statement 10.The default unit may be explicitly specified by an asterisk, as in.DSread(\(**, 10) a,b.DESimilarly, the standard output units is specified by a.B printstatement or an asterisk unit:.DSprint 10write(\(**, 10).DE.NH 2List-Directed Formatting.IPList-directed I/O is akind of free form input for sequential I/O.It is invoked by using an asterisk as theformat identifier, as in.DSread(6, \(**) a,b,c.DE.IPOn input,values are separated by strings of blanksand possibly a comma.Values,except for character strings,cannot contain blanks.End of record counts as a blank,except in character strings,where it is ignored.Complex constants are given as two real constantsseparated by a comma and enclosed in parentheses.A null input field,such as between two consecutive commas,means the corresponding variable in theI/O list is not changed.Values may be preceded by repetition counts,as in.DS4\(**(3.,2.) 2\(**, 4\(**\(fmhello\(fm.DEwhich stands for 4 complex constants, 2 null values,and 4 string constants..IPFor output, suitable formats are chosen foreach item.The values of character strings are printed;they are not enclosed in quotes, so they cannot be read backusing list-directed input..NH 2Direct I/O.IPA file connected for direct access consists ofa set of equal-sized records each of which isuniquely identified by a positive integer.The records may be written or read in any order,using direct access I/O statements..IPDirect access.B readand.B writestatementshave an extra argument,.B rec=,which gives the record number to be read or written..DSread(2, rec=13, err=20) (a(i), i=1, 203).DEreads the thirteenth record into the array.B a..IPThe size of the records must be given by an.B openstatement(see below).Direct access files may be connected for either formattedor unformatted I/O..NH 2Internal Files.IPInternal files are character string objects,such as variables or substrings,or arrays of type character.In the former cases there is only a single recordin the file,in the latter case each array element is a record.The Standard includes only sequentialformatted I/O on internal files.(I/O is not a very precise term to use here,but internal files are dealt with using.B readand.B write).There is no list-directed I/O on internal files.Internal files are used by giving the name of thecharacter object in place of the unit number, as in.DScharacter\(**80 xread(5,"(a)") xread(x,"(i3,i4)") n1,n2.DEwhich reads a card image into.B xand then readstwo integers from the front of it.A sequential.B reador.B writealways starts at the beginningof an internal file..IP(We also support a compatible extension, direct I/O on internal files.This is like direct I/O on external files,except that the number of records in the file cannot bechanged.).NH 2OPEN, CLOSE, and INQUIRE Statements.IPThese statements are used to connect and disconnectunits and files,and to gather information about units and files..NH 3OPEN.IPThe.B openstatement is used to connect a file with aunit,or to alter some properties of the connection.The following is a minimal example..DSopen(1, file=\(fmfort.junk\(fm).DE.B opentakes a variety of arguments with meanings described below..RS. \" macros here.de HP.RT.if !\\(IP .nr IP +1.sp \\n(PDu.ne 3v.in +\\n(PIu.ti -\\n(PIu\fB\\$1\fR\ \c...de P1.KS.nf.in +.3i.ta .3i .6i .9i 1.2i 1.5i 1.8i.sp...de P2.fi.in -.3i.sp.KE...de TH.RT.sp \\n(PDu.ne 3v\fB\\$1\\$2\\$3\\$4\\$5\\$6\fR\ \c... \" end of macros.HP unit=a small non-negative integer which is the unit towhich the file is to be connected.We allow,at the time of this writing,0 through 9.If this parameter is the first one in the.B openstatement,the.B unit=can be omitted..HP iostat=is the same as in.B reador.B write..HP err=is the same as in.B reador.B write..HP file=a character expression,which when stripped of trailing blanks,is the name of the file to be connected to the unit.The filename should not be given if the.B status=scratch..HP status=one of.B old,.B new,.B scratch,or.B unknown.If this parameter is not given,.B unknownis assumed.If.B scratchis given,a temporary file will be created.Temporary files are destroyed at the end of execution.If.B newis given,the file will be created if it doesn't exist,or truncated if it does.The meaning of.B unknownis processor dependent;our system treats it as synonymous with.B old..HP access=.B sequentialor.B direct,depending on whether the file isto be opened for sequential or direct I/O..HP form=.B formattedor.B unformatted..HP recl=a positive integer specifying the record length ofthe direct access file being opened.We measure all record lengths in bytes.On.UXsystems a record length of 1 has the special meaning explainedin section 5.1 of the text..HP blank=.B nullor.B zero.This parameter has meaning only for formatted I/O.The default value is.B null..B zeromeans that blanks,other than leading blanks,in numeric input fields are to be treated as zeros..RE.IPOpening a new file on a unit which is already connectedhas the effect of first closing the old file..NH 3CLOSE.IP.B closesevers the connection between a unit and a file.The unit number must be given.The optional parameters are.B iostat=and.B err=withtheir usual meanings,and.B status=either.B keepor.B delete.Scratch files cannot be kept,otherwise.B keepis the default..B deletemeans the file will be removed.A simple example is.DSclose(3, err=17).DE.NH 3INQUIRE.IPThe.B inquirestatement gives information abouta unit(``inquire by unit'')or a file (``inquire by file'').Simple examples are:.DSinquire(unit=3, namexx)inquire(file=\(fmjunk\(fm, number=n, exist=l).DE.RS.HP file=a character variable specifies the file the.B inquireis about.Trailing blanks in the file name are ignored..HP unit=an integer variable specifies the unit the.B inquireis about.Exactly one of.B file=or.B unit=must be used..HP "iostat=, err="are as before..HP exist=a logical variable.The logical variable is set to.B ".true."if the file or unitexists and is set to.B ".false."otherwise..HP opened=a logical variable.The logical variable is set to.B ".true."if the fileis connected to a unit or if the unit is connectedto a file,and it is set to.B ".false."otherwise..HP number=an integer variable to which is assigned thenumber of the unit connected to the file,if any..HP named=a logical variable to which is assigned.B ".true."ifthe file has a name,or.B ".false."otherwise..HP name=a character variable to which is assigned the nameof the file (inquire by file) or the name of thefile connected to the unit (inquire by unit).The name will be the full name of the file..HP access=a character variable to which will be assignedthe value.B \(fmsequential\(fmif the connection is forsequential I/O,.B \(fmdirect\(fmif the connection is for direct I/O.The value becomes undefined if there is no connection..HP sequential=a character variable to which is assigned thevalue.B \(fmyes\(fmif the file could be connected forsequential I/O,.B \(fmno\(fmif the file could not be connected for sequential I/O,and.B \(fmunknown\(fmif we can't tell..HP direct=a character variable to which is assigned the value.B \(fmyes\(fmif the file could be connected for direct I/O,.B\(fmno\(fmif the file could not be connected for directI/O,and.B \(fmunknown\(fmif we can't tell..HP form=a character variable to which is assigned the value.B \(fmformatted\(fmif the file is connected for formatted I/O,or.B \(fmunformatted\(fmif the file is connected for unformattedI/O..HP formatted=a character variable to which is assigned the value.B \(fmyes\(fmif the file could be connected for formatted I/O,.B \(fmno\(fmif the file could not be connected for formatted I/O,and.B \(fmunknown\(fmif we can't tell..HP unformatted=a character variable to which is assigned the value.B \(fmyes\(fmifthe file could be connected for unformatted I/O,.B \(fmno\(fmif the file could not be connected for unformatted I/O,and.B \(fmunknown\(fmif we can't tell..HP recl=an integer variable to which is assigned the record lengthof the records in the file if the file is connectedfor direct access..HP nextrec=an integer variable to which is assigned one morethan the number of the the last record read from a file connectedfor direct access..HP blank=a character variable to which is assigned the value.B \(fmnull\(fmif null blank control is in effect for the fileconnected for formatted I/O,.B \(fmzero\(fmif blanks are being converted to zeros andthe file is connected for formatted I/O..RE.PP.I "The gentle reader"will remember that the people who wrote the standardprobably weren't thinking of his needs.Here is an example.The declarations are omitted..DSopen(1, file="/dev/console").DEOn a.UXsystem this statement opens the console for formatted sequentialI/O.An.B inquirestatement for either unit 1 or file "/dev/console"would reveal that the file exists, is connected to unit 1,has a name, namely "/dev/console",is opened for sequential I/O,could be connected for sequential I/O,could not be connected for direct I/O (can't seek),is connected for formatted I/O,could be connected for formatted I/O,could not be connected for unformatted I/O(can't seek),has neither a record length nor a next record number,and is ignoring blanks in numeric fields..PPIn the.UXsystem environment,the only way to discover what permissions you havefor a file is to open it and try to read and write it.The.B err=parameter will return system error numbers.The.B inquirestatement does not give a way of determining permissions.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -