A Modular Arbitrary-Order Ocean-Atmosphere Model -- Stochastic implementation
maooam.f90
Go to the documentation of this file.
1 
2 ! maooam.f90
3 !
4 !> Fortran 90 implementation of the modular arbitrary-order ocean-atmosphere
5 !> model MAOOAM.
6 !
7 !> @copyright
8 !> 2015 Lesley De Cruz & Jonathan Demaeyer.
9 !> See LICENSE.txt for license information.
10 !
11 !---------------------------------------------------------------------------!
12 
13 PROGRAM maooam
14  USE params, only: ndim, dt, tw, t_trans, t_run, writeout
15  USE aotensor_def, only: init_aotensor
16  USE ic_def, only: load_ic, ic
18  USE stat
19  IMPLICIT NONE
20 
21  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: X !< State variable in the model
22  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: Xnew !< Updated state variable
23  REAL(KIND=8) :: t=0.d0 !< Time variable
24  REAL(KIND=8) :: t_up
25 
26  print*, 'Model MAOOAM v1.3'
27  print*, 'Loading information...'
28 
29  CALL init_aotensor ! Compute the tensor
30 
31  CALL load_ic ! Load the initial condition
32 
33  CALL init_integrator ! Initialize the integrator
34 
35  t_up=dt/t_trans*100.d0
36 
37  IF (writeout) OPEN(10,file='evol_field.dat')
38 
39  ALLOCATE(x(0:ndim),xnew(0:ndim))
40 
41  x=ic
42 
43  print*, 'Starting the transient time evolution...'
44 
45  DO WHILE (t<t_trans)
46  CALL step(x,t,dt,xnew)
47  x=xnew
48  IF (mod(t/t_trans*100.d0,0.1)<t_up) WRITE(*,'(" Progress ",F6.1," %",A,$)') t/t_trans*100.d0,char(13)
49  END DO
50 
51  print*, 'Starting the time evolution...'
52 
53  CALL init_stat
54 
55  t=0.d0
56  t_up=dt/t_run*100.d0
57 
58  IF (writeout) WRITE(10,*) t,x(1:ndim)
59 
60  DO WHILE (t<t_run)
61  CALL step(x,t,dt,xnew)
62  x=xnew
63  IF (mod(t,tw)<dt) THEN
64  IF (writeout) WRITE(10,*) t,x(1:ndim)
65  CALL acc(x)
66  END IF
67  IF (mod(t/t_run*100.d0,0.1)<t_up) WRITE(*,'(" Progress ",F6.1," %",A,$)') t/t_run*100.d0,char(13)
68  END DO
69 
70  print*, 'Evolution finished.'
71 
72  IF (writeout) CLOSE(10)
73 
74  IF (writeout) OPEN(10,file='mean_field.dat')
75 
76  x=mean()
77  IF (writeout) WRITE(10,*) x(1:ndim)
78  IF (writeout) CLOSE(10)
79 
80 END PROGRAM maooam
program maooam
Fortran 90 implementation of the modular arbitrary-order ocean-atmosphere model MAOOAM.
Definition: maooam.f90:13
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, res)
Routine to perform an integration step (Heun algorithm). The incremented time is returned.
real(kind=8) tw
Write all variables every tw time units.
Definition: params.f90:78
Statistics accumulators.
Definition: stat.f90:14
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), dimension(:), allocatable, public ic
Initial condition vector.
Definition: ic_def.f90:23
Module with the integration routines.
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
subroutine, public init_integrator
Routine to initialise the integration buffers.
real(kind=8) t_trans
Transient time period.
Definition: params.f90:75
subroutine, public init_aotensor
Subroutine to initialise the aotensor tensor.