A Modular Arbitrary-Order Ocean-Atmosphere Model -- Stochastic implementation
maooam_WL.f90
Go to the documentation of this file.
1 ! maooam_WL.f90
2 !
3 !> Fortran 90 implementation of the modular arbitrary-order ocean-atmosphere
4 !> model MAOOAM - WL parameterization.
5 !
6 !> @copyright
7 !> 2018 Jonathan Demaeyer.
8 !> See LICENSE.txt for license information.
9 !
10 !---------------------------------------------------------------------------!
11 
12 PROGRAM maooam_wl
13  USE params, only: ndim, dt, tw, t_trans, t_run, writeout
15  USE ic_def, only: load_ic, ic
17  USE aotensor_def, only: init_aotensor
18  USE wl_tensor, only: init_wl_tensor
19  USE memory, only: compute_m3
20  USE stat
21  IMPLICIT NONE
22 
23  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: X !< State variable in the model
24  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: Xnew !< Updated state variable
25  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: tend !< Store the tendencies
26  REAL(KIND=8) :: t=0.d0 !< Time variable
27  REAL(KIND=8) :: t_up !< Update time for the progress bar
28 
29  print*, 'Model MAOOAM v1.3 WL'
30  print*, 'Loading information...'
31 
32  CALL init_aotensor ! Initialize the aotensor
33  CALL init_wl_tensor ! Load the tensors
34 
35  CALL load_ic ! Load the initial condition
36 
37  CALL init_integrator ! Initialize the integrator
38 
39  t_up=dt/t_trans*100.d0
40 
41  IF (writeout) OPEN(10,file='evol_WL.dat')
42  IF (writeout) OPEN(12,file='ptend_WL.dat')
43  IF (writeout) OPEN(13,file='mem_WL.dat')
44 
45  ALLOCATE(x(0:ndim),xnew(0:ndim),tend(0:ndim))
46 
47  x=ic
48 
49  print*, 'Starting an initial transient time full model evolution...'
50 
51  DO WHILE (t<t_trans)
52  CALL full_step(x,t,dt,dtn,xnew)
53  x=xnew
54  IF (mod(t/t_trans*100.d0,0.1)<t_up) WRITE(*,'(" Progress ",F6.1," %",A,$)') t/t_trans*100.d0,char(13)
55  ENDDO
56 
57  print*, 'Starting a transient time to initialize memory ...'
58 
59  t=0.d0
60  t_up=dt/t_trans_mem*100.d0
61 
62  DO WHILE (t<t_trans_mem)
63  CALL full_step(x,t,dt,dtn,xnew)
64  x=xnew
65  IF (mod(t/t_trans_mem*100.d0,0.1)<t_up) WRITE(*,'(" Progress ",F6.1," %",A,$)') t/t_trans_mem*100.d0,char(13)
66  IF (mod(t,muti)<dt) THEN
67  CALL compute_m3(x,dts,dtsn,.true.,.true.,.true.,muti,xnew)
68  IF ((mod(t,max(tw,muti))<dt).and.(writeout)) WRITE(13,*) t,xnew(1:ndim)
69  ENDIF
70  ENDDO
71 
72  CLOSE(13)
73 
74  print*, 'Starting a transient time WL model evolution...'
75 
76  t=0.d0
77  t_up=dt/t_trans_stoch*100.d0
78 
79  DO WHILE (t<t_trans_stoch)
80  CALL step(x,t,dt,dtn,xnew,tend)
81  x=xnew
82  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)
83  ENDDO
84 
85  print*, 'Starting the WL time evolution...'
86 
87  CALL init_stat
88 
89  t=0.d0
90  t_up=dt/t_run*100.d0
91 
92  DO WHILE (t<t_run)
93  CALL step(x,t,dt,dtn,xnew,tend)
94  x=xnew
95  IF (mod(t,tw)<dt) THEN
96  IF (writeout) WRITE(10,*) t,x(1:ndim)
97  IF (writeout) WRITE(12,*) t,tend(1:ndim)
98  CALL acc(x)
99  END IF
100  IF (mod(t/t_run*100.d0,0.1)<t_up) WRITE(*,'(" Progress ",F6.1," %",A,$)') t/t_run*100.d0,char(13)
101  END DO
102 
103  print*, 'Evolution finished.'
104 
105  IF (writeout) CLOSE(10)
106  IF (writeout) CLOSE(12)
107 
108  IF (writeout) OPEN(10,file='mean_field_WL.dat')
109 
110  x=mean()
111  IF (writeout) WRITE(10,*) x(1:ndim)
112  IF (writeout) CLOSE(10)
113 
114 END PROGRAM maooam_wl
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
subroutine, public step(y, t, dt, dtn, res, tend)
Routine to perform an integration step (Heun algorithm) of the WL system. The incremented time is ret...
real(kind=8) muti
Memory update time interval.
real(kind=8) tw
Write all variables every tw time units.
Definition: params.f90:78
Statistics accumulators.
Definition: stat.f90:14
program maooam_wl
Fortran 90 implementation of the modular arbitrary-order ocean-atmosphere model MAOOAM - WL parameter...
Definition: maooam_WL.f90:12
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 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.
real(kind=8), dimension(:), allocatable, public ic
Initial condition vector.
Definition: ic_def.f90:23
subroutine, public init_integrator
Subroutine that initialize the MARs, the memory unit and the integration buffers. ...
The WL tensors used to integrate the model.
Definition: WL_tensor.f90:18
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.
real(kind=8) dtsn
Square root of the intrisic resolved dynamics time step.
subroutine, public init_stat
Initialise the accumulators.
Definition: stat.f90:35
Module with the WL rk2 integration routines.
The model parameters module.
Definition: params.f90:18
subroutine, public compute_m3(y, dt, dtn, savey, save_ev, evolve, inter, h_int)
Compute the integrand of at each time in the past and integrate to get the memory term...
Definition: memory.f90:86
Module that compute the memory term of the WL parameterization.
Definition: memory.f90:16
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
subroutine, public init_wl_tensor
Subroutine to initialise the WL tensor.
Definition: WL_tensor.f90:94
real(kind=8) t_trans
Transient time period.
Definition: params.f90:75
subroutine, public init_aotensor
Subroutine to initialise the aotensor tensor.
real(kind=8) t_trans_mem
Transient time period to initialize the memory term.
real(kind=8) dts
Intrisic resolved dynamics time step.