Index: trunk/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90
===================================================================
--- trunk/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 2524)
+++ trunk/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 2528)
@@ -5,12 +5,12 @@
    !!======================================================================
    !! History :  OPA  ! 1987-07  (G. Madec)  Original code
-   !!             -   ! 1993-03  (M. Guyon)  symetrical conditions (M. Guyon)
-   !!             -   ! 1996-01  (G. Madec)  suppression of common work arrays
+   !!            6.0  ! 1993-03  (M. Guyon)  symetrical conditions (M. Guyon)
+   !!            7.0  ! 1996-01  (G. Madec)  suppression of common work arrays
    !!             -   ! 1996-05  (G. Madec)  mask computed from tmask and sup-
    !!                 !                      pression of the double computation of bmask
-   !!             -   ! 1997-02  (G. Madec)  mesh information put in domhgr.F
-   !!             -   ! 1997-07  (G. Madec)  modification of mbathy and fmask
+   !!            8.0  ! 1997-02  (G. Madec)  mesh information put in domhgr.F
+   !!            8.1  ! 1997-07  (G. Madec)  modification of mbathy and fmask
    !!             -   ! 1998-05  (G. Roullet)  free surface
-   !!             -   ! 2000-03  (G. Madec)  no slip accurate
+   !!            8.2  ! 2000-03  (G. Madec)  no slip accurate
    !!             -   ! 2001-09  (J.-M. Molines)  Open boundaries
    !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and module
@@ -44,7 +44,6 @@
    !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
    
@@ -56,5 +55,4 @@
       !!      zontal velocity points (u & v), vorticity points (f) and baro-
       !!      tropic stream function  points (b).
-      !!        Set mbathy to the number of non-zero w-levels of a water column
       !!
       !! ** Method  :   The ocean/land mask is computed from the basin bathy-
@@ -73,7 +71,10 @@
       !!                   or mbathy(ji+1,jj)  or mbathy(ji+1,jj+1) =< 0
       !!                1. IF mbathy( ji ,jj) and mbathy( ji ,jj+1)
-      !!                and mbathy(ji+1,jj) and mbathy(ji+1,jj+1) >= jk.
+      !!                  and mbathy(ji+1,jj) and mbathy(ji+1,jj+1) >= jk.
       !!      b-point : the same definition as for f-point of the first ocean
       !!                level (surface level) but with 0 along coastlines.
+      !!      tmask_i : interior ocean mask at t-point, i.e. excluding duplicated
+      !!                rows/lines due to cyclic or North Fold boundaries as well
+      !!                as MPP halos.
       !!
       !!        The lateral friction is set through the value of fmask along
@@ -99,8 +100,4 @@
       !!        - bmask is  set to 0 on the open boundaries.
       !!
-      !!      Set mbathy to the number of non-zero w-levels of a water column
-      !!                  mbathy = min( mbathy, 1 ) + 1
-      !!      (note that the minimum value of mbathy is 2).
-      !!
       !! ** Action :   tmask    : land/ocean mask at t-point (=0. or 1.)
       !!               umask    : land/ocean mask at u-point (=0. or 1.)
@@ -110,5 +107,5 @@
       !!               bmask    : land/ocean mask at barotropic stream
       !!                          function point (=0. or 1.) and set to 0 along lateral boundaries
-      !!               mbathy   : number of non-zero w-levels 
+      !!               tmask_i  : interior ocean mask
       !!----------------------------------------------------------------------
       INTEGER  ::   ji, jj, jk      ! dummy loop indices
@@ -132,5 +129,5 @@
       ENDIF
 
