Index: branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90
===================================================================
--- branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90	(revision 8705)
+++ branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90	(revision 8708)
@@ -86,5 +86,5 @@
             ENDIF
             !
-            CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kiolib = jprstlib )
+            CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kiolib = jprstlib, ndlev = jpl )
             lrst_ice = .TRUE.
          ENDIF
@@ -107,8 +107,8 @@
       CHARACTER(len=25) ::   znam
       CHARACTER(len=2)  ::   zchar, zchar1
-      REAL(wp), POINTER, DIMENSION(:,:) :: z2d
-      !!----------------------------------------------------------------------
-
-      CALL wrk_alloc( jpi, jpj, z2d )
+      REAL(wp), POINTER, DIMENSION(:,:, :) :: z3d
+      !!----------------------------------------------------------------------
+
+      CALL wrk_alloc( jpi, jpj, jpl,  z3d )
 
       iter = kt + nn_fsbc - 1   ! ice restarts are written at kt == nitrst - nn_fsbc + 1
@@ -127,33 +127,24 @@
 
       ! Prognostic variables 
-      DO jl = 1, jpl 
-         WRITE(zchar,'(I2.2)') jl
-         znam = 'v_i'//'_htc'//zchar
-         z2d(:,:) = v_i(:,:,jl)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-         znam = 'v_s'//'_htc'//zchar
-         z2d(:,:) = v_s(:,:,jl)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-         znam = 'smv_i'//'_htc'//zchar
-         z2d(:,:) = smv_i(:,:,jl)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-         znam = 'oa_i'//'_htc'//zchar
-         z2d(:,:) = oa_i(:,:,jl)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-         znam = 'a_i'//'_htc'//zchar
-         z2d(:,:) = a_i(:,:,jl)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-         znam = 't_su'//'_htc'//zchar
-         z2d(:,:) = t_su(:,:,jl)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-         znam = 'tempt_sl1'//'_htc'//zchar
-         z2d(:,:) = e_s(:,:,1,jl)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-         DO jk = 1, nlay_i 
-            WRITE(zchar1,'(I2.2)') jk
-            znam = 'tempt'//'_il'//zchar1//'_htc'//zchar
-            z2d(:,:) = e_i(:,:,jk,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-         END DO
+      znam = 'v_i'
+      CALL iom_rstput( iter, nitrst, numriw, znam , v_i )
+      znam = 'v_s'
+      CALL iom_rstput( iter, nitrst, numriw, znam , v_s )
+      znam = 'smv_i'
+      CALL iom_rstput( iter, nitrst, numriw, znam , smv_i )
+      znam = 'oa_i'
+      CALL iom_rstput( iter, nitrst, numriw, znam , oa_i )
+      znam = 'a_i'
+      CALL iom_rstput( iter, nitrst, numriw, znam , a_i )
+      znam = 't_su'
+      CALL iom_rstput( iter, nitrst, numriw, znam , t_su )
+      znam = 'tempt_sl1'
+      z3d = e_s(:,:,1,:)
+      CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
+      DO jk = 1, nlay_i 
+         WRITE(zchar1,'(I2.2)') jk
+         znam = 'tempt'//'_il'//zchar1
+         z3d(:,:,:) = e_i(:,:,jk,:)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
       END DO
 
@@ -169,98 +160,65 @@
       ! ------------------------------------------------------------------------
       IF( nn_limadv == -1 ) THEN
-         
-         DO jl = 1, jpl 
-            WRITE(zchar,'(I2.2)') jl
-            znam = 'sxice'//'_htc'//zchar
-            z2d(:,:) = sxice(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'syice'//'_htc'//zchar
-            z2d(:,:) = syice(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxxice'//'_htc'//zchar
-            z2d(:,:) = sxxice(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'syyice'//'_htc'//zchar
-            z2d(:,:) = syyice(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxyice'//'_htc'//zchar
-            z2d(:,:) = sxyice(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxsn'//'_htc'//zchar
-            z2d(:,:) = sxsn(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sysn'//'_htc'//zchar
-            z2d(:,:) = sysn(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxxsn'//'_htc'//zchar
-            z2d(:,:) = sxxsn(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'syysn'//'_htc'//zchar
-            z2d(:,:) = syysn(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxysn'//'_htc'//zchar
-            z2d(:,:) = sxysn(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxa'//'_htc'//zchar
-            z2d(:,:) = sxa(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sya'//'_htc'//zchar
-            z2d(:,:) = sya(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxxa'//'_htc'//zchar
-            z2d(:,:) = sxxa(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'syya'//'_htc'//zchar
-            z2d(:,:) = syya(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxya'//'_htc'//zchar
-            z2d(:,:) = sxya(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxc0'//'_htc'//zchar
-            z2d(:,:) = sxc0(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'syc0'//'_htc'//zchar
-            z2d(:,:) = syc0(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxxc0'//'_htc'//zchar
-            z2d(:,:) = sxxc0(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'syyc0'//'_htc'//zchar
-            z2d(:,:) = syyc0(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxyc0'//'_htc'//zchar
-            z2d(:,:) = sxyc0(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxsal'//'_htc'//zchar
-            z2d(:,:) = sxsal(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sysal'//'_htc'//zchar
-            z2d(:,:) = sysal(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxxsal'//'_htc'//zchar
-            z2d(:,:) = sxxsal(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'syysal'//'_htc'//zchar
-            z2d(:,:) = syysal(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxysal'//'_htc'//zchar
-            z2d(:,:) = sxysal(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxage'//'_htc'//zchar
-            z2d(:,:) = sxage(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'syage'//'_htc'//zchar
-            z2d(:,:) = syage(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxxage'//'_htc'//zchar
-            z2d(:,:) = sxxage(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'syyage'//'_htc'//zchar
-            z2d(:,:) = syyage(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            znam = 'sxyage'//'_htc'//zchar
-            z2d(:,:) = sxyage(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-         END DO
+         write(*,*) 'BACK in LIM3+1',nn_limadv 
+         znam = 'sxice'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxice )
+         znam = 'syice'
+         CALL iom_rstput( iter, nitrst, numriw, znam , syice )
+         znam = 'sxxice'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxxice )
+         znam = 'syyice'
+         CALL iom_rstput( iter, nitrst, numriw, znam , syyice )
+         znam = 'sxyice'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxyice )
+         znam = 'sxsn'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxsn )
+         znam = 'sysn'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sysn )
+         znam = 'sxxsn'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxxsn )
+         znam = 'syysn'
+         CALL iom_rstput( iter, nitrst, numriw, znam , syysn )
+         znam = 'sxysn'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxysn )
+         znam = 'sxa'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxa )
+         znam = 'sya'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sya )
+         znam = 'sxxa'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxxa )
+         znam = 'syya'
+         CALL iom_rstput( iter, nitrst, numriw, znam , syya )
+         znam = 'sxya'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxya )
+         znam = 'sxc0'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxc0 )
+         znam = 'syc0'
+         CALL iom_rstput( iter, nitrst, numriw, znam , syc0 )
+         znam = 'sxxc0'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxxc0 )
+         znam = 'syyc0'
+         CALL iom_rstput( iter, nitrst, numriw, znam , syyc0 )
+         znam = 'sxyc0'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxyc0 )
+         znam = 'sxsal'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxsal )
+         znam = 'sysal'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sysal )
+         znam = 'sxxsal'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxxsal )
+         znam = 'syysal'
+         CALL iom_rstput( iter, nitrst, numriw, znam , syysal )
+         znam = 'sxysal'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxysal )
+         znam = 'sxage'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxage )
+         znam = 'syage'
+         CALL iom_rstput( iter, nitrst, numriw, znam , syage )
+         znam = 'sxxage'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxxage )
+         znam = 'syyage'
+         CALL iom_rstput( iter, nitrst, numriw, znam , syyage )
+         znam = 'sxyage'
+         CALL iom_rstput( iter, nitrst, numriw, znam , sxyage )
 
          CALL iom_rstput( iter, nitrst, numriw, 'sxopw ' ,  sxopw  )
@@ -270,24 +228,21 @@
          CALL iom_rstput( iter, nitrst, numriw, 'sxyopw' ,  sxyopw )
          
-         DO jl = 1, jpl 
-            WRITE(zchar,'(I2.2)') jl
-            DO jk = 1, nlay_i 
+         DO jk = 1, nlay_i 
                WRITE(zchar1,'(I2.2)') jk
-               znam = 'sxe'//'_il'//zchar1//'_htc'//zchar
-               z2d(:,:) = sxe(:,:,jk,jl)
-               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-               znam = 'sye'//'_il'//zchar1//'_htc'//zchar
-               z2d(:,:) = sye(:,:,jk,jl)
-               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-               znam = 'sxxe'//'_il'//zchar1//'_htc'//zchar
-               z2d(:,:) = sxxe(:,:,jk,jl)
-               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-               znam = 'syye'//'_il'//zchar1//'_htc'//zchar
-               z2d(:,:) = syye(:,:,jk,jl)
-               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-               znam = 'sxye'//'_il'//zchar1//'_htc'//zchar
-               z2d(:,:) = sxye(:,:,jk,jl)
-               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
-            END DO
+               znam = 'sxe'//'_il'//zchar1
+               z3d(:,:,:) = sxe(:,:,jk,:)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
+               znam = 'sye'//'_il'//zchar1
+               z3d(:,:,:) = sye(:,:,jk,:)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
+               znam = 'sxxe'//'_il'//zchar1
+               z3d(:,:,:) = sxxe(:,:,jk,:)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
+               znam = 'syye'//'_il'//zchar1
+               z3d(:,:,:) = syye(:,:,jk,:)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
+               znam = 'sxye'//'_il'//zchar1
+               z3d(:,:,:) = sxye(:,:,jk,:)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
          END DO
 
@@ -301,5 +256,5 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi, jpj, z2d )
+      CALL wrk_dealloc( jpi, jpj, jpl, z3d )
       !
    END SUBROUTINE lim_rst_write
@@ -314,5 +269,5 @@
       INTEGER :: ji, jj, jk, jl
       REAL(wp) ::   zfice, ziter
-      REAL(wp), POINTER, DIMENSION(:,:) ::   z2d
+      REAL(wp), POINTER, DIMENSION(:,:, :) ::   z3d
       CHARACTER(len=25) ::   znam
       CHARACTER(len=2)  ::   zchar, zchar1
@@ -321,5 +276,5 @@
       !!----------------------------------------------------------------------
 
-      CALL wrk_alloc( jpi, jpj, z2d )
+      CALL wrk_alloc( jpi, jpj, jpl, z3d )
 
       IF(lwp) THEN
@@ -329,5 +284,5 @@
       ENDIF
 
-      CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kiolib = jprstlib )
+      CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kiolib = jprstlib, ndlev = jpl )
 
       CALL iom_get( numrir, 'nn_fsbc', zfice )
@@ -348,33 +303,24 @@
 
       ! Prognostic variables 
-      DO jl = 1, jpl 
-         WRITE(zchar,'(I2.2)') jl
-         znam = 'v_i'//'_htc'//zchar
-         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-         v_i(:,:,jl) = z2d(:,:)
-         znam = 'v_s'//'_htc'//zchar
-         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-         v_s(:,:,jl) = z2d(:,:) 
-         znam = 'smv_i'//'_htc'//zchar
-         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-         smv_i(:,:,jl) = z2d(:,:)
-         znam = 'oa_i'//'_htc'//zchar
-         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-         oa_i(:,:,jl) = z2d(:,:)
-         znam = 'a_i'//'_htc'//zchar
-         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-         a_i(:,:,jl) = z2d(:,:)
-         znam = 't_su'//'_htc'//zchar
-         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-         t_su(:,:,jl) = z2d(:,:)
-         znam = 'tempt_sl1'//'_htc'//zchar
-         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-         e_s(:,:,1,jl) = z2d(:,:)
-         DO jk = 1, nlay_i 
-            WRITE(zchar1,'(I2.2)') jk
-            znam = 'tempt'//'_il'//zchar1//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            e_i(:,:,jk,jl) = z2d(:,:)
-         END DO
+      znam = 'v_i'
+      CALL iom_get( numrir, jpdom_autoglo, znam , v_i )
+      znam = 'v_s'
+      CALL iom_get( numrir, jpdom_autoglo, znam , v_s )
+      znam = 'smv_i'
+      CALL iom_get( numrir, jpdom_autoglo, znam , smv_i )
+      znam = 'oa_i'
+      CALL iom_get( numrir, jpdom_autoglo, znam , oa_i )
+      znam = 'a_i'
+      CALL iom_get( numrir, jpdom_autoglo, znam , a_i )
+      znam = 't_su'
+      CALL iom_get( numrir, jpdom_autoglo, znam , t_su )
+      znam = 'tempt_sl1'
+      CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
+      e_s(:,:,1,:) = z3d
+      DO jk = 1, nlay_i 
+         WRITE(zchar1,'(I2.2)') jk
+         znam = 'tempt'//'_il'//zchar1
+         CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
+         e_i(:,:,jk,:) = z3d(:,:,:)
       END DO
 
@@ -391,97 +337,64 @@
       IF( nn_limadv == -1 ) THEN
 
-         DO jl = 1, jpl 
-            WRITE(zchar,'(I2.2)') jl
-            znam = 'sxice'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxice(:,:,jl) = z2d(:,:)
-            znam = 'syice'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            syice(:,:,jl) = z2d(:,:)
-            znam = 'sxxice'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxxice(:,:,jl) = z2d(:,:)
-            znam = 'syyice'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            syyice(:,:,jl) = z2d(:,:)
-            znam = 'sxyice'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxyice(:,:,jl) = z2d(:,:)
-            znam = 'sxsn'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxsn(:,:,jl) = z2d(:,:)
-            znam = 'sysn'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sysn(:,:,jl) = z2d(:,:)
-            znam = 'sxxsn'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxxsn(:,:,jl) = z2d(:,:)
-            znam = 'syysn'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            syysn(:,:,jl) = z2d(:,:)
-            znam = 'sxysn'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxysn(:,:,jl) = z2d(:,:)
-            znam = 'sxa'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxa(:,:,jl) = z2d(:,:)
-            znam = 'sya'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sya(:,:,jl) = z2d(:,:)
-            znam = 'sxxa'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxxa(:,:,jl) = z2d(:,:)
-            znam = 'syya'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            syya(:,:,jl) = z2d(:,:)
-            znam = 'sxya'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxya(:,:,jl) = z2d(:,:)
-            znam = 'sxc0'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxc0(:,:,jl) = z2d(:,:)
-            znam = 'syc0'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            syc0(:,:,jl) = z2d(:,:)
-            znam = 'sxxc0'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxxc0(:,:,jl) = z2d(:,:)
-            znam = 'syyc0'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            syyc0(:,:,jl) = z2d(:,:)
-            znam = 'sxyc0'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxyc0(:,:,jl) = z2d(:,:)
-            znam = 'sxsal'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxsal(:,:,jl) = z2d(:,:)
-            znam = 'sysal'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sysal(:,:,jl) = z2d(:,:)
-            znam = 'sxxsal'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxxsal(:,:,jl) = z2d(:,:)
-            znam = 'syysal'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            syysal(:,:,jl) = z2d(:,:)
-            znam = 'sxysal'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxysal(:,:,jl) = z2d(:,:)
-            znam = 'sxage'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxage(:,:,jl) = z2d(:,:)
-            znam = 'syage'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            syage(:,:,jl) = z2d(:,:)
-            znam = 'sxxage'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxxage(:,:,jl) = z2d(:,:)
-            znam = 'syyage'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            syyage(:,:,jl) = z2d(:,:)
-            znam = 'sxyage'//'_htc'//zchar
-            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-            sxyage(:,:,jl)= z2d(:,:)
-         END DO
+         znam = 'sxice'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxice )
+         znam = 'syice'
+         CALL iom_get( numrir, jpdom_autoglo, znam , syice )
+         znam = 'sxxice'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxxice )
+         znam = 'syyice'
+         CALL iom_get( numrir, jpdom_autoglo, znam , syyice )
+         znam = 'sxyice'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxyice )
+         znam = 'sxsn'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxsn )
+         znam = 'sysn'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sysn )
+         znam = 'sxxsn'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxxsn )
+         znam = 'syysn'
+         CALL iom_get( numrir, jpdom_autoglo, znam , syysn )
+         znam = 'sxysn'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxysn )
+         znam = 'sxa'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxa )
+         znam = 'sya'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sya )
+         znam = 'sxxa'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxxa )
+         znam = 'syya'
+         CALL iom_get( numrir, jpdom_autoglo, znam , syya )
+         znam = 'sxya'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxya )
+         znam = 'sxc0'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxc0 )
+         znam = 'syc0'
+         CALL iom_get( numrir, jpdom_autoglo, znam , syc0 )
+         znam = 'sxxc0'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxxc0 )
+         znam = 'syyc0'
+         CALL iom_get( numrir, jpdom_autoglo, znam , syyc0 )
+         znam = 'sxyc0'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxyc0 )
+         znam = 'sxsal'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxsal )
+         znam = 'sysal'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sysal )
+         znam = 'sxxsal'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxxsal )
+         znam = 'syysal'
+         CALL iom_get( numrir, jpdom_autoglo, znam , syysal )
+         znam = 'sxysal'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxysal )
+         znam = 'sxage'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxage )
+         znam = 'syage'
+         CALL iom_get( numrir, jpdom_autoglo, znam , syage )
+         znam = 'sxxage'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxxage )
+         znam = 'syyage'
+         CALL iom_get( numrir, jpdom_autoglo, znam , syyage )
+         znam = 'sxyage'
+         CALL iom_get( numrir, jpdom_autoglo, znam , sxyage )
 
          CALL iom_get( numrir, jpdom_autoglo, 'sxopw ' ,  sxopw  )
