Force Fortran Compiler and Editor
"Manual " execution with input or output files
If the program is to accept input data from an existing file or to preserve the output in a file, you must open a Command-Prompt window and execute the compiled program "manually".
Some DOC commands
The following commands will be helpful; each command must be typed explicitly and concluded with the ENTER key.
To change from the C-drive to the I-drive, use the command
To see what files are currently available, use the
command. The names of the files are in the last column of the resulting listing. Subordinate directories/folders have <DIR> in the third column.
To "move into" a subordinate folder (or directory) [e.g., my_stuff], use the command
To move to the next higher folder (the "parent" folder), use the command
(i.e., move to the double-dot (with no space between the dots) folder which represents the "parent" of the current folder).
Assuming that the text file named mfp.dat contains the data to be used by the executable file mfp.exe (i.e., the executable file for "My First Program") and assuming that the output from the program should be preserved in a text file named mfp.out, use the following Command-Prompt command
mfp <mfp.dat >mfp.out
The item <mfp.dat re-directs the input from the keyboard to the existing file named mfp.dat as though its contents were manually entered on the keyboard; each line is one set of data which would be entered manually from the keyboard and concluded by the ENTER key. Omitting this input-redirection item means the executing program will expect the input data to come from the keyboard.
The item >mpf.out re-directs the output from the screen to a file named mfp.out, creating it in the process. Omitting this item means the executing program will send its output to the screen. The order of these two re-direction items is not important. Either or both re-direction items may be omitted.
Unit numbers may range from 1 to 99, inclusive. (Unit zero is used for outputting error messages.) If n is the value of a unit, then the program reads from or writes to a file named fort.n unless the file is explicitly opened with an OPEN statement. However, unit 5 is normally used as standard (or default) input and unit 6 is used as standard output unless an OPEN statement is used to override that association.
Normally, the executing program will create an output file in the same directory/folder as the executable file (i.e., the file with the .EXE suffix). Input files are assume to be in the same directory/folder as the executable file. The OPEN statement can be used to open files in different directories/folders where the path to the desired file must be specified explicitly.
If a program is executed and produces an output file and the program is executed a second time (with the output file now pre-existing), the program will abort and produce an error message indicating that the program cannot create the output file. Either the user must first delete the output file before executing the program or the program itself must detect the existence of the output file and delete it. The following source program creates an output file named test.out but checks to see if the file pre-exists; if it doe pre-exist, the output file is deleted and then re-created.
program testfile character*70 outfile ! name of output file logical there ! T: files does pre-exist character*80 cmmd ! command for operating system real status ! status of executing OS command outfile = 'test.out' inquire(file=outfile, exist=there) if(there) then cmmd = 'del ' // outfile status = system(cmmd) end if open(3, file=outfile, status='new') write(3,*) 'the file exists!!!' end
This program will create an output file named test.out in the same directory/folder as the executable file, probably named testfile.exe. Modifying the source program (to change the test that is output) and re-compiling and re-executing it will re-produce the output file (with different contents) without the programmer/user deleting the output file between executions.
In formatted output, the first character of each line is the carriage control
character (i.e., ccc) which controls the movement of the paper in the printer as
indicated in the following table:
|current line is printed on the next line of the output|
|current line is printed on the same line as the
previous output; |
i.e., the line "overprints" the previously output one
|(zero) a blank line is produced before the
current line is output; |
hence, double spacing
|current line is output at the beginning of the next physical page|
Most printers are not capable of detecting and interpreting the ccc so they merely print it like any other character. However, you can convert the Fortran output file to an HTML file and view it in an Internet browser (like Internet Explorer or Netscape Navigator); you can then print it through that browser. The program f2html converts a standard Fortran output file to an HTML text file suitable for viewing and printing. In a Command Prompt (i..e., DOS) window, enter the command
f2html <project.out >project.htm
where project.out is the Fortran output file and project.htm is
the HTML equivalent. Since HTML files cannot completely control the placement of
individual lines on the screen or divide the image into pages, the following
accommodations are made for f2html:
this is fun!
would be displayed as
this is fun!
Hence, the word "fun" is bolded and the introductory blank used as the ccc is not part of the rendered result. The f2html program can accommodate Fortran output files that are approximately 80 characters "wide". To display files that are up to 140 characters in width, use the companion program f2htmlw (where the "w" stands for "wide"). This latter program is used in exactly the same matter as the f2html program. The resulting file from f2htmlw must be printed in landscape mode.
Compile a program of more than one file
If a complete source program is divided into two or more separate file:
Open all the pertinent files, using the Open tool () to retrieve each one. (Note that the down-arrow will list the files opened recently, but may not be opened now.) Note that all of the files should be in the same directory/folder.
In the Files panel, click the file that contains the main program.
Use Run > Compilation Options. In the Additional Options section and in the Options slot, enter the names of the additional files--including the suffix and separate them from each other by at least one space. Click OK.
Click the Compile tool.
If there are no syntax errors, the complete executable program will begin execution as though all of the source program parts were in in a single file. (The corresponding executable file--with .EXE suffix--can be used later in a DOS/Command Prompt window to associate external input or output files as was indicated earlier.)
Compile and NOT link a single source file
To just compile a single source program file (which may contain a main program or just one subprogram)
Open the appropriate file so that its contents are visible in the source program panel.
Use Run > Compilation Options.
In the Additional Options section and in the Options slot, enter -c -o xxx.exe (i.e., hyphen-C, space, hyphen-O [letter casing does make a difference], space, filename, where xxx is the desired primary name of the file to be created and .EXE is the necessary suffix and click OK. (In the specified option, the -c item indicates to just compile and not also link the associated program unit; the -o item indicates the desired name of the resulting object file. This primary part of the filename must be different from the primary name of the complete executable program when it is assembled) .
Use Run > Compile. Then click OK. The component will be compiled to produce the file xxx.EXE as indicated in the previous step. However, be aware that this file is not an executable file as would be indicated by the file suffix. Strictly speaking, it is an object file would normally have an .O suffix to indicate that.
The resulting non-text/binary file (named xxx.EXE) will be created in the same directory/folder a the source program file but will not appear in the Files panel. Do not try to open the file as such an action will not render the contents for human eyes and will damage the file contents. The resulting compiled file can be linked together with other needed program pats as described in the previous section.