4. How to use Fortran with the BC-FORTRAN77 compiler

Practical details

BC-FORTRAN77 Version b consists of a compiler, linker, module library and a resident run-time system, which also contains a simple debugger. This version runs on an MS-DOS computer with 640kB RAM. A hard disk is not required.

BC-FORTRAN77 version b consists of the following parts:

  1. BCF.EXE Compiler
  2. BCL.EXE Linker
  3. BCRTSY.EXE Resident run-time system
  4. LIB.B Library of standard functions

BEFORE the compiler, linker or program is started, the resident run-time system MUST be loaded. For this, just run the program BCRTSY.EXE. If you use BC-FORTRAN77 regularly, place BCRTSY.EXE in your AUTOEXEC.BAT file.

Source code, object code, compiling, and linking

A Fortran program consists of plain text that follows certain rules (syntax). This is called the source code. You need to use an editor to write (edit) the source code. The MSDOS EDIT program is an acceptable editor. For Windows, Notepad or PFE (Programmers File Editor) are good editors.

When you have written a Fortran program, you should save it in a file that has the extention .f or .for. Before you can execute the program, you have translate the program into machine readable form. This is done by a special program called a compiler. The Fortran 77 compiler in BCFORTRAN is BCF.EXE. The output from the compilation is given the extension .B by default, but you can choose another name if you wish.

The compiler is started by


    BCF [-Option...] File...

If File does not contain a period, a .F will be appended. The object file will be placed in FILE.B.
Example:

    BCF -D TEST.F
Compile TEST.F with the debug option into TEST.B
    BCF TEST SUB
Compile TEST.F into TEST.B and SUB.F into SUB.B
    BCF TEST.X
Compile TEST.X into TEST.B

Refer to the BCFORTRAN77 text file ENGLISH.TXT for information on the options which may be used with the BCF compiler.

The result of the compile is a binary file. In order to execute this file you must link this file to the MSDOS runtime library, and the BCFORTRAN77 library LIB.B. To do this the the BCFORTRAN77 linker BCL.EXE is used.

The Linker is started by


    BCL [-Options...] File...

If File doesn't contain a period, a .B will be appended. The executable file will be created with the name of the first file but with .EXE substituted for .B. It must also search the LIB.B file in order to link the standard functions and I/O routines.

Example:

 

    BCL -S16 TEST.B SUB.B LIB.B

links the files TEST.B and SUB.B into the runnable program TEST.EXE with a stack size of 16kB.

Refer to the BCFORTRAN77 text file ENGLISH.TXT for information on the options which may be used with the BCL linker.


Exercises:

Exercise A
Compile and link the sample program CIRCLE.F. Run the resulting program CIRCLE.EXE. Does it work?

Exercise B
Modify the circle program such that it computes the circumference instead of the area. Compile, link, and run it and verify the answers you get.


[Next] [Previous] [Fortran Tutorial Home]