Index: branches/2011/dev_r2802_MERCATOR10_diadct/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90
===================================================================
--- branches/2011/dev_r2802_MERCATOR10_diadct/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 2919)
+++ branches/2011/dev_r2802_MERCATOR10_diadct/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 2927)
@@ -41,4 +41,5 @@
   USE ice
 #endif
+  USE domvvl
 
   IMPLICIT NONE
@@ -68,4 +69,8 @@
   INTEGER, PARAMETER :: nb_type_class = 14
   INTEGER            :: nb_sec 
+
+  LOGICAL            :: l_strpond ! FALSE: 0 section with heat/salt tranport
+                                  ! TRUE : 1 or more sections  with heat/salt tranport
+                                  ! Used to open/close output files for heat/salt tranport
  
   TYPE POINT_SECTION
@@ -81,5 +86,5 @@
      LOGICAL                                      :: llstrpond         ! true if you want the computation of salt and
                                                                        ! heat transports
-     LOGICAL                                      :: ll_ice_section    ! icesurf and icevol computation
+     LOGICAL                                      :: ll_ice_section    ! ice surface and ice volume computation
      LOGICAL                                      :: ll_date_line      ! = T if the section crosses the date-line
      TYPE(COORD_SECTION), DIMENSION(2)            :: coordSec          ! longitude and latitude of the extremities of the sec