-      IF     (      rn_shlat == 0.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral free-slip '
+      IF     (      rn_shlat == 0.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  free-slip '
       ELSEIF (      rn_shlat == 2.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  no-slip '
       ELSEIF ( 0. < rn_shlat .AND. rn_shlat < 2. ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  partial-slip '
@@ -145,9 +142,9 @@
       ! N.B. tmask has already the right boundary conditions since mbathy is ok
       !
-      tmask(:,:,:) = 0.e0
+      tmask(:,:,:) = 0._wp
       DO jk = 1, jpk
          DO jj = 1, jpj
             DO ji = 1, jpi
-               IF( REAL( mbathy(ji,jj) - jk ) +.1 >= 0.e0 )   tmask(ji,jj,jk) = 1.e0
+               IF( REAL( mbathy(ji,jj) - jk, wp ) + 0.1_wp >= 0._wp )   tmask(ji,jj,jk) = 1._wp
             END DO  
          END DO  
@@ -160,5 +157,5 @@
             ij0 =  87   ;   ij1 =  88
             ii0 = 160   ;   ii1 = 161
-            tmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 0.e0
+            tmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 0._wp
          ELSE
             IF(lwp) WRITE(numout,*)
@@ -182,16 +179,16 @@
       ijl = nlcj - jprecj + 1
 
-      tmask_i( 1 :iif,   :   ) = 0.e0      ! first columns
-      tmask_i(iil:jpi,   :   ) = 0.e0      ! last  columns (including mpp extra columns)
-      tmask_i(   :   , 1 :ijf) = 0.e0      ! first rows
-      tmask_i(   :   ,ijl:jpj) = 0.e0      ! last  rows (including mpp extra rows)
+      tmask_i( 1 :iif,   :   ) = 0._wp      ! first columns
+      tmask_i(iil:jpi,   :   ) = 0._wp      ! last  columns (including mpp extra columns)
+      tmask_i(   :   , 1 :ijf) = 0._wp      ! first rows
+      tmask_i(   :   ,ijl:jpj) = 0._wp      ! last  rows (including mpp extra rows)
 
       ! north fold mask
       ! ---------------
-      tpol(1:jpiglo) = 1.e0 
-      fpol(1:jpiglo) = 1.e0
+      tpol(1:jpiglo) = 1._wp 
+      fpol(1:jpiglo) = 1._wp
       IF( jperio == 3 .OR. jperio == 4 ) THEN      ! T-point pivot
-         tpol(jpiglo/2+1:jpiglo) = 0.e0
-         fpol(     1    :jpiglo) = 0.e0
+         tpol(jpiglo/2+1:jpiglo) = 0._wp
+         fpol(     1    :jpiglo) = 0._wp
          IF( mjg(nlej) == jpjglo ) THEN                  ! only half of the nlcj-1 row
             DO ji = iif+1, iil-1
@@ -201,6 +198,6 @@
       ENDIF
       IF( jperio == 5 .OR. jperio == 6 ) THEN      ! F-point pivot
-         tpol(     1    :jpiglo) = 0.e0
-         fpol(jpiglo/2+1:jpiglo) = 0.e0
+         tpol(     1    :jpiglo) = 0._wp
+         fpol(jpiglo/2+1:jpiglo) = 0._wp
       ENDIF
 
@@ -219,7 +216,7 @@
          END DO
       END DO
-      CALL lbc_lnk( umask, 'U', 1. )      ! Lateral boundary conditions
-      CALL lbc_lnk( vmask, 'V', 1. )
-      CALL lbc_lnk( fmask, 'F', 1. )
+      CALL lbc_lnk( umask, 'U', 1._wp )      ! Lateral boundary conditions
+      CALL lbc_lnk( vmask, 'V', 1._wp )
+      CALL lbc_lnk( fmask, 'F', 1._wp )
 
 
@@ -231,9 +228,9 @@
       !                                    ! cyclic east-west : bmask must be set to 0. on rows 1 and jpi
       IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 ) THEN
-         bmask( 1 ,:) = 0.e0
-         bmask(jpi,:) = 0.e0
+         bmask( 1 ,:) = 0._wp
+         bmask(jpi,:) = 0._wp
       ENDIF
       IF( nperio == 2 ) THEN               ! south symmetric :  bmask must be set to 0. on row 1
-         bmask(:, 1 ) = 0.e0
+         bmask(:, 1 ) = 0._wp
       ENDIF
       !                                    ! north fold : 
@@ -242,17 +239,17 @@
             ii = ji + nimpp - 1
             bmask(ji,jpj-1) = bmask(ji,jpj-1) * tpol(ii)
-            bmask(ji,jpj  ) = 0.e0
+            bmask(ji,jpj  ) = 0._wp
          END DO
       ENDIF
       IF( nperio == 5 .OR. nperio == 6 ) THEN   ! F-pt pivot and T-pt elliptic eq. : bmask set to 0. on row jpj
-         bmask(:,jpj) = 0.e0
+         bmask(:,jpj) = 0._wp
       ENDIF
       !
       IF( lk_mpp ) THEN                    ! mpp specificities
          !                                      ! bmask is set to zero on the overlap region
-         IF( nbondi /= -1 .AND. nbondi /= 2 )   bmask(  1 :jpreci,:) = 0.e0
-         IF( nbondi /=  1 .AND. nbondi /= 2 )   bmask(nlci:jpi   ,:) = 0.e0
-         IF( nbondj /= -1 .AND. nbondj /= 2 )   bmask(:,  1 :jprecj) = 0.e0
-         IF( nbondj /=  1 .AND. nbondj /= 2 )   bmask(:,nlcj:jpj   ) = 0.e0
+         IF( nbondi /= -1 .AND. nbondi /= 2 )   bmask(  1 :jpreci,:) = 0._wp
+         IF( nbondi /=  1 .AND. nbondi /= 2 )   bmask(nlci:jpi   ,:) = 0._wp
+         IF( nbondj /= -1 .AND. nbondj /= 2 )   bmask(:,  1 :jprecj) = 0._wp
+         IF( nbondj /=  1 .AND. nbondj /= 2 )   bmask(:,nlcj:jpj   ) = 0._wp
          !
          IF( npolj == 3 .OR. npolj == 4 ) THEN  ! north fold : bmask must be set to 0. on rows jpj-1 and jpj
@@ -260,10 +257,10 @@
                ii = ji + nimpp - 1
                bmask(ji,nlcj-1) = bmask(ji,nlcj-1) * tpol(ii)
-               bmask(ji,nlcj  ) = 0.e0
+               bmask(ji,nlcj  ) = 0._wp
             END DO
          ENDIF
          IF( npolj == 5 .OR. npolj == 6 ) THEN  ! F-pt pivot and T-pt elliptic eq. : bmask set to 0. on row jpj
             DO ji = 1, nlci
-               bmask(ji,nlcj  ) = 0.e0
+               bmask(ji,nlcj  ) = 0._wp
             END DO
          ENDIF
@@ -282,24 +279,24 @@
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               IF( fmask(ji,jj,jk) == 0. ) THEN
-                  fmask(ji,jj,jk) = rn_shlat * MIN( 1., MAX( zwf(ji+1,jj), zwf(ji,jj+1),   &
-                     &                                       zwf(ji-1,jj), zwf(ji,jj-1)  )  )
+               IF( fmask(ji,jj,jk) == 0._wp ) THEN
+                  fmask(ji,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,jj), zwf(ji,jj+1),   &
+                     &                                           zwf(ji-1,jj), zwf(ji,jj-1)  )  )
                ENDIF
             END DO
          END DO
          DO jj = 2, jpjm1
-            IF( fmask(1,jj,jk) == 0. ) THEN
-               fmask(1  ,jj,jk) = rn_shlat * MIN( 1., MAX( zwf(2,jj), zwf(1,jj+1), zwf(1,jj-1) ) )
-            ENDIF
-            IF( fmask(jpi,jj,jk) == 0. ) THEN
-               fmask(jpi,jj,jk) = rn_shlat * MIN( 1., MAX( zwf(jpi,jj+1), zwf(jpim1,jj), zwf(jpi,jj-1) ) )
+            IF( fmask(1,jj,jk) == 0._wp ) THEN
+               fmask(1  ,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(2,jj), zwf(1,jj+1), zwf(1,jj-1) ) )
+            ENDIF
+            IF( fmask(jpi,jj,jk) == 0._wp ) THEN
+               fmask(jpi,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(jpi,jj+1), zwf(jpim1,jj), zwf(jpi,jj-1) ) )
             ENDIF
          END DO         
          DO ji = 2, jpim1
