The following assignment involves writing and testing three
Fortran 77 programs which use LAPACK routines to solve various linear
systems. You must also prepare a short Maple worksheet for
Problem 3. Follow the instructions carefully and do all program
development on the lnx machines.
All files required by the assignment must reside in the correct
places on your lnx account for the homework to be considered complete.
Note that you
are free--and in fact encouraged--to work from the relevant examples
covered in class.
Note: This assignment is identical for both 410 and 555 students;
i.e. all students must complete all three problems.
Problem 1:
In directory /hw4/a1 on your lnx account, create a source
file lsolve.f and corresponding executable
lsolve which solves a general linear system.
lsolve is to accept exactly two arguments:
usage: lsolve <matrix file> <rhs file>where <matrix file> is the name of a file which contains an matrix () and <rhs file> is the name of a file which contains an -element column vector (). lsolve is to read the matrix and the right-hand-side vector, then compute the solution, of the linear system
Hint: If your solution to this problem starts to get complicated, particularly in terms of how the matrix and vectors are dealt with, you should assume that there is an easier way!
Problem 2:
Consider the following boundary value problem (BVP)
usage: gbvp1d <level> [<option>] Specify option .ne. 0 for output of error instead of solutionwhere the required integer argument, <level>, specifies the discretization level, , such that and . If <option> is 0, or not specified, the standard output of gbvp1d is (two numbers per line), , where are the components of the computed solution. If <option> is non-zero, the standard output of gbvp1d is (two numbers per line), , where is the error in the computed solution. In all cases, the program should also compute the RMS error of the computed solution and output it to standard error. Using gnuplot or supermongo, make postscript plots showing (A) the level 6 solution and the exact solution as a function of (soln6.ps) and (B) the error for level 5, 6 and 7 solutions, also as a function of (err567.ps). (The postscript files should, of course, be located in the directory /hw4/a2.)
Problem 3:
Consider the BVP problem defined in the previous question and,
in /hw4/a3 on your lnx account, create a source
file gbvp1d4.f and executable gbvp1d4 which approximately
solves the ODE using a combination of and
finite-difference approximations of the first and second derivatives.
Specifically, use
> convert(taylor(u(x+h),h,8),polynom); > convert(taylor(u(x+2*h),h,8),polynom);Document your verification in a maple worksheet called /hw4/a3/fd4.mws. Your implementation of gbvp1d4 must first set up the pentadiagonal system for the , and then solve the linear system using the LAPACK banded-solver DGBSV. Use the same and to test your program as you used in Problem 2. gbvp1d4 should accept precisely the same arguments and have precisely the same output behaviour as gbvp1d. Using gnuplot or supermongo, make postscript plots showing (A) the level 6 solution and the exact solution, as a function of (soln6.ps) and (B) the error for level 5, 6 and 7 solutions, also as a function of (err567.ps).
Note: You may find this problem significantly more difficult to
complete than the other two. Don't leave it until the last minute and
don't be afraid to ask for help and/or advice.