Module to load the initial condition.
More...
|
subroutine, public | load_ic |
| Subroutine to load the initial condition if IC.nml exists. If it does not, then write IC.nml with 0 as initial condition. More...
|
|
|
logical | exists |
| Boolean to test for file existence. More...
|
|
real(kind=8), dimension(:), allocatable, public | ic |
| Initial condition vector. More...
|
|
Module to load the initial condition.
- Copyright
- 2016 Lesley De Cruz, Jonathan Demaeyer & Sebastian Schubert See LICENSE.txt for license information.
subroutine, public ic_def::load_ic |
( |
| ) |
|
Subroutine to load the initial condition if IC.nml exists. If it does not, then write IC.nml with 0 as initial condition.
Definition at line 32 of file ic_def.f90.
32 INTEGER :: i,allocstat,j
33 CHARACTER(len=20) :: fm
34 REAL(KIND=8) :: size_of_random_noise
35 INTEGER,
DIMENSION(:),
ALLOCATABLE :: seed
36 CHARACTER(LEN=4) :: init_type
38 namelist /rand/ init_type,size_of_random_noise,seed
43 CALL random_seed(size=j)
45 IF (
ndim == 0) stop
"*** Number of dimensions is 0! ***" 46 ALLOCATE(ic(0:
ndim),seed(j),
stat=allocstat)
47 IF (allocstat /= 0) stop
"*** Not enough memory ! ***" 49 INQUIRE(file=
'./IC.nml',exist=exists)
52 OPEN(8, file=
"IC.nml", status=
'OLD', recl=80, delim=
'APOSTROPHE')
56 SELECT CASE (init_type)
58 CALL random_seed(put=seed)
59 CALL random_number(ic)
61 ic=ic*size_of_random_noise*10.d0
63 WRITE(6,*)
"*** IC.nml namelist written. Starting with 'seeded' random initial condition !***" 65 CALL init_random_seed()
66 CALL random_seed(get=seed)
67 CALL random_number(ic)
69 ic=ic*size_of_random_noise*10.d0
71 WRITE(6,*)
"*** IC.nml namelist written. Starting with random initial condition !***" 73 CALL init_random_seed()
74 CALL random_seed(get=seed)
77 WRITE(6,*)
"*** IC.nml namelist written. Starting with initial condition in IC.nml !***" 79 CALL init_random_seed()
80 CALL random_seed(get=seed)
83 WRITE(6,*)
"*** IC.nml namelist written. Starting with initial condition in IC.nml !***" 86 CALL init_random_seed()
87 CALL random_seed(get=seed)
91 size_of_random_noise=0.d0
92 WRITE(6,*)
"*** IC.nml namelist written. Starting with 0 as initial condition !***" 94 OPEN(8, file=
"IC.nml", status=
'REPLACE')
95 WRITE(8,
'(a)')
"!------------------------------------------------------------------------------!" 96 WRITE(8,
'(a)')
"! Namelist file : !" 97 WRITE(8,
'(a)')
"! Initial condition. !" 98 WRITE(8,
'(a)')
"!------------------------------------------------------------------------------!" 100 WRITE(8,
'(a)')
"&ICLIST" 101 WRITE(8,*)
" ! psi variables" 103 WRITE(8,*)
" IC("//trim(str(i))//
") = ",ic(i),
" ! typ= "&
104 &//awavenum(i)%typ//
", Nx= "//trim(rstr(awavenum(i)&
105 &%Nx,fm))//
", Ny= "//trim(rstr(awavenum(i)%Ny,fm))
107 WRITE(8,*)
" ! theta variables" 109 WRITE(8,*)
" IC("//trim(str(i+natm))//
") = ",ic(i+natm),
" ! typ= "&
110 &//awavenum(i)%typ//
", Nx= "//trim(rstr(awavenum(i)&
111 &%Nx,fm))//
", Ny= "//trim(rstr(awavenum(i)%Ny,fm))
114 WRITE(8,*)
" ! A variables" 116 WRITE(8,*)
" IC("//trim(str(i+2*natm))//
") = ",ic(i+2*natm),
" ! Nx& 117 &= "//trim(rstr(owavenum(i)%Nx,fm))//
", Ny= "&
118 &//trim(rstr(owavenum(i)%Ny,fm))
120 WRITE(8,*)
" ! T variables" 122 WRITE(8,*)
" IC("//trim(str(i+noc+2*natm))//
") = ",ic(i+2*natm+noc),
" & 123 &! Nx= "//trim(rstr(owavenum(i)%Nx,fm))//
", Ny= "&
124 &//trim(rstr(owavenum(i)%Ny,fm))
127 WRITE(8,
'(a)')
"&END" 129 WRITE(8,
'(a)')
"!------------------------------------------------------------------------------!" 130 WRITE(8,
'(a)')
"! Initialisation type. !" 131 WRITE(8,
'(a)')
"!------------------------------------------------------------------------------!" 132 WRITE(8,
'(a)')
"! type = 'read': use IC above (will generate a new seed);" 133 WRITE(8,
'(a)')
"! 'rand': random state (will generate a new seed);" 134 WRITE(8,
'(a)')
"! 'zero': zero IC (will generate a new seed);" 135 WRITE(8,
'(a)')
"! 'seed': use the seed below (generate the same IC)" 137 WRITE(8,
'(a)')
"&RAND" 138 WRITE(8,
'(a)')
" init_type= '"//init_type//
"'" 139 WRITE(8,
'(a,d15.7)')
" size_of_random_noise = ",size_of_random_noise
141 WRITE(8,*)
" seed("//trim(str(i))//
") = ",seed(i)
143 WRITE(8,
'(a)')
"&END" integer ndim
Number of variables (dimension of the model)
Boolean to test for file existence.
Definition at line 21 of file ic_def.f90.
real(kind=8), dimension(:), allocatable, public ic_def::ic |
Initial condition vector.
Definition at line 23 of file ic_def.f90.
23 REAL(KIND=8),
DIMENSION(:),
ALLOCATABLE,
PUBLIC :: ic