This is an example of how an exception can caught with the vector module. More details about this example.
00001 00014 program vector_exception 00015 #include "fml_constants.h" 00016 use mod_vector ! use vector module 00017 implicit none 00018 00019 !********************************************* declaration 00020 integer, parameter :: v1_size = 5 !size of v1 00021 integer, parameter :: v2_size = 6 !size of v1 00022 ! declaration of vector v1 00023 type(vector) :: v1; 00024 ! declaration of vector v2 00025 type(vector) :: v2; 00026 ! declaration of vector v_res 00027 type(vector) :: v_res; 00028 !********************************************* body 00029 00030 ! init of a vector v1 00031 call init(v1,v1_size); !init:=v_init 00032 ! init of a vector v2 00033 call init(v2,v2_size); !init:=v_init 00034 00035 !initialize v1 by random values between 1.0 and 10.0 00036 call random(v1,low=p_notcast(1.0),high=p_notcast(10.0)) !random:=vc_random 00037 00038 print*, "********************************************* try to addition v1+v2" 00039 v_res=v1+v2 !must throw an exception because v1%size != v2%size 00040 00041 call destruct(v1) ! destruct the vector v1 (don't forget to destruct the vector) 00042 call destruct(v2) ! destruct the vector v2 (don't forget to destruct the vector) 00043 end program vector_exception