Index: /branches/UKMO/AMM15_v3_6_STABLE_package_withNOOS/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90
===================================================================
--- /branches/UKMO/AMM15_v3_6_STABLE_package_withNOOS/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 9471)
+++ /branches/UKMO/AMM15_v3_6_STABLE_package_withNOOS/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 9472)
@@ -814,14 +814,14 @@
               SELECT CASE( sec%direction(jseg) ) 
               CASE(0,1) 
-                 ztn   = interp(k%I,k%J,jk,'V',tsn(:,:,:,jp_tem) ) 
-                 zsn   = interp(k%I,k%J,jk,'V',tsn(:,:,:,jp_sal) ) 
-                 zrhop = interp(k%I,k%J,jk,'V',rhop) 
-                 zrhoi = interp(k%I,k%J,jk,'V',rhd*rau0+rau0) 
+                 ztn   = interp(k%I,k%J,jk,'V',0 ) 
+                 zsn   = interp(k%I,k%J,jk,'V',1 ) 
+                 zrhop = interp(k%I,k%J,jk,'V',2 ) 
+                 zrhoi = interp(k%I,k%J,jk,'V',3 ) 
                  zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I,k%J+1)    ) * vmask(k%I,k%J,1) 
               CASE(2,3) 
-                 ztn   = interp(k%I,k%J,jk,'U',tsn(:,:,:,jp_tem) ) 
-                 zsn   = interp(k%I,k%J,jk,'U',tsn(:,:,:,jp_sal) ) 
-                 zrhop = interp(k%I,k%J,jk,'U',rhop) 
-                 zrhoi = interp(k%I,k%J,jk,'U',rhd*rau0+rau0) 
+                 ztn   = interp(k%I,k%J,jk,'U',0 ) 
+                 zsn   = interp(k%I,k%J,jk,'U',1 ) 
+                 zrhop = interp(k%I,k%J,jk,'U',2 ) 
+                 zrhoi = interp(k%I,k%J,jk,'U',3 ) 
                  zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I+1,k%J)    ) * umask(k%I,k%J,1)  
               END SELECT 
@@ -1039,14 +1039,14 @@
               SELECT CASE( sec%direction(jseg) )
               CASE(0,1)
-                 ztn   = interp(k%I,k%J,jk,'V',tsn(:,:,:,jp_tem) )
-                 zsn   = interp(k%I,k%J,jk,'V',tsn(:,:,:,jp_sal) )
-                 zrhop = interp(k%I,k%J,jk,'V',rhop)
-                 zrhoi = interp(k%I,k%J,jk,'V',rhd*rau0+rau0)
+                 ztn   = interp(k%I,k%J,jk,'V',0 )
+                 zsn   = interp(k%I,k%J,jk,'V',1)
+                 zrhop = interp(k%I,k%J,jk,'V',2)
+                 zrhoi = interp(k%I,k%J,jk,'V',3)
                  zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I,k%J+1)    ) * vmask(k%I,k%J,1)
               CASE(2,3)
-                 ztn   = interp(k%I,k%J,jk,'U',tsn(:,:,:,jp_tem) )
-                 zsn   = interp(k%I,k%J,jk,'U',tsn(:,:,:,jp_sal) )
-                 zrhop = interp(k%I,k%J,jk,'U',rhop)
-                 zrhoi = interp(k%I,k%J,jk,'U',rhd*rau0+rau0)
+                 ztn   = interp(k%I,k%J,jk,'U',0)
+                 zsn   = interp(k%I,k%J,jk,'U',1)
+                 zrhop = interp(k%I,k%J,jk,'U',2)
+                 zrhoi = interp(k%I,k%J,jk,'U',3)
                  zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I+1,k%J)    ) * umask(k%I,k%J,1) 
               END SELECT
@@ -1210,14 +1210,14 @@
               SELECT CASE( sec%direction(jseg) ) 
               CASE(0,1) 
-                 ztn   = interp(k%I,k%J,jk,'V',tsn(:,:,:,jp_tem) ) 
-                 zsn   = interp(k%I,k%J,jk,'V',tsn(:,:,:,jp_sal) ) 
-                 zrhop = interp(k%I,k%J,jk,'V',rhop) 
-                 zrhoi = interp(k%I,k%J,jk,'V',rhd*rau0+rau0) 
+                 ztn   = interp(k%I,k%J,jk,'V',0 ) 
+                 zsn   = interp(k%I,k%J,jk,'V',1 ) 
+                 zrhop = interp(k%I,k%J,jk,'V',2) 
+                 zrhoi = interp(k%I,k%J,jk,'V',3) 
 
               CASE(2,3) 