@@ -495,19 +408,19 @@
             DO jk = 1, nlay_i 
                WRITE(zchar1,'(I2.2)') jk
-               znam = 'sxe'//'_il'//zchar1//'_htc'//zchar
-               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-               sxe(:,:,jk,jl) = z2d(:,:)
-               znam = 'sye'//'_il'//zchar1//'_htc'//zchar
-               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-               sye(:,:,jk,jl) = z2d(:,:)
-               znam = 'sxxe'//'_il'//zchar1//'_htc'//zchar
-               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-               sxxe(:,:,jk,jl) = z2d(:,:)
-               znam = 'syye'//'_il'//zchar1//'_htc'//zchar
-               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-               syye(:,:,jk,jl) = z2d(:,:)
-               znam = 'sxye'//'_il'//zchar1//'_htc'//zchar
-               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
-               sxye(:,:,jk,jl) = z2d(:,:)
+               znam = 'sxe'//'_il'//zchar1
+               CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
+               sxe(:,:,jk,:) = z3d(:,:,:)
+               znam = 'sye'//'_il'//zchar1
+               CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
+               sye(:,:,jk,:) = z3d(:,:,:)
+               znam = 'sxxe'//'_il'//zchar1
+               CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
+               sxxe(:,:,jk,:) = z3d(:,:,:)
+               znam = 'syye'//'_il'//zchar1
+               CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
+               syye(:,:,jk,:) = z3d(:,:,:)
+               znam = 'sxye'//'_il'//zchar1
+               CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
+               sxye(:,:,jk,:) = z3d(:,:,:)
             END DO
          END DO
