1 | MODULE traadv_fct |
---|
2 | !!============================================================================== |
---|
3 | !! *** MODULE traadv_fct *** |
---|
4 | !! Ocean tracers: horizontal & vertical advective trend (2nd/4th order Flux Corrected Transport method) |
---|
5 | !!============================================================================== |
---|
6 | !! History : 3.7 ! 2015-09 (L. Debreu, G. Madec) original code (inspired from traadv_tvd.F90) |
---|
7 | !!---------------------------------------------------------------------- |
---|
8 | |
---|
9 | !!---------------------------------------------------------------------- |
---|
10 | !! tra_adv_fct : update the tracer trend with a 3D advective trends using a 2nd or 4th order FCT scheme |
---|
11 | !! with sub-time-stepping in the vertical direction |
---|
12 | !! nonosc : compute monotonic tracer fluxes by a non-oscillatory algorithm |
---|
13 | !! interp_4th_cpt : 4th order compact scheme for the vertical component of the advection |
---|
14 | !!---------------------------------------------------------------------- |
---|
15 | USE oce ! ocean dynamics and active tracers |
---|
16 | USE dom_oce ! ocean space and time domain |
---|
17 | USE trc_oce ! share passive tracers/Ocean variables |
---|
18 | USE trd_oce ! trends: ocean variables |
---|
19 | USE trdtra ! tracers trends |
---|
20 | USE diaptr ! poleward transport diagnostics |
---|
21 | USE diaar5 ! AR5 diagnostics |
---|
22 | USE phycst , ONLY : rho0_rcp |
---|
23 | USE zdf_oce , ONLY : ln_zad_Aimp |
---|
24 | ! |
---|
25 | USE in_out_manager ! I/O manager |
---|
26 | USE iom ! |
---|
27 | USE lib_mpp ! MPP library |
---|
28 | USE lbclnk ! ocean lateral boundary condition (or mpp link) |
---|
29 | USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) |
---|
30 | |
---|
31 | IMPLICIT NONE |
---|
32 | PRIVATE |
---|
33 | |
---|
34 | PUBLIC tra_adv_fct ! called by traadv.F90 |
---|
35 | PUBLIC interp_4th_cpt ! called by traadv_cen.F90 |
---|
36 | |
---|
37 | LOGICAL :: l_trd ! flag to compute trends |
---|
38 | LOGICAL :: l_ptr ! flag to compute poleward transport |
---|
39 | LOGICAL :: l_hst ! flag to compute heat/salt transport |
---|
40 | REAL(wp) :: r1_6 = 1._wp / 6._wp ! =1/6 |
---|
41 | |
---|
42 | ! ! tridiag solver associated indices: |
---|
43 | INTEGER, PARAMETER :: np_NH = 0 ! Neumann homogeneous boundary condition |
---|
44 | INTEGER, PARAMETER :: np_CEN2 = 1 ! 2nd order centered boundary condition |
---|
45 | |
---|
46 | !! * Substitutions |
---|
47 | # include "do_loop_substitute.h90" |
---|
48 | # include "domzgr_substitute.h90" |
---|
49 | !!---------------------------------------------------------------------- |
---|
50 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
51 | !! $Id$ |
---|
52 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
53 | !!---------------------------------------------------------------------- |
---|
54 | CONTAINS |
---|
55 | |
---|
56 | SUBROUTINE tra_adv_fct( kt, kit000, cdtype, p2dt, pU, pV, pW, & |
---|
57 | & Kbb, Kmm, pt, kjpt, Krhs, kn_fct_h, kn_fct_v ) |
---|
58 | !!---------------------------------------------------------------------- |
---|
59 | !! *** ROUTINE tra_adv_fct *** |
---|
60 | !! |
---|
61 | !! ** Purpose : Compute the now trend due to total advection of tracers |
---|
62 | !! and add it to the general trend of tracer equations |
---|
63 | !! |
---|
64 | !! ** Method : - 2nd or 4th FCT scheme on the horizontal direction |
---|
65 | !! (choice through the value of kn_fct) |
---|
66 | !! - on the vertical the 4th order is a compact scheme |
---|
67 | !! - corrected flux (monotonic correction) |
---|
68 | !! |
---|
69 | !! ** Action : - update pt(:,:,:,:,Krhs) with the now advective tracer trends |
---|
70 | !! - send trends to trdtra module for further diagnostics (l_trdtra=T) |
---|
71 | !! - poleward advective heat and salt transport (ln_diaptr=T) |
---|
72 | !!---------------------------------------------------------------------- |
---|
73 | INTEGER , INTENT(in ) :: kt ! ocean time-step index |
---|
74 | INTEGER , INTENT(in ) :: Kbb, Kmm, Krhs ! ocean time level indices |
---|
75 | INTEGER , INTENT(in ) :: kit000 ! first time step index |
---|
76 | CHARACTER(len=3) , INTENT(in ) :: cdtype ! =TRA or TRC (tracer indicator) |
---|
77 | INTEGER , INTENT(in ) :: kjpt ! number of tracers |
---|
78 | INTEGER , INTENT(in ) :: kn_fct_h ! order of the FCT scheme (=2 or 4) |
---|
79 | INTEGER , INTENT(in ) :: kn_fct_v ! order of the FCT scheme (=2 or 4) |
---|
80 | REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step |
---|
81 | ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support) |
---|
82 | ! NOTE: [tiling-comms-merge] These were changed to INTENT(inout) but they are not modified, so it is reverted |
---|
83 | REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pU, pV, pW ! 3 ocean volume flux components |
---|
84 | REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! tracers and RHS of tracer equation |
---|
85 | ! |
---|
86 | INTEGER :: ji, jj, jk, jn ! dummy loop indices |
---|
87 | REAL(wp) :: ztra ! local scalar |
---|
88 | REAL(wp) :: zfp_ui, zfp_vj, zfp_wk, zC2t_u, zC4t_u ! - - |
---|
89 | REAL(wp) :: zfm_ui, zfm_vj, zfm_wk, zC2t_v, zC4t_v ! - - |
---|
90 | REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zwi, zwx, zwy, zwz, ztu, ztv, zltu, zltv, ztw |
---|
91 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ztrdx, ztrdy, ztrdz, zptry |
---|
92 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zwinf, zwdia, zwsup |
---|
93 | LOGICAL :: ll_zAimp ! flag to apply adaptive implicit vertical advection |
---|
94 | !!---------------------------------------------------------------------- |
---|
95 | ! |
---|
96 | IF( ntile == 0 .OR. ntile == 1 ) THEN ! Do only on the first tile |
---|
97 | IF( kt == kit000 ) THEN |
---|
98 | IF(lwp) WRITE(numout,*) |
---|
99 | IF(lwp) WRITE(numout,*) 'tra_adv_fct : FCT advection scheme on ', cdtype |
---|
100 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' |
---|
101 | ENDIF |
---|
102 | ! NOTE: [tiling-comms-merge] Bug fix- move array zeroing out of this IF block |
---|
103 | ! |
---|
104 | l_trd = .FALSE. ! set local switches |
---|
105 | l_hst = .FALSE. |
---|
106 | l_ptr = .FALSE. |
---|
107 | ll_zAimp = .FALSE. |
---|
108 | IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype =='TRC' .AND. l_trdtrc ) ) l_trd = .TRUE. |
---|
109 | IF( cdtype == 'TRA' .AND. ( iom_use( 'sophtadv' ) .OR. iom_use( 'sophtadv' ) ) ) l_ptr = .TRUE. |
---|
110 | IF( cdtype == 'TRA' .AND. ( iom_use("uadv_heattr") .OR. iom_use("vadv_heattr") .OR. & |
---|
111 | & iom_use("uadv_salttr") .OR. iom_use("vadv_salttr") ) ) l_hst = .TRUE. |
---|
112 | ! |
---|
113 | ENDIF |
---|
114 | |
---|
115 | !! -- init to 0 |
---|
116 | zwi(:,:,:) = 0._wp |
---|
117 | zwx(:,:,:) = 0._wp |
---|
118 | zwy(:,:,:) = 0._wp |
---|
119 | zwz(:,:,:) = 0._wp |
---|
120 | ztu(:,:,:) = 0._wp |
---|
121 | ztv(:,:,:) = 0._wp |
---|
122 | zltu(:,:,:) = 0._wp |
---|
123 | zltv(:,:,:) = 0._wp |
---|
124 | ztw(:,:,:) = 0._wp |
---|
125 | ! |
---|
126 | IF( l_trd .OR. l_hst ) THEN |
---|
127 | ALLOCATE( ztrdx(A2D(nn_hls),jpk), ztrdy(A2D(nn_hls),jpk), ztrdz(A2D(nn_hls),jpk) ) |
---|
128 | ztrdx(:,:,:) = 0._wp ; ztrdy(:,:,:) = 0._wp ; ztrdz(:,:,:) = 0._wp |
---|
129 | ENDIF |
---|
130 | ! |
---|
131 | IF( l_ptr ) THEN |
---|
132 | ALLOCATE( zptry(A2D(nn_hls),jpk) ) |
---|
133 | zptry(:,:,:) = 0._wp |
---|
134 | ENDIF |
---|
135 | ! |
---|
136 | ! If adaptive vertical advection, check if it is needed on this PE at this time |
---|
137 | IF( ln_zad_Aimp ) THEN |
---|
138 | IF( MAXVAL( ABS( wi(A2D(nn_hls),:) ) ) > 0._wp ) ll_zAimp = .TRUE. |
---|
139 | END IF |
---|
140 | ! If active adaptive vertical advection, build tridiagonal matrix |
---|
141 | IF( ll_zAimp ) THEN |
---|
142 | ALLOCATE(zwdia(A2D(nn_hls),jpk), zwinf(A2D(nn_hls),jpk), zwsup(A2D(nn_hls),jpk)) |
---|
143 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) |
---|
144 | zwdia(ji,jj,jk) = 1._wp + p2dt * ( MAX( wi(ji,jj,jk) , 0._wp ) - MIN( wi(ji,jj,jk+1) , 0._wp ) ) & |
---|
145 | & / e3t(ji,jj,jk,Krhs) |
---|
146 | zwinf(ji,jj,jk) = p2dt * MIN( wi(ji,jj,jk ) , 0._wp ) / e3t(ji,jj,jk,Krhs) |
---|
147 | zwsup(ji,jj,jk) = -p2dt * MAX( wi(ji,jj,jk+1) , 0._wp ) / e3t(ji,jj,jk,Krhs) |
---|
148 | END_3D |
---|
149 | END IF |
---|
150 | ! |
---|
151 | DO jn = 1, kjpt !== loop over the tracers ==! |
---|
152 | ! |
---|
153 | ! !== upstream advection with initial mass fluxes & intermediate update ==! |
---|
154 | ! !* upstream tracer flux in the i and j direction |
---|
155 | DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) |
---|
156 | ! upstream scheme |
---|
157 | zfp_ui = pU(ji,jj,jk) + ABS( pU(ji,jj,jk) ) |
---|
158 | zfm_ui = pU(ji,jj,jk) - ABS( pU(ji,jj,jk) ) |
---|
159 | zfp_vj = pV(ji,jj,jk) + ABS( pV(ji,jj,jk) ) |
---|
160 | zfm_vj = pV(ji,jj,jk) - ABS( pV(ji,jj,jk) ) |
---|
161 | zwx(ji,jj,jk) = 0.5 * ( zfp_ui * pt(ji,jj,jk,jn,Kbb) + zfm_ui * pt(ji+1,jj ,jk,jn,Kbb) ) |
---|
162 | zwy(ji,jj,jk) = 0.5 * ( zfp_vj * pt(ji,jj,jk,jn,Kbb) + zfm_vj * pt(ji ,jj+1,jk,jn,Kbb) ) |
---|
163 | END_3D |
---|
164 | ! !* upstream tracer flux in the k direction *! |
---|
165 | DO_3D( 1, 1, 1, 1, 2, jpkm1 ) ! Interior value ( multiplied by wmask) |
---|
166 | zfp_wk = pW(ji,jj,jk) + ABS( pW(ji,jj,jk) ) |
---|
167 | zfm_wk = pW(ji,jj,jk) - ABS( pW(ji,jj,jk) ) |
---|
168 | zwz(ji,jj,jk) = 0.5 * ( zfp_wk * pt(ji,jj,jk,jn,Kbb) + zfm_wk * pt(ji,jj,jk-1,jn,Kbb) ) * wmask(ji,jj,jk) |
---|
169 | END_3D |
---|
170 | IF( ln_linssh ) THEN ! top ocean value (only in linear free surface as zwz has been w-masked) |
---|
171 | IF( ln_isfcav ) THEN ! top of the ice-shelf cavities and at the ocean surface |
---|
172 | DO_2D( 1, 1, 1, 1 ) |
---|
173 | zwz(ji,jj, mikt(ji,jj) ) = pW(ji,jj,mikt(ji,jj)) * pt(ji,jj,mikt(ji,jj),jn,Kbb) ! linear free surface |
---|
174 | END_2D |
---|
175 | ELSE ! no cavities: only at the ocean surface |
---|
176 | DO_2D( 1, 1, 1, 1 ) |
---|
177 | zwz(ji,jj,1) = pW(ji,jj,1) * pt(ji,jj,1,jn,Kbb) |
---|
178 | END_2D |
---|
179 | ENDIF |
---|
180 | ENDIF |
---|
181 | ! |
---|
182 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) !* trend and after field with monotonic scheme |
---|
183 | ! ! total intermediate advective trends |
---|
184 | ztra = - ( zwx(ji,jj,jk) - zwx(ji-1,jj ,jk ) & |
---|
185 | & + zwy(ji,jj,jk) - zwy(ji ,jj-1,jk ) & |
---|
186 | & + zwz(ji,jj,jk) - zwz(ji ,jj ,jk+1) ) * r1_e1e2t(ji,jj) |
---|
187 | ! ! update and guess with monotonic sheme |
---|
188 | pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) + ztra & |
---|
189 | & / e3t(ji,jj,jk,Kmm ) * tmask(ji,jj,jk) |
---|
190 | zwi(ji,jj,jk) = ( e3t(ji,jj,jk,Kbb) * pt(ji,jj,jk,jn,Kbb) + p2dt * ztra ) & |
---|
191 | & / e3t(ji,jj,jk,Krhs) * tmask(ji,jj,jk) |
---|
192 | END_3D |
---|
193 | |
---|
194 | IF ( ll_zAimp ) THEN |
---|
195 | CALL tridia_solver( zwdia, zwsup, zwinf, zwi, zwi , 0 ) |
---|
196 | ! |
---|
197 | ztw(:,:,1) = 0._wp ; ztw(:,:,jpk) = 0._wp ; |
---|
198 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Interior value ( multiplied by wmask) |
---|
199 | zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) ) |
---|
200 | zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) ) |
---|
201 | ztw(ji,jj,jk) = 0.5 * e1e2t(ji,jj) * ( zfp_wk * zwi(ji,jj,jk) + zfm_wk * zwi(ji,jj,jk-1) ) * wmask(ji,jj,jk) |
---|
202 | zwz(ji,jj,jk) = zwz(ji,jj,jk) + ztw(ji,jj,jk) ! update vertical fluxes |
---|
203 | END_3D |
---|
204 | DO_3D( 0, 0, 0, 0, 1, jpkm1 ) |
---|
205 | pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) - ( ztw(ji,jj,jk) - ztw(ji ,jj ,jk+1) ) & |
---|
206 | & * r1_e1e2t(ji,jj) / e3t(ji,jj,jk,Kmm) |
---|
207 | END_3D |
---|
208 | ! |
---|
209 | END IF |
---|
210 | ! |
---|
211 | IF( l_trd .OR. l_hst ) THEN ! trend diagnostics (contribution of upstream fluxes) |
---|
212 | ztrdx(:,:,:) = zwx(:,:,:) ; ztrdy(:,:,:) = zwy(:,:,:) ; ztrdz(:,:,:) = zwz(:,:,:) |
---|
213 | END IF |
---|
214 | ! ! "Poleward" heat and salt transports (contribution of upstream fluxes) |
---|
215 | IF( l_ptr ) zptry(:,:,:) = zwy(:,:,:) |
---|
216 | ! |
---|
217 | ! !== anti-diffusive flux : high order minus low order ==! |
---|
218 | ! |
---|
219 | SELECT CASE( kn_fct_h ) !* horizontal anti-diffusive fluxes |
---|
220 | ! |
---|
221 | CASE( 2 ) !- 2nd order centered |
---|
222 | DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) |
---|
223 | zwx(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * ( pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj,jk,jn,Kmm) ) - zwx(ji,jj,jk) |
---|
224 | zwy(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * ( pt(ji,jj,jk,jn,Kmm) + pt(ji,jj+1,jk,jn,Kmm) ) - zwy(ji,jj,jk) |
---|
225 | END_3D |
---|
226 | ! |
---|
227 | CASE( 4 ) !- 4th order centered |
---|
228 | zltu(:,:,jpk) = 0._wp ! Bottom value : flux set to zero |
---|
229 | zltv(:,:,jpk) = 0._wp |
---|
230 | DO jk = 1, jpkm1 ! Laplacian |
---|
231 | DO_2D( 1, 0, 1, 0 ) ! 1st derivative (gradient) |
---|
232 | ztu(ji,jj,jk) = ( pt(ji+1,jj ,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * umask(ji,jj,jk) |
---|
233 | ztv(ji,jj,jk) = ( pt(ji ,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk) |
---|
234 | END_2D |
---|
235 | DO_2D( 0, 0, 0, 0 ) ! 2nd derivative * 1/ 6 |
---|
236 | zltu(ji,jj,jk) = ( ztu(ji,jj,jk) + ztu(ji-1,jj,jk) ) * r1_6 |
---|
237 | zltv(ji,jj,jk) = ( ztv(ji,jj,jk) + ztv(ji,jj-1,jk) ) * r1_6 |
---|
238 | END_2D |
---|
239 | END DO |
---|
240 | #if defined key_mpi3 |
---|
241 | CALL lbc_lnk_nc_multi( 'traadv_fct', zltu, 'T', 1.0_wp , zltv, 'T', 1.0_wp, ncsten=.FALSE. ) ! Lateral boundary cond. (unchanged sgn) |
---|
242 | #else |
---|
243 | CALL lbc_lnk_multi( 'traadv_fct', zltu, 'T', 1.0_wp , zltv, 'T', 1.0_wp ) ! Lateral boundary cond. (unchanged sgn) |
---|
244 | #endif |
---|
245 | ! |
---|
246 | DO_3D( 1, 0, 1, 0, 1, jpkm1 ) ! Horizontal advective fluxes |
---|
247 | zC2t_u = pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj ,jk,jn,Kmm) ! 2 x C2 interpolation of T at u- & v-points |
---|
248 | zC2t_v = pt(ji,jj,jk,jn,Kmm) + pt(ji ,jj+1,jk,jn,Kmm) |
---|
249 | ! ! C4 minus upstream advective fluxes |
---|
250 | zwx(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * ( zC2t_u + zltu(ji,jj,jk) - zltu(ji+1,jj,jk) ) - zwx(ji,jj,jk) |
---|
251 | zwy(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * ( zC2t_v + zltv(ji,jj,jk) - zltv(ji,jj+1,jk) ) - zwy(ji,jj,jk) |
---|
252 | END_3D |
---|
253 | IF (nn_hls.EQ.2) CALL lbc_lnk_multi( 'traadv_fct', zwx, 'U', -1.0_wp, zwy, 'V', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn) |
---|
254 | ! |
---|
255 | CASE( 41 ) !- 4th order centered ==>> !!gm coding attempt need to be tested |
---|
256 | ztu(:,:,jpk) = 0._wp ! Bottom value : flux set to zero |
---|
257 | ztv(:,:,jpk) = 0._wp |
---|
258 | DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) ! 1st derivative (gradient) |
---|
259 | ztu(ji,jj,jk) = ( pt(ji+1,jj ,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * umask(ji,jj,jk) |
---|
260 | ztv(ji,jj,jk) = ( pt(ji ,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk) |
---|
261 | END_3D |
---|
262 | #if defined key_mpi3 |
---|
263 | IF (nn_hls.EQ.1) CALL lbc_lnk_nc_multi( 'traadv_fct', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn) |
---|
264 | #else |
---|
265 | IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_fct', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn) |
---|
266 | #endif |
---|
267 | ! |
---|
268 | DO_3D( 0, 0, 0, 0, 1, jpkm1 ) ! Horizontal advective fluxes |
---|
269 | zC2t_u = pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj ,jk,jn,Kmm) ! 2 x C2 interpolation of T at u- & v-points (x2) |
---|
270 | zC2t_v = pt(ji,jj,jk,jn,Kmm) + pt(ji ,jj+1,jk,jn,Kmm) |
---|
271 | ! ! C4 interpolation of T at u- & v-points (x2) |
---|
272 | zC4t_u = zC2t_u + r1_6 * ( ztu(ji-1,jj ,jk) - ztu(ji+1,jj ,jk) ) |
---|
273 | zC4t_v = zC2t_v + r1_6 * ( ztv(ji ,jj-1,jk) - ztv(ji ,jj+1,jk) ) |
---|
274 | ! ! C4 minus upstream advective fluxes |
---|
275 | zwx(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * zC4t_u - zwx(ji,jj,jk) |
---|
276 | zwy(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * zC4t_v - zwy(ji,jj,jk) |
---|
277 | END_3D |
---|
278 | IF (nn_hls.EQ.2) CALL lbc_lnk_multi( 'traadv_fct', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn) |
---|
279 | ! |
---|
280 | END SELECT |
---|
281 | ! |
---|
282 | SELECT CASE( kn_fct_v ) !* vertical anti-diffusive fluxes (w-masked interior values) |
---|
283 | ! |
---|
284 | CASE( 2 ) !- 2nd order centered |
---|
285 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) |
---|
286 | zwz(ji,jj,jk) = ( pW(ji,jj,jk) * 0.5_wp * ( pt(ji,jj,jk,jn,Kmm) + pt(ji,jj,jk-1,jn,Kmm) ) & |
---|
287 | & - zwz(ji,jj,jk) ) * wmask(ji,jj,jk) |
---|
288 | END_3D |
---|
289 | ! |
---|
290 | CASE( 4 ) !- 4th order COMPACT |
---|
291 | CALL interp_4th_cpt( pt(:,:,:,jn,Kmm) , ztw ) ! zwt = COMPACT interpolation of T at w-point |
---|
292 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) |
---|
293 | zwz(ji,jj,jk) = ( pW(ji,jj,jk) * ztw(ji,jj,jk) - zwz(ji,jj,jk) ) * wmask(ji,jj,jk) |
---|
294 | END_3D |
---|
295 | ! |
---|
296 | END SELECT |
---|
297 | IF( ln_linssh ) THEN ! top ocean value: high order = upstream ==>> zwz=0 |
---|
298 | zwz(:,:,1) = 0._wp ! only ocean surface as interior zwz values have been w-masked |
---|
299 | ENDIF |
---|
300 | ! |
---|
301 | IF (nn_hls.EQ.1) THEN |
---|
302 | CALL lbc_lnk_multi( 'traadv_fct', zwi, 'T', 1.0_wp, zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp, zwz, 'T', 1.0_wp ) |
---|
303 | ELSE |
---|
304 | CALL lbc_lnk( 'traadv_fct', zwi, 'T', 1.0_wp) |
---|
305 | END IF |
---|
306 | ! |
---|
307 | IF ( ll_zAimp ) THEN |
---|
308 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) !* trend and after field with monotonic scheme |
---|
309 | ! ! total intermediate advective trends |
---|
310 | ztra = - ( zwx(ji,jj,jk) - zwx(ji-1,jj ,jk ) & |
---|
311 | & + zwy(ji,jj,jk) - zwy(ji ,jj-1,jk ) & |
---|
312 | & + zwz(ji,jj,jk) - zwz(ji ,jj ,jk+1) ) * r1_e1e2t(ji,jj) |
---|
313 | ztw(ji,jj,jk) = zwi(ji,jj,jk) + p2dt * ztra / e3t(ji,jj,jk,Krhs) * tmask(ji,jj,jk) |
---|
314 | END_3D |
---|
315 | ! |
---|
316 | CALL tridia_solver( zwdia, zwsup, zwinf, ztw, ztw , 0 ) |
---|
317 | ! |
---|
318 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Interior value ( multiplied by wmask) |
---|
319 | zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) ) |
---|
320 | zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) ) |
---|
321 | zwz(ji,jj,jk) = zwz(ji,jj,jk) + 0.5 * e1e2t(ji,jj) * ( zfp_wk * ztw(ji,jj,jk) + zfm_wk * ztw(ji,jj,jk-1) ) * wmask(ji,jj,jk) |
---|
322 | END_3D |
---|
323 | END IF |
---|
324 | ! |
---|
325 | ! !== monotonicity algorithm ==! |
---|
326 | ! |
---|
327 | CALL nonosc( Kmm, pt(:,:,:,jn,Kbb), zwx, zwy, zwz, zwi, p2dt ) |
---|
328 | ! |
---|
329 | ! !== final trend with corrected fluxes ==! |
---|
330 | ! |
---|
331 | DO_3D( 0, 0, 0, 0, 1, jpkm1 ) |
---|
332 | ztra = - ( zwx(ji,jj,jk) - zwx(ji-1,jj ,jk ) & |
---|
333 | & + zwy(ji,jj,jk) - zwy(ji ,jj-1,jk ) & |
---|
334 | & + zwz(ji,jj,jk) - zwz(ji ,jj ,jk+1) ) * r1_e1e2t(ji,jj) |
---|
335 | pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) + ztra / e3t(ji,jj,jk,Kmm) |
---|
336 | zwi(ji,jj,jk) = zwi(ji,jj,jk) + p2dt * ztra / e3t(ji,jj,jk,Krhs) * tmask(ji,jj,jk) |
---|
337 | END_3D |
---|
338 | ! |
---|
339 | IF ( ll_zAimp ) THEN |
---|
340 | ! |
---|
341 | ztw(:,:,1) = 0._wp ; ztw(:,:,jpk) = 0._wp |
---|
342 | DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! Interior value ( multiplied by wmask) |
---|
343 | zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) ) |
---|
344 | zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) ) |
---|
345 | ztw(ji,jj,jk) = - 0.5 * e1e2t(ji,jj) * ( zfp_wk * zwi(ji,jj,jk) + zfm_wk * zwi(ji,jj,jk-1) ) * wmask(ji,jj,jk) |
---|
346 | zwz(ji,jj,jk) = zwz(ji,jj,jk) + ztw(ji,jj,jk) ! Update vertical fluxes for trend diagnostic |
---|
347 | END_3D |
---|
348 | DO_3D( 0, 0, 0, 0, 1, jpkm1 ) |
---|
349 | pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) - ( ztw(ji,jj,jk) - ztw(ji ,jj ,jk+1) ) & |
---|
350 | & * r1_e1e2t(ji,jj) / e3t(ji,jj,jk,Kmm) |
---|
351 | END_3D |
---|
352 | END IF |
---|
353 | ! NOTE: [tiling-comms-merge] I tested this |
---|
354 | ! NOT TESTED - NEED l_trd OR l_hst TRUE |
---|
355 | IF( l_trd .OR. l_hst ) THEN ! trend diagnostics // heat/salt transport |
---|
356 | ztrdx(:,:,:) = ztrdx(:,:,:) + zwx(:,:,:) ! <<< add anti-diffusive fluxes |
---|
357 | ztrdy(:,:,:) = ztrdy(:,:,:) + zwy(:,:,:) ! to upstream fluxes |
---|
358 | ztrdz(:,:,:) = ztrdz(:,:,:) + zwz(:,:,:) ! |
---|
359 | ! |
---|
360 | IF( l_trd ) THEN ! trend diagnostics |
---|
361 | CALL trd_tra( kt, Kmm, Krhs, cdtype, jn, jptra_xad, ztrdx, pU, pt(:,:,:,jn,Kmm) ) |
---|
362 | CALL trd_tra( kt, Kmm, Krhs, cdtype, jn, jptra_yad, ztrdy, pV, pt(:,:,:,jn,Kmm) ) |
---|
363 | CALL trd_tra( kt, Kmm, Krhs, cdtype, jn, jptra_zad, ztrdz, pW, pt(:,:,:,jn,Kmm) ) |
---|
364 | ENDIF |
---|
365 | ! ! heat/salt transport |
---|
366 | IF( l_hst ) CALL dia_ar5_hst( jn, 'adv', ztrdx(:,:,:), ztrdy(:,:,:) ) |
---|
367 | ! |
---|
368 | ENDIF |
---|
369 | ! NOTE: [tiling-comms-merge] I tested this |
---|
370 | ! NOT TESTED - NEED l_ptr TRUE |
---|
371 | IF( l_ptr ) THEN ! "Poleward" transports |
---|
372 | zptry(:,:,:) = zptry(:,:,:) + zwy(:,:,:) ! <<< add anti-diffusive fluxes |
---|
373 | CALL dia_ptr_hst( jn, 'adv', zptry(:,:,:) ) |
---|
374 | ENDIF |
---|
375 | ! |
---|
376 | END DO ! end of tracer loop |
---|
377 | ! |
---|
378 | IF ( ll_zAimp ) THEN |
---|
379 | DEALLOCATE( zwdia, zwinf, zwsup ) |
---|
380 | ENDIF |
---|
381 | IF( l_trd .OR. l_hst ) THEN |
---|
382 | DEALLOCATE( ztrdx, ztrdy, ztrdz ) |
---|
383 | ENDIF |
---|
384 | IF( l_ptr ) THEN |
---|
385 | DEALLOCATE( zptry ) |
---|
386 | ENDIF |
---|
387 | ! |
---|
388 | END SUBROUTINE tra_adv_fct |
---|
389 | |
---|
390 | |
---|
391 | SUBROUTINE nonosc( Kmm, pbef, paa, pbb, pcc, paft, p2dt ) |
---|
392 | !!--------------------------------------------------------------------- |
---|
393 | !! *** ROUTINE nonosc *** |
---|
394 | !! |
---|
395 | !! ** Purpose : compute monotonic tracer fluxes from the upstream |
---|
396 | !! scheme and the before field by a nonoscillatory algorithm |
---|
397 | !! |
---|
398 | !! ** Method : ... ??? |
---|
399 | !! warning : pbef and paft must be masked, but the boundaries |
---|
400 | !! conditions on the fluxes are not necessary zalezak (1979) |
---|
401 | !! drange (1995) multi-dimensional forward-in-time and upstream- |
---|
402 | !! in-space based differencing for fluid |
---|
403 | !!---------------------------------------------------------------------- |
---|
404 | INTEGER , INTENT(in ) :: Kmm ! time level index |
---|
405 | REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step |
---|
406 | REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pbef ! before field |
---|
407 | REAL(wp), DIMENSION(A2D(nn_hls) ,jpk), INTENT(in ) :: paft ! after field |
---|
408 | REAL(wp), DIMENSION(A2D(nn_hls) ,jpk), INTENT(inout) :: paa, pbb, pcc ! monotonic fluxes in the 3 directions |
---|
409 | ! |
---|
410 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
411 | INTEGER :: ikm1 ! local integer |
---|
412 | REAL(dp) :: zpos, zneg, zbt, za, zb, zc, zbig, zrtrn ! local scalars |
---|
413 | REAL(dp) :: zau, zbu, zcu, zav, zbv, zcv, zup, zdo ! - - |
---|
414 | REAL(dp), DIMENSION(A2D(nn_hls),jpk) :: zbetup, zbetdo, zbup, zbdo |
---|
415 | !!---------------------------------------------------------------------- |
---|
416 | ! |
---|
417 | zbig = 1.e+40_dp |
---|
418 | zrtrn = 1.e-15_dp |
---|
419 | zbetup(:,:,:) = 0._dp ; zbetdo(:,:,:) = 0._dp |
---|
420 | |
---|
421 | ! Search local extrema |
---|
422 | ! -------------------- |
---|
423 | ! max/min of pbef & paft with large negative/positive value (-/+zbig) inside land |
---|
424 | DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk ) |
---|
425 | zbup(ji,jj,jk) = MAX( pbef(ji,jj,jk) * tmask(ji,jj,jk) - zbig * ( 1._wp - tmask(ji,jj,jk) ), & |
---|
426 | & paft(ji,jj,jk) * tmask(ji,jj,jk) - zbig * ( 1._wp - tmask(ji,jj,jk) ) ) |
---|
427 | zbdo(ji,jj,jk) = MIN( pbef(ji,jj,jk) * tmask(ji,jj,jk) + zbig * ( 1._wp - tmask(ji,jj,jk) ), & |
---|
428 | & paft(ji,jj,jk) * tmask(ji,jj,jk) + zbig * ( 1._wp - tmask(ji,jj,jk) ) ) |
---|
429 | END_3D |
---|
430 | |
---|
431 | DO jk = 1, jpkm1 |
---|
432 | ikm1 = MAX(jk-1,1) |
---|
433 | DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) |
---|
434 | |
---|
435 | ! search maximum in neighbourhood |
---|
436 | zup = MAX( zbup(ji ,jj ,jk ), & |
---|
437 | & zbup(ji-1,jj ,jk ), zbup(ji+1,jj ,jk ), & |
---|
438 | & zbup(ji ,jj-1,jk ), zbup(ji ,jj+1,jk ), & |
---|
439 | & zbup(ji ,jj ,ikm1), zbup(ji ,jj ,jk+1) ) |
---|
440 | |
---|
441 | ! search minimum in neighbourhood |
---|
442 | zdo = MIN( zbdo(ji ,jj ,jk ), & |
---|
443 | & zbdo(ji-1,jj ,jk ), zbdo(ji+1,jj ,jk ), & |
---|
444 | & zbdo(ji ,jj-1,jk ), zbdo(ji ,jj+1,jk ), & |
---|
445 | & zbdo(ji ,jj ,ikm1), zbdo(ji ,jj ,jk+1) ) |
---|
446 | |
---|
447 | ! positive part of the flux |
---|
448 | zpos = MAX( 0., paa(ji-1,jj ,jk ) ) - MIN( 0., paa(ji ,jj ,jk ) ) & |
---|
449 | & + MAX( 0., pbb(ji ,jj-1,jk ) ) - MIN( 0., pbb(ji ,jj ,jk ) ) & |
---|
450 | & + MAX( 0., pcc(ji ,jj ,jk+1) ) - MIN( 0., pcc(ji ,jj ,jk ) ) |
---|
451 | |
---|
452 | ! negative part of the flux |
---|
453 | zneg = MAX( 0., paa(ji ,jj ,jk ) ) - MIN( 0., paa(ji-1,jj ,jk ) ) & |
---|
454 | & + MAX( 0., pbb(ji ,jj ,jk ) ) - MIN( 0., pbb(ji ,jj-1,jk ) ) & |
---|
455 | & + MAX( 0., pcc(ji ,jj ,jk ) ) - MIN( 0., pcc(ji ,jj ,jk+1) ) |
---|
456 | |
---|
457 | ! up & down beta terms |
---|
458 | zbt = e1e2t(ji,jj) * e3t(ji,jj,jk,Kmm) / p2dt |
---|
459 | zbetup(ji,jj,jk) = ( zup - paft(ji,jj,jk) ) / ( zpos + zrtrn ) * zbt |
---|
460 | zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zdo ) / ( zneg + zrtrn ) * zbt |
---|
461 | END_2D |
---|
462 | END DO |
---|
463 | #if defined key_mpi3 |
---|
464 | IF (nn_hls.EQ.1) CALL lbc_lnk_nc_multi( 'traadv_fct', zbetup, 'T', 1.0_wp , zbetdo, 'T', 1.0_wp ) ! lateral boundary cond. (unchanged sign) |
---|
465 | #else |
---|
466 | IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_fct', zbetup, 'T', 1.0_wp , zbetdo, 'T', 1.0_wp ) ! lateral boundary cond. (unchanged sign) |
---|
467 | #endif |
---|
468 | |
---|
469 | ! 3. monotonic flux in the i & j direction (paa & pbb) |
---|
470 | ! ---------------------------------------- |
---|
471 | DO_3D( 1, 0, 1, 0, 1, jpkm1 ) |
---|
472 | zau = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji+1,jj,jk) ) |
---|
473 | zbu = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) ) |
---|
474 | zcu = ( 0.5 + SIGN( 0.5_wp , paa(ji,jj,jk) ) ) |
---|
475 | paa(ji,jj,jk) = paa(ji,jj,jk) * ( zcu * zau + ( 1._wp - zcu) * zbu ) |
---|
476 | |
---|
477 | zav = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) ) |
---|
478 | zbv = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) ) |
---|
479 | zcv = ( 0.5 + SIGN( 0.5_wp , pbb(ji,jj,jk) ) ) |
---|
480 | pbb(ji,jj,jk) = pbb(ji,jj,jk) * ( zcv * zav + ( 1._wp - zcv) * zbv ) |
---|
481 | |
---|
482 | ! monotonic flux in the k direction, i.e. pcc |
---|
483 | ! ------------------------------------------- |
---|
484 | za = MIN( 1., zbetdo(ji,jj,jk+1), zbetup(ji,jj,jk) ) |
---|
485 | zb = MIN( 1., zbetup(ji,jj,jk+1), zbetdo(ji,jj,jk) ) |
---|
486 | zc = ( 0.5 + SIGN( 0.5_wp , pcc(ji,jj,jk+1) ) ) |
---|
487 | pcc(ji,jj,jk+1) = pcc(ji,jj,jk+1) * ( zc * za + ( 1._wp - zc) * zb ) |
---|
488 | END_3D |
---|
489 | ! |
---|
490 | END SUBROUTINE nonosc |
---|
491 | |
---|
492 | |
---|
493 | SUBROUTINE interp_4th_cpt_org( pt_in, pt_out ) |
---|
494 | !!---------------------------------------------------------------------- |
---|
495 | !! *** ROUTINE interp_4th_cpt_org *** |
---|
496 | !! |
---|
497 | !! ** Purpose : Compute the interpolation of tracer at w-point |
---|
498 | !! |
---|
499 | !! ** Method : 4th order compact interpolation |
---|
500 | !!---------------------------------------------------------------------- |
---|
501 | REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pt_in ! now tracer fields |
---|
502 | REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT( out) :: pt_out ! now tracer field interpolated at w-pts |
---|
503 | ! |
---|
504 | INTEGER :: ji, jj, jk ! dummy loop integers |
---|
505 | REAL(wp),DIMENSION(jpi,jpj,jpk) :: zwd, zwi, zws, zwrm, zwt |
---|
506 | !!---------------------------------------------------------------------- |
---|
507 | |
---|
508 | DO_3D( 1, 1, 1, 1, 3, jpkm1 ) !== build the three diagonal matrix ==! |
---|
509 | zwd (ji,jj,jk) = 4._wp |
---|
510 | zwi (ji,jj,jk) = 1._wp |
---|
511 | zws (ji,jj,jk) = 1._wp |
---|
512 | zwrm(ji,jj,jk) = 3._wp * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) ) |
---|
513 | ! |
---|
514 | IF( tmask(ji,jj,jk+1) == 0._wp) THEN ! Switch to second order centered at bottom |
---|
515 | zwd (ji,jj,jk) = 1._wp |
---|
516 | zwi (ji,jj,jk) = 0._wp |
---|
517 | zws (ji,jj,jk) = 0._wp |
---|
518 | zwrm(ji,jj,jk) = 0.5 * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) ) |
---|
519 | ENDIF |
---|
520 | END_3D |
---|
521 | ! |
---|
522 | jk = 2 ! Switch to second order centered at top |
---|
523 | DO_2D( 1, 1, 1, 1 ) |
---|
524 | zwd (ji,jj,jk) = 1._wp |
---|
525 | zwi (ji,jj,jk) = 0._wp |
---|
526 | zws (ji,jj,jk) = 0._wp |
---|
527 | zwrm(ji,jj,jk) = 0.5 * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) ) |
---|
528 | END_2D |
---|
529 | ! |
---|
530 | ! !== tridiagonal solve ==! |
---|
531 | DO_2D( 1, 1, 1, 1 ) ! first recurrence |
---|
532 | zwt(ji,jj,2) = zwd(ji,jj,2) |
---|
533 | END_2D |
---|
534 | DO_3D( 1, 1, 1, 1, 3, jpkm1 ) |
---|
535 | zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) /zwt(ji,jj,jk-1) |
---|
536 | END_3D |
---|
537 | ! |
---|
538 | DO_2D( 1, 1, 1, 1 ) ! second recurrence: Zk = Yk - Ik / Tk-1 Zk-1 |
---|
539 | pt_out(ji,jj,2) = zwrm(ji,jj,2) |
---|
540 | END_2D |
---|
541 | DO_3D( 1, 1, 1, 1, 3, jpkm1 ) |
---|
542 | pt_out(ji,jj,jk) = zwrm(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1) |
---|
543 | END_3D |
---|
544 | |
---|
545 | DO_2D( 1, 1, 1, 1 ) ! third recurrence: Xk = (Zk - Sk Xk+1 ) / Tk |
---|
546 | pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) |
---|
547 | END_2D |
---|
548 | DO_3DS( 1, 1, 1, 1, jpk-2, 2, -1 ) |
---|
549 | pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - zws(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk) |
---|
550 | END_3D |
---|
551 | ! |
---|
552 | END SUBROUTINE interp_4th_cpt_org |
---|
553 | |
---|
554 | |
---|
555 | SUBROUTINE interp_4th_cpt( pt_in, pt_out ) |
---|
556 | !!---------------------------------------------------------------------- |
---|
557 | !! *** ROUTINE interp_4th_cpt *** |
---|
558 | !! |
---|
559 | !! ** Purpose : Compute the interpolation of tracer at w-point |
---|
560 | !! |
---|
561 | !! ** Method : 4th order compact interpolation |
---|
562 | !!---------------------------------------------------------------------- |
---|
563 | REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pt_in ! field at t-point |
---|
564 | REAL(wp),DIMENSION(A2D(nn_hls) ,jpk), INTENT( out) :: pt_out ! field interpolated at w-point |
---|
565 | ! |
---|
566 | INTEGER :: ji, jj, jk ! dummy loop integers |
---|
567 | INTEGER :: ikt, ikb ! local integers |
---|
568 | REAL(wp),DIMENSION(A2D(nn_hls),jpk) :: zwd, zwi, zws, zwrm, zwt |
---|
569 | !!---------------------------------------------------------------------- |
---|
570 | ! |
---|
571 | ! !== build the three diagonal matrix & the RHS ==! |
---|
572 | ! |
---|
573 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 3, jpkm1 ) ! interior (from jk=3 to jpk-1) |
---|
574 | zwd (ji,jj,jk) = 3._wp * wmask(ji,jj,jk) + 1._wp ! diagonal |
---|
575 | zwi (ji,jj,jk) = wmask(ji,jj,jk) ! lower diagonal |
---|
576 | zws (ji,jj,jk) = wmask(ji,jj,jk) ! upper diagonal |
---|
577 | zwrm(ji,jj,jk) = 3._wp * wmask(ji,jj,jk) & ! RHS |
---|
578 | & * ( pt_in(ji,jj,jk) + pt_in(ji,jj,jk-1) ) |
---|
579 | END_3D |
---|
580 | ! |
---|
581 | !!gm |
---|
582 | ! SELECT CASE( kbc ) !* boundary condition |
---|
583 | ! CASE( np_NH ) ! Neumann homogeneous at top & bottom |
---|
584 | ! CASE( np_CEN2 ) ! 2nd order centered at top & bottom |
---|
585 | ! END SELECT |
---|
586 | !!gm |
---|
587 | ! |
---|
588 | IF ( ln_isfcav ) THEN ! set level two values which may not be set in ISF case |
---|
589 | zwd(:,:,2) = 1._wp ; zwi(:,:,2) = 0._wp ; zws(:,:,2) = 0._wp ; zwrm(:,:,2) = 0._wp |
---|
590 | END IF |
---|
591 | ! |
---|
592 | DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! 2nd order centered at top & bottom |
---|
593 | ikt = mikt(ji,jj) + 1 ! w-point below the 1st wet point |
---|
594 | ikb = MAX(mbkt(ji,jj), 2) ! - above the last wet point |
---|
595 | ! |
---|
596 | zwd (ji,jj,ikt) = 1._wp ! top |
---|
597 | zwi (ji,jj,ikt) = 0._wp |
---|
598 | zws (ji,jj,ikt) = 0._wp |
---|
599 | zwrm(ji,jj,ikt) = 0.5_wp * ( pt_in(ji,jj,ikt-1) + pt_in(ji,jj,ikt) ) |
---|
600 | ! |
---|
601 | zwd (ji,jj,ikb) = 1._wp ! bottom |
---|
602 | zwi (ji,jj,ikb) = 0._wp |
---|
603 | zws (ji,jj,ikb) = 0._wp |
---|
604 | zwrm(ji,jj,ikb) = 0.5_wp * ( pt_in(ji,jj,ikb-1) + pt_in(ji,jj,ikb) ) |
---|
605 | END_2D |
---|
606 | ! |
---|
607 | ! !== tridiagonal solver ==! |
---|
608 | ! |
---|
609 | DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 1st recurrence: Tk = Dk - Ik Sk-1 / Tk-1 |
---|
610 | zwt(ji,jj,2) = zwd(ji,jj,2) |
---|
611 | END_2D |
---|
612 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 3, jpkm1 ) |
---|
613 | zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) /zwt(ji,jj,jk-1) |
---|
614 | END_3D |
---|
615 | ! |
---|
616 | DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 2nd recurrence: Zk = Yk - Ik / Tk-1 Zk-1 |
---|
617 | pt_out(ji,jj,2) = zwrm(ji,jj,2) |
---|
618 | END_2D |
---|
619 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 3, jpkm1 ) |
---|
620 | pt_out(ji,jj,jk) = zwrm(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1) |
---|
621 | END_3D |
---|
622 | |
---|
623 | DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 3d recurrence: Xk = (Zk - Sk Xk+1 ) / Tk |
---|
624 | pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) |
---|
625 | END_2D |
---|
626 | DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpk-2, 2, -1 ) |
---|
627 | pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - zws(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk) |
---|
628 | END_3D |
---|
629 | ! |
---|
630 | END SUBROUTINE interp_4th_cpt |
---|
631 | |
---|
632 | |
---|
633 | SUBROUTINE tridia_solver( pD, pU, pL, pRHS, pt_out , klev ) |
---|
634 | !!---------------------------------------------------------------------- |
---|
635 | !! *** ROUTINE tridia_solver *** |
---|
636 | !! |
---|
637 | !! ** Purpose : solve a symmetric 3diagonal system |
---|
638 | !! |
---|
639 | !! ** Method : solve M.t_out = RHS(t) where M is a tri diagonal matrix ( jpk*jpk ) |
---|
640 | !! |
---|
641 | !! ( D_1 U_1 0 0 0 )( t_1 ) ( RHS_1 ) |
---|
642 | !! ( L_2 D_2 U_2 0 0 )( t_2 ) ( RHS_2 ) |
---|
643 | !! ( 0 L_3 D_3 U_3 0 )( t_3 ) = ( RHS_3 ) |
---|
644 | !! ( ... )( ... ) ( ... ) |
---|
645 | !! ( 0 0 0 L_k D_k )( t_k ) ( RHS_k ) |
---|
646 | !! |
---|
647 | !! M is decomposed in the product of an upper and lower triangular matrix. |
---|
648 | !! The tri-diagonals matrix is given as input 3D arrays: pD, pU, pL |
---|
649 | !! (i.e. the Diagonal, the Upper diagonal, and the Lower diagonal). |
---|
650 | !! The solution is pta. |
---|
651 | !! The 3d array zwt is used as a work space array. |
---|
652 | !!---------------------------------------------------------------------- |
---|
653 | REAL(wp),DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: pD, pU, PL ! 3-diagonal matrix |
---|
654 | REAL(wp),DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: pRHS ! Right-Hand-Side |
---|
655 | REAL(wp),DIMENSION(A2D(nn_hls),jpk), INTENT( out) :: pt_out !!gm field at level=F(klev) |
---|
656 | INTEGER , INTENT(in ) :: klev ! =1 pt_out at w-level |
---|
657 | ! ! =0 pt at t-level |
---|
658 | INTEGER :: ji, jj, jk ! dummy loop integers |
---|
659 | INTEGER :: kstart ! local indices |
---|
660 | REAL(wp),DIMENSION(A2D(nn_hls),jpk) :: zwt ! 3D work array |
---|
661 | !!---------------------------------------------------------------------- |
---|
662 | ! |
---|
663 | kstart = 1 + klev |
---|
664 | ! |
---|
665 | DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 1st recurrence: Tk = Dk - Ik Sk-1 / Tk-1 |
---|
666 | zwt(ji,jj,kstart) = pD(ji,jj,kstart) |
---|
667 | END_2D |
---|
668 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, kstart+1, jpkm1 ) |
---|
669 | zwt(ji,jj,jk) = pD(ji,jj,jk) - pL(ji,jj,jk) * pU(ji,jj,jk-1) /zwt(ji,jj,jk-1) |
---|
670 | END_3D |
---|
671 | ! |
---|
672 | DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 2nd recurrence: Zk = Yk - Ik / Tk-1 Zk-1 |
---|
673 | pt_out(ji,jj,kstart) = pRHS(ji,jj,kstart) |
---|
674 | END_2D |
---|
675 | DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, kstart+1, jpkm1 ) |
---|
676 | pt_out(ji,jj,jk) = pRHS(ji,jj,jk) - pL(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1) |
---|
677 | END_3D |
---|
678 | |
---|
679 | DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 3d recurrence: Xk = (Zk - Sk Xk+1 ) / Tk |
---|
680 | pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) |
---|
681 | END_2D |
---|
682 | DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpk-2, kstart, -1 ) |
---|
683 | pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - pU(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk) |
---|
684 | END_3D |
---|
685 | ! |
---|
686 | END SUBROUTINE tridia_solver |
---|
687 | |
---|
688 | !!====================================================================== |
---|
689 | END MODULE traadv_fct |
---|