15.02.2015 Views

Numerical Modelling in Fortran: day 2

Numerical Modelling in Fortran: day 2

Numerical Modelling in Fortran: day 2

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Exercise 3: Second derivative<br />

• Write a subrout<strong>in</strong>e that calculates the second<br />

derivative of an <strong>in</strong>put 1D array, us<strong>in</strong>g the f<strong>in</strong>ite<br />

difference approximation<br />

• The <strong>in</strong>puts will be the array, number of po<strong>in</strong>ts and grid<br />

spac<strong>in</strong>g.<br />

• The result<strong>in</strong>g 1-D array can be an <strong>in</strong>tent(out) argument.<br />

• Assume the derivative at the end po<strong>in</strong>ts is 0.<br />

• Test this rout<strong>in</strong>e by writ<strong>in</strong>g a ma<strong>in</strong> program that<br />

calls the subrout<strong>in</strong>e with two idealized functions for<br />

which you know the correct answer, e.g., s<strong>in</strong>(x),<br />

x**2.<br />

• Hand <strong>in</strong> your .f90 code and the results of your two<br />

tests

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!