@@ -528,5 +441,5 @@
       !CALL iom_close( numrir ) !clem: closed in sbcice_lim.F90
       !
-      CALL wrk_dealloc( jpi, jpj, z2d )
+      CALL wrk_dealloc( jpi, jpj, jpl, z3d )
       !
    END SUBROUTINE lim_rst_read
Index: branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8705)
+++ branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8708)
@@ -239,5 +239,5 @@
 
 
-   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof )
+   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof, ndlev )
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_open  ***
@@ -252,4 +252,5 @@
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.)
+      INTEGER         , INTENT(in   ), OPTIONAL ::   ndlev     ! number of vertical levels
 
       CHARACTER(LEN=256)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu]
@@ -405,5 +406,5 @@
       IF( istop == nstop ) THEN   ! no error within this routine
          SELECT CASE (iolib)
-         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar )
+         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar, ndlev = ndlev )
          CASE DEFAULT
             CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed) ' )
@@ -672,6 +673,9 @@
       CHARACTER(LEN=1)               ::   clrankpv, cldmspc      ! 
       LOGICAL                        ::   ll_depth_spec ! T => if kstart, kcount present then *only* use values for 3rd spatial dimension.
+      INTEGER                        ::   inlev        ! number of levels for 3D data
       !---------------------------------------------------------------------
       !
