New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 12377 for NEMO/trunk/src/TOP/TRP – NEMO

Ignore:
Timestamp:
2020-02-12T15:39:06+01:00 (4 years ago)
Author:
acc
Message:

The big one. Merging all 2019 developments from the option 1 branch back onto the trunk.

This changeset reproduces 2019/dev_r11943_MERGE_2019 on the trunk using a 2-URL merge
onto a working copy of the trunk. I.e.:

svn merge --ignore-ancestry \

svn+ssh://acc@forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/NEMO/trunk \
svn+ssh://acc@forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/NEMO/branches/2019/dev_r11943_MERGE_2019 ./

The --ignore-ancestry flag avoids problems that may otherwise arise from the fact that
the merge history been trunk and branch may have been applied in a different order but
care has been taken before this step to ensure that all applicable fixes and updates
are present in the merge branch.

The trunk state just before this step has been branched to releases/release-4.0-HEAD
and that branch has been immediately tagged as releases/release-4.0.2. Any fixes
or additions in response to tickets on 4.0, 4.0.1 or 4.0.2 should be done on
releases/release-4.0-HEAD. From now on future 'point' releases (e.g. 4.0.2) will
remain unchanged with periodic releases as needs demand. Note release-4.0-HEAD is a
transitional naming convention. Future full releases, say 4.2, will have a release-4.2
branch which fulfills this role and the first point release (e.g. 4.2.0) will be made
immediately following the release branch creation.

2020 developments can be started from any trunk revision later than this one.