@@ -93,7 +98,7 @@
                                                      zlay              ! level classes      (99 if you don't want)
      REAL(wp), DIMENSION(nb_type_class,nb_class_max)  :: transport     ! transport output
-     REAL(wp)                                         :: slopeSection  ! section's slopesection 
-     INTEGER                                          :: nb_point      ! section's number of points
-     TYPE(POINT_SECTION),DIMENSION(nb_point_max)      :: listPoint     ! section's list point
+     REAL(wp)                                         :: slopeSection  ! slope of the section
+     INTEGER                                          :: nb_point      ! number of points in section
+     TYPE(POINT_SECTION),DIMENSION(nb_point_max)      :: listPoint     ! list point in section
   END TYPE SECTION
 
@@ -134,13 +139,18 @@
           &  CALL ctl_stop( 'diadct: nn_dct should be smaller and a multiple of nn_dctwri' )
 
-        !open output file
-        CALL ctl_opn( numdct_vol,  'volume_transport', 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
-        CALL ctl_opn( numdct_heat, 'heat_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
-        CALL ctl_opn( numdct_salt, 'salt_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
-
      ENDIF
 
      !Read section_ijglobal.diadct
      CALL readsec
+
+     !open output file
+     IF( lwp ) THEN
+        CALL ctl_opn( numdct_vol,  'volume_transport', 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
+        IF( l_strpond )THEN
+           CALL ctl_opn( numdct_heat, 'heat_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
+           CALL ctl_opn( numdct_salt, 'salt_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
+        ENDIF
+     ENDIF
+
 
   END SUBROUTINE dia_dct_init
@@ -238,8 +248,11 @@
      INTEGER :: isec, iiglo, ijglo, iiloc, ijloc,iost,i1 ,i2  ! temporary  integer
      INTEGER :: jsec, jpt                                     ! dummy loop indices
+     INTEGER :: istrpond                                      ! count number of section for which 
+                                                              ! heat/salt tranport is actived
 
      INTEGER, DIMENSION(2) :: icoord 
-     CHARACTER(len=160)  :: clname                            !filename
-     CHARACTER(len=200)  :: cltmp
+     CHARACTER(len=160)    :: clname                          !filename
+     CHARACTER(len=200)    :: cltmp
+     CHARACTER(len=200)    :: clformat                        !automatic format
      TYPE(POINT_SECTION),DIMENSION(nb_point_max)  ::coordtemp !contains listpoints coordinates 
                                                               !read in the file
@@ -249,4 +262,6 @@
                 lldebug                                       !debug the section
      !!-------------------------------------------------------------------------------------
+     istrpond   =  0             ! init  to zero number of section for which heat/salt tranport is actived
+     l_strpond = .FALSE.        !
 
      !open input file
@@ -296,20 +311,25 @@
         READ(numdct_in)iptglo
 
+        istrpond = istrpond + COUNT((/secs(jsec)%llstrpond/))  
+
         !debug
         !-----
+
         IF( lwp .AND. ( jsec==nn_secdebug .OR. nn_secdebug==-1 ) )THEN
-            WRITE(numout,*)                  "   Section name :                       ",TRIM(secs(jsec)%name)
-            WRITE(numout,*)                  "      Compute heat and salt transport ? ",secs(jsec)%llstrpond
-            WRITE(numout,*)                  "      Compute ice transport ?           ",secs(jsec)%ll_ice_section
-            WRITE(numout,*)                  "      Section crosses date-line ?       ",secs(jsec)%ll_date_line
-            WRITE(numout,*)                  "      Slope section :                   ",secs(jsec)%slopeSection
-            WRITE(numout,*)                  "      Number of points in the section:  ",iptglo
-            WRITE(numout,*)                  "      Number of classes                 ",secs(jsec)%nb_class
-!            WRITE(numout,'(A40,10(f8.3,1X))')"      Insitu density classes :          ",secs(jsec)%zsigi
-            WRITE(numout,'(A40,nb_class_max(f8.3,1X))')"      Insitu density classes :          ",secs(jsec)%zsigi
-            WRITE(numout,'(A40,10(f8.3,1X))')"      Potential density classes :       ",secs(jsec)%zsigp
-            WRITE(numout,'(A40,10(f8.3,1X))')"      Salinity classes :                ",secs(jsec)%zsal
-            WRITE(numout,'(A40,10(f8.3,1X))')"      Temperature classes :             ",secs(jsec)%ztem
-            WRITE(numout,'(A40,10(f8.3,1X))')"      Depth classes :                   ",secs(jsec)%zlay
+          
+            WRITE(clformat,'(a,i2,a)') '(A40,', nb_class_max,'(f8.3,1X))' 
+
+            WRITE(numout,*)       "   Section name :                       ",TRIM(secs(jsec)%name)
+            WRITE(numout,*)       "      Compute heat and salt transport ? ",secs(jsec)%llstrpond
+            WRITE(numout,*)       "      Compute ice transport ?           ",secs(jsec)%ll_ice_section
+            WRITE(numout,*)       "      Section crosses date-line ?       ",secs(jsec)%ll_date_line
+            WRITE(numout,*)       "      Slope section :                   ",secs(jsec)%slopeSection
+            WRITE(numout,*)       "      Number of points in the section:  ",iptglo
+            WRITE(numout,*)       "      Number of classes                 ",secs(jsec)%nb_class
+            WRITE(numout,clformat)"      Insitu density classes :          ",secs(jsec)%zsigi
+            WRITE(numout,clformat)"      Potential density classes :       ",secs(jsec)%zsigp
+            WRITE(numout,clformat)"      Salinity classes :                ",secs(jsec)%zsal
+            WRITE(numout,clformat)"      Temperature classes :             ",secs(jsec)%ztem
+            WRITE(numout,clformat)"      Depth classes :                   ",secs(jsec)%zlay
         ENDIF               
 
@@ -402,4 +422,6 @@
      nb_sec = jsec-1   !number of section read in the file
 
+     IF( istrpond .GT. 0 ) l_strpond = .TRUE.   ! output file  for heat/salt transport actived
+
   END SUBROUTINE readsec
 
@@ -426,5 +448,4 @@
                 isgn          ,& ! isgn= 1 : scan listpoint from start to end
                                  ! isgn=-1 : scan listpoint from end to start 
-                ipoint        ,& !way of course in listpoint
                 istart,iend      !first and last points selected in listpoint
      INTEGER :: jpoint   =0      !loop on list points
@@ -485,15 +506,15 @@
      !!                     ***  ROUTINE transport  ***
      !!
-     !!  ** Purpose : Compute the transport trough a sec 
+     !!  ** Purpose : Compute the transport trough 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 points of sec%listPoint  with the next one.   
+     !!	             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 consectuives points in sec%listPoint
-     !!              all points of sec%listPoint are positionned on the F-point of the cell. 
+     !!              all points of sec%listPoint are positioned on the F-point of the cell. 
      !! 
      !!              There are several loops:                 
@@ -580,5 +601,5 @@
               
            !-------------------------------------------------------------------------------------------
-           ! Select good coordinate to have velocity of the segment:
+           ! Select the appropriate coordinate for computing the velocity of the segment
            !
            !                      CASE(0)                                    Case (2)
@@ -1098,15 +1119,11 @@
 #if defined key_vvl
 
-     ze3w  = fsve3w(ii2,ij2,kk) - fsve3w(ii1,ij1,kk)
-
-     zfse3 = fsve3w(ii1,ij1,kk) * ( 1 + sshn(ii2,ij2) * mut(ii2,ij2,kk) )
-     zwgt1 = ( fse3w(ii2,ij2,kk) - zfse3 )/ fse3w(ii2,ij2,kk)
-  
-     zfse3 = fsve3w(ii2,ij2,kk) * ( 1 + sshn(ii1,ij1) * mut(ii1,ij1,kk) )
-     zwgt2 = ( fse3w(ii1,ij1,kk) - zfse3 )/ fse3w(ii1,ij1,kk)
+     ze3t  = fse3t_n(ii2,ij2,kk) - fse3t_n(ii1,ij1,kk) 
+     zwgt1 = ( fse3w_n(ii2,ij2,kk) - fse3w_n(ii1,ij1,kk) ) / fse3w_n(ii2,ij2,kk)
+     zwgt2 = ( fse3w_n(ii1,ij1,kk) - fse3w_n(ii2,ij2,kk) ) / fse3w_n(ii1,ij1,kk)
 
 #else
 
-     ze3t  = fse3t(ii2,ij2,kk)-fse3t(ii1,ij1,kk) 
+     ze3t  = fse3t(ii2,ij2,kk)   - fse3t(ii1,ij1,kk) 
      zwgt1 = ( fse3w(ii2,ij2,kk) - fse3w(ii1,ij1,kk) ) / fse3w(ii2,ij2,kk)
      zwgt2 = ( fse3w(ii1,ij1,kk) - fse3w(ii2,ij2,kk) ) / fse3w(ii1,ij1,kk)
