A Modular Arbitrary-Order Ocean-Atmosphere Model -- Stochastic implementation
test_sqrtm.f90
Go to the documentation of this file.
1 
2 ! test_sqrtm.f90
3 !
4 !> Small program to test the matrix square-root module
5 !
6 !> @copyright
7 !> 2018 Jonathan Demaeyer.
8 !> See LICENSE.txt for license information.
9 !
10 !---------------------------------------------------------------------------!
11 
12 PROGRAM test_sqrtm
13 
14  USE params, only: init_params
15  USE util, only: printmat
17 
18  REAL(KIND=8), DIMENSION(3,3) :: A,B,sqB,sqA
19  INTEGER :: info,info2
20 
21  a=0
22  a(1,:)=(/9.1784812096335050e-009,5.7810098811039660e-009,3.8077584903965249e-009/)
23  a(2,:)=(/5.7810098811039676e-009,3.6411334819038273e-009,2.3982932421037010e-009/)
24  a(3,:)=(/3.8077584903965258e-009,2.3982932421037010e-009,1.5796758080159289e-009/)
25 
26  ! B=matmul(A,A)
27  CALL init_params
28  CALL init_sqrt
29 
30  print*, 'Schur decomposition'
31 
32  CALL sqrtm(a,sqa,info,info2,2)
33 
34  print*, info,info2
35 
36  print*, 'A'
37  CALL printmat(a)
38 
39  print*, 'sqA'
40  CALL printmat(sqa)
41 
42  print*, 'sqA*sqA'
43  CALL printmat(matmul(sqa,sqa))
44 
45  print*, 'Svd Decomposition'
46 
47  CALL sqrtm_svd(a,sqa,info,info2,2)
48 
49  print*, 'A'
50  CALL printmat(a)
51 
52  print*, 'sqA'
53  CALL printmat(sqa)
54 
55  print*, 'sqA*sqA'
56  CALL printmat(matmul(sqa,sqa))
57 
58 
59 
60  ! print*, 'B'
61  ! CALL printmat(B)
62 
63  ! print*, 'sqB'
64  ! CALL printmat(sqB)
65  ! print*, 'sqB*sqB'
66  ! CALL printmat(matmul(sqB,sqB))
67 
68 
69 END PROGRAM test_sqrtm
Utility module.
Definition: util.f90:12
subroutine, public sqrtm(A, sqA, info, info_triu, bs)
Routine to compute a real square-root of a matrix.
Definition: sqrt_mod.f90:63
subroutine, public printmat(A)
Definition: util.f90:200
subroutine, public init_sqrt
Definition: sqrt_mod.f90:39
program test_sqrtm
Small program to test the matrix square-root module.
Definition: test_sqrtm.f90:12
The model parameters module.
Definition: params.f90:18
subroutine init_params
Parameters initialisation routine.
Definition: params.f90:138
Utility module with various routine to compute matrix square root.
Definition: sqrt_mod.f90:20
subroutine, public sqrtm_svd(A, sqA, info, info_triu, bs)
Routine to compute a real square-root of a matrix via a SVD decomposition.
Definition: sqrt_mod.f90:401