Location:
NEMO/trunk
Files:
1 deleted
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • NEMO/trunk

    • Property svn:externals
      •  

        old new  
        33^/utils/build/mk@HEAD         mk 
        44^/utils/tools@HEAD            tools 
        5 ^/vendors/AGRIF/dev@HEAD      ext/AGRIF 
         5^/vendors/AGRIF/dev_r11615_ENHANCE-04_namelists_as_internalfiles_agrif@HEAD      ext/AGRIF 
        66^/vendors/FCM@HEAD            ext/FCM 
        77^/vendors/IOIPSL@HEAD         ext/IOIPSL 
  • NEMO/trunk/src/TOP/TRP/trcadv.F90

    r11536 r12377  
    5959   INTEGER, PARAMETER ::   np_QCK     = 5   ! QUICK scheme 
    6060    
    61    !! * Substitutions 
    62 #  include "vectopt_loop_substitute.h90" 
    6361   !!---------------------------------------------------------------------- 
    6462   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    6866CONTAINS 
    6967 
    70    SUBROUTINE trc_adv( kt ) 
     68   SUBROUTINE trc_adv( kt, Kbb, Kmm, ptr, Krhs ) 
    7169      !!---------------------------------------------------------------------- 
    7270      !!                  ***  ROUTINE trc_adv  *** 
     
    7472      !! ** Purpose :   compute the ocean tracer advection trend. 
    7573      !! 
    76       !! ** Method  : - Update after tracers (tra) with the advection term following nadv 
    77       !!---------------------------------------------------------------------- 
    78       INTEGER, INTENT(in) ::   kt   ! ocean time-step index 
     74      !! ** Method  : - Update after tracers (tr(Krhs)) with the advection term following nadv 
     75      !!---------------------------------------------------------------------- 
     76      INTEGER                                   , INTENT(in)    :: kt   ! ocean time-step index 
     77      INTEGER                                   , INTENT(in)    :: Kbb, Kmm, Krhs ! time level indices 
     78      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr            ! passive tracers and RHS of tracer equation 
    7979      ! 
    8080      INTEGER ::   jk   ! dummy loop index 
    8181      CHARACTER (len=22) ::   charout 
    82       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zun, zvn, zwn  ! effective velocity 
     82      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zuu, zvv, zww  ! effective velocity 
    8383      !!---------------------------------------------------------------------- 
    8484      ! 
     
    8787      !                                         !==  effective transport  ==! 
    8888      IF( l_offline ) THEN 
    89          zun(:,:,:) = un(:,:,:)                    ! already in (un,vn,wn) 
    90          zvn(:,:,:) = vn(:,:,:) 
    91          zwn(:,:,:) = wn(:,:,:) 
     89         zuu(:,:,:) = uu(:,:,:,Kmm)                ! already in (uu(Kmm),vv(Kmm),ww) 
     90         zvv(:,:,:) = vv(:,:,:,Kmm) 
     91         zww(:,:,:) = ww(:,:,:) 
    9292      ELSE                                         ! build the effective transport 
    93          zun(:,:,jpk) = 0._wp 
    94          zvn(:,:,jpk) = 0._wp 
    95          zwn(:,:,jpk) = 0._wp 
     93         zuu(:,:,jpk) = 0._wp 
     94         zvv(:,:,jpk) = 0._wp 
     95         zww(:,:,jpk) = 0._wp 
    9696         IF( ln_wave .AND. ln_sdw )  THEN 
    9797            DO jk = 1, jpkm1                                                       ! eulerian transport + Stokes Drift 
    98                zun(:,:,jk) = e2u  (:,:) * e3u_n(:,:,jk) * ( un(:,:,jk) + usd(:,:,jk) ) 
    99                zvn(:,:,jk) = e1v  (:,:) * e3v_n(:,:,jk) * ( vn(:,:,jk) + vsd(:,:,jk) ) 
    100                zwn(:,:,jk) = e1e2t(:,:)                 * ( wn(:,:,jk) + wsd(:,:,jk) ) 
     98               zuu(:,:,jk) = e2u  (:,:) * e3u(:,:,jk,Kmm) * ( uu(:,:,jk,Kmm) + usd(:,:,jk) ) 
     99               zvv(:,:,jk) = e1v  (:,:) * e3v(:,:,jk,Kmm) * ( vv(:,:,jk,Kmm) + vsd(:,:,jk) ) 
     100               zww(:,:,jk) = e1e2t(:,:)                   * ( ww(:,:,jk) + wsd(:,:,jk) ) 
    101101            END DO 
    102102         ELSE 
    103103            DO jk = 1, jpkm1 
    104                zun(:,:,jk) = e2u  (:,:) * e3u_n(:,:,jk) * un(:,:,jk)                   ! eulerian transport 
    105                zvn(:,:,jk) = e1v  (:,:) * e3v_n(:,:,jk) * vn(:,:,jk) 
    106                zwn(:,:,jk) = e1e2t(:,:)                 * wn(:,:,jk) 
     104               zuu(:,:,jk) = e2u  (:,:) * e3u(:,:,jk,Kmm) * uu(:,:,jk,Kmm)                   ! eulerian transport 
     105               zvv(:,:,jk) = e1v  (:,:) * e3v(:,:,jk,Kmm) * vv(:,:,jk,Kmm) 
     106               zww(:,:,jk) = e1e2t(:,:)                   * ww(:,:,jk) 
    107107            END DO 
    108108         ENDIF 
    109109         ! 
    110110         IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN                                 ! add z-tilde and/or vvl corrections 
    111             zun(:,:,:) = zun(:,:,:) + un_td(:,:,:) 
    112             zvn(:,:,:) = zvn(:,:,:) + vn_td(:,:,:) 
     111            zuu(:,:,:) = zuu(:,:,:) + un_td(:,:,:) 
     112            zvv(:,:,:) = zvv(:,:,:) + vn_td(:,:,:) 
    113113         ENDIF 
    114114         ! 
    115115         IF( ln_ldfeiv .AND. .NOT. ln_traldf_triad )   &  
    116             &              CALL ldf_eiv_trp( kt, nittrc000, zun, zvn, zwn, 'TRC' )  ! add the eiv transport 
    117          ! 
    118          IF( ln_mle    )   CALL tra_mle_trp( kt, nittrc000, zun, zvn, zwn, 'TRC' )  ! add the mle transport 
     116            &              CALL ldf_eiv_trp( kt, nittrc000, zuu, zvv, zww, 'TRC', Kmm, Krhs )  ! add the eiv transport 
     117         ! 
     118         IF( ln_mle    )   CALL tra_mle_trp( kt, nittrc000, zuu, zvv, zww, 'TRC', Kmm      )  ! add the mle transport 
    119119         ! 
    120120      ENDIF 
     
    123123      ! 
    124124      CASE ( np_CEN )                                 ! Centered : 2nd / 4th order 
    125          CALL tra_adv_cen( kt, nittrc000,'TRC',          zun, zvn, zwn     , trn, tra, jptra, nn_cen_h, nn_cen_v ) 
     125         CALL tra_adv_cen( kt, nittrc000,'TRC',          zuu, zvv, zww,      Kmm, ptr, jptra, Krhs, nn_cen_h, nn_cen_v ) 
    126126      CASE ( np_FCT )                                 ! FCT      : 2nd / 4th order 
    127          CALL tra_adv_fct( kt, nittrc000,'TRC', r2dttrc, zun, zvn, zwn, trb, trn, tra, jptra, nn_fct_h, nn_fct_v ) 
     127         CALL tra_adv_fct( kt, nittrc000,'TRC', r2dttrc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, nn_fct_h, nn_fct_v ) 
    128128      CASE ( np_MUS )                                 ! MUSCL 
    129          CALL tra_adv_mus( kt, nittrc000,'TRC', r2dttrc, zun, zvn, zwn, trb,      tra, jptra        , ln_mus_ups )  
     129         CALL tra_adv_mus( kt, nittrc000,'TRC', r2dttrc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, ln_mus_ups        )  
    130130      CASE ( np_UBS )                                 ! UBS 
    131          CALL tra_adv_ubs( kt, nittrc000,'TRC', r2dttrc, zun, zvn, zwn, trb, trn, tra, jptra          , nn_ubs_v ) 
     131         CALL tra_adv_ubs( kt, nittrc000,'TRC', r2dttrc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, nn_ubs_v          ) 
    132132      CASE ( np_QCK )                                 ! QUICKEST 
    133          CALL tra_adv_qck( kt, nittrc000,'TRC', r2dttrc, zun, zvn, zwn, trb, trn, tra, jptra                     ) 
     133         CALL tra_adv_qck( kt, nittrc000,'TRC', r2dttrc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs                     ) 
    134134      ! 
    135135      END SELECT 
    136136      !                   
    137       IF( ln_ctl ) THEN                         !== print mean trends (used for debugging) 
     137      IF( sn_cfctl%l_prttrc ) THEN        !== print mean trends (used for debugging) 
    138138         WRITE(charout, FMT="('adv ')") 
    139139         CALL prt_ctl_trc_info(charout) 
    140          CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
     140         CALL prt_ctl_trc( tab4d=tr(:,:,:,:,Krhs), mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
    141141      END IF 
    142142      ! 
     
    164164      ! 
    165165      !                                !==  Namelist  ==! 
    166       REWIND( numnat_ref )                   !  namtrc_adv in reference namelist  
    167166      READ  ( numnat_ref, namtrc_adv, IOSTAT = ios, ERR = 901) 
    168167901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_adv in reference namelist' ) 
    169       REWIND( numnat_cfg )                   ! namtrc_adv in configuration namelist 
    170168      READ  ( numnat_cfg, namtrc_adv, IOSTAT = ios, ERR = 902 ) 
    171169902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_adv in configuration namelist' ) 
  • NEMO/trunk/src/TOP/TRP/trcbbl.F90

    r10068 r12377  
    2020   !!    trc_bbl      : update the tracer trends due to the bottom boundary layer (advective and/or diffusive) 
    2121   !!---------------------------------------------------------------------- 
    22    USE oce_trc        ! ocean dynamics and active tracers variables 
     22   USE oce_trc        ! ocean dynamics and passive tracers variables 
    2323   USE trc            ! ocean passive tracers variables 
    2424   USE trd_oce        ! trends: ocean variables 
     
    3636CONTAINS 
    3737 
    38    SUBROUTINE trc_bbl( kt ) 
     38   SUBROUTINE trc_bbl( kt, Kbb, Kmm, ptr, Krhs ) 
    3939      !!---------------------------------------------------------------------- 
    4040      !!                  ***  ROUTINE bbl  *** 
     
    4545      !! 
    4646      !!----------------------------------------------------------------------   
    47       INTEGER, INTENT( in ) ::   kt   ! ocean time-step  
     47      INTEGER,                                    INTENT( in  ) :: kt              ! ocean time-step  
     48      INTEGER,                                    INTENT( in  ) :: Kbb, Kmm, Krhs  ! time level indices 
     49      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr             ! passive tracers and RHS of tracer equation 
    4850      INTEGER :: jn                   ! loop index 
    4951      CHARACTER (len=22) :: charout 
     
    5355      IF( ln_timing )   CALL timing_start('trc_bbl') 
    5456      ! 
    55       IF( .NOT. l_offline .AND. nn_dttrc == 1 ) THEN 
    56          CALL bbl( kt, nittrc000, 'TRC' )      ! Online coupling with dynamics  : Computation of bbl coef and bbl transport 
    57          l_bbl = .FALSE.                       ! Offline coupling with dynamics : Read bbl coef and bbl transport from input files 
     57      IF( .NOT. l_offline ) THEN 
     58         CALL bbl( kt, nittrc000, 'TRC', Kbb, Kmm )  ! Online coupling with dynamics  : Computation of bbl coef and bbl transport 
     59         l_bbl = .FALSE.                             ! Offline coupling with dynamics : Read bbl coef and bbl transport from input files 
    5860      ENDIF 
    5961 
    6062      IF( l_trdtrc )  THEN 
    6163         ALLOCATE( ztrtrd(jpi,jpj,jpk,jptra) ) ! temporary save of trends 
    62          ztrtrd(:,:,:,:)  = tra(:,:,:,:) 
     64         ztrtrd(:,:,:,:)  = ptr(:,:,:,:,Krhs) 
    6365      ENDIF 
    6466 
     
    6668      IF( nn_bbl_ldf == 1 ) THEN 
    6769         ! 
    68          CALL tra_bbl_dif( trb, tra, jptra 
    69          IF( ln_ctl )   THEN 
     70         CALL tra_bbl_dif( ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Krhs), jptra, Kmm 
     71         IF( sn_cfctl%l_prttrc )   THEN 
    7072            WRITE(charout, FMT="(' bbl_dif')")  ;  CALL prt_ctl_trc_info(charout) 
    71             CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
     73            CALL prt_ctl_trc( tab4d=ptr(:,:,:,:,Krhs), mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
    7274         ENDIF 
    7375         ! 
     
    7779      IF( nn_bbl_adv /= 0 ) THEN 
    7880         ! 
    79          CALL tra_bbl_adv( trb, tra, jptra 
    80          IF( ln_ctl )   THEN 
     81         CALL tra_bbl_adv( ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Krhs), jptra, Kmm 
     82         IF( sn_cfctl%l_prttrc )   THEN 
    8183            WRITE(charout, FMT="(' bbl_adv')")  ;  CALL prt_ctl_trc_info(charout) 
    82             CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
     84            CALL prt_ctl_trc( tab4d=ptr(:,:,:,:,Krhs), mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
    8385         ENDIF 
    8486         ! 
     
    8789      IF( l_trdtrc )   THEN                      ! save the horizontal diffusive trends for further diagnostics 
    8890        DO jn = 1, jptra 
    89            ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn) 
    90            CALL trd_tra( kt, 'TRC', jn, jptra_bbl, ztrtrd(:,:,:,jn) ) 
     91           ztrtrd(:,:,:,jn) = ptr(:,:,:,jn,Krhs) - ztrtrd(:,:,:,jn) 
     92           CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_bbl, ztrtrd(:,:,:,jn) ) 
    9193        END DO 
    9294        DEALLOCATE( ztrtrd ) ! temporary save of trends 
  • NEMO/trunk/src/TOP/TRP/trcdmp.F90

    r11536 r12377  
    4444 
    4545   !! * Substitutions 
    46 #  include "vectopt_loop_substitute.h90" 
     46#  include "do_loop_substitute.h90" 
    4747   !!---------------------------------------------------------------------- 
    4848   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    6363 
    6464 
    65    SUBROUTINE trc_dmp( kt ) 
     65   SUBROUTINE trc_dmp( kt, Kbb, Kmm, ptr, Krhs ) 
    6666      !!---------------------------------------------------------------------- 
    6767      !!                   ***  ROUTINE trc_dmp  *** 
     
    7373      !! ** Method  :   Newtonian damping towards trdta computed  
    7474      !!      and add to the general tracer trends: 
    75       !!                     trn = tra + restotr * (trdta - trb) 
     75      !!                     tr(Kmm) = tr(Krhs) + restotr * (trdta - tr(Kbb)) 
    7676      !!         The trend is computed either throughout the water column 
    7777      !!      (nlmdmptr=0) or in area of weak vertical mixing (nlmdmptr=1) or 
    7878      !!      below the well mixed layer (nlmdmptr=2) 
    7979      !! 
    80       !! ** Action  : - update the tracer trends tra with the newtonian  
     80      !! ** Action  : - update the tracer trends tr(:,:,:,:,Krhs) with the newtonian  
    8181      !!                damping trends. 
    8282      !!              - save the trends ('key_trdmxl_trc') 
    8383      !!---------------------------------------------------------------------- 
    84       INTEGER, INTENT(in) ::   kt   ! ocean time-step index 
     84      INTEGER,                                    INTENT(in   ) :: kt              ! ocean time-step index 
     85      INTEGER,                                    INTENT(in   ) :: Kbb, Kmm, Krhs  ! time level indices 
     86      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr             ! passive tracers and RHS of tracer equation 
    8587      ! 
    8688      INTEGER ::   ji, jj, jk, jn, jl   ! dummy loop indices 
     
    100102         DO jn = 1, jptra                                           ! tracer loop 
    101103            !                                                       ! =========== 
    102             IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)    ! save trends  
     104            IF( l_trdtrc ) ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs)    ! save trends  
    103105            ! 
    104106            IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file 
    105107               ! 
    106108               jl = n_trc_index(jn)  
    107                CALL trc_dta( kt, sf_trcdta(jl), rf_trfac(jl), ztrcdta )   ! read tracer data at nit000 
     109               CALL trc_dta( kt, Kmm, sf_trcdta(jl), rf_trfac(jl), ztrcdta )   ! read tracer data at nit000 
    108110               ! 
    109111               SELECT CASE ( nn_zdmp_tr ) 
    110112               ! 
    111113               CASE( 0 )                !==  newtonian damping throughout the water column  ==! 
    112                   DO jk = 1, jpkm1 
    113                      DO jj = 2, jpjm1 
    114                         DO ji = fs_2, fs_jpim1   ! vector opt. 
    115                            tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - trb(ji,jj,jk,jn) ) 
    116                         END DO 
    117                      END DO 
    118                   END DO 
     114                  DO_3D_00_00( 1, jpkm1 ) 
     115                     ptr(ji,jj,jk,jn,Krhs) = ptr(ji,jj,jk,jn,Krhs) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - ptr(ji,jj,jk,jn,Kbb) ) 
     116                  END_3D 
    119117                  ! 
    120118               CASE ( 1 )                !==  no damping in the turbocline (avt > 5 cm2/s)  ==! 
    121                   DO jk = 1, jpkm1 
    122                      DO jj = 2, jpjm1 
    123                         DO ji = fs_2, fs_jpim1   ! vector opt. 
    124                            IF( avt(ji,jj,jk) <= avt_c )  THEN  
    125                               tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - trb(ji,jj,jk,jn) ) 
    126                            ENDIF 
    127                         END DO 
    128                      END DO 
    129                   END DO 
     119                  DO_3D_00_00( 1, jpkm1 ) 
     120                     IF( avt(ji,jj,jk) <= avt_c )  THEN  
     121                        ptr(ji,jj,jk,jn,Krhs) = ptr(ji,jj,jk,jn,Krhs) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - ptr(ji,jj,jk,jn,Kbb) ) 
     122                     ENDIF 
     123                  END_3D 
    130124                  ! 
    131125               CASE ( 2 )               !==  no damping in the mixed layer   ==!  
    132                   DO jk = 1, jpkm1 
    133                      DO jj = 2, jpjm1 
    134                         DO ji = fs_2, fs_jpim1   ! vector opt. 
    135                            IF( gdept_n(ji,jj,jk) >= hmlp (ji,jj) ) THEN 
    136                               tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - trb(ji,jj,jk,jn) ) 
    137                            END IF 
    138                         END DO 
    139                      END DO 
    140                   END DO 
     126                  DO_3D_00_00( 1, jpkm1 ) 
     127                     IF( gdept(ji,jj,jk,Kmm) >= hmlp (ji,jj) ) THEN 
     128                        ptr(ji,jj,jk,jn,Krhs) = ptr(ji,jj,jk,jn,Krhs) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - ptr(ji,jj,jk,jn,Kbb) ) 
     129                     END IF 
     130                  END_3D 
    141131                  !   
    142132               END SELECT 
     
    145135            ! 
    146136            IF( l_trdtrc ) THEN 
    147                ztrtrd(:,:,:) = tra(:,:,:,jn) -  ztrtrd(:,:,:) 
    148                CALL trd_tra( kt, 'TRC', jn, jptra_dmp, ztrtrd ) 
     137               ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs) -  ztrtrd(:,:,:) 
     138               CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_dmp, ztrtrd ) 
    149139            END IF 
    150140            !                                                       ! =========== 
     
    156146      IF( l_trdtrc )  DEALLOCATE( ztrtrd ) 
    157147      !                                          ! print mean trends (used for debugging) 
    158       IF( ln_ctl ) THEN 
     148      IF( sn_cfctl%l_prttrc ) THEN 
    159149         WRITE(charout, FMT="('dmp ')") 
    160150         CALL prt_ctl_trc_info(charout) 
    161          CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
     151         CALL prt_ctl_trc( tab4d=ptr(:,:,:,:,Krhs), mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
    162152      ENDIF 
    163153      ! 
     
    181171      !!---------------------------------------------------------------------- 
    182172      ! 
    183       REWIND( numnat_ref )              ! Namelist namtrc_dmp in reference namelist : Passive tracers newtonian damping 
    184173      READ  ( numnat_ref, namtrc_dmp, IOSTAT = ios, ERR = 909) 
    185174909   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_dmp in reference namelist' ) 
    186       REWIND( numnat_cfg )              ! Namelist namtrc_dmp in configuration namelist : Passive tracers newtonian damping 
    187175      READ  ( numnat_cfg, namtrc_dmp, IOSTAT = ios, ERR = 910) 
    188176910   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_dmp in configuration namelist' ) 
     
    224212 
    225213 
    226    SUBROUTINE trc_dmp_clo( kt ) 
     214   SUBROUTINE trc_dmp_clo( kt, Kbb, Kmm ) 
    227215      !!--------------------------------------------------------------------- 
    228216      !!                  ***  ROUTINE trc_dmp_clo  *** 
     
    236224      !!                nctsi2(), nctsj2() : north-east Closed sea limits (i,j) 
    237225      !!---------------------------------------------------------------------- 
    238       INTEGER, INTENT( in ) ::   kt      ! ocean time-step index 
     226      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index 
     227      INTEGER, INTENT( in ) ::   Kbb, Kmm     ! time level indices 
    239228      ! 
    240229      INTEGER :: ji , jj, jk, jn, jl, jc                    ! dummy loop indicesa 
     
    354343            IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file 
    355344                jl = n_trc_index(jn) 
    356                 CALL trc_dta( kt, sf_trcdta(jl), rf_trfac(jl), ztrcdta )   ! read tracer data at nit000 
     345                CALL trc_dta( kt, Kmm, sf_trcdta(jl), rf_trfac(jl), ztrcdta )   ! read tracer data at nit000 
    357346                DO jc = 1, npncts 
    358347                   DO jk = 1, jpkm1 
    359348                      DO jj = nctsj1(jc), nctsj2(jc) 
    360349                         DO ji = nctsi1(jc), nctsi2(jc) 
    361                             trn(ji,jj,jk,jn) = ztrcdta(ji,jj,jk) 
    362                             trb(ji,jj,jk,jn) = trn(ji,jj,jk,jn) 
     350                            tr(ji,jj,jk,jn,Kmm) = ztrcdta(ji,jj,jk) 
     351                            tr(ji,jj,jk,jn,Kbb) = tr(ji,jj,jk,jn,Kmm) 
    363352                         END DO 
    364353                      END DO 
  • NEMO/trunk/src/TOP/TRP/trcldf.F90

    r11536 r12377  
    4343    
    4444   !! * Substitutions 
    45 #  include "vectopt_loop_substitute.h90" 
     45#  include "do_loop_substitute.h90" 
    4646   !!---------------------------------------------------------------------- 
    4747   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    5151CONTAINS 
    5252 
    53    SUBROUTINE trc_ldf( kt ) 
     53   SUBROUTINE trc_ldf( kt, Kbb, Kmm, ptr, Krhs ) 
    5454      !!---------------------------------------------------------------------- 
    5555      !!                  ***  ROUTINE tra_ldf  *** 
     
    5858      !! 
    5959      !!---------------------------------------------------------------------- 
    60       INTEGER, INTENT( in ) ::   kt   ! ocean time-step index 
     60      INTEGER,                                    INTENT(in   ) :: kt              ! ocean time-step index 
     61      INTEGER,                                    INTENT(in   ) :: Kbb, Kmm, Krhs  ! ocean time-level index 
     62      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr             ! passive tracers and RHS of tracer equation 
    6163      ! 
    6264      INTEGER            :: ji, jj, jk, jn 
    6365      REAL(wp)           :: zdep 
    6466      CHARACTER (len=22) :: charout 
    65       REAL(wp), DIMENSION(jpi,jpj,jpk)  ::   zahu, zahv 
    66       REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd 
     67      REAL(wp),          DIMENSION(jpi,jpj,jpk) ::   zahu, zahv 
     68      REAL(wp), POINTER, DIMENSION(:,:,:,:)     ::   ztrtrd 
    6769      !!---------------------------------------------------------------------- 
    6870      ! 
     
    7375      IF( l_trdtrc )  THEN 
    7476         ALLOCATE( ztrtrd(jpi,jpj,jpk,jptra) ) 
    75          ztrtrd(:,:,:,:)  = tra(:,:,:,:) 
     77         ztrtrd(:,:,:,:)  = ptr(:,:,:,:,Krhs) 
    7678      ENDIF 
    7779      !                                  !* set the lateral diffusivity coef. for passive tracer       
     
    7981      zahv(:,:,:) = rldf * ahtv(:,:,:) 
    8082      !                                  !* Enhanced zonal diffusivity coefficent in the equatorial domain 
    81       DO jk= 1, jpk 
    82          DO jj = 1, jpj 
    83             DO ji = 1, jpi 
    84                IF( gdept_n(ji,jj,jk) > 200. .AND. gphit(ji,jj) < 5. .AND. gphit(ji,jj) > -5. ) THEN 
    85                   zdep = MAX( gdept_n(ji,jj,jk) - 1000., 0. ) / 1000. 
    86                   zahu(ji,jj,jk) = zahu(ji,jj,jk) * MAX( 1., rn_fact_lap * EXP( -zdep ) ) 
    87                ENDIF 
    88             END DO 
    89          END DO 
    90       END DO 
     83      DO_3D_11_11( 1, jpk ) 
     84         IF( gdept(ji,jj,jk,Kmm) > 200. .AND. gphit(ji,jj) < 5. .AND. gphit(ji,jj) > -5. ) THEN 
     85            zdep = MAX( gdept(ji,jj,jk,Kmm) - 1000., 0. ) / 1000. 
     86            zahu(ji,jj,jk) = zahu(ji,jj,jk) * MAX( 1., rn_fact_lap * EXP( -zdep ) ) 
     87         ENDIF 
     88      END_3D 
    9189      ! 
    9290      SELECT CASE ( nldf_trc )                 !* compute lateral mixing trend and add it to the general trend 
    9391      ! 
    94       CASE ( np_lap   )                               ! iso-level laplacian 
    95          CALL tra_ldf_lap  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb,      tra, jptra,    1     ) 
    96       CASE ( np_lap_i )                               ! laplacian : standard iso-neutral operator (Madec) 
    97          CALL tra_ldf_iso  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,    1     ) 
    98       CASE ( np_lap_it )                              ! laplacian : triad iso-neutral operator (griffies) 
    99          CALL tra_ldf_triad( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,    1     ) 
    100       CASE ( np_blp , np_blp_i , np_blp_it )          ! bilaplacian: all operator (iso-level, -neutral) 
    101          CALL tra_ldf_blp  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb     , tra, jptra, nldf_trc ) 
     92      CASE ( np_lap   )                                                                                    ! iso-level laplacian 
     93         CALL tra_ldf_lap  ( kt, Kmm, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi,            & 
     94           &                     ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Krhs),                   jptra, 1 ) 
     95      CASE ( np_lap_i )                                                                                    ! laplacian : standard iso-neutral operator (Madec) 
     96         CALL tra_ldf_iso  ( kt, Kmm, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi,            & 
     97           &                     ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Krhs), jptra, 1 ) 
     98      CASE ( np_lap_it )                                                                                   ! laplacian : triad iso-neutral operator (griffies) 
     99         CALL tra_ldf_triad( kt, Kmm, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi,            & 
     100           &                     ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Krhs), jptra, 1 ) 
     101      CASE ( np_blp , np_blp_i , np_blp_it )                                                               ! bilaplacian: all operator (iso-level, -neutral) 
     102         CALL tra_ldf_blp  ( kt, Kmm, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi,            & 
     103           &                     ptr(:,:,:,:,Kbb) , ptr(:,:,:,:,Krhs),                 jptra, nldf_trc ) 
    102104      END SELECT 
    103105      ! 
    104106      IF( l_trdtrc )   THEN                    ! send the trends for further diagnostics 
    105107        DO jn = 1, jptra 
    106            ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn) 
    107            CALL trd_tra( kt, 'TRC', jn, jptra_ldf, ztrtrd(:,:,:,jn) ) 
     108           ztrtrd(:,:,:,jn) = ptr(:,:,:,jn,Krhs) - ztrtrd(:,:,:,jn) 
     109           CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_ldf, ztrtrd(:,:,:,jn) ) 
    108110        END DO 
    109111        DEALLOCATE( ztrtrd ) 
    110112      ENDIF 
    111113      !                 
    112       IF( ln_ctl ) THEN                        ! print mean trends (used for debugging) 
     114      IF( sn_cfctl%l_prttrc ) THEN ! print mean trends (used for debugging) 
    113115         WRITE(charout, FMT="('ldf ')") 
    114116         CALL prt_ctl_trc_info(charout) 
    115          CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
     117         CALL prt_ctl_trc( tab4d=ptr(:,:,:,:,Krhs), mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
    116118      ENDIF 
    117119      ! 
     
    143145      ENDIF 
    144146      ! 
    145       REWIND( numnat_ref )             !  namtrc_ldf in reference namelist  
    146147      READ  ( numnat_ref, namtrc_ldf, IOSTAT = ios, ERR = 903) 
    147148903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_ldf in reference namelist' ) 
    148149      ! 
    149       REWIND( numnat_cfg )             !  namtrc_ldf in configuration namelist  
    150150      READ  ( numnat_cfg, namtrc_ldf, IOSTAT = ios, ERR = 904 ) 
    151151904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_ldf in configuration namelist' ) 
     
    167167      IF( ln_trcldf_OFF  ) THEN   ;   nldf_trc = np_no_ldf   ;   ioptio = ioptio + 1   ;   ENDIF 
    168168      IF( ln_trcldf_tra  ) THEN   ;   nldf_trc = nldf_tra    ;   ioptio = ioptio + 1   ;   ENDIF 
    169       IF( ioptio /=  1   )   CALL ctl_stop( 'trc_ldf_ini: use ONE of the 2 operator options (NONE/tra)' ) 
     169      IF( ioptio /=  1   )   CALL ctl_stop( 'trc_ldf_ini: use ONE of the 2 operator options (OFF/tra)' ) 
    170170       
    171171      !                                ! multiplier : passive/active tracers ration 
  • NEMO/trunk/src/TOP/TRP/trcrad.F90

    r11536 r12377  
    66   !! History :   -   !  01-01  (O. Aumont & E. Kestenare)  Original code 
    77   !!            1.0  !  04-03  (C. Ethe)  free form F90 
     8   !!            4.1  !  08-19  (A. Coward, D. Storkey) tidy up using new time-level indices 
    89   !!---------------------------------------------------------------------- 
    910#if defined key_top 
     
    3031   REAL(wp), DIMENSION(:,:), ALLOCATABLE::   gainmass 
    3132 
     33   !! * Substitutions 
     34#  include "do_loop_substitute.h90" 
    3235   !!---------------------------------------------------------------------- 
    3336   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    3740CONTAINS 
    3841 
    39    SUBROUTINE trc_rad( kt ) 
     42   SUBROUTINE trc_rad( kt, Kbb, Kmm, ptr ) 
    4043      !!---------------------------------------------------------------------- 
    4144      !!                  ***  ROUTINE trc_rad  *** 
     
    5255      !!                (the total CFC content is not strictly preserved) 
    5356      !!---------------------------------------------------------------------- 
    54       INTEGER, INTENT(in) ::   kt   ! ocean time-step index 
     57      INTEGER,                                    INTENT(in   ) :: kt         ! ocean time-step index 
     58      INTEGER,                                    INTENT(in   ) :: Kbb, Kmm   ! time level indices 
     59      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr        ! passive tracers and RHS of tracer equation 
    5560      ! 
    5661      CHARACTER (len=22) :: charout 
     
    5964      IF( ln_timing )   CALL timing_start('trc_rad') 
    6065      ! 
    61       IF( ln_age     )   CALL trc_rad_sms( kt, trb, trn, jp_age , jp_age                )  !  AGE 
    62       IF( ll_cfc     )   CALL trc_rad_sms( kt, trb, trn, jp_cfc0, jp_cfc1               )  !  CFC model 
    63       IF( ln_c14     )   CALL trc_rad_sms( kt, trb, trn, jp_c14 , jp_c14                )  !  C14 
    64       IF( ln_pisces  )   CALL trc_rad_sms( kt, trb, trn, jp_pcs0, jp_pcs1, cpreserv='Y' )  !  PISCES model 
    65       IF( ln_my_trc  )   CALL trc_rad_sms( kt, trb, trn, jp_myt0, jp_myt1               )  !  MY_TRC model 
    66       ! 
    67       IF(ln_ctl) THEN      ! print mean trends (used for debugging) 
     66      IF( ln_age     )   CALL trc_rad_sms( kt, Kbb, Kmm, ptr, jp_age , jp_age                )  !  AGE 
     67      IF( ll_cfc     )   CALL trc_rad_sms( kt, Kbb, Kmm, ptr, jp_cfc0, jp_cfc1               )  !  CFC model 
     68      IF( ln_c14     )   CALL trc_rad_sms( kt, Kbb, Kmm, ptr, jp_c14 , jp_c14                )  !  C14 
     69      IF( ln_pisces  )   CALL trc_rad_sms( kt, Kbb, Kmm, ptr, jp_pcs0, jp_pcs1, cpreserv='Y' )  !  PISCES model 
     70      IF( ln_my_trc  )   CALL trc_rad_sms( kt, Kbb, Kmm, ptr, jp_myt0, jp_myt1               )  !  MY_TRC model 
     71      ! 
     72      IF(sn_cfctl%l_prttrc) THEN      ! print mean trends (used for debugging) 
    6873         WRITE(charout, FMT="('rad')") 
    6974         CALL prt_ctl_trc_info( charout ) 
    70          CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm ) 
     75         CALL prt_ctl_trc( tab4d=ptr(:,:,:,:,Kbb), mask=tmask, clinfo=ctrcnm ) 
    7176      ENDIF 
    7277      ! 
     
    8792      !!---------------------------------------------------------------------- 
    8893      ! 
    89       REWIND( numnat_ref )              ! namtrc_rad in reference namelist  
    9094      READ  ( numnat_ref, namtrc_rad, IOSTAT = ios, ERR = 907) 
    9195907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_rad in reference namelist' ) 
    92       REWIND( numnat_cfg )              ! namtrc_rad in configuration namelist  
    9396      READ  ( numnat_cfg, namtrc_rad, IOSTAT = ios, ERR = 908 ) 
    9497908   IF( ios > 0 )   CALL ctl_nam ( ios , 'namtrc_rad in configuration namelist' ) 
     
    113116 
    114117 
    115    SUBROUTINE trc_rad_sms( kt, ptrb, ptrn, jp_sms0, jp_sms1, cpreserv ) 
    116       !!----------------------------------------------------------------------------- 
    117       !!                  ***  ROUTINE trc_rad_sms  *** 
    118       !! 
    119       !! ** Purpose :   "crappy" routine to correct artificial negative 
    120       !!              concentrations due to isopycnal scheme 
    121       !! 
    122       !! ** Method  : 2 cases : 
    123       !!                - Set negative concentrations to zero while computing 
    124       !!                  the corresponding tracer content that is added to the 
    125       !!                  tracers. Then, adjust the tracer concentration using 
    126       !!                  a multiplicative factor so that the total tracer  
    127       !!                  concentration is preserved. 
    128       !!                - simply set to zero the negative CFC concentration 
    129       !!                  (the total content of concentration is not strictly preserved) 
    130       !!-------------------------------------------------------------------------------- 
    131       INTEGER                                , INTENT(in   ) ::   kt                 ! ocean time-step index 
    132       INTEGER                                , INTENT(in   ) ::   jp_sms0, jp_sms1   ! First & last index of the passive tracer model 
    133       REAL(wp), DIMENSION (jpi,jpj,jpk,jptra), INTENT(inout) ::   ptrb    , ptrn     ! before and now traceur concentration 
    134       CHARACTER( len = 1), OPTIONAL          , INTENT(in   ) ::   cpreserv           ! flag to preserve content or not 
    135       ! 
    136       INTEGER ::   ji, ji2, jj, jj2, jk, jn     ! dummy loop indices 
    137       INTEGER ::   icnt 
    138       LOGICAL ::   lldebug = .FALSE.            ! local logical 
    139       REAL(wp)::   zcoef, zs2rdt, ztotmass 
    140       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrneg, ztrpos 
    141       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd   ! workspace arrays 
    142       !!---------------------------------------------------------------------- 
    143       ! 
    144       IF( l_trdtrc )   ALLOCATE( ztrtrd(jpi,jpj,jpk) ) 
    145       zs2rdt = 1. / ( 2. * rdt * REAL( nn_dttrc, wp ) ) 
    146       ! 
    147       IF( PRESENT( cpreserv )  ) THEN     !==  total tracer concentration is preserved  ==! 
    148          ! 
    149          ALLOCATE( ztrneg(1:jpi,1:jpj,jp_sms0:jp_sms1), ztrpos(1:jpi,1:jpj,jp_sms0:jp_sms1) ) 
    150  
    151          DO jn = jp_sms0, jp_sms1 
    152             ztrneg(:,:,jn) = SUM( MIN( 0., ptrb(:,:,:,jn) ) * cvol(:,:,:), dim = 3 )   ! sum of the negative values 
    153             ztrpos(:,:,jn) = SUM( MAX( 0., ptrb(:,:,:,jn) ) * cvol(:,:,:), dim = 3 )   ! sum of the positive values 
    154          END DO 
    155          CALL sum3x3( ztrneg ) 
    156          CALL sum3x3( ztrpos ) 
    157           
    158          DO jn = jp_sms0, jp_sms1 
    159             ! 
    160             IF( l_trdtrc )   ztrtrd(:,:,:) = ptrb(:,:,:,jn)                            ! save input trb for trend computation            
    161             ! 
    162             DO jk = 1, jpkm1 
    163                DO jj = 1, jpj 
    164                   DO ji = 1, jpi 
    165                      IF( ztrneg(ji,jj,jn) /= 0. ) THEN                                 ! if negative values over the 3x3 box 
    166                         ! 
    167                         ptrb(ji,jj,jk,jn) = ptrb(ji,jj,jk,jn) * tmask(ji,jj,jk)   ! really needed? 
    168                         IF( ptrb(ji,jj,jk,jn) < 0. ) ptrb(ji,jj,jk,jn) = 0.       ! supress negative values 
    169                         IF( ptrb(ji,jj,jk,jn) > 0. ) THEN                         ! use positive values to compensate mass gain 
    170                            zcoef = 1. + ztrneg(ji,jj,jn) / ztrpos(ji,jj,jn)       ! ztrpos > 0 as ptrb > 0 
    171                            ptrb(ji,jj,jk,jn) = ptrb(ji,jj,jk,jn) * zcoef 
    172                            IF( zcoef < 0. ) THEN                                  ! if the compensation exceed the positive value 
    173                               gainmass(jn,1) = gainmass(jn,1) - ptrb(ji,jj,jk,jn) * cvol(ji,jj,jk)   ! we are adding mass... 
    174                               ptrb(ji,jj,jk,jn) = 0.                              ! limit the compensation to keep positive value 
    175                            ENDIF 
    176                         ENDIF 
    177                         ! 
    178                      ENDIF 
    179                   END DO 
    180                END DO 
    181             END DO 
    182             ! 
    183             IF( l_trdtrc ) THEN 
    184                ztrtrd(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrd(:,:,:) ) * zs2rdt 
    185                CALL trd_tra( kt, 'TRC', jn, jptra_radb, ztrtrd )       ! Asselin-like trend handling 
    186             ENDIF 
    187             ! 
    188          END DO 
    189   
    190          IF( kt == nitend ) THEN 
    191             CALL mpp_sum( 'trcrad', gainmass(:,1) ) 
    192             DO jn = jp_sms0, jp_sms1 
    193                IF( gainmass(jn,1) > 0. ) THEN 
    194                   ztotmass = glob_sum( 'trcrad', ptrb(:,:,:,jn) * cvol(:,:,:) ) 
    195                   IF(lwp) WRITE(numout, '(a, i2, a, D23.16, a, D23.16)') 'trcrad ptrb, traceur ', jn  & 
    196                      &        , ' total mass : ', ztotmass, ', mass gain : ',  gainmass(jn,1) 
    197                END IF 
    198             END DO 
    199          ENDIF 
    200  
    201          DO jn = jp_sms0, jp_sms1 
    202             ztrneg(:,:,jn) = SUM( MIN( 0., ptrn(:,:,:,jn) ) * cvol(:,:,:), dim = 3 )   ! sum of the negative values 
    203             ztrpos(:,:,jn) = SUM( MAX( 0., ptrn(:,:,:,jn) ) * cvol(:,:,:), dim = 3 )   ! sum of the positive values 
    204          END DO 
    205          CALL sum3x3( ztrneg ) 
    206          CALL sum3x3( ztrpos ) 
    207           
    208          DO jn = jp_sms0, jp_sms1 
    209             ! 
    210             IF( l_trdtrc )   ztrtrd(:,:,:) = ptrn(:,:,:,jn)                            ! save input trb for trend computation 
    211             ! 
    212             DO jk = 1, jpkm1 
    213                DO jj = 1, jpj 
    214                   DO ji = 1, jpi 
    215                      IF( ztrneg(ji,jj,jn) /= 0. ) THEN                                 ! if negative values over the 3x3 box 
    216                         ! 
    217                         ptrn(ji,jj,jk,jn) = ptrn(ji,jj,jk,jn) * tmask(ji,jj,jk)   ! really needed? 
    218                         IF( ptrn(ji,jj,jk,jn) < 0. ) ptrn(ji,jj,jk,jn) = 0.       ! supress negative values 
    219                         IF( ptrn(ji,jj,jk,jn) > 0. ) THEN                         ! use positive values to compensate mass gain 
    220                            zcoef = 1. + ztrneg(ji,jj,jn) / ztrpos(ji,jj,jn)       ! ztrpos > 0 as ptrb > 0 
    221                            ptrn(ji,jj,jk,jn) = ptrn(ji,jj,jk,jn) * zcoef 
    222                            IF( zcoef < 0. ) THEN                                  ! if the compensation exceed the positive value 
    223                               gainmass(jn,2) = gainmass(jn,2) - ptrn(ji,jj,jk,jn) * cvol(ji,jj,jk)   ! we are adding mass... 
    224                               ptrn(ji,jj,jk,jn) = 0.                              ! limit the compensation to keep positive value 
    225                            ENDIF 
    226                         ENDIF 
    227                         ! 
    228                      ENDIF 
    229                   END DO 
    230                END DO 
    231             END DO 
    232             ! 
    233             IF( l_trdtrc ) THEN 
    234                ztrtrd(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrd(:,:,:) ) * zs2rdt 
    235                CALL trd_tra( kt, 'TRC', jn, jptra_radn, ztrtrd )       ! standard     trend handling 
    236             ENDIF 
    237             ! 
    238          END DO 
    239   
    240          IF( kt == nitend ) THEN 
    241             CALL mpp_sum( 'trcrad', gainmass(:,2) ) 
    242             DO jn = jp_sms0, jp_sms1 
    243                IF( gainmass(jn,2) > 0. ) THEN 
    244                   ztotmass = glob_sum( 'trcrad', ptrn(:,:,:,jn) * cvol(:,:,:) ) 
    245                   WRITE(numout, '(a, i2, a, D23.16, a, D23.16)') 'trcrad ptrn, traceur ', jn  & 
    246                      &        , ' total mass : ', ztotmass, ', mass gain : ',  gainmass(jn,1) 
    247                END IF 
    248             END DO 
    249          ENDIF 
    250  
    251          DEALLOCATE( ztrneg, ztrpos ) 
    252          ! 
    253       ELSE                                !==  total CFC content is NOT strictly preserved  ==! 
    254          ! 
    255          DO jn = jp_sms0, jp_sms1   
    256             ! 
    257             IF( l_trdtrc )   ztrtrd(:,:,:) = ptrb(:,:,:,jn)                        ! save input trb for trend computation 
    258             ! 
    259             WHERE( ptrb(:,:,:,jn) < 0. )   ptrb(:,:,:,jn) = 0. 
    260             ! 
    261             IF( l_trdtrc ) THEN 
    262                ztrtrd(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrd(:,:,:) ) * zs2rdt 
    263                CALL trd_tra( kt, 'TRC', jn, jptra_radb, ztrtrd )       ! Asselin-like trend handling 
    264             ENDIF 
    265             ! 
    266             IF( l_trdtrc )   ztrtrd(:,:,:) = ptrn(:,:,:,jn)                        ! save input trn for trend computation 
    267             ! 
    268             WHERE( ptrn(:,:,:,jn) < 0. )   ptrn(:,:,:,jn) = 0. 
    269             ! 
    270             IF( l_trdtrc ) THEN 
    271                ztrtrd(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrd(:,:,:) ) * zs2rdt 
    272                CALL trd_tra( kt, 'TRC', jn, jptra_radn, ztrtrd )       ! standard     trend handling 
    273             ENDIF 
    274             ! 
    275          END DO 
    276          ! 
    277       ENDIF 
     118   SUBROUTINE trc_rad_sms( kt, Kbb, Kmm, ptr, jp_sms0, jp_sms1, cpreserv ) 
     119     !!----------------------------------------------------------------------------- 
     120     !!                  ***  ROUTINE trc_rad_sms  *** 
     121     !! 
     122     !! ** Purpose :   "crappy" routine to correct artificial negative 
     123     !!              concentrations due to isopycnal scheme 
     124     !! 
     125     !! ** Method  : 2 cases : 
     126     !!                - Set negative concentrations to zero while computing 
     127     !!                  the corresponding tracer content that is added to the 
     128     !!                  tracers. Then, adjust the tracer concentration using 
     129     !!                  a multiplicative factor so that the total tracer  
     130     !!                  concentration is preserved. 
     131     !!                - simply set to zero the negative CFC concentration 
     132     !!                  (the total content of concentration is not strictly preserved) 
     133     !!-------------------------------------------------------------------------------- 
     134     INTEGER                                    , INTENT(in   ) ::   kt                 ! ocean time-step index 
     135     INTEGER                                    , INTENT(in   ) ::   Kbb, Kmm           ! time level indices 
     136     INTEGER                                    , INTENT(in   ) ::   jp_sms0, jp_sms1   ! First & last index of the passive tracer model 
     137     REAL(wp), DIMENSION (jpi,jpj,jpk,jptra,jpt), INTENT(inout) ::   ptr                ! before and now traceur concentration 
     138     CHARACTER( len = 1), OPTIONAL              , INTENT(in   ) ::   cpreserv           ! flag to preserve content or not 
     139     ! 
     140     INTEGER ::   ji, ji2, jj, jj2, jk, jn, jt ! dummy loop indices 
     141     INTEGER ::   icnt, itime 
     142     LOGICAL ::   lldebug = .FALSE.            ! local logical 
     143     REAL(wp)::   zcoef, zs2rdt, ztotmass 
     144     REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrneg, ztrpos 
     145     REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd   ! workspace arrays 
     146     !!---------------------------------------------------------------------- 
     147     ! 
     148     IF( l_trdtrc )   ALLOCATE( ztrtrd(jpi,jpj,jpk) ) 
     149     zs2rdt = 1. / ( 2. * rdt ) 
     150     ! 
     151     DO jt = 1,2  ! Loop over time indices since exactly the same fix is applied to "now" and "after" fields 
     152        IF( jt == 1 ) itime = Kbb 
     153        IF( jt == 2 ) itime = Kmm 
     154 
     155        IF( PRESENT( cpreserv )  ) THEN     !==  total tracer concentration is preserved  ==! 
     156           ! 
     157           ALLOCATE( ztrneg(1:jpi,1:jpj,jp_sms0:jp_sms1), ztrpos(1:jpi,1:jpj,jp_sms0:jp_sms1) ) 
     158 
     159           DO jn = jp_sms0, jp_sms1 
     160              ztrneg(:,:,jn) = SUM( MIN( 0., ptr(:,:,:,jn,itime) ) * cvol(:,:,:), dim = 3 )   ! sum of the negative values 
     161              ztrpos(:,:,jn) = SUM( MAX( 0., ptr(:,:,:,jn,itime) ) * cvol(:,:,:), dim = 3 )   ! sum of the positive values 
     162           END DO 
     163           CALL sum3x3( ztrneg ) 
     164           CALL sum3x3( ztrpos ) 
     165 
     166           DO jn = jp_sms0, jp_sms1 
     167              ! 
     168              IF( l_trdtrc )   ztrtrd(:,:,:) = ptr(:,:,:,jn,itime)                       ! save input tr(:,:,:,:,Kbb) for trend computation            
     169              ! 
     170              DO_3D_11_11( 1, jpkm1 ) 
     171                 IF( ztrneg(ji,jj,jn) /= 0. ) THEN                                 ! if negative values over the 3x3 box 
     172                    ! 
     173                    ptr(ji,jj,jk,jn,itime) = ptr(ji,jj,jk,jn,itime) * tmask(ji,jj,jk)   ! really needed? 
     174                    IF( ptr(ji,jj,jk,jn,itime) < 0. ) ptr(ji,jj,jk,jn,itime) = 0.       ! suppress negative values 
     175                    IF( ptr(ji,jj,jk,jn,itime) > 0. ) THEN                    ! use positive values to compensate mass gain 
     176                       zcoef = 1. + ztrneg(ji,jj,jn) / ztrpos(ji,jj,jn)       ! ztrpos > 0 as ptr > 0 
     177                       ptr(ji,jj,jk,jn,itime) = ptr(ji,jj,jk,jn,itime) * zcoef 
     178                       IF( zcoef < 0. ) THEN                                  ! if the compensation exceed the positive value 
     179                          gainmass(jn,1) = gainmass(jn,1) - ptr(ji,jj,jk,jn,itime) * cvol(ji,jj,jk)   ! we are adding mass... 
     180                          ptr(ji,jj,jk,jn,itime) = 0.                         ! limit the compensation to keep positive value 
     181                       ENDIF 
     182                    ENDIF 
     183                    ! 
     184                 ENDIF 
     185              END_3D 
     186              ! 
     187              IF( l_trdtrc ) THEN 
     188                 ztrtrd(:,:,:) = ( ptr(:,:,:,jn,itime) - ztrtrd(:,:,:) ) * zs2rdt 
     189                 CALL trd_tra( kt, Kbb, Kmm, 'TRC', jn, jptra_radb, ztrtrd )       ! Asselin-like trend handling 
     190              ENDIF 
     191              ! 
     192           END DO 
     193 
     194           IF( kt == nitend ) THEN 
     195              CALL mpp_sum( 'trcrad', gainmass(:,1) ) 
     196              DO jn = jp_sms0, jp_sms1 
     197                 IF( gainmass(jn,1) > 0. ) THEN 
     198                    ztotmass = glob_sum( 'trcrad', ptr(:,:,:,jn,itime) * cvol(:,:,:) ) 
     199                    IF(lwp) WRITE(numout, '(a, i2, a, D23.16, a, D23.16)') 'trcrad ptrb, traceur ', jn  & 
     200                         &        , ' total mass : ', ztotmass, ', mass gain : ',  gainmass(jn,1) 
     201                 END IF 
     202              END DO 
     203           ENDIF 
     204 
     205           DEALLOCATE( ztrneg, ztrpos ) 
     206           ! 
     207        ELSE                                !==  total CFC content is NOT strictly preserved  ==! 
     208           ! 
     209           DO jn = jp_sms0, jp_sms1   
     210              ! 
     211              IF( l_trdtrc )   ztrtrd(:,:,:) = ptr(:,:,:,jn,itime)                 ! save input tr for trend computation 
     212              ! 
     213              WHERE( ptr(:,:,:,jn,itime) < 0. )   ptr(:,:,:,jn,itime) = 0. 
     214              ! 
     215              IF( l_trdtrc ) THEN 
     216                 ztrtrd(:,:,:) = ( ptr(:,:,:,jn,itime) - ztrtrd(:,:,:) ) * zs2rdt 
     217                 CALL trd_tra( kt, Kbb, Kmm, 'TRC', jn, jptra_radb, ztrtrd )       ! Asselin-like trend handling 
     218              ENDIF 
     219              ! 
     220           END DO 
     221           ! 
     222        ENDIF 
     223        ! 
     224      END DO 
    278225      ! 
    279226      IF( l_trdtrc )  DEALLOCATE( ztrtrd ) 
     
    286233   !!---------------------------------------------------------------------- 
    287234CONTAINS 
    288    SUBROUTINE trc_rad( kt )              ! Empty routine 
     235   SUBROUTINE trc_rad( kt, Kbb, Kmm )              ! Empty routine 
    289236      INTEGER, INTENT(in) ::   kt 
     237      INTEGER, INTENT(in) ::   Kbb, Kmm  ! time level indices 
    290238      WRITE(*,*) 'trc_rad: You should not have seen this print! error?', kt 
    291239   END SUBROUTINE trc_rad 
  • NEMO/trunk/src/TOP/TRP/trcsbc.F90

    r10788 r12377  
    2929 
    3030   !! * Substitutions 
    31 #  include "vectopt_loop_substitute.h90" 
     31#  include "do_loop_substitute.h90" 
    3232   !!---------------------------------------------------------------------- 
    3333   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    3737CONTAINS 
    3838 
    39    SUBROUTINE trc_sbc ( kt ) 
     39   SUBROUTINE trc_sbc ( kt, Kmm, ptr, Krhs ) 
    4040      !!---------------------------------------------------------------------- 
    4141      !!                  ***  ROUTINE trc_sbc  *** 
     
    4949      !!            The surface freshwater flux modify the ocean volume 
    5050      !!         and thus the concentration of a tracer as : 
    51       !!            tra = tra + emp * trn / e3t   for k=1 
     51      !!            tr(Krhs) = tr(Krhs) + emp * tr(Kmm) / e3t   for k=1 
    5252      !!         where emp, the surface freshwater budget (evaporation minus 
    5353      !!         precipitation ) given in kg/m2/s is divided 
    5454      !!         by 1035 kg/m3 (density of ocean water) to obtain m/s. 
    5555      !! 
    56       !! ** Action  : - Update the 1st level of tra with the trend associated 
     56      !! ** Action  : - Update the 1st level of tr(:,:,:,:,Krhs) with the trend associated 
    5757      !!                with the tracer surface boundary condition  
    5858      !! 
    5959      !!---------------------------------------------------------------------- 
    60       INTEGER, INTENT(in) ::   kt   ! ocean time-step index 
     60      INTEGER,                                    INTENT(in   ) :: kt        ! ocean time-step index 
     61      INTEGER,                                    INTENT(in   ) :: Kmm, Krhs ! time level indices 
     62      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr       ! passive tracers and RHS of tracer equation 
    6163      ! 
    6264      INTEGER  ::   ji, jj, jn                      ! dummy loop indices 
     
    8284         IF( ln_rsttr .AND. .NOT.ln_top_euler .AND.   &                     ! Restart: read in restart  file 
    8385            iom_varid( numrtr, 'sbc_'//TRIM(ctrcnm(1))//'_b', ldstop = .FALSE. ) > 0 ) THEN 
    84             IF(lwp) WRITE(numout,*) '          nittrc000-nn_dttrc surface tracer content forcing fields red in the restart file' 
     86            IF(lwp) WRITE(numout,*) '          nittrc000-1 surface tracer content forcing fields read in the restart file' 
    8587            zfact = 0.5_wp 
    8688            DO jn = 1, jptra 
     
    102104      ENDIF 
    103105 
    104       ! Coupling online : river runoff is added to the horizontal divergence (hdivn) in the subroutine sbc_rnf_div  
     106      ! Coupling online : river runoff is added to the horizontal divergence (hdiv) in the subroutine sbc_rnf_div  
    105107      ! one only consider the concentration/dilution effect due to evaporation minus precipitation + freezing/melting of sea-ice 
    106108      ! Coupling offline : runoff are in emp which contains E-P-R 
     
    118120         ! 
    119121         DO jn = 1, jptra 
    120             DO jj = 2, jpj 
    121                DO ji = fs_2, fs_jpim1   ! vector opt. 
    122                   sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rau0 * trn(ji,jj,1,jn) 
    123                END DO 
    124             END DO 
     122            DO_2D_01_00 
     123               sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rau0 * ptr(ji,jj,1,jn,Kmm) 
     124            END_2D 
    125125         END DO 
    126126         ! 
     
    128128         ! 
    129129         DO jn = 1, jptra 
    130             DO jj = 2, jpj 
    131                DO ji = fs_2, fs_jpim1   ! vector opt. 
    132                   sbc_trc(ji,jj,jn) = ( zsfx(ji,jj) + fmmflx(ji,jj) ) * r1_rau0 * trn(ji,jj,1,jn) 
    133                END DO 
    134             END DO 
     130            DO_2D_01_00 
     131               sbc_trc(ji,jj,jn) = ( zsfx(ji,jj) + fmmflx(ji,jj) ) * r1_rau0 * ptr(ji,jj,1,jn,Kmm) 
     132            END_2D 
    135133         END DO 
    136134         ! 
     
    138136         ! 
    139137         DO jn = 1, jptra 
    140             DO jj = 2, jpj 
    141                DO ji = fs_2, fs_jpim1   ! vector opt. 
    142                   zse3t = 1. / e3t_n(ji,jj,1) 
    143                   ! tracer flux at the ice/ocean interface (tracer/m2/s) 
    144                   zftra = - trc_i(ji,jj,jn) * fmmflx(ji,jj) ! uptake of tracer in the sea ice 
    145                   !                                         ! only used in the levitating sea ice case 
    146                   ! tracer flux only       : add concentration dilution term in net tracer flux, no F-M in volume flux 
    147                   ! tracer and mass fluxes : no concentration dilution term in net tracer flux, F-M term in volume flux 
    148                   ztfx  = zftra                        ! net tracer flux 
    149                   ! 
    150                   zdtra = r1_rau0 * ( ztfx + ( zsfx(ji,jj) + fmmflx(ji,jj) ) * trn(ji,jj,1,jn) )  
    151                   IF ( zdtra < 0. ) THEN 
    152                      zdtra  = MAX(zdtra, -trn(ji,jj,1,jn) * e3t_n(ji,jj,1) / r2dttrc )   ! avoid negative concentrations to arise 
    153                   ENDIF 
    154                   sbc_trc(ji,jj,jn) =  zdtra  
    155                END DO 
    156             END DO 
     138            DO_2D_01_00 
     139               zse3t = 1. / e3t(ji,jj,1,Kmm) 
     140               ! tracer flux at the ice/ocean interface (tracer/m2/s) 
     141               zftra = - trc_i(ji,jj,jn) * fmmflx(ji,jj) ! uptake of tracer in the sea ice 
     142               !                                         ! only used in the levitating sea ice case 
     143               ! tracer flux only       : add concentration dilution term in net tracer flux, no F-M in volume flux 
     144               ! tracer and mass fluxes : no concentration dilution term in net tracer flux, F-M term in volume flux 
     145               ztfx  = zftra                        ! net tracer flux 
     146               ! 
     147               zdtra = r1_rau0 * ( ztfx + ( zsfx(ji,jj) + fmmflx(ji,jj) ) * ptr(ji,jj,1,jn,Kmm) )  
     148               IF ( zdtra < 0. ) THEN 
     149                  zdtra  = MAX(zdtra, -ptr(ji,jj,1,jn,Kmm) * e3t(ji,jj,1,Kmm) / r2dttrc )   ! avoid negative concentrations to arise 
     150               ENDIF 
     151               sbc_trc(ji,jj,jn) =  zdtra  
     152            END_2D 
    157153         END DO 
    158154      END SELECT 
     
    162158      DO jn = 1, jptra 
    163159         ! 
    164          IF( l_trdtrc )   ztrtrd(:,:,:) = tra(:,:,:,jn)  ! save trends 
    165          ! 
    166          DO jj = 2, jpj 
    167             DO ji = fs_2, fs_jpim1   ! vector opt. 
    168                zse3t = zfact / e3t_n(ji,jj,1) 
    169                tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t 
    170             END DO 
    171          END DO 
     160         IF( l_trdtrc )   ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs)  ! save trends 
     161         ! 
     162         DO_2D_01_00 
     163            zse3t = zfact / e3t(ji,jj,1,Kmm) 
     164            ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t 
     165         END_2D 
    172166         ! 
    173167         IF( l_trdtrc ) THEN 
    174             ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:) 
    175             CALL trd_tra( kt, 'TRC', jn, jptra_nsr, ztrtrd ) 
     168            ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs) - ztrtrd(:,:,:) 
     169            CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_nsr, ztrtrd ) 
    176170         END IF 
    177171         !                                                       ! =========== 
     
    191185      ENDIF 
    192186      ! 
    193       IF( ln_ctl )   THEN 
     187      IF( sn_cfctl%l_prttrc )   THEN 
    194188         WRITE(charout, FMT="('sbc ')") ;  CALL prt_ctl_trc_info(charout) 
    195                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
     189                                           CALL prt_ctl_trc( tab4d=ptr(:,:,:,:,Krhs), mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
    196190      ENDIF 
    197191      IF( l_trdtrc )  DEALLOCATE( ztrtrd ) 
     
    205199   !!   Dummy module :                      NO passive tracer 
    206200   !!---------------------------------------------------------------------- 
     201   USE par_oce 
     202   USE par_trc 
    207203CONTAINS 
    208    SUBROUTINE trc_sbc (kt)              ! Empty routine 
    209       INTEGER, INTENT(in) :: kt 
     204   SUBROUTINE trc_sbc ( kt, Kmm, ptr, Krhs )      ! Empty routine 
     205      INTEGER,                                    INTENT(in   ) :: kt        ! ocean time-step index 
     206      INTEGER,                                    INTENT(in   ) :: Kmm, Krhs ! time level indices 
     207      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr       ! passive tracers and RHS of tracer equation 
    210208      WRITE(*,*) 'trc_sbc: You should not have seen this print! error?', kt 
    211209   END SUBROUTINE trc_sbc 
  • NEMO/trunk/src/TOP/TRP/trcsink.F90

    r11536 r12377  
    2424   INTEGER, PUBLIC :: nitermax      !: Maximum number of iterations for sinking 
    2525 
     26   !! * Substitutions 
     27#  include "do_loop_substitute.h90" 
    2628   !!---------------------------------------------------------------------- 
    2729   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    3537   !!---------------------------------------------------------------------- 
    3638 
    37    SUBROUTINE trc_sink ( kt, pwsink, psinkflx, jp_tra, rsfact ) 
     39   SUBROUTINE trc_sink ( kt, Kbb, Kmm, pwsink, psinkflx, jp_tra, rsfact ) 
    3840      !!--------------------------------------------------------------------- 
    3941      !!                     ***  ROUTINE trc_sink  *** 
     
    4547      !!--------------------------------------------------------------------- 
    4648      INTEGER , INTENT(in)  :: kt 
     49      INTEGER , INTENT(in)  :: Kbb, Kmm 
    4750      INTEGER , INTENT(in)  :: jp_tra    ! tracer index index       
    4851      REAL(wp), INTENT(in)  :: rsfact    ! time step duration 
     
    7073         iiter(:,:) = 1 
    7174      ELSE 
    72          DO jj = 1, jpj 
    73             DO ji = 1, jpi 
    74                iiter(ji,jj) = 1 
    75                DO jk = 1, jpkm1 
    76                   IF( tmask(ji,jj,jk) == 1.0 ) THEN 
    77                       zwsmax =  0.5 * e3t_n(ji,jj,jk) * rday / rsfact 
    78                       iiter(ji,jj) =  MAX( iiter(ji,jj), INT( pwsink(ji,jj,jk) / zwsmax ) ) 
    79                   ENDIF 
    80                END DO 
    81             END DO 
    82          END DO 
     75         DO_2D_11_11 
     76            iiter(ji,jj) = 1 
     77            DO jk = 1, jpkm1 
     78               IF( tmask(ji,jj,jk) == 1.0 ) THEN 
     79                   zwsmax =  0.5 * e3t(ji,jj,jk,Kmm) * rday / rsfact 
     80                   iiter(ji,jj) =  MAX( iiter(ji,jj), INT( pwsink(ji,jj,jk) / zwsmax ) ) 
     81               ENDIF 
     82            END DO 
     83         END_2D 
    8384         iiter(:,:) = MIN( iiter(:,:), nitermax ) 
    8485      ENDIF 
    8586 
    86       DO jk = 1,jpkm1 
    87          DO jj = 1, jpj 
    88             DO ji = 1, jpi 
    89                IF( tmask(ji,jj,jk) == 1.0 ) THEN 
    90                  zwsmax = 0.5 * e3t_n(ji,jj,jk) * rday / rsfact 
    91                  zwsink(ji,jj,jk) = MIN( pwsink(ji,jj,jk), zwsmax * REAL( iiter(ji,jj), wp ) ) 
    92                ELSE 
    93                  ! provide a default value so there is no use of undefinite value in trc_sink2 for zwsink2 initialization 
    94                  zwsink(ji,jj,jk) = 0. 
    95                ENDIF 
    96             END DO 
    97          END DO 
    98       END DO 
     87      DO_3D_11_11( 1,jpkm1 ) 
     88         IF( tmask(ji,jj,jk) == 1.0 ) THEN 
     89           zwsmax = 0.5 * e3t(ji,jj,jk,Kmm) * rday / rsfact 
     90           zwsink(ji,jj,jk) = MIN( pwsink(ji,jj,jk), zwsmax * REAL( iiter(ji,jj), wp ) ) 
     91         ELSE 
     92           ! provide a default value so there is no use of undefinite value in trc_sink2 for zwsink2 initialization 
     93           zwsink(ji,jj,jk) = 0. 
     94         ENDIF 
     95      END_3D 
    9996 
    10097      !  Initializa to zero all the sinking arrays  
     
    104101      !   Compute the sedimentation term using trc_sink2 for the considered sinking particle 
    105102      !   ----------------------------------------------------- 
    106       CALL trc_sink2( zwsink, psinkflx, jp_tra, iiter, rsfact ) 
     103      CALL trc_sink2( Kbb, Kmm, zwsink, psinkflx, jp_tra, iiter, rsfact ) 
    107104      ! 
    108105      IF( ln_timing )   CALL timing_stop('trc_sink') 
     
    110107   END SUBROUTINE trc_sink 
    111108 
    112    SUBROUTINE trc_sink2( pwsink, psinkflx, jp_tra, kiter, rsfact ) 
     109   SUBROUTINE trc_sink2( Kbb, Kmm, pwsink, psinkflx, jp_tra, kiter, rsfact ) 
    113110      !!--------------------------------------------------------------------- 
    114111      !!                     ***  ROUTINE trc_sink2  *** 
     
    121118      !!      transport term, i.e.  div(u*tra). 
    122119      !!--------------------------------------------------------------------- 
     120      INTEGER,  INTENT(in   )                         ::   Kbb, Kmm  ! time level indices 
    123121      INTEGER,  INTENT(in   )                         ::   jp_tra    ! tracer index index       
    124122      REAL(wp), INTENT(in   )                         ::   rsfact    ! duration of time step 
     
    136134      ztraz(:,:,:) = 0.e0 
    137135      zakz (:,:,:) = 0.e0 
    138       ztrb (:,:,:) = trb(:,:,:,jp_tra) 
     136      ztrb (:,:,:) = tr(:,:,:,jp_tra,Kbb) 
    139137 
    140138      DO jk = 1, jpkm1 
     
    147145      DO jn = 1, 2 
    148146         !  first guess of the slopes interior values 
    149          DO jj = 1, jpj 
    150             DO ji = 1, jpi 
    151                ! 
    152                zstep = rsfact / REAL( kiter(ji,jj), wp ) / 2. 
    153                !               
    154                DO jk = 2, jpkm1 
    155                   ztraz(ji,jj,jk) = ( trb(ji,jj,jk-1,jp_tra) - trb(ji,jj,jk,jp_tra) ) * tmask(ji,jj,jk) 
    156                END DO 
    157                ztraz(ji,jj,1  ) = 0.0 
    158                ztraz(ji,jj,jpk) = 0.0 
    159  
    160                ! slopes 
    161                DO jk = 2, jpkm1 
    162                   zign = 0.25 + SIGN( 0.25, ztraz(ji,jj,jk) * ztraz(ji,jj,jk+1) ) 
    163                   zakz(ji,jj,jk) = ( ztraz(ji,jj,jk) + ztraz(ji,jj,jk+1) ) * zign 
    164                END DO 
    165           
    166                ! Slopes limitation 
    167                DO jk = 2, jpkm1 
    168                   zakz(ji,jj,jk) = SIGN( 1., zakz(ji,jj,jk) ) *        & 
    169                      &             MIN( ABS( zakz(ji,jj,jk) ), 2. * ABS(ztraz(ji,jj,jk+1)), 2. * ABS(ztraz(ji,jj,jk) ) ) 
    170                END DO 
    171           
    172                ! vertical advective flux 
    173                DO jk = 1, jpkm1 
    174                   zigma = zwsink2(ji,jj,jk+1) * zstep / e3w_n(ji,jj,jk+1) 
    175                   zew   = zwsink2(ji,jj,jk+1) 
    176                   psinkflx(ji,jj,jk+1) = -zew * ( trb(ji,jj,jk,jp_tra) - 0.5 * ( 1 + zigma ) * zakz(ji,jj,jk) ) * zstep 
    177                END DO 
    178                ! 
    179                ! Boundary conditions 
    180                psinkflx(ji,jj,1  ) = 0.e0 
    181                psinkflx(ji,jj,jpk) = 0.e0 
    182           
    183                DO jk=1,jpkm1 
    184                   zflx = ( psinkflx(ji,jj,jk) - psinkflx(ji,jj,jk+1) ) / e3t_n(ji,jj,jk) 
    185                   trb(ji,jj,jk,jp_tra) = trb(ji,jj,jk,jp_tra) + zflx 
    186                END DO 
    187             END DO 
    188          END DO 
     147         DO_2D_11_11 
     148            ! 
     149            zstep = rsfact / REAL( kiter(ji,jj), wp ) / 2. 
     150            !               
     151            DO jk = 2, jpkm1 
     152               ztraz(ji,jj,jk) = ( tr(ji,jj,jk-1,jp_tra,Kbb) - tr(ji,jj,jk,jp_tra,Kbb) ) * tmask(ji,jj,jk) 
     153            END DO 
     154            ztraz(ji,jj,1  ) = 0.0 
     155            ztraz(ji,jj,jpk) = 0.0 
     156 
     157            ! slopes 
     158            DO jk = 2, jpkm1 
     159               zign = 0.25 + SIGN( 0.25, ztraz(ji,jj,jk) * ztraz(ji,jj,jk+1) ) 
     160               zakz(ji,jj,jk) = ( ztraz(ji,jj,jk) + ztraz(ji,jj,jk+1) ) * zign 
     161            END DO 
     162       
     163            ! Slopes limitation 
     164            DO jk = 2, jpkm1 
     165               zakz(ji,jj,jk) = SIGN( 1., zakz(ji,jj,jk) ) *        & 
     166                  &             MIN( ABS( zakz(ji,jj,jk) ), 2. * ABS(ztraz(ji,jj,jk+1)), 2. * ABS(ztraz(ji,jj,jk) ) ) 
     167            END DO 
     168       
     169            ! vertical advective flux 
     170            DO jk = 1, jpkm1 
     171               zigma = zwsink2(ji,jj,jk+1) * zstep / e3w(ji,jj,jk+1,Kmm) 
     172               zew   = zwsink2(ji,jj,jk+1) 
     173               psinkflx(ji,jj,jk+1) = -zew * ( tr(ji,jj,jk,jp_tra,Kbb) - 0.5 * ( 1 + zigma ) * zakz(ji,jj,jk) ) * zstep 
     174            END DO 
     175            ! 
     176            ! Boundary conditions 
     177            psinkflx(ji,jj,1  ) = 0.e0 
     178            psinkflx(ji,jj,jpk) = 0.e0 
     179       
     180            DO jk=1,jpkm1 
     181               zflx = ( psinkflx(ji,jj,jk) - psinkflx(ji,jj,jk+1) ) / e3t(ji,jj,jk,Kmm) 
     182               tr(ji,jj,jk,jp_tra,Kbb) = tr(ji,jj,jk,jp_tra,Kbb) + zflx 
     183            END DO 
     184         END_2D 
    189185      END DO 
    190186 
    191       DO jk = 1,jpkm1 
    192          DO jj = 1,jpj 
    193             DO ji = 1, jpi 
    194                zflx = ( psinkflx(ji,jj,jk) - psinkflx(ji,jj,jk+1) ) / e3t_n(ji,jj,jk) 
    195                ztrb(ji,jj,jk) = ztrb(ji,jj,jk) + 2. * zflx 
    196             END DO 
    197          END DO 
    198       END DO 
    199  
    200       trb(:,:,:,jp_tra) = ztrb(:,:,:) 
     187      DO_3D_11_11( 1,jpkm1 ) 
     188         zflx = ( psinkflx(ji,jj,jk) - psinkflx(ji,jj,jk+1) ) / e3t(ji,jj,jk,Kmm) 
     189         ztrb(ji,jj,jk) = ztrb(ji,jj,jk) + 2. * zflx 
     190      END_3D 
     191 
     192      tr(:,:,:,jp_tra,Kbb) = ztrb(:,:,:) 
    201193      psinkflx(:,:,:)   = 2. * psinkflx(:,:,:) 
    202194      ! 
     
    216208      !!---------------------------------------------------------------------- 
    217209      ! 
    218       REWIND( numnat_ref )              ! namtrc_rad in reference namelist  
    219210      READ  ( numnat_ref, namtrc_snk, IOSTAT = ios, ERR = 907) 
    220211907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_snk in reference namelist' ) 
    221       REWIND( numnat_cfg )              ! namtrc_rad in configuration namelist  
    222212      READ  ( numnat_cfg, namtrc_snk, IOSTAT = ios, ERR = 908 ) 
    223213908   IF( ios > 0 )   CALL ctl_nam ( ios , 'namtrc_snk in configuration namelist' ) 
  • NEMO/trunk/src/TOP/TRP/trctrp.F90

    r10068 r12377  
    2020   USE trcadv          ! advection                           (trc_adv routine) 
    2121   USE trczdf          ! vertical diffusion                  (trc_zdf routine) 
    22    USE trcnxt          ! time-stepping                       (trc_nxt routine) 
     22   USE trcatf          ! time filtering                      (trc_atf routine) 
    2323   USE trcrad          ! positivity                          (trc_rad routine) 
    2424   USE trcsbc          ! surface boundary condition          (trc_sbc routine) 
     25   USE trcbc           ! Tracers boundary condtions          ( trc_bc routine) 
    2526   USE zpshde          ! partial step: hor. derivative       (zps_hde routine) 
    2627   USE bdy_oce   , ONLY: ln_bdy 
     
    4445CONTAINS 
    4546 
    46    SUBROUTINE trc_trp( kt ) 
     47   SUBROUTINE trc_trp( kt, Kbb, Kmm, Krhs, Kaa ) 
    4748      !!---------------------------------------------------------------------- 
    4849      !!                     ***  ROUTINE trc_trp  *** 
     
    5354      !!              - Update the passive tracers 
    5455      !!---------------------------------------------------------------------- 
    55       INTEGER, INTENT( in ) ::  kt  ! ocean time-step index 
     56      INTEGER, INTENT( in ) :: kt                  ! ocean time-step index 
     57      INTEGER, INTENT( in ) :: Kbb, Kmm, Krhs, Kaa ! time level indices (not swapped in this routine) 
    5658      !! --------------------------------------------------------------------- 
    5759      ! 
     
    6062      IF( .NOT. lk_c1d ) THEN 
    6163         ! 
    62                                 CALL trc_sbc    ( kt )      ! surface boundary condition 
    63          IF( ln_trabbl )        CALL trc_bbl    ( kt )      ! advective (and/or diffusive) bottom boundary layer scheme 
    64          IF( ln_trcdmp )        CALL trc_dmp    ( kt )      ! internal damping trends 
    65          IF( ln_bdy )           CALL trc_bdy_dmp( kt )      ! BDY damping trends 
    66                                 CALL trc_adv    ( kt )      ! horizontal & vertical advection  
     64                                CALL trc_sbc    ( kt,      Kmm, tr, Krhs )      ! surface boundary condition 
     65         IF( ln_trcbc .AND. lltrcbc .AND. kt /= nit000 )  & 
     66                                CALL trc_bc     ( kt,      Kmm, tr, Krhs )      ! tracers: surface and lateral Boundary Conditions  
     67         IF( ln_trabbl )        CALL trc_bbl    ( kt, Kbb, Kmm, tr, Krhs )      ! advective (and/or diffusive) bottom boundary layer scheme 
     68         IF( ln_trcdmp )        CALL trc_dmp    ( kt, Kbb, Kmm, tr, Krhs )      ! internal damping trends 
     69         IF( ln_bdy )           CALL trc_bdy_dmp( kt, Kbb,      Krhs )      ! BDY damping trends 
     70                                CALL trc_adv    ( kt, Kbb, Kmm, tr, Krhs )      ! horizontal & vertical advection  
    6771         !                                                         ! Partial top/bottom cell: GRADh( trb )   
    6872         IF( ln_zps ) THEN 
    69            IF( ln_isfcav ) THEN ; CALL zps_hde_isf( kt, jptra, trb, pgtu=gtru, pgtv=gtrv, pgtui=gtrui, pgtvi=gtrvi )  ! both top & bottom 
    70            ELSE                 ; CALL zps_hde    ( kt, jptra, trb, gtru, gtrv )                                      !  only bottom 
     73           IF( ln_isfcav ) THEN ; CALL zps_hde_isf( kt, Kmm, jptra, tr(:,:,:,:,Kbb), pgtu=gtru, pgtv=gtrv, pgtui=gtrui, pgtvi=gtrvi )  ! both top & bottom 
     74           ELSE                 ; CALL zps_hde    ( kt, Kmm, jptra, tr(:,:,:,:,Kbb), gtru, gtrv )                                      !  only bottom 
    7175           ENDIF 
    7276         ENDIF 
    7377         !                                                       
    74                                 CALL trc_ldf    ( kt )      ! lateral mixing 
     78                                CALL trc_ldf    ( kt, Kbb, Kmm,       tr, Krhs )  ! lateral mixing 
    7579#if defined key_agrif 
    7680         IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_trc       ! tracers sponge 
    7781#endif 
    78                                 CALL trc_zdf    ( kt )      ! vertical mixing and after tracer fields 
    79                                 CALL trc_nxt    ( kt )      ! tracer fields at next time step      
    80          IF( ln_trcrad )        CALL trc_rad    ( kt )      ! Correct artificial negative concentrations 
    81          IF( ln_trcdmp_clo )    CALL trc_dmp_clo( kt )      ! internal damping trends on closed seas only 
     82                                CALL trc_zdf    ( kt, Kbb, Kmm, Krhs, tr, Kaa  )  ! vert. mixing & after tracer   ==> after 
     83                                CALL trc_atf    ( kt, Kbb, Kmm, Kaa , tr )        ! time filtering of "now" tracer fields     
     84         ! 
     85         ! Subsequent calls use the filtered values: Kmm and Kaa  
     86         ! These are used explicitly here since time levels will not be swapped until after tra_atf/dyn_atf/ssh_atf in stp 
     87         ! 
     88         IF( ln_trcrad )        CALL trc_rad    ( kt, Kmm, Kaa, tr       )    ! Correct artificial negative concentrations 
     89         IF( ln_trcdmp_clo )    CALL trc_dmp_clo( kt, Kmm, Kaa )              ! internal damping trends on closed seas only 
    8290 
    8391         ! 
    8492      ELSE                                               ! 1D vertical configuration 
    85                                 CALL trc_sbc( kt )            ! surface boundary condition 
    86          IF( ln_trcdmp )        CALL trc_dmp( kt )            ! internal damping trends 
    87                                 CALL trc_zdf( kt )            ! vertical mixing and after tracer fields 
    88                                 CALL trc_nxt( kt )            ! tracer fields at next time step      
    89           IF( ln_trcrad )       CALL trc_rad( kt )            ! Correct artificial negative concentrations 
     93                                CALL trc_sbc( kt,      Kmm,       tr, Krhs )  ! surface boundary condition 
     94         IF( ln_trcdmp )        CALL trc_dmp( kt, Kbb, Kmm,       tr, Krhs )  ! internal damping trends 
     95                                CALL trc_zdf( kt, Kbb, Kmm, Krhs, tr, Kaa  )  ! vert. mixing & after tracer ==> after 
     96                                CALL trc_atf( kt, Kbb, Kmm, Kaa , tr )        ! time filtering of "now" tracer fields 
     97         ! 
     98         ! Subsequent calls use the filtered values: Kmm and Kaa  
     99         ! These are used explicitly here since time levels will not be swapped until after tra_atf/dyn_atf/ssh_atf in stp 
     100         ! 
     101         IF( ln_trcrad )       CALL trc_rad( kt, Kmm, Kaa, tr       )  ! Correct artificial negative concentrations 
    90102         ! 
    91103      END IF 
  • NEMO/trunk/src/TOP/TRP/trczdf.F90

    r10068 r12377  
    3636CONTAINS 
    3737 
    38    SUBROUTINE trc_zdf( kt ) 
     38   SUBROUTINE trc_zdf( kt, Kbb, Kmm, Krhs, ptr, Kaa ) 
    3939      !!---------------------------------------------------------------------- 
    4040      !!                  ***  ROUTINE trc_zdf  *** 
     
    4343      !!              an implicit time-stepping scheme. 
    4444      !!--------------------------------------------------------------------- 
    45       INTEGER, INTENT( in ) ::  kt      ! ocean time-step index 
     45      INTEGER                                   , INTENT(in   ) ::   kt                   ! ocean time-step index 
     46      INTEGER                                   , INTENT(in   ) ::   Kbb, Kmm, Krhs, Kaa  ! ocean time level indices 
     47      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) ::   ptr                  ! passive tracers and RHS of tracer equation 
    4648      ! 
    4749      INTEGER               ::  jk, jn 
     
    5254      IF( ln_timing )   CALL timing_start('trc_zdf') 
    5355      ! 
    54       IF( l_trdtrc )   ztrtrd(:,:,:,:)  = tra(:,:,:,:) 
     56      IF( l_trdtrc )   ztrtrd(:,:,:,:)  = ptr(:,:,:,:,Krhs) 
    5557      ! 
    56       CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dttrc, trb, tra, jptra )    !   implicit scheme           
     58      CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dttrc, Kbb, Kmm, Krhs, ptr, Kaa, jptra )    !   implicit scheme           
    5759      ! 
    5860      IF( l_trdtrc )   THEN                      ! save the vertical diffusive trends for further diagnostics 
    5961         DO jn = 1, jptra 
    6062            DO jk = 1, jpkm1 
    61                ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / r2dttrc ) - ztrtrd(:,:,jk,jn) 
     63               ztrtrd(:,:,jk,jn) = ( ( ptr(:,:,jk,jn,Kaa) - ptr(:,:,jk,jn,Kbb) ) / r2dttrc ) - ztrtrd(:,:,jk,jn) 
    6264            END DO 
    63             CALL trd_tra( kt, 'TRC', jn, jptra_zdf, ztrtrd(:,:,:,jn) ) 
     65            CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_zdf, ztrtrd(:,:,:,jn) ) 
    6466         END DO 
    6567      ENDIF 
    6668      !                                          ! print mean trends (used for debugging) 
    67       IF( ln_ctl )   THEN 
     69      IF( sn_cfctl%l_prttrc )   THEN 
    6870         WRITE(charout, FMT="('zdf ')") 
    6971         CALL prt_ctl_trc_info(charout) 
    70          CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
     72         CALL prt_ctl_trc( tab4d=tr(:,:,:,:,Kaa), mask=tmask, clinfo=ctrcnm, clinfo2='trd' ) 
    7173      END IF 
    7274      ! 
  • NEMO/trunk/src/TOP/TRP/trdmxl_trc.F90

    r11536 r12377  
    1616   !!   trd_mxl_trc_init : initialization step 
    1717   !!---------------------------------------------------------------------- 
    18    USE trc               ! tracer definitions (trn, trb, tra, etc.) 
    19    USE trc_oce, ONLY :   nn_dttrc  ! frequency of step on passive tracers 
     18   USE trc               ! tracer definitions (tr etc.) 
    2019   USE dom_oce           ! domain definition 
    2120   USE zdfmxl  , ONLY : nmln ! number of level in the mixed layer 
     
    5049   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::  ztmltrd2   ! 
    5150 
     51   !! * Substitutions 
     52#  include "do_loop_substitute.h90" 
    5253   !!---------------------------------------------------------------------- 
    5354   !! NEMO/TOP 4.0 , NEMO Consortium (2018) 
     
    7071 
    7172 
    72    SUBROUTINE trd_mxl_trc_zint( ptrc_trdmxl, ktrd, ctype, kjn ) 
     73   SUBROUTINE trd_mxl_trc_zint( ptrc_trdmxl, ktrd, ctype, kjn, Kmm ) 
    7374      !!---------------------------------------------------------------------- 
    7475      !!                  ***  ROUTINE trd_mxl_trc_zint  *** 
     
    9293      !! 
    9394      INTEGER, INTENT( in ) ::   ktrd, kjn                        ! ocean trend index and passive tracer rank 
     95      INTEGER, INTENT( in ) ::   Kmm                              ! time level index 
    9496      CHARACTER(len=2), INTENT( in ) ::  ctype                    ! surface/bottom (2D) or interior (3D) physics 
    9597      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::  ptrc_trdmxl ! passive tracer trend 
     
    122124 
    123125            IF( jpktrd_trc < jpk ) THEN                           ! description ??? 
    124                DO jj = 1, jpj 
    125                   DO ji = 1, jpi 
    126                      IF( nmld_trc(ji,jj) <= jpktrd_trc ) THEN 
    127                         zvlmsk(ji,jj) = tmask(ji,jj,1) 
    128                      ELSE 
    129                         isum = isum + 1 
    130                         zvlmsk(ji,jj) = 0.e0 
    131                      ENDIF 
    132                   END DO 
    133                END DO 
     126               DO_2D_11_11 
     127                  IF( nmld_trc(ji,jj) <= jpktrd_trc ) THEN 
     128                     zvlmsk(ji,jj) = tmask(ji,jj,1) 
     129                  ELSE 
     130                     isum = isum + 1 
     131                     zvlmsk(ji,jj) = 0.e0 
     132                  ENDIF 
     133               END_2D 
    134134            ENDIF 
    135135 
     
    147147         ! ... Weights for vertical averaging 
    148148         wkx_trc(:,:,:) = 0.e0 
    149          DO jk = 1, jpktrd_trc                                    ! initialize wkx_trc with vertical scale factor in mixed-layer 
    150             DO jj = 1, jpj 
    151                DO ji = 1, jpi 
    152                   IF( jk - nmld_trc(ji,jj) < 0 )   wkx_trc(ji,jj,jk) = e3t_n(ji,jj,jk) * tmask(ji,jj,jk) 
    153                END DO 
    154             END DO 
    155          END DO 
     149         DO_3D_11_11( 1, jpktrd_trc ) 
     150            IF( jk - nmld_trc(ji,jj) < 0 )   wkx_trc(ji,jj,jk) = e3t(ji,jj,jk,Kmm) * tmask(ji,jj,jk) 
     151         END_3D 
    156152          
    157153         rmld_trc(:,:) = 0.e0 
     
    183179 
    184180 
    185    SUBROUTINE trd_mxl_trc( kt ) 
     181   SUBROUTINE trd_mxl_trc( kt, Kmm ) 
    186182      !!---------------------------------------------------------------------- 
    187183      !!                  ***  ROUTINE trd_mxl_trc  *** 
     
    232228      ! 
    233229      INTEGER, INTENT(in) ::   kt   ! ocean time-step index 
     230      INTEGER, INTENT(in) ::   Kmm                              ! time level index 
    234231      ! 
    235232      INTEGER ::   ji, jj, jk, jl, ik, it, itmod, jn 
     
    251248 
    252249 
    253       IF( nn_dttrc  /= 1  )   CALL ctl_stop( " Be careful, trends diags never validated " ) 
    254  
    255250      ! ====================================================================== 
    256251      ! I. Diagnose the purely vertical (K_z) diffusion trend 
     
    263258         ! 
    264259         DO jn = 1, jptra 
    265             DO jj = 1, jpj 
    266                DO ji = 1, jpi 
    267                   ik = nmld_trc(ji,jj) 
    268                   IF( ln_trdtrc(jn) )    & 
    269                   tmltrd_trc(ji,jj,jpmxl_trc_zdf,jn) = - avs(ji,jj,ik) / e3w_n(ji,jj,ik) * tmask(ji,jj,ik)  & 
    270                        &                    * ( trn(ji,jj,ik-1,jn) - trn(ji,jj,ik,jn) )            & 
    271                        &                    / MAX( 1., rmld_trc(ji,jj) ) * tmask(ji,jj,1) 
    272                END DO 
    273             END DO 
     260            DO_2D_11_11 
     261               ik = nmld_trc(ji,jj) 
     262               IF( ln_trdtrc(jn) )    & 
     263               tmltrd_trc(ji,jj,jpmxl_trc_zdf,jn) = - avs(ji,jj,ik) / e3w(ji,jj,ik,Kmm) * tmask(ji,jj,ik)  & 
     264                    &                    * ( tr(ji,jj,ik-1,jn,Kmm) - tr(ji,jj,ik,jn,Kmm) )            & 
     265                    &                    / MAX( 1., rmld_trc(ji,jj) ) * tmask(ji,jj,1) 
     266            END_2D 
    274267         END DO 
    275268 
     
    322315         DO jn = 1, jptra 
    323316            IF( ln_trdtrc(jn) ) & 
    324                tml_trc(:,:,jn) = tml_trc(:,:,jn) + wkx_trc(:,:,jk) * trn(:,:,jk,jn) 
     317               tml_trc(:,:,jn) = tml_trc(:,:,jn) + wkx_trc(:,:,jk) * tr(:,:,jk,jn,Kmm) 
    325318         END DO 
    326319      END DO 
     
    328321      ! II.3 Initialize mixed-layer "before" arrays for the 1rst analysis window     
    329322      ! ------------------------------------------------------------------------ 
    330       IF( kt == nittrc000 + nn_dttrc ) THEN  !  i.e. ( .NOT. ln_rstart ).AND.( kt == nit000 + 1)    ??? 
     323      IF( kt == nittrc000 + 1 ) THEN  !  i.e. ( .NOT. ln_rstart ).AND.( kt == nit000 + 1)    ??? 
    331324         ! 
    332325         DO jn = 1, jptra 
     
    870863#  endif 
    871864      zout = nn_trd_trc * rdt 
    872       iiter = ( nittrc000 - 1 ) / nn_dttrc 
     865      iiter = nittrc000 - 1 
    873866 
    874867      IF(lwp) WRITE (numout,*) '                netCDF initialization' 
     
    970963   !!---------------------------------------------------------------------- 
    971964CONTAINS 
    972    SUBROUTINE trd_mxl_trc( kt )                                   ! Empty routine 
     965   SUBROUTINE trd_mxl_trc( kt, Kmm )                                   ! Empty routine 
    973966      INTEGER, INTENT( in) ::   kt 
     967      INTEGER, INTENT( in) ::   Kmm            ! time level index 
    974968      WRITE(*,*) 'trd_mxl_trc: You should not have seen this print! error?', kt 
    975969   END SUBROUTINE trd_mxl_trc 
    976    SUBROUTINE trd_mxl_trc_zint( ptrc_trdmxl, ktrd, ctype, kjn ) 
     970   SUBROUTINE trd_mxl_trc_zint( ptrc_trdmxl, ktrd, ctype, kjn, Kmm ) 
    977971      INTEGER               , INTENT( in ) ::  ktrd, kjn              ! ocean trend index and passive tracer rank 
     972      INTEGER               , INTENT( in ) ::  Kmm                    ! time level index 
    978973      CHARACTER(len=2)      , INTENT( in ) ::  ctype                  ! surface/bottom (2D) or interior (3D) physics 
    979974      REAL, DIMENSION(:,:,:), INTENT( in ) ::  ptrc_trdmxl            ! passive trc trend 
  • NEMO/trunk/src/TOP/TRP/trdmxl_trc_rst.F90

    r10425 r12377  
    1111   USE in_out_manager  ! I/O manager 
    1212   USE iom             ! I/O module 
    13    USE trc             ! for nn_dttrc ctrcnm 
     13   USE trc             ! for ctrcnm 
    1414   USE trdmxl_trc_oce  ! for lk_trdmxl_trc 
    1515 
     
    4444      !!-------------------------------------------------------------------------------- 
    4545 
    46       IF( kt == nitrst - nn_dttrc .OR. nitend - nit000 + 1 < 2 * nn_dttrc ) THEN ! idem trcrst.F90 
     46      IF( kt == nitrst - 1 .OR. nitend - nit000 + 1 < 2 ) THEN ! idem trcrst.F90 
    4747         IF( nitrst > 1.0e9 ) THEN 
    4848            WRITE(clkt,*) nitrst 
  • NEMO/trunk/src/TOP/TRP/trdtrc.F90

    r10096 r12377  
    1313   !!   trdtrc      : passive tracer trends  
    1414   !!---------------------------------------------------------------------- 
    15    USE trc               ! tracer definitions (trn, trb, tra, etc.) 
     15   USE trc               ! tracer definitions (tr(:,:,:,:,Kmm), tr(:,:,:,:,Kbb), tr(:,:,:,:,Krhs), etc.) 
    1616   USE trd_oce 
    1717   USE trdtrc_oce       ! definition of main arrays used for trends computations 
     
    3232CONTAINS 
    3333 
    34    SUBROUTINE trd_trc( ptrtrd, kjn, ktrd, kt ) 
     34   SUBROUTINE trd_trc( ptrtrd, kjn, ktrd, kt, Kmm ) 
    3535      !!---------------------------------------------------------------------- 
    3636      !!                  ***  ROUTINE trd_trc  *** 
    3737      !!---------------------------------------------------------------------- 
    3838      INTEGER, INTENT( in )  ::   kt                                  ! time step 
     39      INTEGER, INTENT( in )  ::   Kmm                                 ! time level index 
    3940      INTEGER, INTENT( in )  ::   kjn                                 ! tracer index 
    4041      INTEGER, INTENT( in )  ::   ktrd                                ! tracer trend index 
     
    5657         ! 
    5758         SELECT CASE ( ktrd ) 
    58          CASE ( jptra_xad     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_xad, '3D', kjn ) 
    59          CASE ( jptra_yad     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_yad, '3D', kjn ) 
    60          CASE ( jptra_zad     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_zad, '3D', kjn ) 
    61          CASE ( jptra_ldf     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_ldf, '3D', kjn ) 
    62          CASE ( jptra_bbl     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_bbl, '3D', kjn ) 
     59         CASE ( jptra_xad     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_xad, '3D', kjn, Kmm ) 
     60         CASE ( jptra_yad     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_yad, '3D', kjn, Kmm ) 
     61         CASE ( jptra_zad     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_zad, '3D', kjn, Kmm ) 
     62         CASE ( jptra_ldf     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_ldf, '3D', kjn, Kmm ) 
     63         CASE ( jptra_bbl     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_bbl, '3D', kjn, Kmm ) 
    6364         CASE ( jptra_zdf     ) 
    6465            IF( ln_trcldf_iso ) THEN 
    65                CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_ldf, '3D', kjn ) 
     66               CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_ldf, '3D', kjn, Kmm ) 
    6667            ELSE 
    67                CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_zdf, '3D', kjn ) 
     68               CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_zdf, '3D', kjn, Kmm ) 
    6869            ENDIF 
    69          CASE ( jptra_dmp     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_dmp , '3D', kjn ) 
    70          CASE ( jptra_nsr     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_sbc , '2D', kjn ) 
    71          CASE ( jptra_sms     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_sms , '3D', kjn ) 
    72          CASE ( jptra_radb    )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_radb, '3D', kjn ) 
    73          CASE ( jptra_radn    )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_radn, '3D', kjn ) 
    74          CASE ( jptra_atf     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_atf , '3D', kjn ) 
     70         CASE ( jptra_dmp     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_dmp , '3D', kjn, Kmm ) 
     71         CASE ( jptra_nsr     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_sbc , '2D', kjn, Kmm ) 
     72         CASE ( jptra_sms     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_sms , '3D', kjn, Kmm ) 
     73         CASE ( jptra_radb    )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_radb, '3D', kjn, Kmm ) 
     74         CASE ( jptra_radn    )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_radn, '3D', kjn, Kmm ) 
     75         CASE ( jptra_atf     )   ;   CALL trd_mxl_trc_zint( ptrtrd, jpmxl_trc_atf , '3D', kjn, Kmm ) 
    7576         END SELECT 
    7677         ! 
     
    110111CONTAINS 
    111112 
    112    SUBROUTINE trd_trc( ptrtrd, kjn, ktrd, kt ) 
     113   SUBROUTINE trd_trc( ptrtrd, kjn, ktrd, kt, Kmm ) 
    113114      INTEGER               , INTENT( in )     ::   kt      ! time step 
     115      INTEGER               , INTENT( in )     ::   Kmm     ! time level index 
    114116      INTEGER               , INTENT( in )     ::   kjn     ! tracer index 
    115117      INTEGER               , INTENT( in )     ::   ktrd    ! tracer trend index 
Note: See TracChangeset for help on using the changeset viewer.