Index: /branches/2012/dev_UKMO_2012/DOC/TexFiles/Chapters/Chap_DIA.tex
===================================================================
--- /branches/2012/dev_UKMO_2012/DOC/TexFiles/Chapters/Chap_DIA.tex	(revision 3601)
+++ /branches/2012/dev_UKMO_2012/DOC/TexFiles/Chapters/Chap_DIA.tex	(revision 3602)
@@ -838,5 +838,5 @@
 - \texttt{heat\_transport}   for heat transports   (  unit: $10^{15} W $ )
 
-- \texttt{salt\_transport}   for salt transports   (  unit: $10^{9}g s^{-1}$ )\\
+- \texttt{salt\_transport}   for salt transports   (  unit: $10^{9}Kg s^{-1}$ )\\
 
 
Index: /branches/2012/dev_UKMO_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90
===================================================================
--- /branches/2012/dev_UKMO_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 3601)
+++ /branches/2012/dev_UKMO_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 3602)
@@ -21,11 +21,11 @@
   !!----------------------------------------------------------------------
   !!----------------------------------------------------------------------
-  !!   dia_dct      :  compute the transport through a sec.
-  !!   dia_dct_init :  read namelist.
-  !!   readsec      :  read sections description and pathway
-  !!   removepoints :  remove points which are common to 2 procs
+  !!   dia_dct      :  Compute the transport through a sec.
+  !!   dia_dct_init :  Read namelist.
+  !!   readsec      :  Read sections description and pathway
+  !!   removepoints :  Remove points which are common to 2 procs
   !!   transport    :  Compute transport for each sections
-  !!   dia_dct_wri  :  write tranports results in ascii files
-  !!   interp       :  compute Temperature/Salinity/density on U-point or V-point
+  !!   dia_dct_wri  :  Write tranports results in ascii files
+  !!   interp       :  Compute temperature/salinity/density at U-point or V-point
   !!   
   !!----------------------------------------------------------------------
@@ -52,6 +52,7 @@
 
   !! * Routine accessibility
-  PUBLIC   dia_dct     ! routine called by step.F90
-  PUBLIC   dia_dct_init! routine called by opa.F90
+  PUBLIC   dia_dct      ! routine called by step.F90
+  PUBLIC   dia_dct_init ! routine called by opa.F90
+  PUBLIC   diadct_alloc ! routine called by nemo_init in nemogcm.F90 
   PRIVATE  readsec
   PRIVATE  removepoints
@@ -72,5 +73,7 @@
   INTEGER, PARAMETER :: nb_sec_max    = 150
   INTEGER, PARAMETER :: nb_point_max  = 2000
-  INTEGER, PARAMETER :: nb_type_class = 14
+  INTEGER, PARAMETER :: nb_type_class = 10
+  INTEGER, PARAMETER :: nb_3d_vars    = 3 
+  INTEGER, PARAMETER :: nb_2d_vars    = 2 
   INTEGER            :: nb_sec 
 
@@ -92,5 +95,5 @@
      INTEGER                                      :: nb_class          ! number of boundaries for density classes
      INTEGER, DIMENSION(nb_point_max)             :: direction         ! vector direction of the point in the section
