-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathmod_init.F90
More file actions
214 lines (181 loc) · 8.17 KB
/
Copy pathmod_init.F90
File metadata and controls
214 lines (181 loc) · 8.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
MODULE mod_init
!------------------------------------------------------------------------------
!!
!! MODULE: mod_init
!!
!! Defines and allocates variables and matrices necessary.
!!
!! Subroutines included:
!! - init_namelist
!! - init_alloc
!!
!! - reverse (P)
!!
!!------------------------------------------------------------------------------
USE mod_vel
USE mod_grid
USE mod_traj
USE mod_param
USE mod_seedvars
USE mod_time
USE mod_write
USE mod_domain
USE mod_tracervars
USE mod_psi
USE mod_activevars
USE mod_divvars
IMPLICIT NONE
PRIVATE :: reverse
CONTAINS
SUBROUTINE init_namelist()
! --------------------------------------------------
!
! Purpose:
! Reads the variables from the namelist
!
! --------------------------------------------------
! Setup namelists
namelist /INIT_GRID_DESCRIPTION/ griddir, zeroindx, trunit, l_onestep, physDataDir, physPrefixForm, &
dateFormat, tGridName, uGridName, vGridName, wGridName,&
fileSuffix, hs_name, ueul_name, veul_name, &
usgs_name, vsgs_name, usub_name, vsub_name, w_name
namelist /INIT_GRID_SIZE/ imt, jmt, km, iperio, jperio, &
topoDataDir, &
hgridFile, dy_name, dyu_name, dx_name, dxv_name, &
zgridFile, dzt_name, dzu_name, dzv_name, dep_name,&
bathyFile, kmt_name
namelist /INIT_GRID_SUBDOMAIN/ l_subdom, imindom, imaxdom, jmindom, jmaxdom
namelist /INIT_GRID_TIME/ ngcm_step, ngcm_unit, iter
namelist /INIT_START_DATE/ startSec, startMin, startHour, &
startDay, startMon, startYear, &
noleap, mon30day
namelist /INIT_RUN_TIME/ loopYears, loopStartYear, loopEndYear, &
log_level, intrun
namelist /INIT_WRITE_TRAJ/ write_frec, write_form, outDataDir, outDataFile, timeformat, l_compress
namelist /INIT_SEEDING/ nff, isec, idir, nqua, partQuant, nsdtraj, &
loneparticle, SeedType, ist1, &
ist2, jst1, jst2, kst1, kst2, tst1, tst2, &
seedDir, seedFile, maskFile, seedTime, timeFile
namelist /INIT_TRACERS/ l_tracers, l_swtraj, tracertrajscale, &
tracername, tracershift, tracerscale, &
tracerunit, tracervarname, &
traceraction,tracermin, tracermax, &
tracerdimension
namelist /INIT_TRACERS_SEEDING/ tracer0min, tracer0max
namelist /INIT_KILLZONES/ timax, l_nosurface, exitType, ienw, iene, jens, jenn, &
tracerchoice, tracere, maxormin
namelist /INIT_POSTPROCESS/ l_psi, l_offline, l_psi_rerun, dirpsi, xyflux, &
l_divergence, divconst
namelist /INIT_ACTIVE/ l_diffusion, ah, av
! Loop index for scanning geographic killing-zone slots
INTEGER :: izone
! Read namelist
OPEN (8,file='namelist.in', &
& status='OLD', delim='APOSTROPHE')
READ (8,nml=INIT_GRID_DESCRIPTION)
READ (8,nml=INIT_GRID_SIZE)
READ (8,nml=INIT_GRID_SUBDOMAIN)
READ (8,nml=INIT_GRID_TIME)
READ (8,nml=INIT_START_DATE)
READ (8,nml=INIT_RUN_TIME)
READ (8,nml=INIT_WRITE_TRAJ)
READ (8,nml=INIT_SEEDING)
READ (8,nml=INIT_TRACERS)
READ (8,nml=INIT_TRACERS_SEEDING)
READ (8,nml=INIT_KILLZONES)
READ (8,nml=INIT_POSTPROCESS)
READ (8,nml=INIT_ACTIVE)
CLOSE(8)
! Default the output-file prefix here, before it is first used.
! read_rerun runs before open_outfiles, so applying the default only
! inside open_outfiles left read_rerun looking for the wrong filename.
IF (TRIM(outDataFile) == '') outDataFile = 'TRACMASS'
! Detect the highest occupied geographic killing-zone slot from the
! namelist, before reverse()/zeroindx mutate the arrays below. Boxes
! live in up to 10 slots [ienw,iene]x[jens,jenn]; kill_zones sets
! nend = slot+1, so the slot INDEX (not the count) sets the largest
! geographic lbas. Undefined slots are all-zero (initialised in
! mod_vars). Subdomain wall zones and the final maxlbas are added in
! init_subdomain, once exitType and all killing zones are finalised.
ngeozones = 0
DO izone = 1, SIZE(ienw)
IF (ienw(izone) /= 0 .OR. iene(izone) /= 0 .OR. &
jens(izone) /= 0 .OR. jenn(izone) /= 0) ngeozones = izone
END DO
! If input data is on a A grid
#ifdef A_grid
jmt = jmt-1
#endif
! Reverse killing zones
CALL reverse()
! Shift in case of netcdf data starting at zero
IF (zeroindx) THEN
ienw = ienw + 1
iene = iene + 1
END IF
END SUBROUTINE init_namelist
SUBROUTINE init_alloc()
! --------------------------------------------------
!
! Purpose:
! Allocates all the arrays in TRACMASS
!
! --------------------------------------------------
! Allocate information about the coordinates and grid
ALLOCATE( dxv(imt,jmt), dyu(imt,jmt))
dxv(:,:) = 0
dyu(:,:) = 0
ALLOCATE( dxdy(imt,jmt))
ALLOCATE( mask(imt,jmt))
mask(:,:) = 1
ALLOCATE ( kmt(imt,jmt))
kmt(:,:) = km
ALLOCATE( dzt(imt,jmt,km,nst+1), dzu(imt,jmt,km,nst), dzv(imt,jmt,km,nst))
dzt(:,:,:,:) = 0.; dzu(:,:,:,:) = 0.; dzv(:,:,:,:) = 0.
ALLOCATE( dzdt(imt,jmt,km,nst))
dzdt(:,:,:,:) = 0.
ALLOCATE( zstot(imt,jmt,-1:1), zstou(imt,jmt), zstov(imt,jmt))
zstot(:,:,:) = 1.; zstou(:,:) = 1.; zstov(:,:) = 1.
! Allocate surface parameter (SSH ocean, surface pressure atmosphere)
ALLOCATE ( hs(imt+1,0:jmt,-1:1))
hs(:,:,:) = 0.
! Allocate velocity fields
ALLOCATE ( uflux(imt,jmt,km,nst), vflux(imt,0:jmt,km,nst) )
uflux(:,:,:,:) = 0.
vflux(:,:,:,:) = 0.
ALLOCATE ( uvel(imt,jmt,km), vvel(imt,0:jmt,km) )
uvel(:,:,:) = 0.
vvel(:,:,:) = 0.
#if defined w_explicit
ALLOCATE ( wflux(imt ,jmt ,0:km, nst) )
wflux(:,:,:,:) = 0.
#else
ALLOCATE ( wflux(0:km, nst))
wflux(:,:) = 0.
#endif
! Allocate Water/salt trajectories
ALLOCATE(tracertraj(imt,0:jmt,km,-1:1))
tracertraj(:,:,:,:) = 1.d0
END SUBROUTINE init_alloc
SUBROUTINE reverse()
! --------------------------------------------------
!
! Purpose:
! Reverse seeding indexes according to the project type
! --------------------------------------------------
INTEGER :: ii
IF (griddir(2) == -1) THEN
DO ii = 1, SIZE(jenn)
IF (isec == 2) THEN
jenn(ii) = jmt - jenn(ii) ! Meridional reverse
jens(ii) = jmt - jens(ii) ! Meridional reverse
ELSE
jenn(ii) = jmt - jenn(ii) + 1 ! Meridional reverse
jens(ii) = jmt - jens(ii) + 1 ! Meridional reverse
END IF
END DO
END IF
END SUBROUTINE
END MODULE mod_init
!!----------------------------------------------------------------------------
!!----------------------------------------------------------------------------