![]() |
![]() | |||||
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
When you telnet to the class server (et791.ni.utoledo.edu) and log into your account, you will have access to the GNU f77 FORTRAN compiler. This page provides you with the information needed to use the f77 compiler. Compiling a FORTRAN 77 ProgramThe following commands can be used to compile a FORTRAN 77 program on the class server. In this example, the f77 utility is used to compile a FORTRAN 77 program named prog.for: et791:~$ f77 prog.for et791:~$ mv a.out progThe f77 utility calls the GNU preprocessor, the FORTRAN 77 compiler, the assembler, and the link editor. The link editor creates an executable file named (by default) a.out. The second command renames a.out to prog. If you fail to rename the a.out file, the next use of the f77 utility will overwrite the executable file. The compiler should produce an object-code file which has the appropriate UNIX permissions for an executable file. It is, however, worth checking the file to make certain that this is true. If it is not, the command below can be used to make the object code file (now named prog) executable so that you can run it and test it for logic and/or runtime errors. et791:~$ chmod 755 progThe -o argument (or parameter) can be used to speed up this process. The following two commands achieve the same results as the three above: et791:~$ f77 -o prog prog.for et791:~$ chmod 755 progWith this approach, there is no need to rename the a.out executable file as it has not been generated! Instead, the object-code file has been named prog as specified by the -o argument. Order is not importnat with the -o parameter. The following command is also valid. et791:~$ f77 prog.for -o prog GNU C and F77 CompilersThe C and F77 compilers are integrated; f77 is a program to call gcc with options to recognize programs written in Fortran (ANSI FORTRAN 77, also called F77). gcc processes input files through one or more of four stages: preprocessing, compilation, assembly, and linking. Source code filename extensions indicate the specific language:
For example, to compile the FORTRAN 77 program grades.for we could use the f77 command as shown below: et791:~$ f77 grades.for However, as with the f77 utility, a slightly more complex form of the command is both faster and more useful: et791:~$ f77 -Wall -g grades.for -o grades Each of the arguments in this command are explained as follows:
Running a ProgramIt is important to remember that the compiler creates a file which is executable, meaning that you can run it by simply typing its name at the UNIX prompt.et791:~$ program_nameIf you type the name of an executable file and it does not run (i.e., you get an error message) try typing a "./" (dot slash) followed by the program_name, and then press the [Enter] key. et791:~$ ./program_nameOne of these two methods should work for you. Once the program is finished, you will see the UNIX prompt. Note: The "./" is needed to run the program because of a "path" issue.
| |||||
| |
| Added to the Web: September 1, 1999. Last updated: October 2, 1999. Web page design by Dan Solarek. |
![]() http://cset.sp.utoledo.edu/cset4250/ |