next up previous index
Next: The structure of an Up: Annotating Codes with FWEB Previous: Processing an FWEB file

About FWEB sections and modules

@n9[-n/] % Set FWEB language to Fortran, and recognize short // comments.

\Title{example.web} % \Title is an FWEB TeX macro.
\author{Hermenegilde Kociubinsky} % \author is a LaTeX macro.

This code is intended to illustrate the use of the |write| statement.
The general structure of the code is straightforward:


program main
  @<constants and variables@>
  stop 0
  @<functions and subroutines@>
end program main

@ The first block, or \FWEB\ module, introduces the only
constant of the program, |a_constant|.

@<constants and variables@>=

  real(kind=4), parameter :: a_constant = 1.2345

@ The program itself comprises one statement only: we call subroutine
|compute| and pass |a_constant| as a parameter.


  call compute(a_constant)

@* Functions and Subroutines.

In this program we have defined only one subroutine. All that it
does is to print a |real(kind=4)| value on standard output.

@<functions and subroutines@>=

  subroutine compute(a)
    real(kind=4), intent(in) :: a
    write(*,*) 'a = ', a
  end subroutine compute

@* \INDEX.

Here is what the resulting document looks like:

\includegraphics[width=12cm,viewport=0 380 612 740,clip=true]{}

\includegraphics[width=12cm,viewport=0 0 612 380,clip=true]{}

Zdzislaw Meglicki