-                 ztn   = interp(k%I,k%J,jk,'U',tsn(:,:,:,jp_tem) ) 
-                 zsn   = interp(k%I,k%J,jk,'U',tsn(:,:,:,jp_sal) ) 
-                 zrhop = interp(k%I,k%J,jk,'U',rhop) 
-                 zrhoi = interp(k%I,k%J,jk,'U',rhd*rau0+rau0) 
+                 ztn   = interp(k%I,k%J,jk,'U',0 ) 
+                 zsn   = interp(k%I,k%J,jk,'U',1 ) 
+                 zrhop = interp(k%I,k%J,jk,'U',2 ) 
+                 zrhoi = interp(k%I,k%J,jk,'U',3 ) 
                  zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I+1,k%J)    ) * umask(k%I,k%J,1)  
               END SELECT 
@@ -1421,14 +1421,14 @@
               SELECT CASE( sec%direction(jseg) )
               CASE(0,1)
-                 ztn   = interp(k%I,k%J,jk,'V',tsn(:,:,:,jp_tem) )
-                 zsn   = interp(k%I,k%J,jk,'V',tsn(:,:,:,jp_sal) )
-                 zrhop = interp(k%I,k%J,jk,'V',rhop)
-                 zrhoi = interp(k%I,k%J,jk,'V',rhd*rau0+rau0)
+                 ztn   = interp(k%I,k%J,jk,'V',0 )
+                 zsn   = interp(k%I,k%J,jk,'V',1 )
+                 zrhop = interp(k%I,k%J,jk,'V',2 )
+                 zrhoi = interp(k%I,k%J,jk,'V',3 )
                  zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I,k%J+1)    ) * vmask(k%I,k%J,1)
               CASE(2,3)
-                 ztn   = interp(k%I,k%J,jk,'U',tsn(:,:,:,jp_tem) )
-                 zsn   = interp(k%I,k%J,jk,'U',tsn(:,:,:,jp_sal) )
-                 zrhop = interp(k%I,k%J,jk,'U',rhop)
-                 zrhoi = interp(k%I,k%J,jk,'U',rhd*rau0+rau0)
+                 ztn   = interp(k%I,k%J,jk,'U',0 )
+                 zsn   = interp(k%I,k%J,jk,'U',1 )
+                 zrhop = interp(k%I,k%J,jk,'U',2 )
+                 zrhoi = interp(k%I,k%J,jk,'U',3 )
                  zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I+1,k%J)    ) * umask(k%I,k%J,1) 
               END SELECT
@@ -1869,5 +1869,5 @@
   END SUBROUTINE dia_dct_wri
 
-  FUNCTION interp(ki, kj, kk, cd_point, ptab)
+   PURE  FUNCTION interp(ki, kj, kk, cd_point,var) 
   !!----------------------------------------------------------------------
   !!
@@ -1931,6 +1931,6 @@
   !*arguments
   INTEGER, INTENT(IN)                          :: ki, kj, kk   ! coordinate of point
+  INTEGER, INTENT(IN)                          :: var   !  which variable
   CHARACTER(len=1), INTENT(IN)                 :: cd_point     ! type of point (U, V)
-  REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(IN) :: ptab         ! variable to compute at (ki, kj, kk )
   REAL(wp)                                     :: interp       ! interpolated variable 
 
@@ -1943,4 +1943,6 @@
   !!----------------------------------------------------------------------
 
+ 
+
   IF( cd_point=='U' )THEN 
      ii1 = ki    ; ij1 = kj 
@@ -1973,6 +1975,10 @@
   
      ! result
-     interp = zmsk * ( zwgt2 *  ptab(ii1,ij1,kk) + zwgt1 *  ptab(ii1,ij1,kk) ) / ( zwgt2 + zwgt1 )   
-
+           SELECT CASE( var )
+              CASE(0)  ;    interp = zmsk * ( zwgt2 *  tsn(ii1,ij1,kk,jp_tem) + zwgt1 *  tsn(ii1,ij1,kk,jp_tem) ) / ( zwgt2 + zwgt1 )
+              CASE(1)  ;    interp = zmsk * ( zwgt2 *  tsn(ii1,ij1,kk,jp_sal) + zwgt1 *  tsn(ii1,ij1,kk,jp_sal) ) / ( zwgt2 + zwgt1 )
+              CASE(2)  ;    interp = zmsk * ( zwgt2 *  rhop(ii1,ij1,kk) + zwgt1 *  rhop(ii1,ij1,kk) ) / ( zwgt2 + zwgt1 )
+              CASE(3)  ;    interp = zmsk * ( zwgt2 *  (rhd(ii1,ij1,kk)*rau0+rau0) + zwgt1 *  (rhd(ii1,ij1,kk)*rau0+rau0) ) / ( zwgt2 + zwgt1 )
+           END SELECT
 
   ELSE       ! full step or partial step case 
@@ -1996,20 +2002,51 @@
         IF( ze3t >= 0. )THEN 
            ! zbis