-            IF( fmask(ji,1,jk) == 0. ) THEN
-               fmask(ji, 1 ,jk) = rn_shlat * MIN( 1., MAX( zwf(ji+1,1), zwf(ji,2), zwf(ji-1,1) ) )
-            ENDIF
-            IF( fmask(ji,jpj,jk) == 0. ) THEN
-               fmask(ji,jpj,jk) = rn_shlat * MIN( 1., MAX( zwf(ji+1,jpj), zwf(ji-1,jpj), zwf(ji,jpjm1) ) )
+            IF( fmask(ji,1,jk) == 0._wp ) THEN
+               fmask(ji, 1 ,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,1), zwf(ji,2), zwf(ji-1,1) ) )
+            ENDIF
+            IF( fmask(ji,jpj,jk) == 0._wp ) THEN
+               fmask(ji,jpj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,jpj), zwf(ji-1,jpj), zwf(ji,jpjm1) ) )
             ENDIF
          END DO
@@ -308,39 +305,68 @@
       IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN   ! ORCA_R2 configuration
          !                                                 ! Increased lateral friction near of some straits
-         IF( n_cla == 0 ) THEN
+         IF( nn_cla == 0 ) THEN
             !                                ! Gibraltar strait  : partial slip (fmask=0.5)
             ij0 = 101   ;   ij1 = 101