+      inlev = -1
+      IF(PRESENT(pv_r3d)) inlev = SIZE(pv_r3d, 3)
       clname = iom_file(kiomid)%name   !   esier to read
       clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar)
@@ -801,7 +805,7 @@
                   ENDIF
                   IF( PRESENT(pv_r3d) ) THEN
-                     IF( idom == jpdom_data ) THEN                                  ; icnt(3) = jpkglo
+                     IF( idom == jpdom_data ) THEN                                  ; icnt(3) = inlev
                      ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN            ; istart(3) = kstart(3); icnt(3) = kcount(3)
-                     ELSE                                                           ; icnt(3) = jpk
+                     ELSE                                                           ; icnt(3) = inlev
                      ENDIF
                   ENDIF
@@ -886,5 +890,5 @@
             ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
                ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
-               IF( icnt(3) == jpk ) THEN
+               IF( icnt(3) == inlev ) THEN
                   CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
                ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
Index: branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90
===================================================================
--- branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 8705)
+++ branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 8708)
@@ -64,4 +64,5 @@
       REAL(kind=wp), DIMENSION(jpmax_vars)      ::   scf      !: scale_factor of the variables
       REAL(kind=wp), DIMENSION(jpmax_vars)      ::   ofs      !: add_offset of the variables
