Index: trunk/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c3d.h90
===================================================================
--- trunk/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c3d.h90	(revision 2524)
+++ trunk/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c3d.h90	(revision 2528)
@@ -4,7 +4,7 @@
 
    !!----------------------------------------------------------------------
-   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
 
@@ -26,11 +26,8 @@
       !!       ??? explanation of the default is missing
       !!----------------------------------------------------------------------
-      !! * Modules used
       USE ldftra_oce, ONLY : aht0
-
-      !! * Arguments
+      !!
       LOGICAL, INTENT (in) :: ld_print   ! If true, output arrays on numout
-
-      !! * local variables
+      !!
       INTEGER  ::   ji, jj, jk      ! dummy loop indices
       REAL(wp) ::   &
@@ -86,10 +83,10 @@
 
 
-         ! Special case for ORCA R2 and R4 configurations (overwrite the value of ahm1 ahm2)
+         ! Special case for ORCA R1, R2 and R4 configurations (overwrite the value of ahm1 ahm2)
          ! ==============================================
-         IF( cp_cfg == "orca" .AND. ( jp_cfg == 2 .OR. jp_cfg == 4 ) ) THEN
+         IF( cp_cfg == "orca" .AND. ( jp_cfg == 1 .OR. jp_cfg == 2 .OR. jp_cfg == 4 ) ) THEN 
             IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '              ORCA R2 or R4: overwrite the previous definition of ahm'
-            IF(lwp) WRITE(numout,*) '              ============='
+            IF(lwp) WRITE(numout,*) '              ORCA R1, R2 or R4: overwrite the previous definition of ahm'
+            IF(lwp) WRITE(numout,*) '              ================='
             CALL ldf_dyn_c3d_orca( ld_print )
          ENDIF
@@ -122,5 +119,5 @@
          IF(lwp) WRITE(numout,*) '              maximum grid-spacing = ', zd_max, ' maximum value for ahm = ', ahm0
 
-         za00 = ahm0 / ( zd_max * zd_max * zd_max )
+         za00 = ahm0_blp / ( zd_max * zd_max * zd_max )
          DO jj = 1, jpj
             DO ji = 1, jpi
@@ -148,9 +145,5 @@
             END DO
          ELSE                            ! partial steps or s-ccordinate
-# if defined key_zco
-            zc = gdept_0(jpkm1)
-# else
             zc = MAXVAL( fsdept(:,:,jpkm1) )
-# endif
             IF( lk_mpp )   CALL mpp_max( zc )   ! max over the global domain
 
@@ -196,15 +189,12 @@
       !!                  ***  ROUTINE ldf_dyn_c3d  ***
       !!                   
-      !! ** Purpose :   ORCA R2 an R4 only
+      !! ** Purpose :   ORCA R1, R2 and R4 only
       !!
       !! ** Method  :   blah blah blah ....
       !!----------------------------------------------------------------------
-      !! * Modules used
       USE ldftra_oce, ONLY : aht0
-
-      !! * Arguments
+      !!
       LOGICAL, INTENT (in) :: ld_print   ! If true, output arrays on numout
-
-      !! * local variables
+      !!
       INTEGER ::   ji, jj, jk, jn      ! dummy loop indices
       INTEGER ::   ii0, ii1, ij0, ij1  ! temporary integers
@@ -228,5 +218,5 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~'
       IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '        orca R2 or R4 ocean model'
+      IF(lwp) WRITE(numout,*) '        orca R1, R2 or R4 ocean model'
       IF(lwp) WRITE(numout,*) '  reduced in the surface Eq. strip '
       IF(lwp) WRITE(numout,*)
@@ -318,4 +308,10 @@
       ENDIF
 
+      IF( jp_cfg == 1 )   THEN
+         zahmeq     = aht0  ! reduced to aht0 on equator; set to ahm0 if no tropical reduction is required
+         zahmm      = ahm0
+         zahm0(:,:) = ahm0
+      ENDIF
+
       DO jj = 1, jpj
          DO ji = 1, jpi
@@ -363,37 +359,38 @@
 
       ! other level: re-increase the coef in the deep ocean
