Read Section 7 (pp18-22) of the Fortran summary. Also
take a look at Appendix four which lists some of the internal
FORTRAN functions. Note in particular the array
operations such as Dot_Product and Matmul. Another function
you will use today is the random number generator Rand().
This command generates a random number on the interval [0,1] and
does not need an argument. We will also
use file output commands OPEN and CLOSE which are
discussed on page 30 of the Fortran summary. You will
do some plotting of your data today, using the
graphics package xmgrace. You will write data
to a two column format text file (space delimited,
not comma delimited). If your data file is
results.dat, then entering
will plot your results.
PROBLEM 1 Write a fortran program to take the inner product of two vectors of length N, where N is entered from the screen by the user. Demonstrate your program by generating two vectors: One which has a unit value for each element and the other with random elements uniformly distributed on interval [-1,1]. Now study how the inner product of these two vectors depends on N. Make a plot of the result of this inner product as a function of N using xmgrace. You can do this by writing an outer loop which runs over values of N and printing the result to a data file.
Using allocatable arrays, write a fortran program to generate an
NxN (choose N odd) array which is bidiagonal, with value zero
everywhere except on two diagonals. The
two diagonals are the one above and the one below
the major diagonal and the value of the entries
on these two diagonals is unity. Create a vector
of length N which is zero everywhere except at entry (N+1)/2 where
it has value one. Now write a program to repeatedly
act on your vector with the matrix. At each step, normalize
the vector and write it to a file. Plot the final result
of your simulation.