-     CHARACTER(len=40),DIMENSION(nb_class_max)    :: classname         ! caracteristics of the class
+     CHARACTER(len=40),DIMENSION(nb_class_max)    :: classname         ! characteristics of the class
      REAL(wp), DIMENSION(nb_class_max)            :: zsigi           ,&! in-situ   density classes    (99 if you don't want)
                                                      zsigp           ,&! potential density classes    (99 if you don't want)
@@ -106,6 +109,24 @@
   TYPE(SECTION),DIMENSION(nb_sec_max) :: secs ! Array of sections
  
- 
+  REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) ::  transports_3d 
+  REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::  transports_2d  
+
 CONTAINS
+
+ 
+  INTEGER FUNCTION diadct_alloc() 
+     !!---------------------------------------------------------------------- 
+     !!                   ***  FUNCTION diadct_alloc  *** 
+     !!---------------------------------------------------------------------- 
+     INTEGER :: ierr(2) 
+     !!---------------------------------------------------------------------- 
+
+     ALLOCATE(transports_3d(nb_3d_vars,nb_sec_max,nb_point_max,jpk), STAT=ierr(1) ) 
+     ALLOCATE(transports_2d(nb_2d_vars,nb_sec_max,nb_point_max)    , STAT=ierr(2) ) 
+
+     diadct_alloc = MAXVAL( ierr ) 
+     IF( diadct_alloc /= 0 )   CALL ctl_warn('diadct_alloc: failed to allocate arrays') 
+ 
+  END FUNCTION diadct_alloc 
 
   SUBROUTINE dia_dct_init
@@ -113,5 +134,5 @@
      !!               ***  ROUTINE diadct  ***  
      !!
-     !!  ** Purpose: Read the namelist parametres
+     !!  ** Purpose: Read the namelist parameters
      !!              Open output files
      !!
@@ -154,4 +175,8 @@
      ENDIF
 
+     ! Initialise arrays to zero 
+     transports_3d(:,:,:,:)=0.0 
+     transports_2d(:,:,:)  =0.0 
+
      IF( nn_timing == 1 )   CALL timing_stop('dia_dct_init')
      !
@@ -163,5 +188,16 @@
      !!               ***  ROUTINE diadct  ***  
      !!
-     !!  ** Purpose: Compute sections tranport and write it in numdct file
+     !!  Purpose :: Compute section transports and write it in numdct files 
+     !!   
+     !!  Method  :: All arrays initialised to zero in dct_init 
+     !!             Each nn_dct time step call subroutine 'transports' for 
+     !!               each section to sum the transports over each grid cell. 
+     !!             Each nn_dctwri time step: 
+     !!               Divide the arrays by the number of summations to gain 
+     !!               an average value 
+     !!               Call dia_dct_sum to sum relevant grid boxes to obtain 
+     !!               totals for each class (density, depth, temp or sal) 
+     !!               Call dia_dct_wri to write the transports into file 
+     !!               Reinitialise all relevant arrays to zero 
      !!---------------------------------------------------------------------
      !! * Arguments
@@ -170,9 +206,6 @@
      !! * Local variables
      INTEGER             :: jsec,            &! loop on sections
-                            iost,            &! error for opening fileout
                             itotal            ! nb_sec_max*nb_type_class*nb_class_max
      LOGICAL             :: lldebug =.FALSE.  ! debug a section  
-     CHARACTER(len=160)  :: clfileout         ! fileout name
-
      
      INTEGER , DIMENSION(1)             :: ish   ! tmp array for mpp_sum
@@ -190,4 +223,8 @@
      ENDIF    
  
+     ! Initialise arrays
+     zwork(:) = 0.0 
+     zsum(:,:,:) = 0.0
+
      IF( lwp .AND. kt==nit000+nn_dct-1 ) THEN
          WRITE(numout,*) " "
@@ -208,5 +245,5 @@
 
            !Compute transport through section  
-           CALL transport(secs(jsec),lldebug) 
+           CALL transport(secs(jsec),lldebug,jsec) 
 
         ENDDO
@@ -214,6 +251,15 @@
         IF( MOD(kt,nn_dctwri)==0 )THEN
 
-           IF( lwp .AND. kt==nit000+nn_dctwri-1 )WRITE(numout,*)"      diadct: write at kt = ",kt         
+           IF( lwp .AND. kt==nit000+nn_dctwri-1 )WRITE(numout,*)"      diadct: average transports and write at kt = ",kt         
   
+           !! divide arrays by nn_dctwri/nn_dct to obtain average 
+           transports_3d(:,:,:,:)=transports_3d(:,:,:,:)/(nn_dctwri/nn_dct) 
+           transports_2d(:,:,:)  =transports_2d(:,:,:)  /(nn_dctwri/nn_dct) 
+ 
+           ! Sum over each class 
+           DO jsec=1,nb_sec 
+              CALL dia_dct_sum(secs(jsec),jsec) 
+           ENDDO 
+
            !Sum on all procs 
            IF( lk_mpp )THEN
@@ -233,4 +279,6 @@
             
               !nullify transports values after writing
+              transports_3d(:,jsec,:,:)=0.
+              transports_2d(:,jsec,:  )=0.
               secs(jsec)%transport(:,:)=0.  
 
@@ -265,5 +313,4 @@
      INTEGER :: isec, iiglo, ijglo, iiloc, ijloc,iost,i1 ,i2  ! temporary  integer
      INTEGER :: jsec, jpt                                     ! dummy loop indices
-                                                              ! heat/salt tranport is actived
 
      INTEGER, DIMENSION(2) :: icoord 
@@ -457,7 +504,5 @@
      !!             *** function removepoints
      !!
-     !!   ** Purpose ::
-     !!              remove points which are common to 2 procs
-     !!
+     !!   ** Purpose :: Remove points which are common to 2 procs
      !!
      !----------------------------------------------------------------------------
@@ -535,28 +580,22 @@
   END SUBROUTINE removepoints
 
-  SUBROUTINE transport(sec,ld_debug)
+  SUBROUTINE transport(sec,ld_debug,jsec)
      !!-------------------------------------------------------------------------------------------
      !!                     ***  ROUTINE transport  ***
      !!
-     !!  ** Purpose : Compute the transport through a section
-     !!
-     !!  ** Method  :Transport through a given section is equal to the sum of transports
-     !!              computed on each proc.
-     !!              On each proc,transport is equal to the sum of transport computed through
-     !!	             segments linking each point of sec%listPoint  with the next one.   
-     !!
-     !!              !BE carefull :          
-     !!              one section is a sum of segments
-     !!              one segment is defined by 2 consectuve points in sec%listPoint
-     !!              all points of sec%listPoint are positioned on the F-point of the cell. 
+     !!  Purpose ::  Compute the transport for each point in a section 
      !! 
-     !!              There are several loops:                 
-     !!              loop on the density/temperature/salinity/level classes
-     !!              loop on the segment between 2 nodes
-     !!              loop on the level jk
-     !!              test on the density/temperature/salinity/level
-     !!
-     !! ** Output: sec%transport: volume/mass/ice/heat/salt transport in the 2 directions
-     !!
+     !!  Method  ::  Loop over each segment, and each vertical level and add the transport 
+     !!              Be aware :           
+     !!              One section is a sum of segments 
+     !!              One segment is defined by 2 consecutive points in sec%listPoint 
+     !!              All points of sec%listPoint are positioned on the F-point of the cell 
+     !! 
+     !!              There are two loops:                  
+     !!              loop on the segment between 2 nodes 
+     !!              loop on the level jk !!
+     !! 
+     !!  Output  ::  Arrays containing the volume,density,heat,salt transports for each i
+     !!              point in a section, summed over each nn_dct. 
      !!
      !!-------------------------------------------------------------------------------------------
@@ -564,34 +603,18 @@
      TYPE(SECTION),INTENT(INOUT) :: sec
      LOGICAL      ,INTENT(IN)    :: ld_debug
+     INTEGER      ,INTENT(IN)    :: jsec        ! numeric identifier of section
     
      !! * Local variables
-     INTEGER             :: jk,jseg,jclass,   &!loop on level/segment/classes 
-                            isgnu  , isgnv     !
-     INTEGER :: ii, ij ! local integer
-     REAL(wp):: zumid        , zvmid        ,&!U/V velocity on a cell segment
-                zumid_ice    , zvmid_ice    ,&!U/V ice velocity
-                zTnorm                      ,&!transport of velocity through one cell's sides
-                ztransp1     , ztransp2     ,&!total        transport in directions 1 and 2
-                ztemp1       , ztemp2       ,&!temperature  transport     "
-                zrhoi1       , zrhoi2       ,&!mass         transport     "
-                zrhop1       , zrhop2       ,&!mass         transport     "
-                zsal1        , zsal2        ,&!salinity     transport     "
-                zice_vol_pos , zice_vol_neg ,&!volume  ice  transport     "
-                zice_surf_pos, zice_surf_neg  !surface ice  transport     "
-     REAL(wp):: ztn, zsn, zrhoi, zrhop, zsshn, zfsdep ! temperature/salinity/ssh/potential density /depth at u/v point
+     INTEGER             :: jk, jseg, jclass,                    &!loop on level/segment/classes  
+                            isgnu, isgnv                          ! 
+     REAL(wp)            :: zumid, zvmid,                        &!U/V velocity on a cell segment 
+                            zumid_ice, zvmid_ice,                &!U/V ice velocity 
+                            zTnorm                                !transport of velocity through one cell's sides 
+     REAL(wp)            :: ztn, zsn, zrhoi, zrhop, zsshn, zfsdep !temperature/salinity/potential density/ssh/depth at u/v point
 
      TYPE(POINT_SECTION) :: k
-     REAL(wp), POINTER, DIMENSION(:,:):: zsum ! 2D work array
      !!--------------------------------------------------------
-     CALL wrk_alloc( nb_type_class , nb_class_max , zsum   )
 
      IF( ld_debug )WRITE(numout,*)'      Compute transport'
-
-     !----------------!
-     ! INITIALIZATION !
-     !----------------!
-     zsum    = 0._wp
-     zice_surf_neg = 0._wp ; zice_surf_pos = 0._wp
-     zice_vol_pos  = 0._wp ; zice_vol_neg  = 0._wp
 
      !---------------------------!
@@ -670,127 +693,60 @@
            END SELECT
 
-           !-------------------------------
-           !  LOOP ON THE DENSITY CLASSES |
-           !-------------------------------
-           !The computation is made for each density class
-           DO jclass=1,MAX(1,sec%nb_class-1)
-
-              ztransp1=0._wp ; zrhoi1=0._wp ; zrhop1=0._wp ; ztemp1=0._wp ;zsal1=0._wp
-              ztransp2=0._wp ; zrhoi2=0._wp ; zrhop2=0._wp ; ztemp2=0._wp ;zsal2=0._wp
-    
-              !---------------------------|
-              !     LOOP ON THE LEVEL     |
-              !---------------------------|
-              !Sum of the transport on the vertical 
-              DO jk=1,jpk
-                    
-
-                 ! compute temparature, salinity, insitu & potential density, ssh and depth at U/V point
-                 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)
-                    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)
-                    zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I+1,k%J)    ) * umask(k%I,k%J,1) 
-                 END SELECT
-
-                 zfsdep= gdept(k%I,k%J,jk)
- 
-                 !----------------------------------------------!
-                 !TEST ON THE DENSITY/SALINITY/TEMPERATURE/LEVEL! 
-                 !----------------------------------------------!
- 
-                 IF ( (    ((( zrhop .GE. (sec%zsigp(jclass)+1000.  )) .AND.    &
-                           (   zrhop .LE. (sec%zsigp(jclass+1)+1000. ))) .OR.    &
-                           ( sec%zsigp(jclass) .EQ. 99.)) .AND.                 &
-                           ((( zrhoi .GE. (sec%zsigi(jclass) + 1000.  )) .AND.    &
-                           (   zrhoi .LE. (sec%zsigi(jclass+1)+1000. ))) .OR.    &
-                           ( sec%zsigi(jclass) .EQ. 99.)) .AND.                 &
-                           ((( zsn .GT. sec%zsal(jclass)) .AND.                &
-                           (   zsn .LE. sec%zsal(jclass+1))) .OR.              &
-                           ( sec%zsal(jclass) .EQ. 99.)) .AND.                 &
-                           ((( ztn .GE. sec%ztem(jclass)) .AND.                &
-                           (   ztn .LE. sec%ztem(jclass+1))) .OR.              &
-                           ( sec%ztem(jclass) .EQ.99.)) .AND.                  &
-                           ((( zfsdep .GE. sec%zlay(jclass)) .AND.            &
-                           (   zfsdep .LE. sec%zlay(jclass+1))) .OR.          &
-                           ( sec%zlay(jclass) .EQ. 99. ))))   THEN
-
-
-                    !compute velocity with the correct direction
-                    SELECT CASE( sec%direction(jseg) )
-                    CASE(0,1)  
-                       zumid=0.
-                       zvmid=isgnv*vn(k%I,k%J,jk)*vmask(k%I,k%J,jk)
-                    CASE(2,3)
-                       zumid=isgnu*un(k%I,k%J,jk)*umask(k%I,k%J,jk)
-                       zvmid=0.
-                    END SELECT
-
-                    !velocity* cell's length * cell's thickness
-                    zTnorm=zumid*e2u(k%I,k%J)*  fse3u(k%I,k%J,jk)+     &
-                           zvmid*e1v(k%I,k%J)*  fse3v(k%I,k%J,jk)
+           !---------------------------| 
+           !     LOOP ON THE LEVEL     | 
+           !---------------------------| 
+           !Sum of the transport on the vertical  
+           DO jk=1,mbathy(k%I,k%J) 
+ 
+              ! compute temperature, salinity, insitu & potential density, ssh and depth at U/V point 
+              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) 
+                 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) 
+                 zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I+1,k%J)    ) * umask(k%I,k%J,1)  
+              END SELECT 
+ 
+              zfsdep= gdept(k%I,k%J,jk) 
+  
+              !compute velocity with the correct direction 
+              SELECT CASE( sec%direction(jseg) ) 
+              CASE(0,1)   
+                 zumid=0. 
+                 zvmid=isgnv*vn(k%I,k%J,jk)*vmask(k%I,k%J,jk) 
+              CASE(2,3) 
+                 zumid=isgnu*un(k%I,k%J,jk)*umask(k%I,k%J,jk) 
+                 zvmid=0. 
+              END SELECT 
+ 
+              !zTnorm=transport through one cell; 
+              !velocity* cell's length * cell's thickness 
+              zTnorm=zumid*e2u(k%I,k%J)*  fse3u(k%I,k%J,jk)+     & 
+                     zvmid*e1v(k%I,k%J)*  fse3v(k%I,k%J,jk) 
 
 #if ! defined key_vvl
