Index: NEMO/trunk/src/OCE/DIA/diawri.F90
===================================================================
--- NEMO/trunk/src/OCE/DIA/diawri.F90	(revision 15062)
+++ NEMO/trunk/src/OCE/DIA/diawri.F90	(revision 15087)
@@ -135,4 +135,8 @@
       ENDIF
 
+      ! initialize arrays
+      z2d(:,:)   = 0._wp
+      z3d(:,:,:) = 0._wp
+      
       ! Output of initial vertical scale factor
       CALL iom_put("e3t_0", e3t_0(:,:,:) )
@@ -142,42 +146,45 @@
       !
       IF ( iom_use("tpt_dep") ) THEN
-         DO jk = 1, jpk
-            z3d(:,:,jk) = gdept(:,:,jk,Kmm)
-         END DO
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            z3d(ji,jj,jk) = gdept(ji,jj,jk,Kmm)
+         END_3D
          CALL iom_put( "tpt_dep", z3d )
       ENDIF
 
+      ! --- vertical scale factors --- !
       IF ( iom_use("e3t") .OR. iom_use("e3tdef") ) THEN  ! time-varying e3t
-         DO jk = 1, jpk
-            z3d(:,:,jk) =  e3t(:,:,jk,Kmm)
-         END DO
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            z3d(ji,jj,jk) =  e3t(ji,jj,jk,Kmm)
+         END_3D
          CALL iom_put( "e3t", z3d )
          IF ( iom_use("e3tdef") ) THEN
