@device(imprint10)
@style(spacing 1, leftmargin .5 inch, rightmargin .5 inch, topmargin 3 lines,
bottommargin 1 line, font computermodernroman10)
@modify(hdg, fixed 2 lines)
@modify(ftg, fixed -2 lines)
@modify(format, leftmargin +3)
@pagefooting(left="L. B. Merims,Project Athena", right="Rev. A, Feb. 4, 1985")
@modify(heading, flushleft)
@begin(majorheading, flushright, below .75 lines)
One Page Emacs -- Fortran Example
@end(majorheading)

@i(One Page Emacs -- Fortran Example) shows you how to create a Fortran
program using the @p(emacs) text editor.  It is
meant to be used with @i(One Page Fortran).  For more information
on @i(emacs), see the free Athena document @i(Essential Emacs), available
in most Athena terminal clusters.

@heading(Starting Emacs)
To enter @i(emacs), type the emacs command and the name of the file you
want to edit, then press the RETURN key.
If the filename is new, @i(emacs) will create it.
@begin(format)
yourhost% @b(emacs  ftoc.f)
@end(format)
Your screen will blank out, and then (after some seconds) come back with
a new screen that looks something like:
@begin(verbatim)
                    ------------------------------------------
                    | _                                      |
                    |                                        |
                    |                                        |
                    |                                        |
                    |                                        |
                    |                                        |
                    |                                        |
                    |                                        |
                    |                                        |
                    |EMACS (Fundamental) Main: ftoc.f -0%-   |
                    |                                        |
                    ------------------------------------------
@end(verbatim)
The real screen is usually 24 lines long and 80 characters wide.
Everything above the line is a "blank page" that you can fill up with
text.  The line shows @i(emacs) status information.  If @i(emacs)
has any questions to ask you, it will prompt you for answers
at the bottom of the screen.

@heading(Fortran Format)
With this and all Fortran programs, you need to be careful about
which columns you put things in.  If you violate the rules,
the errors that result are usually copious, obscure, and
hard to diagnose correctly.  The screen is 80 columns wide
(like an old data card).  This is the format to follow:
@begin(description, spread 0)
@b(Columns@\What it contains)

1@\If a C is present, for "comment," the rest of the line is ignored.  Notice
below how the programmer uses a comment card to help her line things up.

2-5@\Fortran statement numbers.

6@\If not blank, this card is a continuation of the previous card.

7-72@\Program statements, indented as necessary.

73-80@\@b(MUST) be left blank.  Fortran ignores them.
@end(description)

@heading(Typing in Text)
Type in the fahrenheit to centrigrade program as shown below.
@begin(example, above 1 line, below 0 line)
C
C   Convert Fahrenheit temperatures to Centigrade: C = 5/9 (F - 32)
C
C234567----------------------------------------------------------------|------

      real  ftemp, ctemp

      print *, 'Type in a Fahrenheit temperature, then press RETURN'
      read  ftemp

      ctemp = (5.0/9.0) * ( ftemp - 32.0 )

      print *, ftemp, 'Fahrenheit is', ctemp, 'Centrigrade'
      print *, 'Exiting.  Bye.'
      end
@end(example)
@begin(description)
@b(To enter text)@\Just start typing.  When you get to the end of the line, press the
RETURN key, just as you would on an electric typewriter.

@b(Blankspace)@\Use the SPACEBAR to make blanks.  In @i(emacs), there
is a difference between a blank (made with the SPACEBAR) and
nothing at all. 

@b(Blanklines)@\Make blank lines just as you would on a typewriter, press
the RETURN key an extra time.

@b(Typos)@\If you make a mistake while typing along, use the
DELETE key at the upper right of the main keyboard (sometimes
labeled <--) to backup and fix the mistake.
@end(description)

@heading(Fixing Text)
You edit existing text (fix typos, add or delete words or lines, etc.)
by moving the @b(cursor) around the "page" to the point you want to
fix and then entering a command.
@begin(description)
@b(Move the cursor)@\You move the cursor with the arrow keys at the right
of the keyboard.  Notice how the cursor "wraps around" when you go over
the end of a line.  Please note that on some terminals there is a <--
delete key and a <-- arrow key.  They are different.

@b(Inserting letters)@\Move the cursor to where you want the new characters.
Type them.  The rest of the text shifts over to accommodate them.

@b(Inserting lines)@\Move the cursor to where you want the new line to be.
Press RETURN.  A new line will open up.  You may have to move the cursor one
spot to the beginning of the new line.

@b(Deleting letters)@\Move to just @i(after) the character you want to remove.
Press the DELETE key.

@b(Deleting lines)@\You can delete a whole line by just typing enough DELETEs
to devour it.  Alternatively, move the cursor to the beginning
of the line, hold down the CTRL key (lower left of the keyboard), and
while still holding it down, press K.  Press CTRL-K again to get rid of
the space the line occupied.
@end(description)

@heading(Exit Emacs)
To leave @i(emacs), type @i(two) CTRL-Cs.  Hold down the CTRL key at
the lower left of the keyboard while you press C.  Release and repeat.
At the bottom of the screen you'll see:
@begin(format, leftmargin +3)
Buffer Main modified since last write to file ftoc.f, write?  @b(y)
@end(format)
Nothing you have done is permanent until you reply y for yes to this
question.  Reply no, and everything will be thrown away.  If @i(emacs)
asks you about adding newlines, reply y for yes.

@heading(Debugging with Emacs)
Fortran @i(f77) compiler error messages tell you the line number
where it found the error.  How, when there is more than just a few
lines, do you find this line in the original file, short of counting them
with your finger?  You can get @i(emacs) to display a file with line
numbers.  These line numbers are not part of the file, nor can you
edit them.  They are illustrative only.  The numbers will not be saved
when you
leave @i(emacs).  To display line numbers:
@begin(enumerate, above 0 line, below 0 line,spread 0)
Press the ESC key.  You may have to hunt for it.  It will either be
in the upper left corner of the keyboard, or on terminals with
a row of buttons across the top (VT240, VT220, VS100) it is the F11
key.

Press X.  Emacs will promt M-X at the bottom of the screen.

Now type out:  Line number mode  ,and press RETURN.  It will look something
like:
@end(enumerate)
@begin(example, above .5 line, below 0 lines)
1    C
2    C   Convert Fahrenheit temperatures to Centigrade: C = 5/9 (F - 32)
3    C
4    C234567----------------------------------------------------------------|------
5    
6          real  ftemp, ctemp
7   
8          print *, 'Type in a Fahrenheit temperature, then press RETURN'
9          read  ftemp
10
11         ctemp = (5.0/9.0) * ( ftemp - 32.0 )
12
13         print *, ftemp, 'Fahrenheit is', ctemp, 'Centrigrade'
14         print *, 'Exiting.  Bye.'
15         end
@end(example)