-            ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5e0
+            ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
             ij0 = 102   ;   ij1 = 102
-            ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5e0
+            ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
             !
             !                                ! Bab el Mandeb : partial slip (fmask=1)
             ij0 =  87   ;   ij1 =  88
-            ii0 = 160   ;   ii1 = 160   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1.e0
+            ii0 = 160   ;   ii1 = 160   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
             ij0 =  88   ;   ij1 =  88
-            ii0 = 159   ;   ii1 = 159   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1.e0
+            ii0 = 159   ;   ii1 = 159   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
             !
          ENDIF
-
          !                                ! Danish straits  : strong slip (fmask > 2)
 ! We keep this as an example but it is instable in this case 
 !         ij0 = 115   ;   ij1 = 115
-!         ii0 = 145   ;   ii1 = 146   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 4.0e0
+!         ii0 = 145   ;   ii1 = 146   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 4._wp
 !         ij0 = 116   ;   ij1 = 116
-!         ii0 = 145   ;   ii1 = 146   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 4.0e0
+!         ii0 = 145   ;   ii1 = 146   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 4._wp
          !
       ENDIF
       !
-      CALL lbc_lnk( fmask, 'F', 1. )      ! Lateral boundary conditions on fmask
-
-      
-      ! Mbathy set to the number of w-level (minimum value 2)
-      ! -----------------------------------
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            mbathy(ji,jj) = MAX( 1, mbathy(ji,jj) ) + 1
-         END DO
-      END DO
-      
+      IF( cp_cfg == "orca" .AND. jp_cfg == 1 ) THEN   ! ORCA R1 configuration
+         !                                                 ! Increased lateral friction near of some straits
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '   orca_r1: increase friction near the following straits : '
+         IF(lwp) WRITE(numout,*) '      Gibraltar '
+         ii0 = 283   ;   ii1 = 284        ! Gibraltar Strait 
+         ij0 = 200   ;   ij1 = 200   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1), 1:jpk ) =  2._wp  
+
+         IF(lwp) WRITE(numout,*) '      Bhosporus '
+         ii0 = 314   ;   ii1 = 315        ! Bhosporus Strait 
+         ij0 = 208   ;   ij1 = 208   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1), 1:jpk ) =  2._wp  
+
+         IF(lwp) WRITE(numout,*) '      Makassar (Top) '
+         ii0 =  48   ;   ii1 =  48        ! Makassar Strait (Top) 
+         ij0 = 149   ;   ij1 = 150   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1), 1:jpk ) =  3._wp  
+
+         IF(lwp) WRITE(numout,*) '      Lombok '
+         ii0 =  44   ;   ii1 =  44        ! Lombok Strait 
+         ij0 = 124   ;   ij1 = 125   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1), 1:jpk ) =  2._wp  
+
+         IF(lwp) WRITE(numout,*) '      Ombai '
+         ii0 =  53   ;   ii1 =  53        ! Ombai Strait 
+         ij0 = 124   ;   ij1 = 125   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1), 1:jpk ) = 2._wp  
+
+         IF(lwp) WRITE(numout,*) '      Timor Passage '
+         ii0 =  56   ;   ii1 =  56        ! Timor Passage 
+         ij0 = 124   ;   ij1 = 125   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1), 1:jpk ) = 2._wp  
+
+         IF(lwp) WRITE(numout,*) '      West Halmahera '
+         ii0 =  58   ;   ii1 =  58        ! West Halmahera Strait 
+         ij0 = 141   ;   ij1 = 142   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1), 1:jpk ) = 3._wp  
+
+         IF(lwp) WRITE(numout,*) '      East Halmahera '
+         ii0 =  55   ;   ii1 =  55        ! East Halmahera Strait 
+         ij0 = 141   ;   ij1 = 142   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1), 1:jpk ) = 3._wp  
+         !
+      ENDIF
+      !
+      CALL lbc_lnk( fmask, 'F', 1._wp )      ! Lateral boundary conditions on fmask
+
+            
       IF( nprint == 1 .AND. lwp ) THEN      ! Control print
          imsk(:,:) = INT( tmask_i(:,:) )