-                    !add transport due to free surface
-                    IF( jk==1 )THEN
-                       zTnorm = zTnorm + zumid* e2u(k%I,k%J) * zsshn * umask(k%I,k%J,jk) + &
-                                         zvmid* e1v(k%I,k%J) * zsshn * vmask(k%I,k%J,jk)
-                    ENDIF
+              !add transport due to free surface 
+              IF( jk==1 )THEN 
+                 zTnorm = zTnorm + zumid* e2u(k%I,k%J) * zsshn * umask(k%I,k%J,jk) + & 
+                                   zvmid* e1v(k%I,k%J) * zsshn * vmask(k%I,k%J,jk) 
+              ENDIF 
 #endif
-                    !COMPUTE TRANSPORT 
-                    !zTnorm=transport through one cell for one class
-                    !ztransp1 or ztransp2=transport through one cell i
-                    !                     for one class for one direction
-                    IF( zTnorm .GE. 0 )THEN
-
-                       ztransp1=zTnorm+ztransp1
- 
-                       IF ( sec%llstrpond ) THEN
-                          ztemp1 = ztemp1  + zTnorm * ztn 
-                          zsal1  = zsal1   + zTnorm * zsn
-                          zrhoi1 = zrhoi1  + zTnorm * zrhoi
-                          zrhop1 = zrhop1  + zTnorm * zrhop
-                       ENDIF
-
-                    ELSE
-
-                       ztransp2=(zTnorm)+ztransp2
-
-                       IF ( sec%llstrpond ) THEN
-                          ztemp2 = ztemp2  + zTnorm * ztn 
-                          zsal2  = zsal2   + zTnorm * zsn
-                          zrhoi2 = zrhoi2  + zTnorm * zrhoi
-                          zrhop2 = zrhop2  + zTnorm * zrhop
-                       ENDIF
-                    ENDIF
- 
-            
-                 ENDIF ! end of density test
-              ENDDO!end of loop on the level
-
-              !ZSUM=TRANSPORT FOR EACH CLASSES FOR THE  DIRECTIONS
-              !---------------------------------------------------
-              zsum(1,jclass)     = zsum(1,jclass)+ztransp1
-              zsum(2,jclass)     = zsum(2,jclass)+ztransp2
-              IF( sec%llstrpond )THEN
-                 zsum(3 ,jclass) = zsum( 3,jclass)+zrhoi1
-                 zsum(4 ,jclass) = zsum( 4,jclass)+zrhoi2
-                 zsum(5 ,jclass) = zsum( 5,jclass)+zrhop1
-                 zsum(6 ,jclass) = zsum( 6,jclass)+zrhop2
-                 zsum(7 ,jclass) = zsum( 7,jclass)+ztemp1
-                 zsum(8 ,jclass) = zsum( 8,jclass)+ztemp2
-                 zsum(9 ,jclass) = zsum( 9,jclass)+zsal1
-                 zsum(10,jclass) = zsum(10,jclass)+zsal2
+              !COMPUTE TRANSPORT  
+ 
+              transports_3d(1,jsec,jseg,jk) = transports_3d(1,jsec,jseg,jk) + zTnorm 
+  
+              IF ( sec%llstrpond ) THEN 
+                 transports_3d(2,jsec,jseg,jk) = transports_3d(2,jsec,jseg,jk)  + zTnorm * ztn * zrhop * rcp
+                 transports_3d(3,jsec,jseg,jk) = transports_3d(3,jsec,jseg,jk)  + zTnorm * zsn * zrhop * 0.001
               ENDIF
    
