vi or vim and emacs or xemacs. My preference
is emacs but some hard-core Unix-types prefer vi. A third editor is
pico. Pico is really easy to use but not very powerful.
Use a text editor to type in the following code and save it with the name
power3.f90. If you need help, ask! PROGRAM power3 ! program to calculate 3rd power of 5 IMPLICIT NONE INTEGER :: a, b ! set variable `a' to equal 5, take the cube and write answer a = 5 b = a*a*a WRITE(*,*) a,b END PROGRAM power3After typing in the program, save it, and get back to the command prompt. (If you are using pico, exit and saving using Ctrl-X. If you are using emacs, use Ctrl-X Ctrl-C.) Now, you have the source code for a program. To turn that code into something the computer can execute, it must be compiled. In this case we will use the Fortran compiler called
f90. To compile your code, type f90 power3.f90. (If you
didn't use the name power3.f90 for your file, replace it with the
appropriate filename.) This creates a program named a.out. Now
that an executable has been created from the source code, the
computer can run it. Type a.out to run the program.
insert day 2 of Emacs here.
To edit a file with emacs (or create a new file), type emacs
filename where filename is the name of the file you want to
edit/create. The emacs ``window'' will appear. The bottom line of the
window is called the ``minibuffer''. The minibuffer is where you emacs
commands are displayed as you type them. The main part of the window is
where the current ``buffer'' is displayed. You can think of the buffer as
simply the current open file that you are editing. When you save the
buffer, you save the file.
Here are some of the most common emacs commands:
| Ctrl-x Ctrl-c | exit |
| Ctrl-x Ctrl-s | save |
| Ctrl-x Ctrl-f | save to different file name |
| Ctrl-g | cancel command |
| Ctrl-k | delete from here to end of the line (and copy to the |
| ``clipboard'' for later ``pasting''. In emacs-speak, the | |
| selection is copied to the ``kill ring'' where it can | |
| later be ``yanked'') | |
| Ctrl-y | ``Paste'' (``Yank'' in emacs-speak) |
| Ctrl-x Ctrl-v | Oops, opened the wrong file--open this one instead |
| Ctrl-x k | Exit out of the current buffer but keep Emacs open |