-      
-#if defined key_orca_lev10
-      DO jk = 1, 210
-         zcoef(jk) = 1.
-      END DO
-      DO jk= 211, 230
-         zcoef(jk) = 1. + 0.1 * FLOAT(jk-210)
-      END DO
-      DO jk= 231, 260
-         zcoef(jk) = 3. + 0.2 * FLOAT(jk-230)
-      END DO
-      DO jk= 261, 270
-         zcoef(jk) = 9. + 0.1 * FLOAT(jk-260)
-      END DO
-      DO jk= 271, jpk
-         zcoef(jk) = 10.
-      END DO
-      DO jk= 1, jpk
-         IF(lwp) WRITE(numout,*) 'k= ',jk, 'cof ', zcoef(jk)
-      END DO
-#else
-       DO jk = 1, 21
-         zcoef(jk) = 1.
-      END DO
-      zcoef(22) = 2.
-      zcoef(23) = 3.
-      zcoef(24) = 5.
-      zcoef(25) = 7.
-      zcoef(26) = 9.
-      DO jk = 27, jpk
-         zcoef(jk) = 10.
-      END DO
-#endif
+      !==================================================================
+      ! Prior to v3.3, zcoeff was hardwired according to k-index jk.
+      !
+      ! From v3.3 onwards this has been generalised to a function of 
+      ! depth so that it can be used with any number of levels.
+      !
+      ! The function has been chosen to match the original values (shown
+      ! in the following comments) when using the standard 31 ORCA levels.  
+      !     DO jk = 1, 21
+      !        zcoef(jk) = 1._wp
+      !     END DO
+      !     zcoef(22) = 2._wp
+      !     zcoef(23) = 3._wp
+      !     zcoef(24) = 5._wp
+      !     zcoef(25) = 7._wp
+      !     zcoef(26) = 9._wp
+      !     DO jk = 27, jpk
+      !        zcoef(jk) = 10._wp
+      !     END DO
+      !==================================================================
+
+       IF(lwp) THEN
+          WRITE(numout,*)
+          WRITE(numout,*) '         1D zcoef array '
+          WRITE(numout,*) '         ~~~~~~~~~~~~~~ '
+          WRITE(numout,*)
+          WRITE(numout,*) '    jk        zcoef '
+       ENDIF
+
+      DO jk=1, jpk
+         zcoef(jk) = 1.0_wp + NINT(9.0_wp*(gdept_0(jk)-800.0_wp)/(3000.0_wp-800.0_wp))
+         zcoef(jk) = MIN(10.0_wp, MAX(1.0_wp, zcoef(jk)))
+         IF(lwp) WRITE(numout,'(4x,i3,6x,f7.3)') jk,zcoef(jk)
+      END DO
 
       DO jk = 2, jpk
@@ -402,22 +399,17 @@
       END DO
 
-      IF( jp_cfg == 4 )   THEN
-         ! Limit AHM in Gibraltar strait
+      IF( jp_cfg == 4 )   THEN         ! Limit AHM in Gibraltar strait
          ij0 = 50   ;   ij1 = 53
          ii0 = 69   ;   ii1 = 71
          DO jk = 1, jpk
-            ahm1(mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk) = min( zahmm, ahm1 (mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk) ) 
-            ahm2(mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk) = min( zahmm, ahm2 (mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk) )
-         END DO
-      ENDIF
-      
-      ! Lateral boundary conditions on ( ahm1, ahm2 )
-      !                                ==============
-      CALL lbc_lnk( ahm1, 'T', 1. )   ! T-point, unchanged sign
-      CALL lbc_lnk( ahm2, 'F', 1. )   ! F-point, unchanged sign
-
-      ! Control print
-
-      IF(lwp) THEN
+            ahm1(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),jk) = MIN( zahmm, ahm1(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),jk) ) 
+            ahm2(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),jk) = MIN( zahmm, ahm2(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),jk) )
+         END DO
+      ENDIF
+      CALL lbc_lnk( ahm1, 'T', 1. )   ! Lateral boundary conditions (unchanged sign)
+      CALL lbc_lnk( ahm2, 'F', 1. )
+
+
+      IF(lwp) THEN                    ! Control print
          WRITE(numout,*)
          WRITE(numout,*) '         3D ahm1 array (k=1)'
@@ -451,8 +443,6 @@
       ahm4 ( :, 1, :) = ahm4 ( :, 2, :)
       
-      ! Lateral boundary conditions on ( ahm3, ahm4 )
-      !                                ==============
-      CALL lbc_lnk( ahm3, 'U', 1. )   ! U-point, unchanged sign
-      CALL lbc_lnk( ahm4, 'V', 1. )   ! V-point, unchanged sign
+      CALL lbc_lnk( ahm3, 'U', 1. )    ! Lateral boundary conditions (unchanged sign)
+      CALL lbc_lnk( ahm4, 'V', 1. )
 
       ! Control print
