Nodes of different colours represent the following:
Solid arrows point from a submodule to the (sub)module which it is
descended from. Dashed arrows point from a module or program unit to
modules which it uses.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Variables
Type
Attributes
Name
Initial
real(kind=rk),
dimension(:,:), allocatable
::
A
real(kind=rk),
dimension(:,:), allocatable
::
Ainv1
real(kind=rk),
dimension(:,:), allocatable
::
Ainv2
integer
::
m
integer
::
n
real(kind=rk)
::
rel_err
Source Code
program test2use kinds! Import the module 'kinds' for precision typesuse forinv,only:inv! Import only the 'inv' function from the 'forinv' moduleimplicit nonereal(rk),dimension(:,:),allocatable::A,Ainv1,Ainv2! Define dynamically allocated matrices A and Ainvinteger::m,n! Define variables for matrix dimensionsreal(rk)::rel_errm=1000! Set the number of rows for matrix An=100! Set the number of columns for matrix Aallocate(A(m,n),Ainv1(n,m),Ainv2(n,m))! Allocate memory for matrix Acall random_number(A)! Fill matrix A with random numbers between 0 and 1Ainv1=inv(A*10)! Calculate the matrix inverse of A using the 'inv' functionAinv2=inv(A*10)! Calculate the matrix inverse of A using the 'inv' functionrel_err=norm2(Ainv1-Ainv2)/norm2(Ainv1)print*,"Ainv1(1,1) =",Ainv1(1,1)print*,"Ainv2(1,1) =",Ainv2(1,1)print*,"Relative error:",rel_errif(rel_err<1e-13_rk)then print*,"Test 2 passed."print*,""else print*,"Test 2 failed!"print*,""end if deallocate(Ainv1,Ainv2)! Deallocate memory for matrix Ainvend program test2