A Modular Arbitrary-Order Ocean-Atmosphere Model -- Stochastic implementation
test_MAR.f90
Go to the documentation of this file.
1 
2 ! test_MAR.f90
3 !
4 !> Small program to test the Multivariate AutoRegressive model
5 !
6 !> @copyright
7 !> 2018 Jonathan Demaeyer.
8 !> See LICENSE.txt for license information.
9 !
10 !---------------------------------------------------------------------------!
11 
12 PROGRAM test_mar
13 
14  USE params, only: ndim,dt,tw
15  USE aotensor_def, only: init_aotensor
16  USE dec_tensor, only: init_dec_tensor
17  USE sf_def, only: n_unres
18  USE util, only: printmat
19  USE mar
20 
21  REAL(KIND=8), DIMENSION(:,:), ALLOCATABLE :: x
22 
23  REAL(KIND=8) :: t
24  INTEGER :: AllocStat,i,n
25 
26  CALL init_aotensor ! Initialize the aotensor
27  CALL init_dec_tensor
28  CALL init_mar
29 
30  print*, 'Qred'
31  CALL printmat(qred)
32  print*, 'Q'
33  CALL printmat(q)
34  DO i=1,ms
35  print*, 'Wred',i
36  CALL printmat(wred(i,:,:))
37  print*, 'W',i
38  CALL printmat(w(i,:,:))
39  ENDDO
40 
41  print*, 'Generating 100 steps of MAR evolution ...'
42  ALLOCATE(x(0:ndim,ms), stat=allocstat)
43  x=0.d0
44  DO i=1,100
45  CALL mar_step(x)
46  ENDDO
47  DO i=1,100
48  CALL mar_step(x)
49  print*, i,x(1:ndim,1)
50  ENDDO
51 
52  ! print*, 'Generating roughly 2500000 days of MAR reduced evolution and saving it to ./tests/test_MAR.dat ...'
53  ! OPEN(30,file='./tests/test_MAR.dat')
54  ! x=0.D0
55  ! t=0.D0
56  ! DO WHILE (t<5.D4)
57  ! CALL MAR_step_red(x)
58  ! t=t+dt
59  ! ENDDO
60  ! t=0.D0
61  ! DO WHILE (t<2.5D7)
62  ! CALL MAR_step_red(x)
63  ! t=t+dt
64  ! IF (mod(t,tw)<dt) WRITE(30,*) t,x(1:n_unres,1)
65  ! ENDDO
66  ! CLOSE(30)
67  print*, 'Test finished'
68 
69 END PROGRAM test_mar
70 
subroutine, public mar_step(x)
Routine to generate one step of the MAR.
Definition: MAR.f90:93
integer ndim
Number of variables (dimension of the model)
Definition: params.f90:85
real(kind=8), dimension(:,:), allocatable, public q
Square root of the noise covariance matrix.
Definition: MAR.f90:29
Utility module.
Definition: util.f90:12
real(kind=8), dimension(:,:,:), allocatable, public w
W_i matrix.
Definition: MAR.f90:32
program test_mar
Small program to test the Multivariate AutoRegressive model.
Definition: test_MAR.f90:12
real(kind=8) tw
Write all variables every tw time units.
Definition: params.f90:78
Statistics accumulators.
Definition: stat.f90:14
The resolved-unresolved components decomposition of the tensor.
Definition: dec_tensor.f90:16
subroutine, public printmat(A)
Definition: util.f90:200
The equation tensor for the coupled ocean-atmosphere model with temperature which allows for an exten...
real(kind=8), dimension(:,:,:), allocatable, public wred
Reduce W_i matrix.
Definition: MAR.f90:33
integer, public n_unres
Number of unresolved variables.
Definition: sf_def.f90:26
real(kind=8), dimension(:,:), allocatable, public qred
Reduce version of Q.
Definition: MAR.f90:30
The model parameters module.
Definition: params.f90:18
Multidimensional Autoregressive module to generate the correlation for the WL parameterization.
Definition: MAR.f90:19
real(kind=8) dt
Integration time step.
Definition: params.f90:77
Module to select the resolved-unresolved components.
Definition: sf_def.f90:12
subroutine, public init_dec_tensor
Subroutine that initialize and compute the decomposed tensors.
Definition: dec_tensor.f90:195
subroutine, public init_aotensor
Subroutine to initialise the aotensor tensor.
integer, public ms
order of the MAR
Definition: MAR.f90:36
subroutine, public init_mar
Subroutine to initialise the MAR.
Definition: MAR.f90:45