Next: Compiling and Running
Up: Programming
Previous: Programming Languages

Fortran

Let's make this more concrete by taking a look at a Fortran program. If you push the button below, I'll create a directory called ``examples'' in your home directory. Within this directory I'll put some example programs. (I'm telling you all this so you'll be able to locate the example programs and read them into an Emacs buffer.)

Click here to copy files

Take a look the program ``sample1.f'' (which is in the ``examples'' directory that I just created) with Emacs (or view it directly). This is a simple Fortran program.

If you understood Fortran, you would be able to read this program and figure out what it does. (In fact, you can probably figure out what it does anyway.) But just to confirm your suspicions, let's run the program. Here's how to do that.

Pull down the Compile menu of Emacs and select the Compile This File... option. The command that is required to compile the program will appear at the bottom of the window. It should look something like this:

f77 -C sample1.f -o sample1

At this point Emacs is waiting for you to confirm that it should compile the file. To do this, type the Enter key. What happens?

Click here for the answer

Now that the program has been compiled, you can run it. To do this, go to the UNIX Shell window, and use cd to connect to your ``examples'' directory. Then type the name of the compiled version of the file, which in this case is simply ``sample1''. (The original program was ``sample1.f.'') What happens?

Click here for the answer

To summarize, once you have written a program, there are two steps required to run it.

First, you must successfully ``compile'' it, whatever that means! Second, you must run the compiled program. We'll now look in more detail at what compilation is.


Next: Compiling and Running
Up: Programming
Previous: Programming Languages

Hamlet Project
hamlet@cs.utah.edu