-           ENDDO !end of loop on the density classes
+           ENDDO !end of loop on the level
 
 #if defined key_lim2 || defined key_lim3
@@ -816,28 +772,10 @@
               zTnorm=zumid_ice*e2u(k%I,k%J)+zvmid_ice*e1v(k%I,k%J)
    
-              IF( zTnorm .GE. 0)THEN
-                 zice_vol_pos = (zTnorm)*   &
-                                      (1.0 - frld(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J))  &
-                                     *(hsnif(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J) +  &
-                                       hicif(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J)) &
-                                      +zice_vol_pos
-                 zice_surf_pos = (zTnorm)*   &
-                                       (1.0 -  frld(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J))  &
-                                      +zice_surf_pos
-              ELSE
-                 zice_vol_neg=(zTnorm)*   &
-                                   (1.0 - frld(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J))  &
-                                  *(hsnif(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J) +  &
-                                    hicif(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J)) &
-                                  +zice_vol_neg
-                 zice_surf_neg=(zTnorm)*   &
-                                    (1.0 - frld(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J))  &
-                                     +zice_surf_neg
-              ENDIF
-   
-              zsum(11,1) = zsum(11,1)+zice_vol_pos
-              zsum(12,1) = zsum(12,1)+zice_vol_neg
-              zsum(13,1) = zsum(13,1)+zice_surf_pos
-              zsum(14,1) = zsum(14,1)+zice_surf_neg
+              transports_2d(1,jsec,jseg) = transports_2d(1,jsec,jseg) + (zTnorm)*   & 
+                                   (1.0 - frld(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J))  & 
+                                  *(hsnif(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J) +  & 
+                                    hicif(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J))
+              transports_2d(2,jsec,jseg) = transports_2d(2,jsec,jseg) + (zTnorm)*   & 
+                                    (1.0 -  frld(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J))
    
            ENDIF !end of ice case
@@ -846,51 +784,199 @@
         ENDDO !end of loop on the segment
 
-
-     ELSE  !if sec%nb_point =0
-        zsum(1:2,:)=0.
-        IF (sec%llstrpond) zsum(3:10,:)=0.
-        zsum( 11:14,:)=0.
-     ENDIF   !end of sec%nb_point =0 case
-
-     !-------------------------------|
-     !FINISH COMPUTING TRANSPORTS    |
-     !-------------------------------|
-     DO jclass=1,MAX(1,sec%nb_class-1)
-        sec%transport(1,jclass)=sec%transport(1,jclass)+zsum(1,jclass)*1.E-6
-        sec%transport(2,jclass)=sec%transport(2,jclass)+zsum(2,jclass)*1.E-6
-        IF( sec%llstrpond ) THEN
-           IF( zsum(1,jclass) .NE. 0._wp ) THEN
-              sec%transport( 3,jclass) = sec%transport( 3,jclass) + zsum( 3,jclass)/zsum(1,jclass)
-              sec%transport( 5,jclass) = sec%transport( 5,jclass) + zsum( 5,jclass)/zsum(1,jclass)
-              sec%transport( 7,jclass) = sec%transport( 7,jclass) + zsum( 7,jclass)
-              sec%transport( 9,jclass) = sec%transport( 9,jclass) + zsum( 9,jclass)
-           ENDIF
-           IF( zsum(2,jclass) .NE. 0._wp )THEN
-              sec%transport( 4,jclass) = sec%transport( 4,jclass) + zsum( 4,jclass)/zsum(2,jclass)
-              sec%transport( 6,jclass) = sec%transport( 6,jclass) + zsum( 6,jclass)/zsum(2,jclass)
-              sec%transport( 8,jclass) = sec%transport( 8,jclass) + zsum( 8,jclass)
-              sec%transport(10,jclass) = sec%transport(10,jclass) + zsum(10,jclass)
-           ENDIF
-        ELSE
-           sec%transport( 3,jclass) = 0._wp
-           sec%transport( 4,jclass) = 0._wp
-           sec%transport( 5,jclass) = 0._wp
-           sec%transport( 6,jclass) = 0._wp
-           sec%transport( 7,jclass) = 0._wp
-           sec%transport( 8,jclass) = 0._wp
-           sec%transport(10,jclass) = 0._wp
-        ENDIF
-     ENDDO   
-
-     IF( sec%ll_ice_section ) THEN
-        sec%transport( 9,1)=sec%transport( 9,1)+zsum( 9,1)*1.E-6
-        sec%transport(10,1)=sec%transport(10,1)+zsum(10,1)*1.E-6
-        sec%transport(11,1)=sec%transport(11,1)+zsum(11,1)*1.E-6
-        sec%transport(12,1)=sec%transport(12,1)+zsum(12,1)*1.E-6
-     ENDIF
-
-     CALL wrk_dealloc( nb_type_class , nb_class_max , zsum   )
+     ENDIF !end of sec%nb_point =0 case
      !
   END SUBROUTINE transport