@@ -385,5 +411,5 @@
          imsk(:,:) = INT( bmask(:,:) )
          CALL prihin( imsk(:,:), jpi, jpj, 1, jpi, 1,   &
-               &                           1, jpj, 1, 1, numout )
+            &                              1, jpj, 1, 1, numout )
       ENDIF
       !
@@ -404,5 +430,4 @@
       !!
       !! ** Action :
-      !!
       !!----------------------------------------------------------------------
       INTEGER  :: ji, jj, jk, jl      ! dummy loop indices
@@ -448,5 +473,5 @@
                zaa = tmask(ji  ,jj,jk) + tmask(ji  ,jj+1,jk)   &
                   &+ tmask(ji+1,jj,jk) + tmask(ji+1,jj+1,jk)
-               IF( ABS(zaa-3.) <= 0.1 )   fmask(ji,jj,jk) = 1.
+               IF( ABS(zaa-3._wp) <= 0.1_wp )   fmask(ji,jj,jk) = 1._wp
             END DO
          END DO
@@ -461,5 +486,5 @@
             DO ji = 2, jpim1
                zaa = tmask(ji+1,jj,jk) + tmask(ji+1,jj+1,jk)
-               IF( ABS(zaa-2.) <= 0.1 .AND. fmask(ji,jj,jk) == 0 ) THEN
+               IF( ABS(zaa-2._wp) <= 0.1_wp .AND. fmask(ji,jj,jk) == 0._wp ) THEN
                   inw = inw + 1
                   nicoa(inw,1,jk) = ji
@@ -468,5 +493,5 @@
                ENDIF
                zaa = tmask(ji,jj,jk) + tmask(ji,jj+1,jk)
-               IF( ABS(zaa-2.) <= 0.1 .AND. fmask(ji,jj,jk) == 0 ) THEN
+               IF( ABS(zaa-2._wp) <= 0.1_wp .AND. fmask(ji,jj,jk) == 0._wp ) THEN
                   ine = ine + 1
                   nicoa(ine,2,jk) = ji
@@ -488,5 +513,5 @@
             DO ji =2, jpim1
                zaa = tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk)
-               IF( ABS(zaa-2.) <= 0.1 .AND. fmask(ji,jj,jk) == 0 ) THEN
+               IF( ABS(zaa-2._wp) <= 0.1_wp .AND. fmask(ji,jj,jk) == 0._wp ) THEN
                   ins = ins + 1
                   nicoa(ins,3,jk) = ji
@@ -495,5 +520,5 @@
                ENDIF
                zaa = tmask(ji+1,jj,jk) + tmask(ji,jj,jk)
-               IF( ABS(zaa-2.) <= 0.1 .AND. fmask(ji,jj,jk) == 0 ) THEN
+               IF( ABS(zaa-2._wp) <= 0.1_wp .AND. fmask(ji,jj,jk) == 0._wp ) THEN
                   inn = inn + 1
                   nicoa(inn,4,jk) = ji
@@ -524,6 +549,6 @@
       iind = 0
       ijnd = 0
-      IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 ) iind = 2
-      IF( nperio == 3 .OR. nperio == 4 .OR. nperio == 5 .OR. nperio == 6 ) ijnd = 2
+      IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 )   iind = 2
+      IF( nperio == 3 .OR. nperio == 4 .OR. nperio == 5 .OR. nperio == 6 )   ijnd = 2
       DO jk = 1, jpk
          DO jl = 1, npcoa(1,jk)
@@ -551,10 +576,10 @@
             ENDIF
          END DO
-         DO jl=1,npcoa(4,jk)
+         DO jl = 1, npcoa(4,jk)
             IF( njcoa(jl,4,jk)-2 < 1) THEN
-               ierror=ierror+1
-               icoord(ierror,1)=nicoa(jl,4,jk)
-               icoord(ierror,2)=njcoa(jl,4,jk)
-               icoord(ierror,3)=jk
+               ierror=ierror + 1
+               icoord(ierror,1) = nicoa(jl,4,jk)
+               icoord(ierror,2) = njcoa(jl,4,jk)
+               icoord(ierror,3) = jk
             ENDIF
          END DO
