[3] | 1 | MODULE divcur |
---|
| 2 | !!============================================================================== |
---|
| 3 | !! *** MODULE divcur *** |
---|
| 4 | !! Ocean diagnostic variable : horizontal divergence and relative vorticity |
---|
| 5 | !!============================================================================== |
---|
[2528] | 6 | !! History : OPA ! 1987-06 (P. Andrich, D. L Hostis) Original code |
---|
| 7 | !! 4.0 ! 1991-11 (G. Madec) |
---|
| 8 | !! 6.0 ! 1993-03 (M. Guyon) symetrical conditions |
---|
| 9 | !! 7.0 ! 1996-01 (G. Madec) s-coordinates |
---|
| 10 | !! 8.0 ! 1997-06 (G. Madec) lateral boundary cond., lbc |
---|
| 11 | !! 8.1 ! 1997-08 (J.M. Molines) Open boundaries |
---|
| 12 | !! 8.2 ! 2000-03 (G. Madec) no slip accurate |
---|
| 13 | !! NEMO 1.0 ! 2002-09 (G. Madec, E. Durand) Free form, F90 |
---|
| 14 | !! - ! 2005-01 (J. Chanut) Unstructured open boundaries |
---|
| 15 | !! - ! 2003-08 (G. Madec) merged of cur and div, free form, F90 |
---|
| 16 | !! - ! 2005-01 (J. Chanut, A. Sellar) unstructured open boundaries |
---|
| 17 | !! 3.3 ! 2010-09 (D.Storkey and E.O'Dea) bug fixes for BDY module |
---|
| 18 | !! - ! 2010-10 (R. Furner, G. Madec) runoff and cla added directly here |
---|
| 19 | !!---------------------------------------------------------------------- |
---|
[3] | 20 | |
---|
| 21 | !!---------------------------------------------------------------------- |
---|
| 22 | !! div_cur : Compute the horizontal divergence and relative |
---|
| 23 | !! vorticity fields |
---|
| 24 | !!---------------------------------------------------------------------- |
---|
| 25 | USE oce ! ocean dynamics and tracers |
---|
| 26 | USE dom_oce ! ocean space and time domain |
---|
[2528] | 27 | USE sbc_oce, ONLY : ln_rnf ! surface boundary condition: ocean |
---|
| 28 | USE sbcrnf ! river runoff |
---|
| 29 | USE cla ! cross land advection (cla_div routine) |
---|
[3] | 30 | USE in_out_manager ! I/O manager |
---|
| 31 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
[2715] | 32 | USE lib_mpp ! MPP library |
---|
[3294] | 33 | USE wrk_nemo ! Memory Allocation |
---|
| 34 | USE timing ! Timing |
---|
[3] | 35 | |
---|
| 36 | IMPLICIT NONE |
---|
| 37 | PRIVATE |
---|
| 38 | |
---|
[2528] | 39 | PUBLIC div_cur ! routine called by step.F90 and istate.F90 |
---|
[3] | 40 | |
---|
| 41 | !! * Substitutions |
---|
| 42 | # include "domzgr_substitute.h90" |
---|
| 43 | # include "vectopt_loop_substitute.h90" |
---|
| 44 | !!---------------------------------------------------------------------- |
---|
[2528] | 45 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
[1152] | 46 | !! $Id$ |
---|
[2528] | 47 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[3] | 48 | !!---------------------------------------------------------------------- |
---|
| 49 | CONTAINS |
---|
| 50 | |
---|
| 51 | #if defined key_noslip_accurate |
---|
| 52 | !!---------------------------------------------------------------------- |
---|
[2715] | 53 | !! 'key_noslip_accurate' 2nd order interior + 4th order at the coast |
---|
[3] | 54 | !!---------------------------------------------------------------------- |
---|
| 55 | |
---|
| 56 | SUBROUTINE div_cur( kt ) |
---|
| 57 | !!---------------------------------------------------------------------- |
---|
| 58 | !! *** ROUTINE div_cur *** |
---|
| 59 | !! |
---|
| 60 | !! ** Purpose : compute the horizontal divergence and the relative |
---|
[2715] | 61 | !! vorticity at before and now time-step |
---|
[3] | 62 | !! |
---|
[2528] | 63 | !! ** Method : I. divergence : |
---|
[3] | 64 | !! - save the divergence computed at the previous time-step |
---|
| 65 | !! (note that the Asselin filter has not been applied on hdivb) |
---|
| 66 | !! - compute the now divergence given by : |
---|
| 67 | !! hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] ) |
---|
[2528] | 68 | !! correct hdiv with runoff inflow (div_rnf) and cross land flow (div_cla) |
---|
| 69 | !! II. vorticity : |
---|
[3] | 70 | !! - save the curl computed at the previous time-step |
---|
| 71 | !! rotb = rotn |
---|
| 72 | !! (note that the Asselin time filter has not been applied to rotb) |
---|
| 73 | !! - compute the now curl in tensorial formalism: |
---|
| 74 | !! rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] ) |
---|
| 75 | !! - Coastal boundary condition: 'key_noslip_accurate' defined, |
---|
| 76 | !! the no-slip boundary condition is computed using Schchepetkin |
---|
| 77 | !! and O'Brien (1996) scheme (i.e. 4th order at the coast). |
---|
| 78 | !! For example, along east coast, the one-sided finite difference |
---|
| 79 | !! approximation used for di[v] is: |
---|
[2528] | 80 | !! di[e2v vn] = 1/(e1f*e2f) * ( (e2v vn)(i) + (e2v vn)(i-1) + (e2v vn)(i-2) ) |
---|
[3] | 81 | !! |
---|
| 82 | !! ** Action : - update hdivb, hdivn, the before & now hor. divergence |
---|
| 83 | !! - update rotb , rotn , the before & now rel. vorticity |
---|
| 84 | !!---------------------------------------------------------------------- |
---|
[2715] | 85 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
[2528] | 86 | ! |
---|
[2715] | 87 | INTEGER :: ji, jj, jk, jl ! dummy loop indices |
---|
| 88 | INTEGER :: ii, ij, ijt, iju, ierr ! local integer |
---|
| 89 | REAL(wp) :: zraur, zdep ! local scalar |
---|
[3294] | 90 | REAL(wp), POINTER, DIMENSION(:,:) :: zwu ! specific 2D workspace |
---|
| 91 | REAL(wp), POINTER, DIMENSION(:,:) :: zwv ! specific 2D workspace |
---|
[3] | 92 | !!---------------------------------------------------------------------- |
---|
[3294] | 93 | ! |
---|
| 94 | IF( nn_timing == 1 ) CALL timing_start('div_cur') |
---|
| 95 | ! |
---|
| 96 | CALL wrk_alloc( jpi , jpj+2, zwu ) |
---|
| 97 | CALL wrk_alloc( jpi+4, jpj , zwv, kjstart = -1 ) |
---|
| 98 | ! |
---|
[3] | 99 | IF( kt == nit000 ) THEN |
---|
| 100 | IF(lwp) WRITE(numout,*) |
---|
| 101 | IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and relative vorticity' |
---|
| 102 | IF(lwp) WRITE(numout,*) '~~~~~~~ NOT optimal for auto-tasking case' |
---|
| 103 | ENDIF |
---|
| 104 | |
---|
| 105 | ! ! =============== |
---|
| 106 | DO jk = 1, jpkm1 ! Horizontal slab |
---|
| 107 | ! ! =============== |
---|
[2528] | 108 | ! |
---|
[3] | 109 | hdivb(:,:,jk) = hdivn(:,:,jk) ! time swap of div arrays |
---|
| 110 | rotb (:,:,jk) = rotn (:,:,jk) ! time swap of rot arrays |
---|
[2528] | 111 | ! |
---|
[3] | 112 | ! ! -------- |
---|
| 113 | ! Horizontal divergence ! div |
---|
| 114 | ! ! -------- |
---|
| 115 | DO jj = 2, jpjm1 |
---|
| 116 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
| 117 | hdivn(ji,jj,jk) = & |
---|
[455] | 118 | ( e2u(ji,jj)*fse3u(ji,jj,jk) * un(ji,jj,jk) - e2u(ji-1,jj )*fse3u(ji-1,jj ,jk) * un(ji-1,jj ,jk) & |
---|
| 119 | + e1v(ji,jj)*fse3v(ji,jj,jk) * vn(ji,jj,jk) - e1v(ji ,jj-1)*fse3v(ji ,jj-1,jk) * vn(ji ,jj-1,jk) ) & |
---|
[3] | 120 | / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) ) |
---|
| 121 | END DO |
---|
| 122 | END DO |
---|
| 123 | |
---|
[1792] | 124 | IF( .NOT. AGRIF_Root() ) THEN |
---|
| 125 | IF ((nbondi == 1).OR.(nbondi == 2)) hdivn(nlci-1 , : ,jk) = 0.e0 ! east |
---|
| 126 | IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2 , : ,jk) = 0.e0 ! west |
---|
| 127 | IF ((nbondj == 1).OR.(nbondj == 2)) hdivn(: ,nlcj-1 ,jk) = 0.e0 ! north |
---|
| 128 | IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(: ,2 ,jk) = 0.e0 ! south |
---|
| 129 | ENDIF |
---|
[3] | 130 | |
---|
| 131 | ! ! -------- |
---|
| 132 | ! relative vorticity ! rot |
---|
| 133 | ! ! -------- |
---|
| 134 | ! contravariant velocity (extended for lateral b.c.) |
---|
| 135 | ! inside the model domain |
---|
| 136 | DO jj = 1, jpj |
---|
| 137 | DO ji = 1, jpi |
---|
| 138 | zwu(ji,jj) = e1u(ji,jj) * un(ji,jj,jk) |
---|
| 139 | zwv(ji,jj) = e2v(ji,jj) * vn(ji,jj,jk) |
---|
| 140 | END DO |
---|
| 141 | END DO |
---|
| 142 | |
---|
| 143 | ! East-West boundary conditions |
---|
| 144 | IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6) THEN |
---|
| 145 | zwv( 0 ,:) = zwv(jpi-2,:) |
---|
| 146 | zwv( -1 ,:) = zwv(jpi-3,:) |
---|
| 147 | zwv(jpi+1,:) = zwv( 3 ,:) |
---|
| 148 | zwv(jpi+2,:) = zwv( 4 ,:) |
---|
| 149 | ELSE |
---|
| 150 | zwv( 0 ,:) = 0.e0 |
---|
| 151 | zwv( -1 ,:) = 0.e0 |
---|
| 152 | zwv(jpi+1,:) = 0.e0 |
---|
| 153 | zwv(jpi+2,:) = 0.e0 |
---|
| 154 | ENDIF |
---|
| 155 | |
---|
| 156 | ! North-South boundary conditions |
---|
| 157 | IF( nperio == 3 .OR. nperio == 4 ) THEN |
---|
| 158 | ! north fold ( Grid defined with a T-point pivot) ORCA 2 degre |
---|
| 159 | zwu(jpi,jpj+1) = 0.e0 |
---|
| 160 | zwu(jpi,jpj+2) = 0.e0 |
---|
| 161 | DO ji = 1, jpi-1 |
---|
| 162 | iju = jpi - ji + 1 |
---|
| 163 | zwu(ji,jpj+1) = - zwu(iju,jpj-3) |
---|
| 164 | zwu(ji,jpj+2) = - zwu(iju,jpj-4) |
---|
| 165 | END DO |
---|
| 166 | ELSEIF( nperio == 5 .OR. nperio == 6 ) THEN |
---|
| 167 | ! north fold ( Grid defined with a F-point pivot) ORCA 0.5 degre\ |
---|
| 168 | zwu(jpi,jpj+1) = 0.e0 |
---|
| 169 | zwu(jpi,jpj+2) = 0.e0 |
---|
| 170 | DO ji = 1, jpi-1 |
---|
| 171 | iju = jpi - ji |
---|
| 172 | zwu(ji,jpj ) = - zwu(iju,jpj-1) |
---|
| 173 | zwu(ji,jpj+1) = - zwu(iju,jpj-2) |
---|
| 174 | zwu(ji,jpj+2) = - zwu(iju,jpj-3) |
---|
| 175 | END DO |
---|
| 176 | DO ji = -1, jpi+2 |
---|
| 177 | ijt = jpi - ji + 1 |
---|
| 178 | zwv(ji,jpj) = - zwv(ijt,jpj-2) |
---|
| 179 | END DO |
---|
| 180 | DO ji = jpi/2+1, jpi+2 |
---|
| 181 | ijt = jpi - ji + 1 |
---|
| 182 | zwv(ji,jpjm1) = - zwv(ijt,jpjm1) |
---|
| 183 | END DO |
---|
| 184 | ELSE |
---|
| 185 | ! closed |
---|
| 186 | zwu(:,jpj+1) = 0.e0 |
---|
| 187 | zwu(:,jpj+2) = 0.e0 |
---|
| 188 | ENDIF |
---|
| 189 | |
---|
| 190 | ! relative vorticity (vertical component of the velocity curl) |
---|
| 191 | DO jj = 1, jpjm1 |
---|
| 192 | DO ji = 1, fs_jpim1 ! vector opt. |
---|
| 193 | rotn(ji,jj,jk) = ( zwv(ji+1,jj ) - zwv(ji,jj) & |
---|
[2528] | 194 | & - zwu(ji ,jj+1) + zwu(ji,jj) ) * fmask(ji,jj,jk) / ( e1f(ji,jj)*e2f(ji,jj) ) |
---|
[3] | 195 | END DO |
---|
| 196 | END DO |
---|
| 197 | |
---|
| 198 | ! second order accurate scheme along straight coast |
---|
| 199 | DO jl = 1, npcoa(1,jk) |
---|
| 200 | ii = nicoa(jl,1,jk) |
---|
| 201 | ij = njcoa(jl,1,jk) |
---|
| 202 | rotn(ii,ij,jk) = 1. / ( e1f(ii,ij) * e2f(ii,ij) ) & |
---|
| 203 | * ( + 4. * zwv(ii+1,ij) - zwv(ii+2,ij) + 0.2 * zwv(ii+3,ij) ) |
---|
| 204 | END DO |
---|
| 205 | DO jl = 1, npcoa(2,jk) |
---|
| 206 | ii = nicoa(jl,2,jk) |
---|
| 207 | ij = njcoa(jl,2,jk) |
---|
| 208 | rotn(ii,ij,jk) = 1./(e1f(ii,ij)*e2f(ii,ij)) & |
---|
| 209 | *(-4.*zwv(ii,ij)+zwv(ii-1,ij)-0.2*zwv(ii-2,ij)) |
---|
| 210 | END DO |
---|
| 211 | DO jl = 1, npcoa(3,jk) |
---|
| 212 | ii = nicoa(jl,3,jk) |
---|
| 213 | ij = njcoa(jl,3,jk) |
---|
| 214 | rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) ) & |
---|
| 215 | * ( +4. * zwu(ii,ij+1) - zwu(ii,ij+2) + 0.2 * zwu(ii,ij+3) ) |
---|
| 216 | END DO |
---|
| 217 | DO jl = 1, npcoa(4,jk) |
---|
| 218 | ii = nicoa(jl,4,jk) |
---|
| 219 | ij = njcoa(jl,4,jk) |
---|
| 220 | rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) ) & |
---|
| 221 | * ( -4. * zwu(ii,ij) + zwu(ii,ij-1) - 0.2 * zwu(ii,ij-2) ) |
---|
| 222 | END DO |
---|
| 223 | ! ! =============== |
---|
| 224 | END DO ! End of slab |
---|
| 225 | ! ! =============== |
---|
[2528] | 226 | |
---|
| 227 | IF( ln_rnf ) CALL sbc_rnf_div( hdivn ) ! runoffs (update hdivn field) |
---|
| 228 | IF( nn_cla == 1 ) CALL cla_div ( kt ) ! Cross Land Advection (Update Hor. divergence) |
---|
[3] | 229 | |
---|
| 230 | ! 4. Lateral boundary conditions on hdivn and rotn |
---|
| 231 | ! ---------------------------------=======---====== |
---|
[2528] | 232 | CALL lbc_lnk( hdivn, 'T', 1. ) ; CALL lbc_lnk( rotn , 'F', 1. ) ! lateral boundary cond. (no sign change) |
---|
| 233 | ! |
---|
[3294] | 234 | CALL wrk_dealloc( jpi , jpj+2, zwu ) |
---|
| 235 | CALL wrk_dealloc( jpi+4, jpj , zwv, kjstart = -1 ) |
---|
| 236 | ! |
---|
| 237 | IF( nn_timing == 1 ) CALL timing_stop('div_cur') |
---|
| 238 | ! |
---|
[3] | 239 | END SUBROUTINE div_cur |
---|
| 240 | |
---|
| 241 | #else |
---|
| 242 | !!---------------------------------------------------------------------- |
---|
| 243 | !! Default option 2nd order centered schemes |
---|
| 244 | !!---------------------------------------------------------------------- |
---|
| 245 | |
---|
| 246 | SUBROUTINE div_cur( kt ) |
---|
| 247 | !!---------------------------------------------------------------------- |
---|
| 248 | !! *** ROUTINE div_cur *** |
---|
| 249 | !! |
---|
| 250 | !! ** Purpose : compute the horizontal divergence and the relative |
---|
| 251 | !! vorticity at before and now time-step |
---|
| 252 | !! |
---|
| 253 | !! ** Method : - Divergence: |
---|
| 254 | !! - save the divergence computed at the previous time-step |
---|
| 255 | !! (note that the Asselin filter has not been applied on hdivb) |
---|
| 256 | !! - compute the now divergence given by : |
---|
| 257 | !! hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] ) |
---|
[2528] | 258 | !! correct hdiv with runoff inflow (div_rnf) and cross land flow (div_cla) |
---|
[3] | 259 | !! - Relavtive Vorticity : |
---|
| 260 | !! - save the curl computed at the previous time-step (rotb = rotn) |
---|
| 261 | !! (note that the Asselin time filter has not been applied to rotb) |
---|
| 262 | !! - compute the now curl in tensorial formalism: |
---|
| 263 | !! rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] ) |
---|
| 264 | !! Note: Coastal boundary condition: lateral friction set through |
---|
| 265 | !! the value of fmask along the coast (see dommsk.F90) and shlat |
---|
| 266 | !! (namelist parameter) |
---|
| 267 | !! |
---|
| 268 | !! ** Action : - update hdivb, hdivn, the before & now hor. divergence |
---|
| 269 | !! - update rotb , rotn , the before & now rel. vorticity |
---|
| 270 | !!---------------------------------------------------------------------- |
---|
[2715] | 271 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
[2528] | 272 | ! |
---|
[2715] | 273 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
| 274 | REAL(wp) :: zraur, zdep ! local scalars |
---|
[3] | 275 | !!---------------------------------------------------------------------- |
---|
[3294] | 276 | ! |
---|
| 277 | IF( nn_timing == 1 ) CALL timing_start('div_cur') |
---|
| 278 | ! |
---|
[3] | 279 | IF( kt == nit000 ) THEN |
---|
| 280 | IF(lwp) WRITE(numout,*) |
---|
| 281 | IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and' |
---|
| 282 | IF(lwp) WRITE(numout,*) '~~~~~~~ relative vorticity' |
---|
| 283 | ENDIF |
---|
| 284 | |
---|
| 285 | ! ! =============== |
---|
| 286 | DO jk = 1, jpkm1 ! Horizontal slab |
---|
| 287 | ! ! =============== |
---|
[2528] | 288 | ! |
---|
[3] | 289 | hdivb(:,:,jk) = hdivn(:,:,jk) ! time swap of div arrays |
---|
| 290 | rotb (:,:,jk) = rotn (:,:,jk) ! time swap of rot arrays |
---|
[2528] | 291 | ! |
---|
[3] | 292 | ! ! -------- |
---|
| 293 | ! Horizontal divergence ! div |
---|
| 294 | ! ! -------- |
---|
| 295 | DO jj = 2, jpjm1 |
---|
| 296 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
[455] | 297 | hdivn(ji,jj,jk) = & |
---|
[2528] | 298 | ( e2u(ji,jj)*fse3u(ji,jj,jk) * un(ji,jj,jk) - e2u(ji-1,jj)*fse3u(ji-1,jj,jk) * un(ji-1,jj,jk) & |
---|
| 299 | + e1v(ji,jj)*fse3v(ji,jj,jk) * vn(ji,jj,jk) - e1v(ji,jj-1)*fse3v(ji,jj-1,jk) * vn(ji,jj-1,jk) ) & |
---|
[455] | 300 | / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) ) |
---|
[3] | 301 | END DO |
---|
| 302 | END DO |
---|
| 303 | |
---|
[1792] | 304 | IF( .NOT. AGRIF_Root() ) THEN |
---|
[780] | 305 | IF ((nbondi == 1).OR.(nbondi == 2)) hdivn(nlci-1 , : ,jk) = 0.e0 ! east |
---|
| 306 | IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2 , : ,jk) = 0.e0 ! west |
---|
| 307 | IF ((nbondj == 1).OR.(nbondj == 2)) hdivn(: ,nlcj-1 ,jk) = 0.e0 ! north |
---|
| 308 | IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(: ,2 ,jk) = 0.e0 ! south |
---|
[1792] | 309 | ENDIF |
---|
[780] | 310 | |
---|
[3] | 311 | ! ! -------- |
---|
| 312 | ! relative vorticity ! rot |
---|
| 313 | ! ! -------- |
---|
| 314 | DO jj = 1, jpjm1 |
---|
| 315 | DO ji = 1, fs_jpim1 ! vector opt. |
---|
| 316 | rotn(ji,jj,jk) = ( e2v(ji+1,jj ) * vn(ji+1,jj ,jk) - e2v(ji,jj) * vn(ji,jj,jk) & |
---|
| 317 | & - e1u(ji ,jj+1) * un(ji ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk) ) & |
---|
| 318 | & * fmask(ji,jj,jk) / ( e1f(ji,jj) * e2f(ji,jj) ) |
---|
| 319 | END DO |
---|
| 320 | END DO |
---|
| 321 | ! ! =============== |
---|
| 322 | END DO ! End of slab |
---|
| 323 | ! ! =============== |
---|
[2528] | 324 | |
---|
| 325 | IF( ln_rnf ) CALL sbc_rnf_div( hdivn ) ! runoffs (update hdivn field) |
---|
| 326 | IF( nn_cla == 1 ) CALL cla_div ( kt ) ! Cross Land Advection (update hdivn field) |
---|
[2715] | 327 | ! |
---|
[2528] | 328 | CALL lbc_lnk( hdivn, 'T', 1. ) ; CALL lbc_lnk( rotn , 'F', 1. ) ! lateral boundary cond. (no sign change) |
---|
| 329 | ! |
---|
[3294] | 330 | IF( nn_timing == 1 ) CALL timing_stop('div_cur') |
---|
| 331 | ! |
---|
[3] | 332 | END SUBROUTINE div_cur |
---|
| 333 | |
---|
| 334 | #endif |
---|
| 335 | !!====================================================================== |
---|
| 336 | END MODULE divcur |
---|