+      INTEGER                                   ::   nlev     ! number of vertical levels
    END TYPE file_descriptor
    TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC ::   iom_file !: array containing the info for all opened files
Index: branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90
===================================================================
--- branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 8705)
+++ branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 8708)
@@ -53,5 +53,5 @@
 CONTAINS
 
-   SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdompar )
+   SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdompar, ndlev )
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_open  ***
@@ -64,4 +64,5 @@
       LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
       INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
+      INTEGER                , INTENT(in   ), OPTIONAL ::   ndlev
 
       CHARACTER(LEN=256) ::   clinfo           ! info character
@@ -76,8 +77,13 @@
       INTEGER            ::   ihdf5            ! local variable for retrieval of value for NF90_HDF5
       LOGICAL            ::   llclobber        ! local definition of ln_clobber
+      INTEGER            ::   ilevels           ! vertical levels
       !---------------------------------------------------------------------
 
       clinfo = '                    iom_nf90_open ~~~  '
       istop = nstop   ! store the actual value of nstop
+      ilevels = jpk
+      IF(PRESENT(ndlev)) ilevels = ndlev      ! number of vertical levels
+                                             ! by default jpk, but can be
+                                             ! different for LIM3
       IF( nn_chunksz > 0 ) THEN   ;   ichunk = nn_chunksz
       ELSE                        ;   ichunk = NF90_SIZEHINT_DEFAULT
@@ -126,5 +132,5 @@
             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'x', kdompar(1,1)  , idmy ), clinfo)
             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'y', kdompar(2,1)  , idmy ), clinfo)
-            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'z', jpk           , idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'z', ilevels       , idmy ), clinfo)
             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 't', NF90_UNLIMITED, idmy ), clinfo)
             ! global attributes
@@ -156,4 +162,5 @@
          iom_file(kiomid)%nvars  = 0
          iom_file(kiomid)%irec   = -1   ! useless for NetCDF files, used to know if the file is in define mode 
+         iom_file(kiomid)%nlev   = ilevels
          CALL iom_nf90_check(NF90_Inquire(if90id, unlimitedDimId = iom_file(kiomid)%iduld), clinfo)
          IF ( iom_file(kiomid)%iduld .GE. 0 ) THEN
@@ -693,4 +700,5 @@
       LOGICAL               :: lchunk               ! logical switch to activate chunking and compression
                                                     ! when appropriate (currently chunking is applied to 4d fields only)
+      INTEGER               :: i                    ! local variable
       !---------------------------------------------------------------------
       !
@@ -706,5 +714,9 @@
          ENDIF
          ! define the dimension variables if it is not already done
-         cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter' /)
+         IF(iom_file(kiomid)%nlev == jpk ) THEN
+          cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter' /)
+         ELSE
+          cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'numcat     ', 'time_counter' /)
+         ENDIF
          CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(1)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(1) ), clinfo)
          CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(2)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(2) ), clinfo)
@@ -819,6 +831,12 @@
                CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lat'     , idmy ), clinfo)
                CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, gphit(ix1:ix2, iy1:iy2) ), clinfo)