-           zbis = ptab(ii2,ij2,kk) + zwgt1 * ( ptab(ii2,ij2,kk-1) - ptab(ii2,ij2,kk) ) 
+           SELECT CASE( var )
+           CASE(0)  
+                     zbis   =  tsn(ii2,ij2,kk,jp_tem) + zwgt1 *  (tsn(ii2,ij2,kk-1,jp_tem)-tsn(ii2,ij2,kk,jp_tem)   )
+                     interp =  zmsk * ( zet2 * tsn(ii1,ij1,kk,jp_tem) + zet1 * zbis )/( zet1 + zet2 )
+           CASE(1)  
+                     zbis   =  tsn(ii2,ij2,kk,jp_sal) + zwgt1 *  (tsn(ii2,ij2,kk-1,jp_sal)-tsn(ii2,ij2,kk,jp_sal)   )
+                     interp =  zmsk * ( zet2 * tsn(ii1,ij1,kk,jp_sal) + zet1 * zbis )/( zet1 + zet2 )
+           CASE(2)  
+                     zbis   =  rhop(ii2,ij2,kk) + zwgt1 *  (rhop(ii2,ij2,kk-1)-rhop(ii2,ij2,kk)   )
+                     interp =  zmsk * ( zet2 * rhop(ii1,ij1,kk) + zet1 * zbis )/( zet1 + zet2 )
+           CASE(3)  
+                     zbis   =  (rhd(ii2,ij2,kk)*rau0+rau0) + zwgt1 *  ( (rhd(ii2,ij2,kk-1)*rau0+rau0)-(rhd(ii2,ij2,kk)*rau0+rau0)   )
+                     interp =  zmsk * ( zet2 * (rhd(ii1,ij1,kk)*rau0+rau0) + zet1 * zbis )/( zet1 + zet2 )
+           END SELECT
            ! result
-            interp = zmsk * ( zet2 * ptab(ii1,ij1,kk) + zet1 * zbis )/( zet1 + zet2 )
         ELSE
            ! zbis
-           zbis = ptab(ii1,ij1,kk) + zwgt2 * ( ptab(ii1,ij1,kk-1) - ptab(ii1,ij2,kk) )
-           ! result
-           interp = zmsk * ( zet2 * zbis + zet1 * ptab(ii2,ij2,kk) )/( zet1 + zet2 )
+           SELECT CASE( var )
+           CASE(0)  
+                 zbis   = tsn(ii1,ij1,kk,jp_tem) + zwgt2 * ( tsn(ii1,ij1,kk-1,jp_tem) - tsn(ii1,ij2,kk,jp_tem) )
+                 interp = zmsk * ( zet2 * zbis + zet1 * tsn(ii2,ij2,kk,jp_tem) )/( zet1 + zet2 )
+           CASE(1)  
+                 zbis   = tsn(ii1,ij1,kk,jp_sal) + zwgt2 * ( tsn(ii1,ij1,kk-1,jp_sal) - tsn(ii1,ij2,kk,jp_sal) )
+                 interp = zmsk * ( zet2 * zbis + zet1 * tsn(ii2,ij2,kk,jp_sal) )/( zet1 + zet2 )
+           CASE(2)  
+                 zbis   = rhop(ii1,ij1,kk) + zwgt2 * ( rhop(ii1,ij1,kk-1) - rhop(ii1,ij2,kk) )
+                 interp = zmsk * ( zet2 * zbis + zet1 * rhop(ii2,ij2,kk) )/( zet1 + zet2 )
+           CASE(3)  
+                 zbis   = (rhd(ii1,ij1,kk)*rau0+rau0) + zwgt2 * ( (rhd(ii1,ij1,kk-1)*rau0+rau0) - (rhd(ii1,ij2,kk)*rau0+rau0) )
+                 interp = zmsk * ( zet2 * zbis + zet1 * (rhd(ii2,ij2,kk)*rau0+rau0) )/( zet1 + zet2 )
+           END SELECT
         ENDIF    
 
      ELSE
-        interp = zmsk * (  zet2 * ptab(ii1,ij1,kk) + zet1 * ptab(ii2,ij2,kk) )/( zet1 + zet2 )
+        SELECT CASE( var )
+        CASE(0)  
+           interp = zmsk * (  zet2 * tsn(ii1,ij1,kk,jp_tem) + zet1 * tsn(ii2,ij2,kk,jp_tem) )/( zet1 + zet2 )
+        CASE(1)  
+           interp = zmsk * (  zet2 * tsn(ii1,ij1,kk,jp_sal) + zet1 * tsn(ii2,ij2,kk,jp_sal) )/( zet1 + zet2 )
+        CASE(2)  
+           interp = zmsk * (  zet2 * rhop(ii1,ij1,kk) + zet1 * rhop(ii2,ij2,kk) )/( zet1 + zet2 )
+        CASE(3)  
+           interp = zmsk * (  zet2 * (rhd(ii1,ij1,kk)*rau0+rau0) + zet1 * (rhd(ii2,ij2,kk)*rau0+rau0) )/( zet1 + zet2 )
+        END SELECT
      ENDIF
 
   ENDIF
-
 
   END FUNCTION interp
