Index: branches/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90
===================================================================
--- branches/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 2740)
+++ branches/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 3211)
@@ -58,4 +58,12 @@
    REAL(wp) ::   rbcp   ! Brown & Campana parameters for semi-implicit hpg
 
+   !! * Control permutation of array indices
+#  include "oce_ftrans.h90"
+#  include "dom_oce_ftrans.h90"
+#  include "sbc_oce_ftrans.h90"
+#  include "zdf_oce_ftrans.h90"
+#  include "domvvl_ftrans.h90"
+#  include "obc_oce_ftrans.h90"
+
    !! * Substitutions
 #  include "domzgr_substitute.h90"
@@ -93,6 +101,8 @@
       INTEGER, INTENT(in) ::   kt    ! ocean time-step index
       !!
-      INTEGER  ::   jk, jn    ! dummy loop indices
-      REAL(wp) ::   zfact     ! local scalars
+      INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
+      REAL(wp) ::   zfact            ! local scalar
+
+!FTRANS ztrdt ztrds :I :I :z
       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  ztrdt, ztrds
       !!----------------------------------------------------------------------
@@ -142,7 +152,17 @@
       IF( neuler == 0 .AND. kt == nit000 ) THEN       ! Euler time-stepping at first time-step (only swap)
          DO jn = 1, jpts
+#if defined key_z_first
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  DO jk = 1, jpkm1
+                     tsn(ji,jj,jk,jn) = tsa(ji,jj,jk,jn)    
+                  END DO
+               END DO
+            END DO
+#else
             DO jk = 1, jpkm1
                tsn(:,:,jk,jn) = tsa(:,:,jk,jn)    
             END DO
+#endif
          END DO
       ELSE                                            ! Leap-Frog + Asselin filter time stepping
@@ -162,4 +182,15 @@
       ! trends computation
       IF( l_trdtra ) THEN      ! trend of the Asselin filter (tb filtered - tb)/dt     
+#if defined key_z_first
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               DO jk = 1, jpkm1
+                  zfact = 1.e0 / r2dtra(jk)             
+                  ztrdt(ji,jj,jk) = ( tsb(ji,jj,jk,jp_tem) - ztrdt(ji,jj,jk) ) * zfact
+                  ztrds(ji,jj,jk) = ( tsb(ji,jj,jk,jp_sal) - ztrds(ji,jj,jk) ) * zfact
+               END DO
+            END DO
+         END DO
+#else
          DO jk = 1, jpkm1
             zfact = 1.e0 / r2dtra(jk)             
@@ -167,4 +198,5 @@
             ztrds(:,:,jk) = ( tsb(:,:,jk,jp_sal) - ztrds(:,:,jk) ) * zfact
          END DO
+#endif
          CALL trd_tra( kt, 'TRA', jp_tem, jptra_trd_atf, ztrdt )
          CALL trd_tra( kt, 'TRA', jp_sal, jptra_trd_atf, ztrds )
@@ -178,4 +210,12 @@
    END SUBROUTINE tra_nxt
 
+   !! * Reset control of array index permutation
+!FTRANS CLEAR
+#  include "oce_ftrans.h90"
+#  include "dom_oce_ftrans.h90"
+#  include "sbc_oce_ftrans.h90"
+#  include "zdf_oce_ftrans.h90"
+#  include "domvvl_ftrans.h90"
+#  include "obc_oce_ftrans.h90"
 
    SUBROUTINE tra_nxt_fix( kt, cdtype, ptb, ptn, pta, kjpt )
@@ -205,7 +245,14 @@
       CHARACTER(len=3), INTENT(in   )                               ::   cdtype   ! =TRA or TRC (tracer indicator)
       INTEGER         , INTENT(in   )                               ::   kjpt     ! number of tracers
-      REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptb      ! before tracer fields
-      REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptn      ! now tracer fields
-      REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   pta      ! tracer trend
+
+      !! DCSE_NEMO: This style defeats ftrans
+!     REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptb      ! before tracer fields
+!     REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptn      ! now tracer fields
+!     REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   pta      ! tracer trend
+
+!FTRANS ptb ptn pta :I :I :z :
+      REAL(wp)        , INTENT(inout)             ::   ptb(jpi,jpj,jpk,kjpt)      ! before tracer fields
+      REAL(wp)        , INTENT(inout)             ::   ptn(jpi,jpj,jpk,kjpt)      ! now tracer fields
+      REAL(wp)        , INTENT(inout)             ::   pta(jpi,jpj,jpk,kjpt)      ! tracer trend
       !
       INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
@@ -226,7 +273,13 @@
       DO jn = 1, kjpt
          !
+#if defined key_z_first
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               DO jk = 1, jpkm1
+#else
          DO jk = 1, jpkm1
             DO jj = 1, jpj
                DO ji = 1, jpi
+#endif
                   ztn = ptn(ji,jj,jk,jn)                                    
                   ztd = pta(ji,jj,jk,jn) - 2. * ztn + ptb(ji,jj,jk,jn)      !  time laplacian on tracers
@@ -244,4 +297,12 @@
    END SUBROUTINE tra_nxt_fix
 
+   !! * Reset control of array index permutation
+!FTRANS CLEAR
+#  include "oce_ftrans.h90"
+#  include "dom_oce_ftrans.h90"
+#  include "sbc_oce_ftrans.h90"
+#  include "zdf_oce_ftrans.h90"
+#  include "domvvl_ftrans.h90"
+#  include "obc_oce_ftrans.h90"
 
    SUBROUTINE tra_nxt_vvl( kt, cdtype, ptb, ptn, pta, kjpt )
@@ -272,7 +333,15 @@
       CHARACTER(len=3), INTENT(in   )                               ::   cdtype   ! =TRA or TRC (tracer indicator)
       INTEGER         , INTENT(in   )                               ::   kjpt     ! number of tracers
-      REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptb      ! before tracer fields
-      REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptn      ! now tracer fields
-      REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   pta      ! tracer trend
+
+      !! DCSE_NEMO: This style defeats ftrans
+!     REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptb      ! before tracer fields
+!     REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptn      ! now tracer fields
+!     REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   pta      ! tracer trend
+
+!FTRANS ptb ptn pta :I :I :z :
+      REAL(wp)        , INTENT(inout)             ::   ptb(jpi,jpj,jpk,kjpt)      ! before tracer fields
+      REAL(wp)        , INTENT(inout)             ::   ptn(jpi,jpj,jpk,kjpt)      ! now tracer fields
+      REAL(wp)        , INTENT(inout)             ::   pta(jpi,jpj,jpk,kjpt)      ! tracer trend
+
       !!     
       LOGICAL  ::   ll_tra, ll_tra_hpg, ll_traqsr   ! local logical
@@ -299,4 +368,12 @@
       !
       DO jn = 1, kjpt      
+#if defined key_z_first
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               DO jk = 1, jpkm1
+                  !! DCSE_NEMO: could try promoting these scalars to vectors
+                  zfact1 = atfp * rdttra(jk)
+                  zfact2 = zfact1 / rau0
+#else
          DO jk = 1, jpkm1
             zfact1 = atfp * rdttra(jk)
@@ -304,4 +381,5 @@
             DO jj = 1, jpj
                DO ji = 1, jpi
+#endif
                   ze3t_b = fse3t_b(ji,jj,jk)
                   ze3t_n = fse3t_n(ji,jj,jk)