-               CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo)
-               CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, gdept_1d                ), clinfo)
+               IF(iom_file(kiomid)%nlev == jpk ) THEN 
+                  !NEMO
+                  CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo)
+                  CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, gdept_1d                ), clinfo)
+               ELSE
+                  CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'numcat'     , idmy ), clinfo)
+                  CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, (/ (i, i = 1,iom_file(kiomid)%nlev) /)), clinfo)
+               ENDIF
                ! +++ WRONG VALUE: to be improved but not really useful...
                CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'time_counter', idmy ), clinfo)
Index: branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90
===================================================================
--- branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90	(revision 8705)
+++ branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90	(revision 8708)
@@ -135,5 +135,5 @@
       !!----------------------------------------------------------------------
       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type1, cd_type2   ! nature of pt3d grid-points
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pt3d1   , pt3d2      ! 3D array on which the lbc is applied
+      REAL(wp), DIMENSION(:,:,:)      , INTENT(inout) ::   pt3d1   , pt3d2      ! 3D array on which the lbc is applied
       REAL(wp)                        , INTENT(in   ) ::   psgn                 ! control of the sign 
       !!----------------------------------------------------------------------
@@ -154,14 +154,15 @@
       !!----------------------------------------------------------------------
       CHARACTER(len=1)                , INTENT(in   )           ::   cd_type   ! nature of pt3d grid-points
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)           ::   pt3d      ! 3D array on which the lbc is applied
+      REAL(wp), DIMENSION(:,:,:)      , INTENT(inout)           ::   pt3d      ! 3D array on which the lbc is applied
       REAL(wp)                        , INTENT(in   )           ::   psgn      ! control of the sign 
       CHARACTER(len=3)                , INTENT(in   ), OPTIONAL ::   cd_mpp    ! MPP only (here do nothing)
       REAL(wp)                        , INTENT(in   ), OPTIONAL ::   pval      ! background value (for closed boundaries)
       !
-      INTEGER  ::   jk     ! dummy loop index
-      REAL(wp) ::   ztab   ! local scalar
-      !!----------------------------------------------------------------------
-      !
-      DO jk = 1, jpk
+      INTEGER  ::   jk, ilev     ! dummy loop index
+      REAL(wp) ::   ztab         ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      ilev = SIZE(pt3d, 3)
+      DO jk = 1, ilev
          ztab = pt3d(2,2,jk)
          pt3d(:,:,jk) = ztab
@@ -268,5 +269,5 @@
       !!----------------------------------------------------------------------
       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type1, cd_type2   ! nature of pt3d grid-points
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pt3d1   , pt3d2      ! 3D array on which the lbc is applied
+      REAL(wp), DIMENSION(:,:,:)      , INTENT(inout) ::   pt3d1   , pt3d2      ! 3D array on which the lbc is applied
       REAL(wp)                        , INTENT(in   ) ::   psgn                 ! control of the sign 
       !!----------------------------------------------------------------------
@@ -291,5 +292,5 @@
       !!----------------------------------------------------------------------
       CHARACTER(len=1)                , INTENT(in   )           ::   cd_type   ! nature of pt3d grid-points
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)           ::   pt3d      ! 3D array on which the lbc is applied
+      REAL(wp), DIMENSION(:,:,:)      , INTENT(inout)           ::   pt3d      ! 3D array on which the lbc is applied
       REAL(wp)                        , INTENT(in   )           ::   psgn      ! control of the sign 
       CHARACTER(len=3)                , INTENT(in   ), OPTIONAL ::   cd_mpp    ! MPP only (here do nothing)
@@ -567,5 +568,5 @@
       !!----------------------------------------------------------------------
       CHARACTER(len=1)                , INTENT(in   )           ::   cd_type   ! nature of pt3d grid-points
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)           ::   pt3d      ! 3D array on which the lbc is applied
+      REAL(wp), DIMENSION(:,:,:)      , INTENT(inout)           ::   pt3d      ! 3D array on which the lbc is applied
       REAL(wp)                        , INTENT(in   )           ::   psgn      ! control of the sign 
       CHARACTER(len=3)                , INTENT(in   ), OPTIONAL ::   cd_mpp    ! MPP only (here do nothing)
@@ -623,5 +624,5 @@
       !!----------------------------------------------------------------------
       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pt3d      ! 3D array on which the lbc is applied
+      REAL(wp), DIMENSION(:,:,:)      , INTENT(inout) ::   pt3d      ! 3D array on which the lbc is applied
       REAL(wp)                        , INTENT(in   ) ::   psgn      ! control of the sign 
       INTEGER                         , INTENT(in   ) ::   ib_bdy    ! BDY boundary set
Index: branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90
===================================================================
--- branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 8705)
+++ branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 8708)
@@ -62,5 +62,5 @@
       !
       INTEGER  ::   ji, jk
-      INTEGER  ::   ijt, iju, ijpj, ijpjm1
+      INTEGER  ::   ijt, iju, ijpj, ijpjm1, ilev
       !!----------------------------------------------------------------------
 
@@ -71,5 +71,6 @@
       ijpjm1 = ijpj-1
 
-      DO jk = 1, jpk
+      ilev = SIZE(pt3d, 3)
+      DO jk = 1, ilev
          !
          SELECT CASE ( npolj )
