3/24/2023 0 Comments Fortran file peekStandard input is logical unit 5 (also Fortran 90 unit 100) These preconnected units are standard input, standard output, and standard error: Three unit numbers are automatically associated with specific standard I/O files at the start of program execution. In this case, you would specify only the file's logical unit number and the parameters to change. If the file has already been opened by the program, you can use a subsequent OPEN statement to change some of the file's characteristics for example, BLANK and FORM. This file is deleted upon termination of the program or execution of a CLOSE statement, unless (with f77) STATUS='KEEP' is specified in the CLOSE statement. Specifying STATUS='SCRATCH' in the OPEN statement opens a file with a name of the form tmp.F AAAxnnnnn, where nnnnn is replaced by the current process ID, AAA is a string of three characters, and x is a letter the AAA and x make the file name unique. ![]() ![]() The OPEN statement need not specify a name the runtime system supplies a file name according to several conventions. The program uses the library routines GETENV, LNBLNK, and GETCWD to return the value of the $HOME environment variable, find the last non-blank in the string, and determine the current working directory:Ĭ If name starts with '~/', replace tilde with homeĬ directory otherwise prefix relative path name withĬompiling and running GetFilNam.f results in: The following example ( GetFilNam.f) shows one way to construct an absolute path file name from a typed-in name. (See man page entries for getarg(3F) and getenv(3F) for details these and other useful library routines are also described in the Fortran Library Reference). Library routines can be used to bring command-line arguments and environment variables into the program as character variables for use as file names in OPEN statements. Also, the specifier may be a character constant, variable, or character expression. The FILE= specifier on an OPEN statement may specify a simple file name ( FILE='myfile.out') or a file name preceded by an absolute or relative directory path ( FILE='./Amber/Qproj/myfile.out'). See the Sun FORTRAN 77 Language Reference Manual for a full discussion of the OPEN statement. This file can be pre-existing or created by the program. The OPEN statement's FILE= specifier establishes the association of a logical unit to a named, physical file at runtime. Also, certain "preconnected " units are automatically associated with specific files at the start of program execution. The asterisk stands for standard input file when it appears in a READ statement it stands for standard output file when it appears in a WRITE or PRINT statement.Ī Fortran logical unit can be associated with a specific, named file through the OPEN statement. ![]() The character * can appear as a logical unit identifier. Logical units are identified in an I/O statement by a logical unit number, a nonnegative integer from 0 to the maximum 4-byte integer value (2,147,483,647). Accessing Files From Within Fortran Programsĭata is transferred between the program and devices or files through a Fortran logical unit. This chapter discusses the input/output features provided by Sun Fortran compilers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |