You can download the 1999 version of this compiler (version 2.95
along with the SLATEC
library (Version 4.1, July 1993), from this page. The
package runs under all (32-bit) versions of
All the needed files are packed in one zipped file
Fort99.zip) of about 6MB.
(If for some
reason you need the older
which does not include a library and does not run under Windows
XP, then you
can download it from my old page.)
C:), and then selecting New Folder from the File menu and calling the folder
Ffolder, and save the file in it.
Ffolder with their path names preserved (this is usually the default). If you don't have a zip/unzip program, download one from the Internet.
path. How these two environment variables are set varies from one version of Windows to another:
autoexec.batfile, which is stored in the root directory of your hard disk; i.e.
\. Hence, you need to edit this file and add to the two lines:
PATH=\F\G77\bin;%PATH% SET LIBRARY_PATH=\F\G77\libYou can do this by opening this file in Notepad or any other editor, adding the two lines at the end, and then saving the changes.
Control Panel, selecting
System, and then locating the
environment(or advanced, environment) section. You need to add a new variable with name
LIBRARY_PATHand set its value to
\F\G77\lib. Similarly add a new variable named
PATHand set its value to
;\F\G77\binto its value if it already exists.
\F\Yorkdirectory, compile them using:
f2exe, and create library object files using
f2lib. Here is a very short program to test the compiler and the configuration:
program Convert implicit none ! -----------------------------------------------Declare real*4 tempC, tempF, FACTOR integer*2 ZERO_SHIFT parameter (ZERO_SHIFT = 32, FACTOR = 5./9.) ! -----------------------------------------------Input print*, "Enter the temperature in Fahrenheit ..." read*, tempF ! -----------------------------------------------Compute tempC = FACTOR * (tempF - ZERO_SHIFT) ! -----------------------------------------------Output print*, "The corresponding Centigrade temperature is " print*, tempC, " degrees." endUse any editor to create this program (simply copy and paste) and save it as a text file in the
\F\Yorkdirectory under the name
test.for. You can, of course, use any editor you like as long as you can save the file in text format and with the extension you want. Notepad, for example, uses text but insists on using the
txtextension (unless you override by double-quoting) while MS-Word insists on its propriety format (unless you explicitly override). I highly recommend using the
Crimsoneditor, which can be downloaded from the on-line Lab-1 (see below).
Compile and run your program from the DOS command prompt by typing:
cd \F\York f2exe test testIf the first command returned an error then the directory was not created (or named) correctly. If the second command was not recognized, or complained that a library is missing, then the environment variables were not set correctly (you can issue the
setcommand to inspect all environment variables).
More information on using the compiler can be found in the on-line Labs at the Fortran@York site.
\F\G77\docdirectory has a detailed reference to the language, which is largly ANSI Fortran-77 but with some Fortran-90 features added (see below).
The above Fortran@York site contains a quick reference guide, lab, and SLATEC usage examples. If you are already familiar with Fortran then the following points may be all you need to know about this compiler:
f2execommand is just a batch file that invokes
g77, the "real" compilation command. The command:
g77 -ffree-form prog.for -oprog.exedirects the compiler to compile the file
prog.forand stores the output in the file
-ffree-formswitch indicates free-form style (remove it if you are using the old style).
") as well as single quotes,
DO WHILE, the
INCLUDEstatements, list-directed and namelist I/O on internal files, binary, octal, and hex constants, `O' and `Z' edit descriptors,
FILE=specifier may be omitted in an
STATUS='SCRATCH'is supplied, relational operators
>=may be used instead of
SELECT CASE(but not for character types).
programstatement, as in the
Convertprogram above. The subprograms (functions and subroutines) can be included in the same file as the main program (in which case you can compile everything in one shot) or can be stored in separate file(s). It is recommended that you store general reusable subprograms in separate files so that you can reuse them (without recompiling them) in future projects. To compile a file that contains only subprograms (no
programstatement), use the
f2libcommand, which generates object files, one per sub, in the
f2lib utilwill compile (without linking) the subprogram in
util.forand store the output (an object file) in the file
f2libis just a batch file that invokes the
g77command with the
-c(compile-only) switch, viz.
g77 -c -ffree-form util.for -o..\mine\util.oA program that uses pre-compiled object files can be compiled (and linked to them) by simply referring to them in the compilation command:
g77 -ffree-form prog.for -oprog.exe ..\mine\*.oThe above command searches all object files in
mineto resolve any missing reference in
f2libbatch files take care of separate compilation and delayed linking with object files and with the SLATEC subprograms. You don't have to directly issue the
g77command unless you use the old columnar style or you want to change one of the switches or directories.
-S(capital S) switch allows you to see a listing of the generated assembly code.