@@ -393,5 +394,5 @@
       REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pt3dr     ! 3D array on which the boundary condition is applied
       !
-      INTEGER  ::   ji, jk
+      INTEGER  ::   ji, jk, ilev
       INTEGER  ::   ijt, iju, ijpj, ijpjm1, ijta, ijua, jia, startloop, endloop
       !!----------------------------------------------------------------------
@@ -402,5 +403,5 @@
       END SELECT
       ijpjm1 = ijpj-1
-
+      ilev = SIZE(pt3dl,3)
          !
          SELECT CASE ( npolj )
@@ -416,5 +417,5 @@
                ENDIF
 
-               DO jk = 1, jpk
+               DO jk = 1, ilev
                   DO ji = startloop, nlci
                      ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
@@ -434,5 +435,5 @@
                ENDIF
                IF(startloop .le. nlci) THEN
-                 DO jk = 1, jpk
+                 DO jk = 1, ilev
                     DO ji = startloop, nlci
                        ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
@@ -455,5 +456,5 @@
                   endloop = nlci - 1
                ENDIF
-               DO jk = 1, jpk
+               DO jk = 1, ilev
                   DO ji = 1, endloop
                      iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
@@ -481,5 +482,5 @@
                ENDIF
                IF (startloop .le. endloop) THEN
-                 DO jk = 1, jpk
+                 DO jk = 1, ilev
                     DO ji = startloop, endloop
                       iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
@@ -501,5 +502,5 @@
                   startloop = 2
                ENDIF
-               DO jk = 1, jpk
+               DO jk = 1, ilev
                   DO ji = startloop, nlci
                      ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
@@ -517,5 +518,5 @@
                   endloop = nlci - 1
                ENDIF
-               DO jk = 1, jpk
+               DO jk = 1, ilev
                   DO ji = 1, endloop
                      iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
@@ -537,5 +538,5 @@
             SELECT CASE ( cd_type )
             CASE ( 'T' , 'W' )                         ! T-, W-point
-               DO jk = 1, jpk
+               DO jk = 1, ilev
                   DO ji = 1, nlci
                      ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
@@ -550,5 +551,5 @@
                   endloop = nlci - 1
                ENDIF
-               DO jk = 1, jpk
+               DO jk = 1, ilev
                   DO ji = 1, endloop
                      iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
@@ -561,5 +562,5 @@
 
             CASE ( 'V' )                               ! V-point
-               DO jk = 1, jpk
+               DO jk = 1, ilev
                   DO ji = 1, nlci
                      ijt = jpiglo - ji- nimpp - nfiimpp(isendto(1),jpnj) + 3
@@ -576,5 +577,5 @@
                ENDIF
                IF(startloop .le. nlci) THEN
-                 DO jk = 1, jpk
+                 DO jk = 1, ilev
                     DO ji = startloop, nlci
                        ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
@@ -590,5 +591,5 @@
                   endloop = nlci - 1
                ENDIF
-               DO jk = 1, jpk
+               DO jk = 1, ilev
                   DO ji = 1, endloop
                      iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
@@ -613,5 +614,5 @@
                ENDIF
                IF (startloop .le. endloop) THEN
-                  DO jk = 1, jpk
+                  DO jk = 1, ilev
                      DO ji = startloop, endloop
                         iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
@@ -627,8 +628,8 @@
             SELECT CASE ( cd_type)
             CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
-               pt3dl(:, 1  ,jk) = 0.e0
-               pt3dl(:,ijpj,jk) = 0.e0
+               pt3dl(:, 1  ,:) = 0.e0
+               pt3dl(:,ijpj,:) = 0.e0
             CASE ( 'F' )                               ! F-point
-               pt3dl(:,ijpj,jk) = 0.e0
+               pt3dl(:,ijpj,:) = 0.e0
             END SELECT
             !
Index: branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 8705)
+++ branches/2017/dev_rev8689_LIM3_RST/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 8708)
@@ -351,5 +351,5 @@
       !!
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab     ! 3D array on which the boundary condition is applied
+      REAL(wp), DIMENSION(:,:,:)      , INTENT(inout) ::   ptab     ! 3D array on which the boundary condition is applied
       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type  ! define the nature of ptab array grid-points
       !                                                             ! = T , U , V , F , W points
@@ -359,5 +359,5 @@
       REAL(wp)        , OPTIONAL      , INTENT(in   ) ::   pval     ! background value (used at closed boundaries)
       !
-      INTEGER  ::   ji, jj, jk, jl             ! dummy loop indices
+      INTEGER  ::   ji, jj, jk, jl, ilev       ! dummy loop indices
       INTEGER  ::   imigr, iihom, ijhom        ! temporary integers
       INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
@@ -367,7 +367,7 @@
       REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   zt3ew, zt3we   ! 3d for east-west & west-east
       !!----------------------------------------------------------------------