+  
+  SUBROUTINE dia_dct_sum(sec,jsec) 
+     !!------------------------------------------------------------- 
+     !! Purpose: Average the transport over nn_dctwri time steps  
+     !! and sum over the density/salinity/temperature/depth classes 
+     !! 
+     !! Method:   Sum over relevant grid cells to obtain values  
+     !!           for each class
+     !!              There are several loops:                  
+     !!              loop on the segment between 2 nodes 
+     !!              loop on the level jk 
+     !!              loop on the density/temperature/salinity/level classes 
+     !!              test on the density/temperature/salinity/level 
+     !! 
+     !!  Note:    Transport through a given section is equal to the sum of transports 
+     !!           computed on each proc. 
+     !!           On each proc,transport is equal to the sum of transport computed through 
+     !!           segments linking each point of sec%listPoint  with the next one.    
+     !! 
+     !!------------------------------------------------------------- 
+     !! * arguments 
+     TYPE(SECTION),INTENT(INOUT) :: sec 
+     INTEGER      ,INTENT(IN)    :: jsec        ! numeric identifier of section 
+ 
+     TYPE(POINT_SECTION) :: k 
+     INTEGER  :: jk,jseg,jclass                        ! dummy variables for looping on level/segment/classes  
+     REAL(wp) :: ztn, zsn, zrhoi, zrhop, zsshn, zfsdep ! temperature/salinity/ssh/potential density /depth at u/v point 
+     !!------------------------------------------------------------- 
+ 
+     !! Sum the relevant segments to obtain values for each class 
+     IF(sec%nb_point .NE. 0)THEN    
+ 
+        !--------------------------------------! 
+        ! LOOP ON THE SEGMENT BETWEEN 2 NODES  ! 
+        !--------------------------------------! 
+        DO jseg=1,MAX(sec%nb_point-1,0) 
+            
+           !------------------------------------------------------------------------------------------- 
+           ! Select the appropriate coordinate for computing the velocity of the segment 
+           ! 
+           !                      CASE(0)                                    Case (2) 
+           !                      -------                                    -------- 
+           !  listPoint(jseg)                 listPoint(jseg+1)       listPoint(jseg)  F(i,j)       
+           !      F(i,j)----------V(i+1,j)-------F(i+1,j)                               | 
+           !                                                                            | 
+           !                                                                            | 
+           !                                                                            | 
+           !                      Case (3)                                            U(i,j) 
+           !                      --------                                              | 
+           !                                                                            | 
+           !  listPoint(jseg+1) F(i,j+1)                                                | 
+           !                        |                                                   | 
+           !                        |                                                   | 
+           !                        |                                 listPoint(jseg+1) F(i,j-1) 
+           !                        |                                             
+           !                        |                                             
+           !                     U(i,j+1)                                             
+           !                        |                                       Case(1)      
+           !                        |                                       ------       
+           !                        |                                             
+           !                        |                 listPoint(jseg+1)             listPoint(jseg)                            
+           !                        |                 F(i-1,j)-----------V(i,j) -------f(jseg)                            
+           ! listPoint(jseg)     F(i,j) 
+           !  
+           !------------------------------------------------------------------------------------------- 
+ 
+           SELECT CASE( sec%direction(jseg) ) 
+           CASE(0)  ;   k = sec%listPoint(jseg) 
+           CASE(1)  ;   k = POINT_SECTION(sec%listPoint(jseg)%I+1,sec%listPoint(jseg)%J) 
+           CASE(2)  ;   k = sec%listPoint(jseg) 
+           CASE(3)  ;   k = POINT_SECTION(sec%listPoint(jseg)%I,sec%listPoint(jseg)%J+1) 
+           END SELECT 
+ 
+           !---------------------------| 
+           !     LOOP ON THE LEVEL     | 
+           !---------------------------| 
+           !Sum of the transport on the vertical  
+           DO jk=1,mbathy(k%I,k%J) 
+ 
+              ! compute temperature, salinity, insitu & potential density, ssh and depth at U/V point 
+              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) 
+
+              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) 
+                 zsshn =  0.5*( sshn(k%I,k%J)    + sshn(k%I+1,k%J)    ) * umask(k%I,k%J,1)  
+              END SELECT 
+ 
+              zfsdep= gdept(k%I,k%J,jk) 
+  
+              !------------------------------- 
+              !  LOOP ON THE DENSITY CLASSES | 
+              !------------------------------- 
+              !The computation is made for each density/temperature/salinity/depth class 
+              DO jclass=1,MAX(1,sec%nb_class-1) 
+ 
+                 !----------------------------------------------! 
+                 !TEST ON THE DENSITY/SALINITY/TEMPERATURE/LEVEL!  
+                 !----------------------------------------------! 
+
+                 IF ( (                                                    & 
+                    ((( zrhop .GE. (sec%zsigp(jclass)+1000.  )) .AND.      & 
+                    (   zrhop .LE. (sec%zsigp(jclass+1)+1000. ))) .OR.     & 
+                    ( sec%zsigp(jclass) .EQ. 99.)) .AND.                   & 
+ 
+                    ((( zrhoi .GE. (sec%zsigi(jclass) + 1000.  )) .AND.    & 
+                    (   zrhoi .LE. (sec%zsigi(jclass+1)+1000. ))) .OR.     & 
+                    ( sec%zsigi(jclass) .EQ. 99.)) .AND.                   & 
+ 
+                    ((( zsn .GT. sec%zsal(jclass)) .AND.                   & 
+                    (   zsn .LE. sec%zsal(jclass+1))) .OR.                 & 
+                    ( sec%zsal(jclass) .EQ. 99.)) .AND.                    & 
+ 
+                    ((( ztn .GE. sec%ztem(jclass)) .AND.                   & 
+                    (   ztn .LE. sec%ztem(jclass+1))) .OR.                 & 
+                    ( sec%ztem(jclass) .EQ.99.)) .AND.                     & 
+ 
+                    ((( zfsdep .GE. sec%zlay(jclass)) .AND.                & 
+                    (   zfsdep .LE. sec%zlay(jclass+1))) .OR.              & 
+                    ( sec%zlay(jclass) .EQ. 99. ))                         & 
+                                                                   ))   THEN 
+ 
+                    !SUM THE TRANSPORTS FOR EACH CLASSES FOR THE POSITIVE AND NEGATIVE DIRECTIONS 
+                    !---------------------------------------------------------------------------- 
+                    IF (transports_3d(1,jsec,jseg,jk) .GE. 0.0) THEN  
+                       sec%transport(1,jclass) = sec%transport(1,jclass)+transports_3d(1,jsec,jseg,jk)*1.E-6 
+                    ELSE 
+                       sec%transport(2,jclass) = sec%transport(2,jclass)+transports_3d(1,jsec,jseg,jk)*1.E-6 
+                    ENDIF 
+                    IF( sec%llstrpond )THEN 
+ 
+                       IF ( transports_3d(2,jsec,jseg,jk) .GE. 0.0 ) THEN 
+                          sec%transport(3,jclass) = sec%transport(3,jclass)+transports_3d(2,jsec,jseg,jk) 
+                       ELSE 
+                          sec%transport(4,jclass) = sec%transport(4,jclass)+transports_3d(2,jsec,jseg,jk) 
+                       ENDIF 
+ 
+                       IF ( transports_3d(3,jsec,jseg,jk) .GE. 0.0 ) THEN 
+                          sec%transport(5,jclass) = sec%transport(5,jclass)+transports_3d(3,jsec,jseg,jk) 
+                       ELSE 
+                          sec%transport(6,jclass) = sec%transport(6,jclass)+transports_3d(3,jsec,jseg,jk) 
+                       ENDIF 
+ 
+                    ELSE 
+                       sec%transport( 3,jclass) = 0._wp 
+                       sec%transport( 4,jclass) = 0._wp 
+                       sec%transport( 5,jclass) = 0._wp 
+                       sec%transport( 6,jclass) = 0._wp 
+                    ENDIF 
+ 
+                 ENDIF ! end of test if point is in class 
+    
+              ENDDO ! end of loop on the classes 
+ 
+           ENDDO ! loop over jk 
+ 
+#if defined key_lim2 || defined key_lim3 
+ 
+           !ICE CASE     
+           IF( sec%ll_ice_section )THEN 
+ 
+              IF ( transports_2d(1,jsec,jseg) .GE. 0.0 ) THEN 
+                 sec%transport( 7,1) = sec%transport( 7,1)+transports_2d(1,jsec,jseg)*1.E-6 
+              ELSE 
+                 sec%transport( 8,1) = sec%transport( 8,1)+transports_2d(1,jsec,jseg)*1.E-6 
+              ENDIF 
+ 
+              IF ( transports_2d(3,jsec,jseg) .GE. 0.0 ) THEN 
+                 sec%transport( 9,1) = sec%transport( 9,1)+transports_2d(2,jsec,jseg)*1.E-6 
+              ELSE 
+                 sec%transport(10,1) = sec%transport(10,1)+transports_2d(2,jsec,jseg)*1.E-6 
+              ENDIF 
+ 
+           ENDIF !end of ice case 
+#endif 
+  
+        ENDDO !end of loop on the segment 
+ 
+     ELSE  !if sec%nb_point =0 
+        sec%transport(1:2,:)=0. 
+        IF (sec%llstrpond) sec%transport(3:6,:)=0. 
+        IF (sec%ll_ice_section) sec%transport(7:10,:)=0. 
+     ENDIF !end of sec%nb_point =0 case 
+ 
+  END SUBROUTINE dia_dct_sum 
   
   SUBROUTINE dia_dct_wri(kt,ksec,sec)
