MODULE traldf_iso !!====================================================================== !! *** MODULE traldf_iso *** !! Ocean tracers: horizontal component of the lateral tracer mixing trend !!====================================================================== !! History : OPA ! 1994-08 (G. Madec, M. Imbard) !! 8.0 ! 1997-05 (G. Madec) split into traldf and trazdf !! NEMO ! 2002-08 (G. Madec) Free form, F90 !! 1.0 ! 2005-11 (G. Madec) merge traldf and trazdf :-) !! 3.3 ! 2010-09 (C. Ethe, G. Madec) Merge TRA-TRC !!---------------------------------------------------------------------- #if defined key_ldfslp || defined key_esopa !!---------------------------------------------------------------------- !! 'key_ldfslp' slope of the lateral diffusive direction !!---------------------------------------------------------------------- !! tra_ldf_iso : update the tracer trend with the horizontal !! component of a iso-neutral laplacian operator !! and with the vertical part of !! the isopycnal or geopotential s-coord. operator !!---------------------------------------------------------------------- USE oce ! ocean dynamics and active tracers USE dom_oce ! ocean space and time domain USE trc_oce ! share passive tracers/Ocean variables USE zdf_oce ! ocean vertical physics USE ldftra_oce ! ocean active tracers: lateral physics USE ldfslp ! iso-neutral slopes USE diaptr ! poleward transport diagnostics USE in_out_manager ! I/O manager USE iom ! I/O library #if defined key_diaar5 USE phycst ! physical constants USE lbclnk ! ocean lateral boundary conditions (or mpp link) #endif IMPLICIT NONE PRIVATE PUBLIC tra_ldf_iso ! routine called by step.F90 !! * Substitutions # include "domzgr_substitute.h90" # include "ldftra_substitute.h90" # include "vectopt_loop_substitute.h90" !!---------------------------------------------------------------------- !! NEMO/OPA 3.3 , NEMO Consortium (2010) !! $Id$ !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) !!---------------------------------------------------------------------- CONTAINS SUBROUTINE tra_ldf_iso( kt, cdtype, pgu, pgv, & & ptb, pta, kjpt, pahtb0 ) !!---------------------------------------------------------------------- !! *** ROUTINE tra_ldf_iso *** !! !! ** Purpose : Compute the before horizontal tracer (t & s) diffusive !! trend for a laplacian tensor (ezxcept the dz[ dz[.] ] term) and !! add it to the general trend of tracer equation. !! !! ** Method : The horizontal component of the lateral diffusive trends !! is provided by a 2nd order operator rotated along neural or geopo- !! tential surfaces to which an eddy induced advection can be added !! It is computed using before fields (forward in time) and isopyc- !! nal or geopotential slopes computed in routine ldfslp. !! !! 1st part : masked horizontal derivative of T ( di[ t ] ) !! ======== with partial cell update if ln_zps=T. !! !! 2nd part : horizontal fluxes of the lateral mixing operator !! ======== !! zftu = (aht+ahtb0) e2u*e3u/e1u di[ tb ] !! - aht e2u*uslp dk[ mi(mk(tb)) ] !! zftv = (aht+ahtb0) e1v*e3v/e2v dj[ tb ] !! - aht e2u*vslp dk[ mj(mk(tb)) ] !! take the horizontal divergence of the fluxes: !! difft = 1/(e1t*e2t*e3t) { di-1[ zftu ] + dj-1[ zftv ] } !! Add this trend to the general trend (ta,sa): !! ta = ta + difft !! !! 3rd part: vertical trends of the lateral mixing operator !! ======== (excluding the vertical flux proportional to dk[t] ) !! vertical fluxes associated with the rotated lateral mixing: !! zftw =-aht { e2t*wslpi di[ mi(mk(tb)) ] !! + e1t*wslpj dj[ mj(mk(tb)) ] } !! take the horizontal divergence of the fluxes: !! difft = 1/(e1t*e2t*e3t) dk[ zftw ] !! Add this trend to the general trend (ta,sa): !! pta = pta + difft !! !! ** Action : Update pta arrays with the before rotated diffusion !!---------------------------------------------------------------------- USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released USE oce , ONLY: zftu => ua , zftv => va ! (ua,va) used as workspace USE wrk_nemo, ONLY: zdkt => wrk_2d_1 , zdk1t => wrk_2d_2 , z2d => wrk_2d_3 ! 2D workspace USE wrk_nemo, ONLY: zdit => wrk_3d_1 , zdjt => wrk_3d_2 , ztfw => wrk_3d_3 ! 3D workspace ! INTEGER , INTENT(in ) :: kt ! ocean time-step index CHARACTER(len=3) , INTENT(in ) :: cdtype ! =TRA or TRC (tracer indicator) INTEGER , INTENT(in ) :: kjpt ! number of tracers REAL(wp), DIMENSION(jpi,jpj ,kjpt), INTENT(in ) :: pgu, pgv ! tracer gradient at pstep levels REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in ) :: ptb ! before and now tracer fields REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) :: pta ! tracer trend REAL(wp) , INTENT(in ) :: pahtb0 ! background diffusion coef ! INTEGER :: ji, jj, jk, jn ! dummy loop indices REAL(wp) :: zmsku, zabe1, zcof1, zcoef3 ! local scalars REAL(wp) :: zmskv, zabe2, zcof2, zcoef4 ! - - REAL(wp) :: zcoef0, zbtr, ztra ! - - #if defined key_diaar5 REAL(wp) :: zztmp ! local scalar #endif !!---------------------------------------------------------------------- IF( wrk_in_use(3, 1,2,3) .OR. wrk_in_use(2, 1,2,3) ) THEN CALL ctl_stop('tra_ldf_iso : requested workspace array unavailable') ; RETURN ENDIF IF( kt == nit000 ) THEN IF(lwp) WRITE(numout,*) IF(lwp) WRITE(numout,*) 'tra_ldf_iso : rotated laplacian diffusion operator on ', cdtype IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' ENDIF ! ! ! =========== DO jn = 1, kjpt ! tracer loop ! ! =========== ! !!---------------------------------------------------------------------- !! I - masked horizontal derivative !!---------------------------------------------------------------------- !!bug ajout.... why? ( 1,jpj,:) and (jpi,1,:) should be sufficient.... zdit (1,:,:) = 0.e0 ; zdit (jpi,:,:) = 0.e0 zdjt (1,:,:) = 0.e0 ; zdjt (jpi,:,:) = 0.e0 !!end ! Horizontal tracer gradient DO jk = 1, jpkm1 DO jj = 1, jpjm1 DO ji = 1, fs_jpim1 ! vector opt. zdit(ji,jj,jk) = ( ptb(ji+1,jj ,jk,jn) - ptb(ji,jj,jk,jn) ) * umask(ji,jj,jk) zdjt(ji,jj,jk) = ( ptb(ji ,jj+1,jk,jn) - ptb(ji,jj,jk,jn) ) * vmask(ji,jj,jk) END DO END DO END DO IF( ln_zps ) THEN ! partial steps correction at the last ocean level DO jj = 1, jpjm1 DO ji = 1, fs_jpim1 ! vector opt. zdit(ji,jj,mbku(ji,jj)) = pgu(ji,jj,jn) zdjt(ji,jj,mbkv(ji,jj)) = pgv(ji,jj,jn) END DO END DO ENDIF !!---------------------------------------------------------------------- !! II - horizontal trend (full) !!---------------------------------------------------------------------- !CDIR PARALLEL DO PRIVATE( zdk1t ) ! ! =============== DO jk = 1, jpkm1 ! Horizontal slab ! ! =============== ! 1. Vertical tracer gradient at level jk and jk+1 ! ------------------------------------------------ ! surface boundary condition: zdkt(jk=1)=zdkt(jk=2) zdk1t(:,:) = ( ptb(:,:,jk,jn) - ptb(:,:,jk+1,jn) ) * tmask(:,:,jk+1) ! IF( jk == 1 ) THEN ; zdkt(:,:) = zdk1t(:,:) ELSE ; zdkt(:,:) = ( ptb(:,:,jk-1,jn) - ptb(:,:,jk,jn) ) * tmask(:,:,jk) ENDIF ! 2. Horizontal fluxes ! -------------------- DO jj = 1 , jpjm1 DO ji = 1, fs_jpim1 ! vector opt. zabe1 = ( fsahtu(ji,jj,jk) + pahtb0 ) * e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj) zabe2 = ( fsahtv(ji,jj,jk) + pahtb0 ) * e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj) ! zmsku = 1. / MAX( tmask(ji+1,jj,jk ) + tmask(ji,jj,jk+1) & & + tmask(ji+1,jj,jk+1) + tmask(ji,jj,jk ), 1. ) ! zmskv = 1. / MAX( tmask(ji,jj+1,jk ) + tmask(ji,jj,jk+1) & & + tmask(ji,jj+1,jk+1) + tmask(ji,jj,jk ), 1. ) ! zcof1 = - fsahtu(ji,jj,jk) * e2u(ji,jj) * uslp(ji,jj,jk) * zmsku zcof2 = - fsahtv(ji,jj,jk) * e1v(ji,jj) * vslp(ji,jj,jk) * zmskv ! zftu(ji,jj,jk ) = ( zabe1 * zdit(ji,jj,jk) & & + zcof1 * ( zdkt (ji+1,jj) + zdk1t(ji,jj) & & + zdk1t(ji+1,jj) + zdkt (ji,jj) ) ) * umask(ji,jj,jk) zftv(ji,jj,jk) = ( zabe2 * zdjt(ji,jj,jk) & & + zcof2 * ( zdkt (ji,jj+1) + zdk1t(ji,jj) & & + zdk1t(ji,jj+1) + zdkt (ji,jj) ) ) * vmask(ji,jj,jk) END DO END DO ! II.4 Second derivative (divergence) and add to the general trend ! ---------------------------------------------------------------- DO jj = 2 , jpjm1 DO ji = fs_2, fs_jpim1 ! vector opt. zbtr = 1.0 / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) ) ztra = zbtr * ( zftu(ji,jj,jk) - zftu(ji-1,jj,jk) + zftv(ji,jj,jk) - zftv(ji,jj-1,jk) ) pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra END DO END DO ! ! =============== END DO ! End of slab ! ! =============== ! ! "Poleward" diffusive heat or salt transports (T-S case only) IF( cdtype == 'TRA' .AND. ln_diaptr .AND. ( MOD( kt, nn_fptr ) == 0 ) ) THEN IF( jn == jp_tem) htr_ldf(:) = ptr_vj( zftv(:,:,:) ) IF( jn == jp_sal) str_ldf(:) = ptr_vj( zftv(:,:,:) ) ENDIF #if defined key_diaar5 IF( cdtype == 'TRA' .AND. jn == jp_tem ) THEN z2d(:,:) = 0._wp zztmp = rau0 * rcp DO jk = 1, jpkm1 DO jj = 2, jpjm1 DO ji = fs_2, fs_jpim1 ! vector opt. z2d(ji,jj) = z2d(ji,jj) + zftu(ji,jj,jk) END DO END DO END DO z2d(:,:) = zztmp * z2d(:,:) CALL lbc_lnk( z2d, 'U', -1. ) CALL iom_put( "udiff_heattr", z2d ) ! heat transport in i-direction z2d(:,:) = 0._wp DO jk = 1, jpkm1 DO jj = 2, jpjm1 DO ji = fs_2, fs_jpim1 ! vector opt. z2d(ji,jj) = z2d(ji,jj) + zftv(ji,jj,jk) END DO END DO END DO z2d(:,:) = zztmp * z2d(:,:) CALL lbc_lnk( z2d, 'V', -1. ) CALL iom_put( "vdiff_heattr", z2d ) ! heat transport in i-direction END IF #endif !!---------------------------------------------------------------------- !! III - vertical trend of T & S (extra diagonal terms only) !!---------------------------------------------------------------------- ! Local constant initialization ! ----------------------------- ztfw(1,:,:) = 0.e0 ; ztfw(jpi,:,:) = 0.e0 ! Vertical fluxes ! --------------- ! Surface and bottom vertical fluxes set to zero ztfw(:,:, 1 ) = 0.e0 ; ztfw(:,:,jpk) = 0.e0 ! interior (2=