-      
-      ALLOCATE( zt3ns(jpi,jprecj,jpk,2), zt3sn(jpi,jprecj,jpk,2),   &
-         &      zt3ew(jpj,jpreci,jpk,2), zt3we(jpj,jpreci,jpk,2)  )
+      ilev = SIZE(ptab, 3) 
+      ALLOCATE( zt3ns(jpi,jprecj,ilev,2), zt3sn(jpi,jprecj,ilev,2),   &
+         &      zt3ew(jpj,jpreci,ilev,2), zt3we(jpj,jpreci,ilev,2)  )
 
       !
@@ -381,5 +381,5 @@
          !
          ! WARNING ptab is defined only between nld and nle
-         DO jk = 1, jpk
+         DO jk = 1, ilev
             DO jj = nlcj+1, jpj                 ! added line(s)   (inner only)
                ptab(nldi  :nlei  , jj          ,jk) = ptab(nldi:nlei,     nlej,jk)
@@ -430,5 +430,5 @@
       !
       !                           ! Migrations
-      imigr = jpreci * jpj * jpk
+      imigr = jpreci * jpj * ilev
       !
       SELECT CASE ( nbondi )
@@ -482,5 +482,5 @@
       !
       !                           ! Migrations
-      imigr = jprecj * jpi * jpk
+      imigr = jprecj * jpi * ilev
       !
       SELECT CASE ( nbondj )
@@ -1055,11 +1055,11 @@
       !!
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab1     ! first and second 3D array on which
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab2     ! the boundary condition is applied
+      REAL(wp), DIMENSION(:,:,:)      , INTENT(inout) ::   ptab1     ! first and second 3D array on which
+      REAL(wp), DIMENSION(:,:,:)      , INTENT(inout) ::   ptab2     ! the boundary condition is applied
       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type1  ! nature of ptab1 and ptab2 arrays
       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type2  ! i.e. grid-points = T , U , V , F or W points
       REAL(wp)                        , INTENT(in   ) ::   psgn      ! =-1 the sign change across the north fold boundary
       !!                                                             ! =  1. , the sign is kept
-      INTEGER  ::   jl   ! dummy loop indices
+      INTEGER  ::   jl, ilev                   ! dummy loop indices
       INTEGER  ::   imigr, iihom, ijhom        ! temporary integers
       INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
@@ -1069,6 +1069,7 @@
       !!----------------------------------------------------------------------
       !
-      ALLOCATE( zt4ns(jpi,jprecj,jpk,2,2), zt4sn(jpi,jprecj,jpk,2,2) ,    &
-         &      zt4ew(jpj,jpreci,jpk,2,2), zt4we(jpj,jpreci,jpk,2,2) )
+      ilev = SIZE(ptab1, 3)
+      ALLOCATE( zt4ns(jpi,jprecj,ilev,2,2), zt4sn(jpi,jprecj,ilev,2,2) ,    &
+         &      zt4ew(jpj,jpreci,ilev,2,2), zt4we(jpj,jpreci,ilev,2,2) )
       !
       ! 1. standard boundary treatment
@@ -1117,5 +1118,5 @@
       !
       !                           ! Migrations
-      imigr = jpreci * jpj * jpk *2
+      imigr = jpreci * jpj * ilev *2
       !
       SELECT CASE ( nbondi )
@@ -1176,5 +1177,5 @@
       !
       !                           ! Migrations
-      imigr = jprecj * jpi * jpk * 2
+      imigr = jprecj * jpi * ilev * 2
       !
       SELECT CASE ( nbondj )
@@ -1451,5 +1452,5 @@
       !!
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab     ! 3D array on which the boundary condition is applied
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   ptab     ! 3D array on which the boundary condition is applied
       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type  ! define the nature of ptab array grid-points
       !                                                             ! = T , U , V , F , W points
@@ -1459,5 +1460,5 @@
       REAL(wp)        , OPTIONAL      , INTENT(in   ) ::   pval     ! background value (used at closed boundaries)
       !!
-      INTEGER  ::   ji, jj, jk, jl             ! dummy loop indices
+      INTEGER  ::   ji, jj, jk, jl,ilev        ! dummy loop indices
       INTEGER  ::   imigr, iihom, ijhom        ! temporary integers
       INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
@@ -1469,7 +1470,7 @@
 
       !!----------------------------------------------------------------------
-      
-      ALLOCATE( zt3ns(jpi,jprecj,jpk,2), zt3sn(jpi,jprecj,jpk,2),   &
-         &      zt3ew(jpj,jpreci,jpk,2), zt3we(jpj,jpreci,jpk,2)  )
+      ilev = SIZE(ptab, 3) 
+      ALLOCATE( zt3ns(jpi,jprecj,ilev,2), zt3sn(jpi,jprecj,ilev,2),   &
+         &      zt3ew(jpj,jpreci,ilev,2), zt3we(jpj,jpreci,ilev,2)  )
 
       !
@@ -1494,5 +1495,5 @@
       !
       !                           ! Migrations
-      imigr = jpreci * jpj * jpk
+      imigr = jpreci * jpj * ilev
       !
       SELECT CASE ( nbondi )
@@ -1547,5 +1548,5 @@
       !
       !                           ! Migrations
-      imigr = jprecj * jpi * jpk
+      imigr = jprecj * jpi * ilev
       !
       SELECT CASE ( nbondj )