@@ -905,8 +991,8 @@
      !! 
      !!        2. Write heat transports in "heat_transport"
-     !!           Unit: Peta W : area * Velocity * T * rhau * Cp / 1.e15
+     !!           Unit: Peta W : area * Velocity * T * rhop * Cp * 1.e-15
      !! 
      !!        3. Write salt transports in "salt_transport"
-     !!           Unit: 10^9 g m^3 / s : area * Velocity * S / 1.e6
+     !!           Unit: 10^9 Kg/m^2/s : area * Velocity * S * rhop * 1.e-9 
      !!
      !!------------------------------------------------------------- 
@@ -917,68 +1003,66 @@
 
      !!local declarations
-     INTEGER               :: jcl,ji             ! Dummy loop
+     INTEGER               :: jclass             ! Dummy loop
      CHARACTER(len=2)      :: classe             ! Classname 
      REAL(wp)              :: zbnd1,zbnd2        ! Class bounds
      REAL(wp)              :: zslope             ! section's slope coeff
      !
-     REAL(wp), POINTER, DIMENSION(:):: zsumclass ! 1D workspace 
+     REAL(wp), POINTER, DIMENSION(:):: zsumclasses ! 1D workspace 
      !!------------------------------------------------------------- 
-     CALL wrk_alloc(nb_type_class , zsumclass )  
-
-     zsumclass(:)=0._wp
+     CALL wrk_alloc(nb_type_class , zsumclasses )  
+
+     zsumclasses(:)=0._wp
      zslope = sec%slopeSection       
 
  
-     DO jcl=1,MAX(1,sec%nb_class-1)
-
-        ! Mean computation
-        sec%transport(:,jcl)=sec%transport(:,jcl)/(nn_dctwri/nn_dct)
+     DO jclass=1,MAX(1,sec%nb_class-1)
+
         classe   = 'N       '
         zbnd1   = 0._wp
         zbnd2   = 0._wp
-        zsumclass(1:nb_type_class)=zsumclass(1:nb_type_class)+sec%transport(1:nb_type_class,jcl)
+        zsumclasses(1:nb_type_class)=zsumclasses(1:nb_type_class)+sec%transport(1:nb_type_class,jclass)
 
    
         !insitu density classes transports
-        IF( ( sec%zsigi(jcl)   .NE. 99._wp ) .AND. &
-            ( sec%zsigi(jcl+1) .NE. 99._wp )       )THEN
+        IF( ( sec%zsigi(jclass)   .NE. 99._wp ) .AND. &
+            ( sec%zsigi(jclass+1) .NE. 99._wp )       )THEN
            classe = 'DI       '
