Index: NEMO/trunk/src/TOP/C14/trcsms_c14.F90
===================================================================
--- NEMO/trunk/src/TOP/C14/trcsms_c14.F90	(revision 10069)
+++ NEMO/trunk/src/TOP/C14/trcsms_c14.F90	(revision 12377)
@@ -26,4 +26,6 @@
    PUBLIC   trc_sms_c14       ! called in trcsms.F90
 
+   !! * Substitutions
+#  include "do_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 4.0 , NEMO Consortium (2018)
@@ -33,5 +35,5 @@
 CONTAINS
 
-   SUBROUTINE trc_sms_c14( kt )
+   SUBROUTINE trc_sms_c14( kt, Kbb, Kmm, Krhs )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE trc_sms_c14  ***
@@ -46,11 +48,12 @@
       !            freshwater fluxes which should not impact the C14/C ratio
       !
-      !        =>   Delta-C14= ( trn(...jp_c14) -1)*1000.
+      !        =>   Delta-C14= ( tr(...jp_c14,Kmm) -1)*1000.
       !!
       !!----------------------------------------------------------------------
       !
-      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      INTEGER, INTENT(in) ::   kt               ! ocean time-step index
+      INTEGER, INTENT(in) ::   Kbb, Kmm, Krhs   ! ocean time level
       !
-      INTEGER  :: ji, jj, jk         ! dummy loop indices 
+      INTEGER  :: ji, jj, jk        ! dummy loop indices 
       REAL(wp) :: zt, ztp, zsk      ! dummy variables
       REAL(wp) :: zsol              ! solubility
@@ -77,40 +80,38 @@
       ! -------------------------------------------------------------------
 
-      DO jj = 1, jpj
-         DO ji = 1, jpi  
-            IF( tmask(ji,jj,1) >  0. ) THEN
-               !
-               zt   = MIN( 40. , tsn(ji,jj,1,jp_tem) )
-               !
-               !  Computation of solubility zsol in [mol/(L * atm)]
-               !   after Wanninkhof (2014) referencing Weiss (1974)
-               ztp  = ( zt + 273.16 ) * 0.01
-               zsk  = 0.027766 + ztp * ( -0.025888 + 0.0050578 * ztp )   ! [mol/(L * atm)]
-               zsol = EXP( -58.0931 + 90.5069 / ztp  + 22.2940 * LOG( ztp ) + zsk * tsn(ji,jj,1,jp_sal) )
-               ! convert solubilities [mol/(L * atm)] -> [mol/(m^3 * ppm)]
-               zsol = zsol * 1.e-03
+      DO_2D_11_11
+         IF( tmask(ji,jj,1) >  0. ) THEN
+            !
+            zt   = MIN( 40. , ts(ji,jj,1,jp_tem,Kmm) )
+            !
+            !  Computation of solubility zsol in [mol/(L * atm)]
+            !   after Wanninkhof (2014) referencing Weiss (1974)
+            ztp  = ( zt + 273.16 ) * 0.01
+            zsk  = 0.027766 + ztp * ( -0.025888 + 0.0050578 * ztp )   ! [mol/(L * atm)]
+            zsol = EXP( -58.0931 + 90.5069 / ztp  + 22.2940 * LOG( ztp ) + zsk * ts(ji,jj,1,jp_sal,Kmm) )
+            ! convert solubilities [mol/(L * atm)] -> [mol/(m^3 * ppm)]
+            zsol = zsol * 1.e-03
 
-               ! Computes the Schmidt number of CO2 in seawater
-               !               Wanninkhof-2014
-               zsch = 2116.8 + zt * ( -136.25 + zt * (4.7353 + zt * (-0.092307 + 0.0007555 * zt ) ) )
+            ! Computes the Schmidt number of CO2 in seawater
+            !               Wanninkhof-2014
+            zsch = 2116.8 + zt * ( -136.25 + zt * (4.7353 + zt * (-0.092307 + 0.0007555 * zt ) ) )
 
