LAB #1


This Lab enables you to set up the Fortran development environment that you will be using to write, compile, and run Fortran programs. You can create this environment in one of the academic labs on campus or on your home personal computer. Even if you are planning to do all programming on your home PC, it is highly recommended that familiarize yourself with the campus environment so that you can work at either location. This will prove particularly useful for last-minute modifications (to programs created at home) or for generating output using a York printing facility.

The Home Environment

Download and configure the Fortran Compiler from this site. You can ignore the USAGE and LANGUAGE sections in that site because we are going to discuss them in more details here.

The following additional download is optional:

You can of course create programs using any editor, or even a word processor, as long as you can save the file in text format with the extension you want. Notepad, for example, uses text but insists on using the txt extension (unless you override by double-quoting), and MS-Word allows any extension but saves in a propriety doc format (unless you override by specifying text format). Ideally, however, the editor knows that you are writing programs, not sentences and paragraphs, and thus offers services like: Highlighting keywords, operators, literals, and other language-specific features; block indent and un-indent; support user-defined tab stops; display line numbers; plus a host of standard services, like opening multiple files, spell checking, editing text, and so on. One freeware editor that meets the above requirements is Crimson ( and here are step-by-step instructions for its download and configuration:

If you chose to download the editor, use it whenever the Lab refers to creating a program or invoking the DOS edit editor.

The Campus Environment

You will need to obtain an ACADLABS account in order to access the Fortran compiler from one of the academic labs on campus. The LABS page in the course Web site has details (under WHERE) on obtaining an account and on the locations of campus labs.

The Setup

  1. Start MS-DOS. You do this by finding the Command Prompt under Start | Programs. In some Windows version, it is under "accessories".
  2. At the MS-DOS prompt, type Edit.
  3. Click the Windows Start button again. If Start is not visible, simply press Ctrl-Esc to open it.
  4. If you are working in a campus lab, select Start | Programs | MS-DOS Applications | COSC1540 Fortran. This will prepare the compiler and leave you at the F:\ prompt.
    If working at home, choose the MS-DOS Command Prompt again and in its window, type: cd \F\York
  5. Note that the above steps allow you to have two tasks running in two separate windows: one for the editor and one for the compiler. Windows allows you to switch from task to another by repeatedly pressing Alt-Tab; i.e. press the Tab key while holding down the (left or right) alt key.
  6. Press Alt-Tab to switch to the Edit window.
  7. Type the following program exactly as shown:
    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."
  8. Save the program by choosing File|Save. Since this is the first time you save this file, you will be prompted for a filename. If you are in a campus lab, save the file by supplying the name Lab1.FOR (this will save it in your F:\ directory). At home, save it in the \F\York by typing: \F\York\Lab1.FOR.
  9. Compile the program: switch to the other open DOS window by pressing Alt-Tab. There, type the command:
    f2exe Lab1
  10. If compilation (syntax) errors were detected, an executable file will not be generated and you will see errors and corresponding line numbers shown. In that case, you will need to go back to the editor and fix the errors.
  11. Run the program. Simply type Lab1 at the DOS prompt. This works because a file named Lab1.EXE has been created.

Lab Checking

Visit the Lab TA (see the course home page for location and times) and inform him/her that you completed this Lab. No deliverables are involved.