Self study guide: Fortran 95 - University of Cambridge
Self study guide: Fortran 95 - University of Cambridge
Self study guide: Fortran 95 - University of Cambridge
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Suggested Exercise 2<br />
Write a program which initialises two arrays<br />
real(kind(1.0d0)) :: x(128), y(128)<br />
as the real and imaginary parts <strong>of</strong> a complex vector. The real part x should contain<br />
x(i) = sin(i/a) where a is a parameter to be read in. The imaginary part, y, should be<br />
initialised to zero. The arrays should be initialised in a subroutine called from the<br />
main program.<br />
Now extend the program to use a NAG routine to take the Fourier transform <strong>of</strong> the<br />
values and write the result out to disc so that the data can be plotted in gnuplot.<br />
For the purposes <strong>of</strong> this exercise you can simply adopt an arbitrary scale for the<br />
frequency.<br />
You can find a solution to this problem in the examples directory<br />
$PHYTEACH/part_2/examples/exercise2.f90<br />
49