-           zbnd1 = sec%zsigi(jcl)
-           zbnd2 = sec%zsigi(jcl+1)
+           zbnd1 = sec%zsigi(jclass)
+           zbnd2 = sec%zsigi(jclass+1)
         ENDIF
         !potential density classes transports
-        IF( ( sec%zsigp(jcl)   .NE. 99._wp ) .AND. &
-            ( sec%zsigp(jcl+1) .NE. 99._wp )       )THEN
+        IF( ( sec%zsigp(jclass)   .NE. 99._wp ) .AND. &
+            ( sec%zsigp(jclass+1) .NE. 99._wp )       )THEN
            classe = 'DP      '
-           zbnd1 = sec%zsigp(jcl)
-           zbnd2 = sec%zsigp(jcl+1)
+           zbnd1 = sec%zsigp(jclass)
+           zbnd2 = sec%zsigp(jclass+1)
         ENDIF
         !depth classes transports
-        IF( ( sec%zlay(jcl)    .NE. 99._wp ) .AND. &
-            ( sec%zlay(jcl+1)  .NE. 99._wp )       )THEN 
+        IF( ( sec%zlay(jclass)    .NE. 99._wp ) .AND. &
+            ( sec%zlay(jclass+1)  .NE. 99._wp )       )THEN 
            classe = 'Z       '
-           zbnd1 = sec%zlay(jcl)
-           zbnd2 = sec%zlay(jcl+1)
+           zbnd1 = sec%zlay(jclass)
+           zbnd2 = sec%zlay(jclass+1)
         ENDIF
         !salinity classes transports
-        IF( ( sec%zsal(jcl) .NE. 99._wp    ) .AND. &
-            ( sec%zsal(jcl+1) .NE. 99._wp  )       )THEN
+        IF( ( sec%zsal(jclass) .NE. 99._wp    ) .AND. &
+            ( sec%zsal(jclass+1) .NE. 99._wp  )       )THEN
            classe = 'S       '
-           zbnd1 = sec%zsal(jcl)
-           zbnd2 = sec%zsal(jcl+1)   
+           zbnd1 = sec%zsal(jclass)
+           zbnd2 = sec%zsal(jclass+1)   
         ENDIF
         !temperature classes transports
-        IF( ( sec%ztem(jcl) .NE. 99._wp     ) .AND. &
-            ( sec%ztem(jcl+1) .NE. 99._wp     )       ) THEN
+        IF( ( sec%ztem(jclass) .NE. 99._wp     ) .AND. &
+            ( sec%ztem(jclass+1) .NE. 99._wp     )       ) THEN
            classe = 'T       '
-           zbnd1 = sec%ztem(jcl)
-           zbnd2 = sec%ztem(jcl+1)
+           zbnd1 = sec%ztem(jclass)
+           zbnd2 = sec%ztem(jclass+1)
         ENDIF
                   
         !write volume transport per class
         WRITE(numdct_vol,118) ndastp,kt,ksec,sec%name,zslope, &
-                              jcl,classe,zbnd1,zbnd2,&
-                              sec%transport(1,jcl),sec%transport(2,jcl), &
-                              sec%transport(1,jcl)+sec%transport(2,jcl)
+                              jclass,classe,zbnd1,zbnd2,&
+                              sec%transport(1,jclass),sec%transport(2,jclass), &
+                              sec%transport(1,jclass)+sec%transport(2,jclass)
 
         IF( sec%llstrpond )THEN
@@ -986,12 +1070,12 @@
            !write heat transport per class:
            WRITE(numdct_heat,119) ndastp,kt,ksec,sec%name,zslope,  &
-                              jcl,classe,zbnd1,zbnd2,&
-                              sec%transport(7,jcl)*1000._wp*rcp/1.e15,sec%transport(8,jcl)*1000._wp*rcp/1.e15, &
-                              ( sec%transport(7,jcl)+sec%transport(8,jcl) )*1000._wp*rcp/1.e15
+                              jclass,classe,zbnd1,zbnd2,&
+                              sec%transport(3,jclass)*1.e-15,sec%transport(4,jclass)*1.e-15, &
+                              ( sec%transport(3,jclass)+sec%transport(4,jclass) )*1.e-15
            !write salt transport per class
            WRITE(numdct_salt,119) ndastp,kt,ksec,sec%name,zslope,  &
-                              jcl,classe,zbnd1,zbnd2,&
-                              sec%transport(9,jcl)*1000._wp/1.e9,sec%transport(10,jcl)*1000._wp/1.e9,&
-                              (sec%transport(9,jcl)+sec%transport(10,jcl))*1000._wp/1.e9
+                              jclass,classe,zbnd1,zbnd2,&
+                              sec%transport(5,jclass)*1.e-9,sec%transport(6,jclass)*1.e-9,&
+                              (sec%transport(5,jclass)+sec%transport(6,jclass))*1.e-9
         ENDIF
 
@@ -1000,10 +1084,10 @@
      zbnd1 = 0._wp
      zbnd2 = 0._wp
-     jcl=0
+     jclass=0
 
      !write total volume transport
      WRITE(numdct_vol,118) ndastp,kt,ksec,sec%name,zslope, &
-                           jcl,"total",zbnd1,zbnd2,&
-                           zsumclass(1),zsumclass(2),zsumclass(1)+zsumclass(2)
+                           jclass,"total",zbnd1,zbnd2,&
+                           zsumclasses(1),zsumclasses(2),zsumclasses(1)+zsumclasses(2)
 
      IF( sec%llstrpond )THEN
@@ -1011,12 +1095,12 @@
         !write total heat transport
         WRITE(numdct_heat,119) ndastp,kt,ksec,sec%name,zslope, &
-                           jcl,"total",zbnd1,zbnd2,&
-                           zsumclass(7)* 1000._wp*rcp/1.e15,zsumclass(8)* 1000._wp*rcp/1.e15,&
-                           (zsumclass(7)+zsumclass(8) )* 1000._wp*rcp/1.e15
+                           jclass,"total",zbnd1,zbnd2,&
+                           zsumclasses(3)*1.e-15,zsumclasses(4)*1.e-15,&
+                           (zsumclasses(3)+zsumclasses(4) )*1.e-15
         !write total salt transport
         WRITE(numdct_salt,119) ndastp,kt,ksec,sec%name,zslope, &