-            z3d(:,:,:) = ( ( z3d(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100._wp * tmask(:,:,:) ) ** 2 
+            DO_3D( 0, 0, 0, 0, 1, jpk )
+               z3d(ji,jj,jk) = ( ( z3d(ji,jj,jk) - e3t_0(ji,jj,jk) ) / e3t_0(ji,jj,jk) * 100._wp * tmask(ji,jj,jk) ) ** 2
+            END_3D
             CALL iom_put( "e3tdef", z3d ) 
          ENDIF
       ENDIF 
       IF ( iom_use("e3u") ) THEN                         ! time-varying e3u
-         DO jk = 1, jpk
-            z3d(:,:,jk) =  e3u(:,:,jk,Kmm)
-         END DO 
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            z3d(ji,jj,jk) =  e3u(ji,jj,jk,Kmm)
+         END_3D 
          CALL iom_put( "e3u" , z3d )
       ENDIF
       IF ( iom_use("e3v") ) THEN                         ! time-varying e3v
-         DO jk = 1, jpk
-            z3d(:,:,jk) =  e3v(:,:,jk,Kmm)
-         END DO 
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            z3d(ji,jj,jk) =  e3v(ji,jj,jk,Kmm)
+         END_3D
          CALL iom_put( "e3v" , z3d )
       ENDIF
       IF ( iom_use("e3w") ) THEN                         ! time-varying e3w
-         DO jk = 1, jpk
-            z3d(:,:,jk) =  e3w(:,:,jk,Kmm)
-         END DO 
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            z3d(ji,jj,jk) =  e3w(ji,jj,jk,Kmm)
+         END_3D
          CALL iom_put( "e3w" , z3d )
       ENDIF
       IF ( iom_use("e3f") ) THEN                         ! time-varying e3f caution here at Kaa
-          DO jk = 1, jpk
-            z3d(:,:,jk) =  e3f(:,:,jk)
-         END DO
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            z3d(ji,jj,jk) =  e3f(ji,jj,jk)
+         END_3D
          CALL iom_put( "e3f" , z3d )
       ENDIF
@@ -199,7 +206,9 @@
       IF( iom_use("hf") )   CALL iom_put( "hf" , hf_0(:,:)*( 1._wp + r3f(:,:) ) )   ! water column at f-point (caution here at Naa)
 #endif
-      
+
+      ! --- tracers T&S --- !      
       CALL iom_put( "toce", ts(:,:,:,jp_tem,Kmm) )    ! 3D temperature
       CALL iom_put(  "sst", ts(:,:,1,jp_tem,Kmm) )    ! surface temperature
+
       IF ( iom_use("sbt") ) THEN
          DO_2D( 0, 0, 0, 0 )
@@ -222,4 +231,5 @@
       IF( .NOT.lk_SWE )   CALL iom_put( "rhop", rhop(:,:,:) )          ! 3D potential density (sigma0)
 
+      ! --- momentum --- !
       IF ( iom_use("taubot") ) THEN                ! bottom stress
          zztmp = rho0 * 0.25_wp
@@ -257,17 +267,26 @@
 
       !                                            ! vertical velocity
-      IF( ln_zad_Aimp ) THEN   ;   IF( iom_use('woce') )   CALL iom_put( "woce", ww + wi )   ! explicit plus implicit parts
-      ELSE                     ;                           CALL iom_put( "woce", ww )
+      IF( ln_zad_Aimp ) THEN
+         IF( iom_use('woce') ) THEN
+            DO_3D( 0, 0, 0, 0, 1, jpk )
+               z3d(ji,jj,jk) = ww(ji,jj,jk) + wi(ji,jj,jk)
+            END_3D
+            CALL iom_put( "woce", z3d )   ! explicit plus implicit parts
+         ENDIF
+      ELSE
+         CALL iom_put( "woce", ww )
       ENDIF
 
       IF( iom_use('w_masstr') .OR. iom_use('w_masstr2') ) THEN   ! vertical mass transport & its square value
          !                     ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
-         DO jk = 1, jpk
-            IF( ln_zad_Aimp ) THEN
-               z3d(:,:,jk) = rho0 * e1e2t(:,:) * ( ww(:,:,jk) + wi(:,:,jk) )
-            ELSE
-               z3d(:,:,jk) = rho0 * e1e2t(:,:) * ww(:,:,jk)
-            ENDIF
-         END DO
+         IF( ln_zad_Aimp ) THEN
+            DO_3D( 0, 0, 0, 0, 1, jpk )
+               z3d(ji,jj,jk) = rho0 * e1e2t(ji,jj) * ( ww(ji,jj,jk) + wi(ji,jj,jk) )
+            END_3D
+         ELSE
+            DO_3D( 0, 0, 0, 0, 1, jpk )
+               z3d(ji,jj,jk) = rho0 * e1e2t(ji,jj) * ww(ji,jj,jk)
+            END_3D
+         ENDIF
          CALL iom_put( "w_masstr" , z3d )  
          IF( iom_use('w_masstr2') )   CALL iom_put( "w_masstr2", z3d * z3d )
@@ -341,6 +360,5 @@
       !
       IF ( iom_use("ke") .OR. iom_use("ke_int") ) THEN
-         z3d(:,:,jpk) = 0._wp 
-         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
+         DO_3D( 0, 0, 0, 0, 1, jpk )
             zztmpx = uu(ji-1,jj  ,jk,Kmm) + uu(ji,jj,jk,Kmm)
             zztmpy = vv(ji  ,jj-1,jk,Kmm) + vv(ji,jj,jk,Kmm)
@@ -384,8 +402,7 @@
       IF( iom_use("u_masstr") .OR. iom_use("u_masstr_vint") .OR. iom_use("u_heattr") .OR. iom_use("u_salttr") ) THEN
          
-         z3d(:,:,jpk) = 0._wp
-         DO jk = 1, jpkm1
-            z3d(:,:,jk) = rho0 * uu(:,:,jk,Kmm) * e2u(:,:) * e3u(:,:,jk,Kmm) * umask(:,:,jk)
-         END DO
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            z3d(ji,jj,jk) = rho0 * uu(ji,jj,jk,Kmm) * e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * umask(ji,jj,jk)
+         END_3D
          CALL iom_put( "u_masstr"     , z3d )      ! mass transport in i-direction
          
@@ -393,5 +410,5 @@
             z2d(:,:) = 0._wp 
             DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-               z2d(:,:) = z2d(:,:) + z3d(:,:,jk)
+               z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk)
             END_3D
             CALL iom_put( "u_masstr_vint", z2d )   ! mass transport in i-direction vertical sum
@@ -417,8 +434,7 @@
       IF( iom_use("v_masstr") .OR. iom_use("v_heattr") .OR. iom_use("v_salttr") ) THEN
          
-         z3d(:,:,jpk) = 0._wp
-         DO jk = 1, jpkm1
-            z3d(:,:,jk) = rho0 * vv(:,:,jk,Kmm) * e1v(:,:) * e3v(:,:,jk,Kmm) * vmask(:,:,jk)
-         END DO
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            z3d(ji,jj,jk) = rho0 * vv(ji,jj,jk,Kmm) * e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * vmask(ji,jj,jk)
+         END_3D
          CALL iom_put( "v_masstr", z3d )           ! mass transport in j-direction
          