-               ! Wanninkhof Piston velocity: zpv in units [m/s]
-               zv2 = xkwind * (wndm(ji,jj) * wndm(ji,jj))              ! wind speed module at T points
-               ! chemical enhancement (Wanninkhof & Knox, 1996)
-               IF( ln_chemh ) zv2 = zv2 + 2.5 * ( 0.5246 + zt * (0.016256 + 0.00049946  * zt ) )
-               zv2 = zv2/360000._wp                                    ! conversion cm/h -> m/s
-               !
-               zpv  = ( zv2 * SQRT( 660./ zsch ) ) * ( 1. - fr_i(ji,jj) ) * tmask(ji,jj,1)
+            ! Wanninkhof Piston velocity: zpv in units [m/s]
+            zv2 = xkwind * (wndm(ji,jj) * wndm(ji,jj))              ! wind speed module at T points
+            ! chemical enhancement (Wanninkhof & Knox, 1996)
+            IF( ln_chemh ) zv2 = zv2 + 2.5 * ( 0.5246 + zt * (0.016256 + 0.00049946  * zt ) )
+            zv2 = zv2/360000._wp                                    ! conversion cm/h -> m/s
+            !
+            zpv  = ( zv2 * SQRT( 660./ zsch ) ) * ( 1. - fr_i(ji,jj) ) * tmask(ji,jj,1)
 
-               ! CO2 piston velocity (m/s)
-               exch_co2(ji,jj)= zpv
-               ! CO2 invasion rate (mol/ppm/m2/s) = 1st part of 14C/C exchange velocity
-               exch_c14(ji,jj)= zpv * zsol
-            ELSE
-               exch_co2(ji,jj) = 0._wp
-               exch_c14(ji,jj) = 0._wp
-            ENDIF
-         END DO
-      END DO
+            ! CO2 piston velocity (m/s)
+            exch_co2(ji,jj)= zpv
+            ! CO2 invasion rate (mol/ppm/m2/s) = 1st part of 14C/C exchange velocity
+            exch_c14(ji,jj)= zpv * zsol
+         ELSE
+            exch_co2(ji,jj) = 0._wp
+            exch_c14(ji,jj) = 0._wp
+         ENDIF
+      END_2D
 
       ! Exchange velocity for 14C/C ratio (m/s)
@@ -120,5 +121,5 @@
       ! Flux of C-14 from air-to-sea; units: (C14/C ratio) x m/s
       !                               already masked
-      qtr_c14(:,:) = exch_c14(:,:) * ( c14sbc(:,:) - trb(:,:,1,jp_c14) )
+      qtr_c14(:,:) = exch_c14(:,:) * ( c14sbc(:,:) - tr(:,:,1,jp_c14,Kbb) )
             
       ! cumulation of air-to-sea flux at each time step
@@ -126,20 +127,14 @@
       !
       ! Add the surface flux to the trend of jp_c14
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            tra(ji,jj,1,jp_c14) = tra(ji,jj,1,jp_c14) + qtr_c14(ji,jj) / e3t_n(ji,jj,1) 
-         END DO
-      END DO
+      DO_2D_11_11
+         tr(ji,jj,1,jp_c14,Krhs) = tr(ji,jj,1,jp_c14,Krhs) + qtr_c14(ji,jj) / e3t(ji,jj,1,Kmm) 
+      END_2D
       !
       ! Computation of decay effects on jp_c14
-      DO jk = 1, jpk
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               !
-               tra(ji,jj,jk,jp_c14) = tra(ji,jj,jk,jp_c14) - rlam14 * trb(ji,jj,jk,jp_c14) * tmask(ji,jj,jk) 
-               !
-            END DO
-         END DO
-      END DO
+      DO_3D_11_11( 1, jpk )
+         !
+         tr(ji,jj,jk,jp_c14,Krhs) = tr(ji,jj,jk,jp_c14,Krhs) - rlam14 * tr(ji,jj,jk,jp_c14,Kbb) * tmask(ji,jj,jk) 
+         !
+      END_3D
       !
       IF( lrst_trc ) THEN
@@ -157,5 +152,5 @@
       ENDIF
 
-      IF( l_trdtrc )  CALL trd_trc( tra(:,:,:,jp_c14), 1, jptra_sms, kt )   ! save trends
+      IF( l_trdtrc )  CALL trd_trc( tr(:,:,:,jp_c14,Krhs), 1, jptra_sms, kt, Kmm )   ! save trends
       !
       IF( ln_timing )   CALL timing_stop('trc_sms_c14')
