A Modular Arbitrary-Order Ocean-Atmosphere Model -- Stochastic implementation
maooam_MTV.f90
Go to the documentation of this file.
1 ! maooam_mtv.f90
2 !
3 !> Fortran 90 implementation of the modular arbitrary-order ocean-atmosphere
4 !> model MAOOAM - MTV parameterization.
5 !
6 !> @copyright
7 !> 2018 Jonathan Demaeyer.
8 !> See LICENSE.txt for license information.
9 !
10 !---------------------------------------------------------------------------!
11 
12 PROGRAM maooam_mtv
13  USE params, only: ndim, dt, tw, t_trans, t_run, writeout
14  USE stoch_params, only: dtn, t_trans_stoch
15  USE ic_def, only: load_ic, ic
17  USE aotensor_def, only: init_aotensor
19  USE stat
20  IMPLICIT NONE
21 
22  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: X !< State variable in the model
23  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: Xnew !< Updated state variable
24  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: tend !< Store the tendencies
25  REAL(KIND=8) :: t=0.d0 !< Time variable
26  REAL(KIND=8) :: t_up !< Update time for the progress bar
27 
28  print*, 'Model MAOOAM v1.3 MTV'
29  print*, 'Loading information...'
30 
31  CALL init_aotensor ! Initialize the aotensor
32  CALL init_mtv_int_tensor ! Load the tensors
33 
34  CALL load_ic ! Load the initial condition
35 
36  CALL init_integrator ! Initialize the integrator
37 
38  t_up=dt/t_trans*100.d0
39 
40  IF (writeout) OPEN(10,file='evol_MTV.dat')
41  IF (writeout) OPEN(12,file='ptend_MTV.dat')
42 
43  ALLOCATE(x(0:ndim),xnew(0:ndim),tend(0:ndim))
44 
45  x=ic
46 
47  print*, 'Starting an initial transient time full model evolution...'
48 
49  DO WHILE (t<t_trans)
50  CALL full_step(x,t,dt,dtn,xnew)
51  x=xnew
52  IF (mod(t/t_trans*100.d0,0.1)<t_up) WRITE(*,'(" Progress ",F6.1," %",A,$)') t/t_trans*100.d0,char(13)
53  ENDDO
54 
55  print*, 'Starting a transient time MTV model evolution...'
56 
57  t=0.d0
58  t_up=dt/t_trans_stoch*100.d0
59 
60  DO WHILE (t<t_trans_stoch)
61  CALL step(x,t,dt,dtn,xnew,tend)
62  x=xnew
63  IF (mod(t/t_trans_stoch*100.d0,0.1)<t_up) WRITE(*,'(" Progress ",F6.1," %",A,$)') t/t_trans_stoch*100.d0,char(13)
64  ENDDO
65 
66 
67  print*, 'Starting the MTV time evolution...'
68 
69  CALL init_stat
70 
71  t=0.d0
72  t_up=dt/t_run*100.d0
73 
74  DO WHILE (t<t_run)
75  CALL step(x,t,dt,dtn,xnew,tend)
76  x=xnew
77  IF (mod(t,tw)<dt) THEN
78  IF (writeout) WRITE(10,*) t,x(1:ndim)
79  IF (writeout) WRITE(12,*) t,tend(1:ndim)
80  CALL acc(x)
81  END IF
82  IF (mod(t/t_run*100.d0,0.1)<t_up) WRITE(*,'(" Progress ",F6.1," %",A,$)') t/t_run*100.d0,char(13)
83  END DO
84 
85  print*, 'Evolution finished.'
86 
87  IF (writeout) CLOSE(10)
88  IF (writeout) CLOSE(12)
89 
90  IF (writeout) OPEN(10,file='mean_field_MTV.dat')
91 
92  x=mean()
93  IF (writeout) WRITE(10,*) x(1:ndim)
94  IF (writeout) CLOSE(10)
95 
96 END PROGRAM maooam_mtv
The stochastic models parameters module.
Module to load the initial condition.
Definition: ic_def.f90:12
integer ndim
Number of variables (dimension of the model)
Definition: params.f90:85
The MTV tensors used to integrate the MTV model.
real(kind=8) tw
Write all variables every tw time units.
Definition: params.f90:78
Statistics accumulators.
Definition: stat.f90:14
subroutine, public init_integrator
Subroutine to initialize the MTV rk2 integrator.
subroutine, public step(y, t, dt, dtn, res, tend)
Routine to perform an integration step (Heun algorithm) of the MTV system. The incremented time is re...
logical writeout
Write to file boolean.
Definition: params.f90:79
real(kind=8) t_run
Effective intergration time (length of the generated trajectory)
Definition: params.f90:76
subroutine, public full_step(y, t, dt, dtn, res)
Routine to perform an integration step (Heun algorithm) of the full stochastic system. The incremented time is returned.
subroutine, public acc(x)
Accumulate one state.
Definition: stat.f90:48
The equation tensor for the coupled ocean-atmosphere model with temperature which allows for an exten...
real(kind=8) t_trans_stoch
Transient time period of the stochastic model evolution.
real(kind=8) dtn
Square root of the timestep.
Module with the MTV rk2 integration routines.
real(kind=8), dimension(:), allocatable, public ic
Initial condition vector.
Definition: ic_def.f90:23
program maooam_mtv
Fortran 90 implementation of the modular arbitrary-order ocean-atmosphere model MAOOAM - MTV paramete...
Definition: maooam_MTV.f90:12
subroutine, public init_mtv_int_tensor
Subroutine to initialise the MTV tensor.
subroutine, public init_stat
Initialise the accumulators.
Definition: stat.f90:35
The model parameters module.
Definition: params.f90:18
real(kind=8) function, dimension(0:ndim), public mean()
Function returning the mean.
Definition: stat.f90:60
real(kind=8) dt
Integration time step.
Definition: params.f90:77
subroutine, public load_ic
Subroutine to load the initial condition if IC.nml exists. If it does not, then write IC...
Definition: ic_def.f90:32
real(kind=8) t_trans
Transient time period.
Definition: params.f90:75
subroutine, public init_aotensor
Subroutine to initialise the aotensor tensor.