This example show an example of catch exception with the linear_equation module. More details about this example.
00001 00014 program leq_exception 00015 #include "fml_constants.h" 00016 use mod_linear_equation ! use linear_equation module 00017 implicit none 00018 00019 !********************************************* declaration 00020 integer, parameter :: size_ab=4 00021 type(matrix) :: A !main square matrix 00022 type(vector) :: b !second member 00023 type(t_soleq) :: x !contains solution (v_sol), iterations (iter) and errors (v_err) 00024 00025 !********************************************* body 00026 call init(A,size_ab,size_ab); !init:=m_init 00027 call init(b,size_ab); !init:=v_init 00028 !initialize A by random values between 1.0 and 10.0 (diagonal dominant) 00029 call mc_diagDominant(A,size_ab,low=p_notcast(1.0),high=p_notcast(6.5)) 00030 !initialize b by random values between 1.0 and 5.0 00031 call random(b,low=p_notcast(1.0),high=p_notcast(6.5)) 00032 00033 print*; !newline 00034 print*, "********************************************* display initial data" 00035 print*,"* A="; call print(A); !print A (print:=m_print) 00036 write(*,'(A5)',advance='no')"* b="; call print(b); !print b (print:=v_print) 00037 print*; !newline 00038 00039 !must throw an exception because conjugate gradient method need symmetric matrix 00040 print*, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> solve :: Conjugate Gradient element " 00041 x=ilinsolve(A,b,meth_solve='cgelt') 00042 write(*,'(A5)',advance='no')"* x="; call print(x%v_sol); 00043 write(*,'(A24,I3)')"# number of iterations=", x%iter 00044 write(*,'(A9)',advance='no')"# A*x-b="; call print(A*x%v_sol-b); 00045 print*; !newline 00046 00047 call destruct(A) ! destruct the matrix A (don't forget to destruct the matrix) 00048 call destruct(b) 00049 call destruct(x) 00050 end program leq_exception