-                           jcl,"total",zbnd1,zbnd2,&
-                           zsumclass(9)*1000._wp/1.e9,zsumclass(10)*1000._wp/1.e9,&
-                           (zsumclass(9)+zsumclass(10))*1000._wp/1.e9
+                           jclass,"total",zbnd1,zbnd2,&
+                           zsumclasses(5)*1.e-9,zsumclasses(6)*1.e-9,&
+                           (zsumclasses(5)+zsumclasses(6))*1.e-9
      ENDIF
 
@@ -1025,12 +1109,12 @@
         !write total ice volume transport
         WRITE(numdct_vol,118) ndastp,kt,ksec,sec%name,zslope,&
-                              jcl,"ice_vol",zbnd1,zbnd2,&
-                              sec%transport(9,1),sec%transport(10,1),&
-                              sec%transport(9,1)+sec%transport(10,1)
+                              jclass,"ice_vol",zbnd1,zbnd2,&
+                              sec%transport(7,1),sec%transport(8,1),&
+                              sec%transport(7,1)+sec%transport(8,1)
         !write total ice surface transport
         WRITE(numdct_vol,118) ndastp,kt,ksec,sec%name,zslope,&
-                              jcl,"ice_surf",zbnd1,zbnd2,&
-                              sec%transport(11,1),sec%transport(12,1), &
-                              sec%transport(11,1)+sec%transport(12,1) 
+                              jclass,"ice_surf",zbnd1,zbnd2,&
+                              sec%transport(9,1),sec%transport(10,1), &
+                              sec%transport(9,1)+sec%transport(10,1) 
      ENDIF
                                               
@@ -1038,5 +1122,5 @@
 119 FORMAT(I8,1X,I8,1X,I4,1X,A30,1X,f9.2,1X,I4,3X,A8,1X,2F12.4,5X,3E15.6)
 
-     CALL wrk_dealloc(nb_type_class , zsumclass )  
+     CALL wrk_dealloc(nb_type_class , zsumclasses )  
   END SUBROUTINE dia_dct_wri
 
@@ -1044,5 +1128,5 @@
   !!----------------------------------------------------------------------
   !!
-  !!   Purpose: compute Temperature/Salinity/density at U-point or V-point
+  !!   Purpose: compute temperature/salinity/density at U-point or V-point
   !!   --------
   !!
@@ -1053,7 +1137,7 @@
   !! 
   !!
-  !!    |    I          |    I+1           |    Z=Temperature/Salinity/density at U-poinT
+  !!    |    I          |    I+1           |    Z=temperature/salinity/density at U-poinT
   !!    |               |                  |
-  !!  ----------------------------------------  1. Veritcale interpolation: compute zbis
+  !!  ----------------------------------------  1. Veritcal interpolation: compute zbis
   !!    |               |                  |       interpolation between ptab(I,J,K) and ptab(I,J,K+1)
   !!    |               |                  |       zbis = 
@@ -1136,5 +1220,5 @@
      zdep2 = fsdept(ii2,ij2,kk) - zdepu
 
-     !weights
+     ! weights
      zwgt1 = SQRT( ( 0.5 * zet1 ) * ( 0.5 * zet1 ) + ( zdep1 * zdep1 ) )
      zwgt2 = SQRT( ( 0.5 * zet2 ) * ( 0.5 * zet2 ) + ( zdep2 * zdep2 ) )
@@ -1163,10 +1247,10 @@
 
         IF( ze3t >= 0. )THEN 
-           !zbis
+           ! zbis
            zbis = ptab(ii2,ij2,kk) + zwgt1 * ( ptab(ii2,ij2,kk-1) - ptab(ii2,ij2,kk) ) 
            ! result
             interp = umask(ii1,ij1,kk) * ( zet2 * ptab(ii1,ij1,kk) + zet1 * zbis )/( zet1 + zet2 )
         ELSE
-           !zbis
+           ! zbis
            zbis = ptab(ii1,ij1,kk) + zwgt2 * ( ptab(ii1,ij1,kk-1) - ptab(ii1,ij2,kk) )
            ! result
@@ -1195,6 +1279,6 @@
    END SUBROUTINE dia_dct_init
 
-   SUBROUTINE dia_dct( kt )           ! Dummy routine
-      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+   SUBROUTINE dia_dct( kt )         ! Dummy routine
+      INTEGER, INTENT( in ) :: kt   ! ocean time-step index
       WRITE(*,*) 'dia_dct: You should not have seen this print! error?', kt
    END SUBROUTINE dia_dct
Index: /branches/2012/dev_UKMO_2012/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- /branches/2012/dev_UKMO_2012/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 3601)
+++ /branches/2012/dev_UKMO_2012/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 3602)
@@ -512,4 +512,7 @@
       USE ldftra_oce, ONLY: ldftra_oce_alloc
       USE trc_oce   , ONLY: trc_oce_alloc
+#if defined key_diadct 
+      USE diadct    , ONLY: diadct_alloc 
+#endif 
       !
       INTEGER :: ierr
@@ -525,4 +528,8 @@
       ierr = ierr + lib_mpp_alloc   (numout)    ! mpp exchanges
       ierr = ierr + trc_oce_alloc   ()          ! shared TRC / TRA arrays
+      !
+#if defined key_diadct 
+      ierr = ierr + diadct_alloc    ()          ! 
+#endif 
       !
       IF( lk_mpp    )   CALL mpp_sum( ierr )
Index: /branches/2012/dev_UKMO_2012/NEMOGCM/TOOLS/SECTIONS_DIADCT/src/declarations.f90
===================================================================
--- /branches/2012/dev_UKMO_2012/NEMOGCM/TOOLS/SECTIONS_DIADCT/src/declarations.f90	(revision 3601)
+++ /branches/2012/dev_UKMO_2012/NEMOGCM/TOOLS/SECTIONS_DIADCT/src/declarations.f90	(revision 3602)
@@ -15,5 +15,5 @@
   INTEGER, PUBLIC, PARAMETER   :: nb_sec_max    = 150           ! Max number of sections
   INTEGER, PUBLIC, PARAMETER   :: nb_point_max  = 2000          ! Max number of segments per section
-  INTEGER, PUBLIC, PARAMETER   :: nb_type_class = 14            ! Max number of types of classes
+  INTEGER, PUBLIC, PARAMETER   :: nb_type_class = 10            ! Max number of types of classes
   INTEGER, PUBLIC, PARAMETER   :: numnam=3                      ! Unit for namelist
   INTEGER, PUBLIC, PARAMETER   :: numdctin=1                    ! Unit for input file
