-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbdydyn3d.f90
218 lines (218 loc) · 7.28 KB
/
bdydyn3d.f90
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
215
216
217
218
MODULE bdydyn3d
USE timing
USE oce
USE dom_oce
USE bdy_oce
USE bdylib
USE lbclnk
USE in_out_manager
USE phycst
IMPLICIT NONE
PRIVATE
PUBLIC :: bdy_dyn3d
PUBLIC :: bdy_dyn3d_dmp
CONTAINS
SUBROUTINE bdy_dyn3d(kt)
INTEGER, INTENT(IN) :: kt
INTEGER :: ib_bdy
DO ib_bdy = 1, nb_bdy
SELECT CASE (cn_dyn3d(ib_bdy))
CASE ('none')
CYCLE
CASE ('frs')
CALL bdy_dyn3d_frs(idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy)
CASE ('specified')
CALL bdy_dyn3d_spe(idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy)
CASE ('zero')
CALL bdy_dyn3d_zro(idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy)
CASE ('orlanski')
CALL bdy_dyn3d_orlanski(idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, ll_npo = .FALSE.)
CASE ('orlanski_npo')
CALL bdy_dyn3d_orlanski(idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, ll_npo = .TRUE.)
CASE ('zerograd')
CALL bdy_dyn3d_zgrad(idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy)
CASE ('neumann')
CALL bdy_dyn3d_nmn(idx_bdy(ib_bdy), ib_bdy)
CASE DEFAULT
CALL ctl_stop('bdy_dyn3d : unrecognised option for open boundaries for baroclinic velocities')
END SELECT
END DO
END SUBROUTINE bdy_dyn3d
SUBROUTINE bdy_dyn3d_spe(idx, dta, kt, ib_bdy)
INTEGER, INTENT(IN) :: kt
TYPE(OBC_INDEX), INTENT(IN) :: idx
TYPE(OBC_DATA), INTENT(IN) :: dta
INTEGER, INTENT(IN) :: ib_bdy
INTEGER :: jb, jk
INTEGER :: ii, ij, igrd
REAL(KIND = wp) :: zwgt
igrd = 2
DO jb = 1, idx % nblenrim(igrd)
DO jk = 1, jpkm1
ii = idx % nbi(jb, igrd)
ij = idx % nbj(jb, igrd)
ua(ii, ij, jk) = dta % u3d(jb, jk) * umask(ii, ij, jk)
END DO
END DO
igrd = 3
DO jb = 1, idx % nblenrim(igrd)
DO jk = 1, jpkm1
ii = idx % nbi(jb, igrd)
ij = idx % nbj(jb, igrd)
va(ii, ij, jk) = dta % v3d(jb, jk) * vmask(ii, ij, jk)
END DO
END DO
CALL lbc_bdy_lnk(ua, 'U', - 1., ib_bdy)
CALL lbc_bdy_lnk(va, 'V', - 1., ib_bdy)
IF (kt == nit000) CLOSE(UNIT = 102)
END SUBROUTINE bdy_dyn3d_spe
SUBROUTINE bdy_dyn3d_zgrad(idx, dta, kt, ib_bdy)
INTEGER :: kt
TYPE(OBC_INDEX), INTENT(IN) :: idx
TYPE(OBC_DATA), INTENT(IN) :: dta
INTEGER, INTENT(IN) :: ib_bdy
INTEGER :: jb, jk
INTEGER :: ii, ij, igrd
REAL(KIND = wp) :: zwgt
INTEGER :: fu, fv
igrd = 2
DO jb = 1, idx % nblenrim(igrd)
DO jk = 1, jpkm1
ii = idx % nbi(jb, igrd)
ij = idx % nbj(jb, igrd)
fu = ABS(ABS(NINT(idx % flagu(jb, igrd))) - 1)
ua(ii, ij, jk) = ua(ii, ij, jk) * REAL(1 - fu) + (ua(ii, ij + fu, jk) * umask(ii, ij + fu, jk) + ua(ii, ij - fu, jk) * umask(ii, ij - fu, jk)) * umask(ii, ij, jk) * REAL(fu)
END DO
END DO
igrd = 3
DO jb = 1, idx % nblenrim(igrd)
DO jk = 1, jpkm1
ii = idx % nbi(jb, igrd)
ij = idx % nbj(jb, igrd)
fv = ABS(ABS(NINT(idx % flagv(jb, igrd))) - 1)
va(ii, ij, jk) = va(ii, ij, jk) * REAL(1 - fv) + (va(ii + fv, ij, jk) * vmask(ii + fv, ij, jk) + va(ii - fv, ij, jk) * vmask(ii - fv, ij, jk)) * vmask(ii, ij, jk) * REAL(fv)
END DO
END DO
CALL lbc_bdy_lnk(ua, 'U', - 1., ib_bdy)
CALL lbc_bdy_lnk(va, 'V', - 1., ib_bdy)
IF (kt == nit000) CLOSE(UNIT = 102)
END SUBROUTINE bdy_dyn3d_zgrad
SUBROUTINE bdy_dyn3d_zro(idx, dta, kt, ib_bdy)
INTEGER, INTENT(IN) :: kt
TYPE(OBC_INDEX), INTENT(IN) :: idx
TYPE(OBC_DATA), INTENT(IN) :: dta
INTEGER, INTENT(IN) :: ib_bdy
INTEGER :: ib, ik
INTEGER :: ii, ij, igrd
REAL(KIND = wp) :: zwgt
igrd = 2
DO ib = 1, idx % nblenrim(igrd)
ii = idx % nbi(ib, igrd)
ij = idx % nbj(ib, igrd)
!$ACC KERNELS
DO ik = 1, jpkm1
ua(ii, ij, ik) = 0._wp
END DO
!$ACC END KERNELS
END DO
igrd = 3
DO ib = 1, idx % nblenrim(igrd)
ii = idx % nbi(ib, igrd)
ij = idx % nbj(ib, igrd)
!$ACC KERNELS
DO ik = 1, jpkm1
va(ii, ij, ik) = 0._wp
END DO
!$ACC END KERNELS
END DO
CALL lbc_bdy_lnk(ua, 'U', - 1., ib_bdy)
CALL lbc_bdy_lnk(va, 'V', - 1., ib_bdy)
IF (kt == nit000) CLOSE(UNIT = 102)
END SUBROUTINE bdy_dyn3d_zro
SUBROUTINE bdy_dyn3d_frs(idx, dta, kt, ib_bdy)
INTEGER, INTENT(IN) :: kt
TYPE(OBC_INDEX), INTENT(IN) :: idx
TYPE(OBC_DATA), INTENT(IN) :: dta
INTEGER, INTENT(IN) :: ib_bdy
INTEGER :: jb, jk
INTEGER :: ii, ij, igrd
REAL(KIND = wp) :: zwgt
igrd = 2
DO jb = 1, idx % nblen(igrd)
DO jk = 1, jpkm1
ii = idx % nbi(jb, igrd)
ij = idx % nbj(jb, igrd)
zwgt = idx % nbw(jb, igrd)
ua(ii, ij, jk) = (ua(ii, ij, jk) + zwgt * (dta % u3d(jb, jk) - ua(ii, ij, jk))) * umask(ii, ij, jk)
END DO
END DO
igrd = 3
DO jb = 1, idx % nblen(igrd)
DO jk = 1, jpkm1
ii = idx % nbi(jb, igrd)
ij = idx % nbj(jb, igrd)
zwgt = idx % nbw(jb, igrd)
va(ii, ij, jk) = (va(ii, ij, jk) + zwgt * (dta % v3d(jb, jk) - va(ii, ij, jk))) * vmask(ii, ij, jk)
END DO
END DO
CALL lbc_bdy_lnk(ua, 'U', - 1., ib_bdy)
CALL lbc_bdy_lnk(va, 'V', - 1., ib_bdy)
IF (kt == nit000) CLOSE(UNIT = 102)
END SUBROUTINE bdy_dyn3d_frs
SUBROUTINE bdy_dyn3d_orlanski(idx, dta, ib_bdy, ll_npo)
TYPE(OBC_INDEX), INTENT(IN) :: idx
TYPE(OBC_DATA), INTENT(IN) :: dta
INTEGER, INTENT(IN) :: ib_bdy
LOGICAL, INTENT(IN) :: ll_npo
INTEGER :: jb, igrd
igrd = 2
CALL bdy_orlanski_3d(idx, igrd, ub, ua, dta % u3d, ll_npo)
igrd = 3
CALL bdy_orlanski_3d(idx, igrd, vb, va, dta % v3d, ll_npo)
CALL lbc_bdy_lnk(ua, 'U', - 1., ib_bdy)
CALL lbc_bdy_lnk(va, 'V', - 1., ib_bdy)
END SUBROUTINE bdy_dyn3d_orlanski
SUBROUTINE bdy_dyn3d_dmp(kt)
INTEGER, INTENT(IN) :: kt
INTEGER :: jb, jk
INTEGER :: ib_bdy
INTEGER :: ii, ij, igrd
REAL(KIND = wp) :: zwgt
IF (ln_timing) CALL timing_start('bdy_dyn3d_dmp')
DO ib_bdy = 1, nb_bdy
IF (ln_dyn3d_dmp(ib_bdy) .AND. cn_dyn3d(ib_bdy) /= 'none') THEN
igrd = 2
DO jb = 1, idx_bdy(ib_bdy) % nblen(igrd)
ii = idx_bdy(ib_bdy) % nbi(jb, igrd)
ij = idx_bdy(ib_bdy) % nbj(jb, igrd)
zwgt = idx_bdy(ib_bdy) % nbd(jb, igrd)
DO jk = 1, jpkm1
ua(ii, ij, jk) = (ua(ii, ij, jk) + zwgt * (dta_bdy(ib_bdy) % u3d(jb, jk) - ub(ii, ij, jk) + ub_b(ii, ij))) * umask(ii, ij, jk)
END DO
END DO
igrd = 3
DO jb = 1, idx_bdy(ib_bdy) % nblen(igrd)
ii = idx_bdy(ib_bdy) % nbi(jb, igrd)
ij = idx_bdy(ib_bdy) % nbj(jb, igrd)
zwgt = idx_bdy(ib_bdy) % nbd(jb, igrd)
DO jk = 1, jpkm1
va(ii, ij, jk) = (va(ii, ij, jk) + zwgt * (dta_bdy(ib_bdy) % v3d(jb, jk) - vb(ii, ij, jk) + vb_b(ii, ij))) * vmask(ii, ij, jk)
END DO
END DO
END IF
END DO
CALL lbc_lnk_multi(ua, 'U', - 1., va, 'V', - 1.)
IF (ln_timing) CALL timing_stop('bdy_dyn3d_dmp')
END SUBROUTINE bdy_dyn3d_dmp
SUBROUTINE bdy_dyn3d_nmn(idx, ib_bdy)
TYPE(OBC_INDEX), INTENT(IN) :: idx
INTEGER, INTENT(IN) :: ib_bdy
INTEGER :: jb, igrd
igrd = 2
CALL bdy_nmn(idx, igrd, ua)
igrd = 3
CALL bdy_nmn(idx, igrd, va)
CALL lbc_bdy_lnk(ua, 'U', - 1., ib_bdy)
CALL lbc_bdy_lnk(va, 'V', - 1., ib_bdy)
END SUBROUTINE bdy_dyn3d_nmn
END MODULE bdydyn3d