A FORTRAN program can be typed (keyed in) and saved using any ASCII text editor such as Sidekick (SK), WordStar Release 4(WS4), DOS line editor (EDLIN), dBASE III PLUS, dBASE IV, Turbo C and PASCAL integrated development environments, COPY CON command of DOS, or any package that stores texts exactly as they were entered. The program is often saved with file extension .FOR, though any file extension can be used. Note that when typing the program, the coding format treated in section 1.3 must be observed.
After keying in the program and saved, then, compile the program using the FORTRAN compiler to create any object file that will have the extension .OBJ. In most cases, the compiler is normally F77.EXE, or FORTRAN77.EXE, or FORTRAN.EXE, or any name given to the compiler file. As an example, to compile a FORTRAN program that has been saved with the name PROG.FOR, we type, at the DOS directory that contains the compiler file, the following
F77 PROG
or
F77 PROG.FOR
This will request you to press the return key(i.e ENTER key) to continue. When the return key is pressed, the following message will appear:
Fortran 77 Compiler – Version 3.15 17 FEB 96 09:30:45
(C) Copyright FortranSoft Ltd 1987 --------------
******Lines Compiled = x ******
****** Compilation Successful *****
where x is the total number of lines in the program. If the program has some errors, then the return key is press, the following message
***** x errors – No object produced *****
After compiling the above program, the object file PROG.OBJ is automatically created. The next stage is to create the executable file with extension.EXE by the use of any linker (LINK.EXE) program. So, having compiled the program as described above, we create (or link) an executable file by issuing the command
LINK PROG
where PROG is the source program name. The following messages will appear:
Microsoft (R) 8086 Object linker Version 3.05
Copyright (C) Microsoft corp. 1983, 1984, 9185. All right reserved.
Run file.[PROG.EXE]
You can then type a new name for the executable file or you press the ENTER key to use the default name PROG.EXE. Next the listing and library files will be requested for, in turn, thus:
List File [NUL.MAP]
LIBRARIES [.LIB]:
Supply new file names or press the ENTER key for none, in each case. The executable file PROG.EXE is now created and can be executed, independent of the source nd object files, by simply typing its name at the DOS command line, thus:
PROG
NB: The above compilation procedure may differ from version to version of FORTRAN 77 (Consult your FORTRAN 77 Manual or supplier of FORTRAN packages for more information on how to run your v programs.).
No comments:
Post a Comment