[4619] | 1 | MODULE trdken |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE trdken *** |
---|
| 4 | !! Ocean diagnostics: compute and output 3D kinetic energy trends |
---|
| 5 | !!===================================================================== |
---|
| 6 | !! History : 3.5 ! 2012-02 (G. Madec) original code |
---|
| 7 | !!---------------------------------------------------------------------- |
---|
| 8 | |
---|
| 9 | !!---------------------------------------------------------------------- |
---|
| 10 | !! trd_ken : compute and output 3D Kinetic energy trends using IOM |
---|
| 11 | !! trd_ken_init : initialisation |
---|
| 12 | !!---------------------------------------------------------------------- |
---|
| 13 | USE oce ! ocean dynamics and tracers variables |
---|
| 14 | USE dom_oce ! ocean space and time domain variables |
---|
[6808] | 15 | USE sbc_oce ! surface boundary condition: ocean |
---|
[4619] | 16 | USE zdf_oce ! ocean vertical physics variables |
---|
| 17 | USE trd_oce ! trends: ocean variables |
---|
| 18 | !!gm USE dynhpg ! hydrostatic pressure gradient |
---|
| 19 | USE zdfbfr ! bottom friction |
---|
[6808] | 20 | USE ldftra ! ocean active tracers lateral physics |
---|
[4619] | 21 | USE phycst ! physical constants |
---|
| 22 | USE trdvor ! ocean vorticity trends |
---|
| 23 | USE trdglo ! trends:global domain averaged |
---|
[6808] | 24 | USE trdmxl ! ocean active mixed layer tracers trends |
---|
| 25 | ! |
---|
[4619] | 26 | USE in_out_manager ! I/O manager |
---|
| 27 | USE iom ! I/O manager library |
---|
| 28 | USE lib_mpp ! MPP library |
---|
| 29 | USE wrk_nemo ! Memory allocation |
---|
| 30 | |
---|
| 31 | IMPLICIT NONE |
---|
| 32 | PRIVATE |
---|
| 33 | |
---|
| 34 | PUBLIC trd_ken ! called by trddyn module |
---|
| 35 | PUBLIC trd_ken_init ! called by trdini module |
---|
| 36 | |
---|
| 37 | INTEGER :: nkstp ! current time step |
---|
| 38 | |
---|
| 39 | REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: bu, bv ! volume of u- and v-boxes |
---|
| 40 | REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: r1_bt ! inverse of t-box volume |
---|
| 41 | |
---|
| 42 | !! * Substitutions |
---|
| 43 | # include "vectopt_loop_substitute.h90" |
---|
| 44 | !!---------------------------------------------------------------------- |
---|
| 45 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
[5215] | 46 | !! $Id$ |
---|
[4619] | 47 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 48 | !!---------------------------------------------------------------------- |
---|
| 49 | CONTAINS |
---|
| 50 | |
---|
| 51 | INTEGER FUNCTION trd_ken_alloc() |
---|
| 52 | !!--------------------------------------------------------------------- |
---|
| 53 | !! *** FUNCTION trd_ken_alloc *** |
---|
| 54 | !!--------------------------------------------------------------------- |
---|
| 55 | ALLOCATE( bu(jpi,jpj,jpk) , bv(jpi,jpj,jpk) , r1_bt(jpi,jpj,jpk) , STAT= trd_ken_alloc ) |
---|
| 56 | ! |
---|
| 57 | IF( lk_mpp ) CALL mpp_sum ( trd_ken_alloc ) |
---|
| 58 | IF( trd_ken_alloc /= 0 ) CALL ctl_warn('trd_ken_alloc: failed to allocate arrays') |
---|
| 59 | END FUNCTION trd_ken_alloc |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | SUBROUTINE trd_ken( putrd, pvtrd, ktrd, kt ) |
---|
| 63 | !!--------------------------------------------------------------------- |
---|
| 64 | !! *** ROUTINE trd_ken *** |
---|
| 65 | !! |
---|
| 66 | !! ** Purpose : output 3D Kinetic Energy trends using IOM |
---|
| 67 | !! |
---|
| 68 | !! ** Method : - apply lbc to the input masked velocity trends |
---|
| 69 | !! - compute the associated KE trend: |
---|
| 70 | !! zke = 0.5 * ( mi-1[ un * putrd * bu ] + mj-1[ vn * pvtrd * bv] ) / bt |
---|
| 71 | !! where bu, bv, bt are the volume of u-, v- and t-boxes. |
---|
| 72 | !! - vertical diffusion case (jpdyn_zdf): |
---|
| 73 | !! diagnose separately the KE trend associated with wind stress |
---|
| 74 | !! - bottom friction case (jpdyn_bfr): |
---|
| 75 | !! explicit case (ln_bfrimp=F): bottom trend put in the 1st level |
---|
| 76 | !! of putrd, pvtrd |
---|
| 77 | ! |
---|
| 78 | ! |
---|
| 79 | !!---------------------------------------------------------------------- |
---|
| 80 | REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: putrd, pvtrd ! U and V masked trends |
---|
| 81 | INTEGER , INTENT(in ) :: ktrd ! trend index |
---|
| 82 | INTEGER , INTENT(in ) :: kt ! time step |
---|
| 83 | ! |
---|
| 84 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
| 85 | INTEGER :: ikbu , ikbv ! local integers |
---|
| 86 | INTEGER :: ikbum1, ikbvm1 ! - - |
---|
| 87 | REAL(wp), POINTER, DIMENSION(:,:) :: z2dx, z2dy, zke2d ! 2D workspace |
---|
| 88 | REAL(wp), POINTER, DIMENSION(:,:,:) :: zke ! 3D workspace |
---|
| 89 | !!---------------------------------------------------------------------- |
---|
| 90 | ! |
---|
| 91 | CALL wrk_alloc( jpi, jpj, jpk, zke ) |
---|
| 92 | ! |
---|
| 93 | CALL lbc_lnk( putrd, 'U', -1. ) ; CALL lbc_lnk( pvtrd, 'V', -1. ) ! lateral boundary conditions |
---|
| 94 | ! |
---|
[6808] | 95 | nkstp = kt |
---|
| 96 | DO jk = 1, jpkm1 |
---|
| 97 | bu (:,:,jk) = e1e2u(:,:) * e3u_n(:,:,jk) |
---|
| 98 | bv (:,:,jk) = e1e2v(:,:) * e3v_n(:,:,jk) |
---|
| 99 | r1_bt(:,:,jk) = r1_e1e2t(:,:) / e3t_n(:,:,jk) * tmask(:,:,jk) |
---|
| 100 | END DO |
---|
[4619] | 101 | ! |
---|
| 102 | zke(:,:,jpk) = 0._wp |
---|
| 103 | zke(1,:, : ) = 0._wp |
---|
| 104 | zke(:,1, : ) = 0._wp |
---|
| 105 | DO jk = 1, jpkm1 |
---|
| 106 | DO jj = 2, jpj |
---|
| 107 | DO ji = 2, jpi |
---|
| 108 | zke(ji,jj,jk) = 0.5_wp * rau0 *( un(ji ,jj,jk) * putrd(ji ,jj,jk) * bu(ji ,jj,jk) & |
---|
| 109 | & + un(ji-1,jj,jk) * putrd(ji-1,jj,jk) * bu(ji-1,jj,jk) & |
---|
| 110 | & + vn(ji,jj ,jk) * pvtrd(ji,jj ,jk) * bv(ji,jj ,jk) & |
---|
| 111 | & + vn(ji,jj-1,jk) * pvtrd(ji,jj-1,jk) * bv(ji,jj-1,jk) ) * r1_bt(ji,jj,jk) |
---|
| 112 | END DO |
---|
| 113 | END DO |
---|
| 114 | END DO |
---|
| 115 | ! |
---|
| 116 | SELECT CASE( ktrd ) |
---|
[6808] | 117 | CASE( jpdyn_hpg ) ; CALL iom_put( "ketrd_hpg" , zke ) ! hydrostatic pressure gradient |
---|
| 118 | CASE( jpdyn_spg ) ; CALL iom_put( "ketrd_spg" , zke ) ! surface pressure gradient |
---|
| 119 | CASE( jpdyn_pvo ) ; CALL iom_put( "ketrd_pvo" , zke ) ! planetary vorticity |
---|
| 120 | CASE( jpdyn_rvo ) ; CALL iom_put( "ketrd_rvo" , zke ) ! relative vorticity (or metric term) |
---|
| 121 | CASE( jpdyn_keg ) ; CALL iom_put( "ketrd_keg" , zke ) ! Kinetic Energy gradient (or had) |
---|
| 122 | CASE( jpdyn_zad ) ; CALL iom_put( "ketrd_zad" , zke ) ! vertical advection |
---|
| 123 | CASE( jpdyn_ldf ) ; CALL iom_put( "ketrd_ldf" , zke ) ! lateral diffusion |
---|
| 124 | CASE( jpdyn_zdf ) ; CALL iom_put( "ketrd_zdf" , zke ) ! vertical diffusion |
---|
| 125 | ! ! ! wind stress trends |
---|
| 126 | CALL wrk_alloc( jpi, jpj, z2dx, z2dy, zke2d ) |
---|
| 127 | z2dx(:,:) = un(:,:,1) * ( utau_b(:,:) + utau(:,:) ) * e1e2u(:,:) * umask(:,:,1) |
---|
| 128 | z2dy(:,:) = vn(:,:,1) * ( vtau_b(:,:) + vtau(:,:) ) * e1e2v(:,:) * vmask(:,:,1) |
---|
| 129 | zke2d(1,:) = 0._wp ; zke2d(:,1) = 0._wp |
---|
| 130 | DO jj = 2, jpj |
---|
| 131 | DO ji = 2, jpi |
---|
| 132 | zke2d(ji,jj) = r1_rau0 * 0.5_wp * ( z2dx(ji,jj) + z2dx(ji-1,jj) & |
---|
| 133 | & + z2dy(ji,jj) + z2dy(ji,jj-1) ) * r1_bt(ji,jj,1) |
---|
| 134 | END DO |
---|
| 135 | END DO |
---|
| 136 | CALL iom_put( "ketrd_tau" , zke2d ) ! |
---|
| 137 | CALL wrk_dealloc( jpi, jpj , z2dx, z2dy, zke2d ) |
---|
| 138 | CASE( jpdyn_bfr ) ; CALL iom_put( "ketrd_bfr" , zke ) ! bottom friction (explicit case) |
---|
[4619] | 139 | !!gm TO BE DONE properly |
---|
| 140 | !!gm only valid if ln_bfrimp=F otherwise the bottom stress as to be recomputed at the end of the computation.... |
---|
| 141 | ! IF(.NOT. ln_bfrimp) THEN |
---|
| 142 | ! DO jj = 1, jpj ! |
---|
| 143 | ! DO ji = 1, jpi |
---|
| 144 | ! ikbu = mbku(ji,jj) ! deepest ocean u- & v-levels |
---|
| 145 | ! ikbv = mbkv(ji,jj) |
---|
| 146 | ! z2dx(ji,jj) = un(ji,jj,ikbu) * bfrua(ji,jj) * un(ji,jj,ikbu) |
---|
| 147 | ! z2dy(ji,jj) = vn(ji,jj,ikbu) * bfrva(ji,jj) * vn(ji,jj,ikbv) |
---|
| 148 | ! END DO |
---|
| 149 | ! END DO |
---|
| 150 | ! zke2d(1,:) = 0._wp ; zke2d(:,1) = 0._wp |
---|
| 151 | ! DO jj = 2, jpj |
---|
| 152 | ! DO ji = 2, jpi |
---|
| 153 | ! zke2d(ji,jj) = 0.5_wp * ( z2dx(ji,jj) + z2dx(ji-1,jj) & |
---|
| 154 | ! & + z2dy(ji,jj) + z2dy(ji,jj-1) ) * r1_bt(ji,jj, BEURK!!! |
---|
| 155 | ! END DO |
---|
| 156 | ! END DO |
---|
[6808] | 157 | ! CALL iom_put( "ketrd_bfr" , zke2d ) ! bottom friction (explicit case) |
---|
[4619] | 158 | ! ENDIF |
---|
| 159 | !!gm end |
---|
[6808] | 160 | CASE( jpdyn_atf ) ; CALL iom_put( "ketrd_atf" , zke ) ! asselin filter trends |
---|
[4619] | 161 | !! a faire !!!! idee changer dynnxt pour avoir un appel a jpdyn_bfr avant le swap !!! |
---|
| 162 | !! reflechir a une possible sauvegarde du "vrai" un,vn pour le calcul de atf.... |
---|
| 163 | ! |
---|
| 164 | ! IF( ln_bfrimp ) THEN ! bottom friction (implicit case) |
---|
| 165 | ! DO jj = 1, jpj ! after velocity known (now filed at this stage) |
---|
| 166 | ! DO ji = 1, jpi |
---|
| 167 | ! ikbu = mbku(ji,jj) ! deepest ocean u- & v-levels |
---|
| 168 | ! ikbv = mbkv(ji,jj) |
---|
[6808] | 169 | ! z2dx(ji,jj) = un(ji,jj,ikbu) * bfrua(ji,jj) * un(ji,jj,ikbu) / e3u_n(ji,jj,ikbu) |
---|
| 170 | ! z2dy(ji,jj) = un(ji,jj,ikbu) * bfrva(ji,jj) * vn(ji,jj,ikbv) / e3v_n(ji,jj,ikbv) |
---|
[4619] | 171 | ! END DO |
---|
| 172 | ! END DO |
---|
| 173 | ! zke2d(1,:) = 0._wp ; zke2d(:,1) = 0._wp |
---|
| 174 | ! DO jj = 2, jpj |
---|
| 175 | ! DO ji = 2, jpi |
---|
| 176 | ! zke2d(ji,jj) = 0.5_wp * ( z2dx(ji,jj) + z2dx(ji-1,jj) & |
---|
| 177 | ! & + z2dy(ji,jj) + z2dy(ji,jj-1) ) |
---|
| 178 | ! END DO |
---|
| 179 | ! END DO |
---|
| 180 | ! CALL iom_put( "ketrd_bfri", zke2d ) |
---|
| 181 | ! ENDIF |
---|
[6808] | 182 | CASE( jpdyn_ken ) ; ! kinetic energy |
---|
| 183 | ! called in dynnxt.F90 before asselin time filter with putrd=ua and pvtrd=va |
---|
| 184 | zke(:,:,:) = 0.5_wp * zke(:,:,:) |
---|
| 185 | CALL iom_put( "KE", zke ) |
---|
| 186 | ! |
---|
| 187 | CALL ken_p2k( kt , zke ) |
---|
| 188 | CALL iom_put( "ketrd_convP2K", zke ) ! conversion -rau*g*w |
---|
[4619] | 189 | ! |
---|
| 190 | END SELECT |
---|
| 191 | ! |
---|
| 192 | CALL wrk_dealloc( jpi, jpj, jpk, zke ) |
---|
| 193 | ! |
---|
| 194 | END SUBROUTINE trd_ken |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | SUBROUTINE ken_p2k( kt , pconv ) |
---|
| 198 | !!--------------------------------------------------------------------- |
---|
| 199 | !! *** ROUTINE ken_p2k *** |
---|
| 200 | !! |
---|
| 201 | !! ** Purpose : compute rate of conversion from potential to kinetic energy |
---|
| 202 | !! |
---|
| 203 | !! ** Method : - compute conv defined as -rau*g*w on T-grid points |
---|
| 204 | !! |
---|
| 205 | !! ** Work only for full steps and partial steps (ln_hpg_zco or ln_hpg_zps) |
---|
| 206 | !!---------------------------------------------------------------------- |
---|
| 207 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
| 208 | !! |
---|
| 209 | REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT( out) :: pconv |
---|
| 210 | ! |
---|
| 211 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
| 212 | INTEGER :: iku, ikv ! temporary integers |
---|
| 213 | REAL(wp) :: zcoef ! temporary scalars |
---|
| 214 | REAL(wp), POINTER, DIMENSION(:,:,:) :: zconv ! temporary conv on W-grid |
---|
| 215 | !!---------------------------------------------------------------------- |
---|
| 216 | ! |
---|
| 217 | CALL wrk_alloc( jpi,jpj,jpk, zconv ) |
---|
| 218 | ! |
---|
| 219 | ! Local constant initialization |
---|
| 220 | zcoef = - rau0 * grav * 0.5_wp |
---|
| 221 | |
---|
| 222 | ! Surface value (also valid in partial step case) |
---|
[6808] | 223 | zconv(:,:,1) = zcoef * ( 2._wp * rhd(:,:,1) ) * wn(:,:,1) * e3w_n(:,:,1) |
---|
[4619] | 224 | |
---|
| 225 | ! interior value (2=<jk=<jpkm1) |
---|
| 226 | DO jk = 2, jpk |
---|
[6808] | 227 | zconv(:,:,jk) = zcoef * ( rhd(:,:,jk) + rhd(:,:,jk-1) ) * wn(:,:,jk) * e3w_n(:,:,jk) |
---|
[4619] | 228 | END DO |
---|
| 229 | |
---|
| 230 | ! conv value on T-point |
---|
| 231 | DO jk = 1, jpkm1 |
---|
| 232 | DO jj = 1, jpj |
---|
| 233 | DO ji = 1, jpi |
---|
[6808] | 234 | zcoef = 0.5_wp / e3t_n(ji,jj,jk) |
---|
[4619] | 235 | pconv(ji,jj,jk) = zcoef * ( zconv(ji,jj,jk) + zconv(ji,jj,jk+1) ) * tmask(ji,jj,jk) |
---|
| 236 | END DO |
---|
| 237 | END DO |
---|
| 238 | END DO |
---|
| 239 | ! |
---|
| 240 | CALL wrk_dealloc( jpi,jpj,jpk, zconv ) |
---|
| 241 | ! |
---|
| 242 | END SUBROUTINE ken_p2k |
---|
| 243 | |
---|
| 244 | |
---|
| 245 | SUBROUTINE trd_ken_init |
---|
| 246 | !!--------------------------------------------------------------------- |
---|
| 247 | !! *** ROUTINE trd_ken_init *** |
---|
| 248 | !! |
---|
| 249 | !! ** Purpose : initialisation of 3D Kinetic Energy trend diagnostic |
---|
| 250 | !!---------------------------------------------------------------------- |
---|
| 251 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
| 252 | !!---------------------------------------------------------------------- |
---|
| 253 | ! |
---|
| 254 | IF(lwp) THEN |
---|
| 255 | WRITE(numout,*) |
---|
| 256 | WRITE(numout,*) 'trd_ken_init : 3D Kinetic Energy trends' |
---|
| 257 | WRITE(numout,*) '~~~~~~~~~~~~~' |
---|
| 258 | ENDIF |
---|
| 259 | ! ! allocate box volume arrays |
---|
[6808] | 260 | IF( trd_ken_alloc() /= 0 ) CALL ctl_stop('trd_ken_alloc: failed to allocate arrays') |
---|
[4619] | 261 | ! |
---|
| 262 | END SUBROUTINE trd_ken_init |
---|
| 263 | |
---|
| 264 | !!====================================================================== |
---|
| 265 | END MODULE trdken |
---|