Index: NEMO/branches/UKMO/NEMO_4.0.4_FOAM_IAU_SI3_SIC/src/OCE/ASM/asminc.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_FOAM_IAU_SI3_SIC/src/OCE/ASM/asminc.F90	(revision 15412)
+++ NEMO/branches/UKMO/NEMO_4.0.4_FOAM_IAU_SI3_SIC/src/OCE/ASM/asminc.F90	(revision 15476)
@@ -35,5 +35,5 @@
    USE sbc_oce         ! Surface boundary condition variables.
    USE diaobs   , ONLY : calc_date     ! Compute the calendar date on a given step
-#if defined key_si3
+#if defined key_si3 && defined key_asminc
    USE phycst         ! physical constants
    USE ice1D          ! sea-ice: thermodynamics variables
@@ -92,8 +92,8 @@
    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   ssh_bkg, ssh_bkginc   ! Background sea surface height and its increment
    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   seaice_bkginc         ! Increment to the background sea ice conc
-#if defined key_si3
+   REAL(wp) :: zhi_damin                                            ! Ice thickness for new sea ice from DA increment
+#if defined key_si3 && defined key_asminc
    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   a_i_bkginc          ! Increment to the background sea ice conc categories
    LOGICAL, PUBLIC, DIMENSION(:,:,:), ALLOCATABLE :: incr_newice    ! Mask .TRUE.=DA positive ice increment to open water
-   REAL(wp) :: zhi_damin                                            ! Ice thickness for new sea ice from DA increment
 #endif
 #if defined key_cice && defined key_asminc
@@ -336,5 +336,5 @@
       ALLOCATE( ssh_bkginc   (jpi,jpj)     )   ;   ssh_bkginc   (:,:)   = 0._wp
       ALLOCATE( seaice_bkginc(jpi,jpj)     )   ;   seaice_bkginc(:,:)   = 0._wp
-#if defined key_si3
+#if defined key_si3 && defined key_asminc
       ALLOCATE( a_i_bkginc   (jpi,jpj,jpl) )   ;   a_i_bkginc   (:,:,:) = 0._wp
       ALLOCATE( incr_newice(jpi,jpj,jpl) )     ;   incr_newice(:,:,:) = .FALSE.
@@ -414,9 +414,10 @@
             ! very small increments are also set to zero
             WHERE( ABS( seaice_bkginc(:,:) ) > 1.0e+10 .OR. &
-              &    ABS( seaice_bkginc(:,:) ) < epsi03 ) seaice_bkginc(:,:) = 0.0_wp
+              &    ABS( seaice_bkginc(:,:) ) < 1.0e-03_wp ) seaice_bkginc(:,:) = 0.0_wp
             
+#if defined key_si3 && defined key_asminc
             IF (lwp) THEN
                WRITE(numout,*)
-               WRITE(numout,*) 'asm_inc_init : Converting seaice_bkginc to a_i_bkginc'
+               WRITE(numout,*) 'asm_inc_init : Converting single category increment to multi-category'
                WRITE(numout,*) '~~~~~~~~~~~~'
             END IF
@@ -424,13 +425,19 @@
             !single category increment for sea ice conc
             !convert single category increment to multi category
-            a_i_bkginc = 0.0_wp
             at_i = SUM( a_i(:,:,:), DIM=3 )
 
             ! ensure zhi_damin lies within 1st category
-            IF ( zhi_damin > hi_max(1) ) zhi_damin = hi_max(1) - epsi02
+            IF ( zhi_damin > hi_max(1) ) THEN 
+               IF (lwp) THEN
+                  WRITE(numout,*)
+                  WRITE(numout,*) 'minimum DA thickness > hmax(1): setting minimum DA thickness to hmax(1)'
+                  WRITE(numout,*) '~~~~~~~~~~~~'
+               END IF
+               zhi_damin = hi_max(1) - epsi02
+            END IF
             
             DO jj = 1, jpj
                DO ji = 1, jpi
-                  IF ( seaice_bkginc(ji,jj) > 0.0_wp) THEN
+                  IF ( seaice_bkginc(ji,jj) > 0.0_wp ) THEN
                      !positive ice concentration increments are always 
                      !added to the thinnest category of ice
@@ -440,4 +447,8 @@
                      !available category until it reaches zero concentration
                      !and then progressively removed from thicker categories
+
+                     !NOTE: might consider the remote possibility that zremaining_increment 
+                     !left over is not zero, particulary if SI3 is being run 
+                     !as a single category 
                      zremaining_increment = seaice_bkginc(ji,jj)
                      DO jl = 1, jpl
@@ -451,4 +462,5 @@
             END DO
             ! find model points where DA new ice should be added to open water
+            ! in any ice category
             DO jl = 1,jpl
                WHERE ( at_i(:,:) < epsi02 .AND. seaice_bkginc(:,:) > 0.0_wp )
@@ -457,4 +469,5 @@
             END DO
          ENDIF
+#endif
          !
          CALL iom_close( inum )
@@ -881,12 +894,11 @@
       INTEGER, INTENT(in), OPTIONAL ::   kindic   ! flag for disabling the deallocation
       !
-      INTEGER  ::   it, jl
+      INTEGER  ::   it, jk
       REAL(wp) ::   zincwgt                            ! IAU weight for current time step
-#if defined key_si3
-      LOGICAL, SAVE :: logical_newice = .TRUE.         ! Flag to add new ice from DA to open water
+#if defined key_si3 && defined key_asminc
       REAL(wp), DIMENSION(jpi,jpj,jpl) :: da_i         ! change in ice concentration
       REAL(wp), DIMENSION(jpi,jpj,jpl) :: dv_i         ! change in ice volume
-      REAL(wp), DIMENSION(jpi,jpj,jpl) :: z1_a_i       ! inverse of old ice concentration
-      REAL(wp), DIMENSION(jpi,jpj,jpl) :: z1_v_i       ! inverse of old ice volume
+      REAL(wp), DIMENSION(jpi,jpj,jpl) :: z1_a_i       ! inverse of ice concentration before current IAU step
+      REAL(wp), DIMENSION(jpi,jpj,jpl) :: z1_v_i       ! inverse of ice volume before current IAU step
       REAL(wp), DIMENSION(jpi,jpj)     :: zhi_damin_2D ! array with DA thickness for incr_newice
 #endif
@@ -911,8 +923,5 @@
             ! Sea-ice : SI3 case
             !
-#if defined key_si3
-            ! ensure zhi_damin lies within 1st category
-            IF ( zhi_damin > hi_max(1) ) zhi_damin = hi_max(1) - epsi02
-
+#if defined key_si3 && defined key_asminc
             ! compute the inverse of key sea ice variables
             ! to be used later in the code 
@@ -953,5 +962,5 @@
             ! just do it once since next IAU steps assume that new ice has 
             ! already been added in
-            IF ( kt == nitiaustr_r .AND. logical_newice ) THEN
+            IF ( kt == nitiaustr_r ) THEN
 
                ! assign zhi_damin to ice forming in open water
@@ -972,12 +981,12 @@
                   sv_i(:,:,:) = 0.0_wp
                END WHERE
-               DO jl = 1, nlay_i
+               DO jk = 1, nlay_i
                   WHERE ( incr_newice )
-                     e_i(:,:,jl,:) = 0.0_wp
+                     e_i(:,:,jk,:) = 0.0_wp
                   END WHERE
                END DO
-               DO jl = 1, nlay_s
+               DO jk = 1, nlay_s
                   WHERE ( incr_newice )
-                     e_s(:,:,jl,:) = 0.0_wp
+                     e_s(:,:,jk,:) = 0.0_wp
                   END WHERE
                END DO
@@ -985,5 +994,5 @@
                ! Initialisation of the salt content and ice enthalpy
                ! set flag of new ice to false after this
-               call init_new_ice_thd( zhi_damin_2D )
+               CALL init_new_ice_thd( zhi_damin_2D )
                incr_newice(:,:,:) = .FALSE.
             END IF
@@ -991,6 +1000,6 @@
             ! maintain equivalent values for key prognostic variables
             v_s(:,:,:) = v_s(:,:,:) * da_i(:,:,:)
-            DO jl = 1, nlay_s
-               e_s(:,:,jl,:) = e_s(:,:,jl,:) * da_i(:,:,:)
+            DO jk = 1, nlay_s
+               e_s(:,:,jk,:) = e_s(:,:,jk,:) * da_i(:,:,:)
             END DO
             a_ip (:,:,:) = a_ip(:,:,:) * da_i(:,:,:)
@@ -999,6 +1008,6 @@
             ! ice volume dependent variables
             sv_i (:,:,:) = sv_i(:,:,:) * dv_i(:,:,:)
-            DO jl = 1, nlay_i
-               e_i(:,:,jl,:) = e_i(:,:,jl,:) * dv_i(:,:,:)
+            DO jk = 1, nlay_i
+               e_i(:,:,jk,:) = e_i(:,:,jk,:) * dv_i(:,:,:)
             END DO
 #endif
@@ -1011,5 +1020,5 @@
             IF ( kt == nitiaufin_r ) THEN
                DEALLOCATE( seaice_bkginc )
-#if defined key_si3
+#if defined key_si3 && defined key_asminc
                DEALLOCATE( incr_newice )
                DEALLOCATE( a_i_bkginc )
@@ -1066,12 +1075,12 @@
       !!                forming at 1st category with thickness hi_new
       !!
-      !! ** Method  :   Apply SI3 thermodynamic equations to initialise
-      !!                thermodynamic of new ice
-      !!
-      !! ** Action  :   update thermodynamic variables
+      !! ** Method  :   Apply SI3  equations to initialise
+      !!                thermodynamics of new ice
+      !!
+      !! ** Action  :   update sea ice thermodynamics
       !!----------------------------------------------------------------------
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in)    ::   hi_new  ! total thickness of new ice
 
-      INTEGER :: jj, ji, jk, jl
+      INTEGER :: jj, ji, jk
       REAL(wp) ::   ztmelts   ! melting point
 
@@ -1108,8 +1117,8 @@
          CASE ( 2 )                    ! Sice = F(z,t) [Vancoppenolle et al (2005)]
             DO ji = 1, npti
-               zs_newice(ji) = MIN(  4.606 + 0.91 / zh_newice(ji) , rn_simax , 0.5 * sss_1d(ji) )
+               zs_newice(ji) = MIN(  4.606_wp + 0.91_wp / zh_newice(ji) , rn_simax , 0.5_wp * sss_1d(ji) )
             END DO
          CASE ( 3 )                    ! Sice = F(z) [multiyear ice]
-            zs_newice(1:npti) =   2.3
+            zs_newice(1:npti) =   2.3_wp
          END SELECT
 
@@ -1123,6 +1132,6 @@
          DO ji = 1, npti
                ztmelts       = - rTmlt * zs_newice(ji)                  ! Melting point (C)
-               e_i_1d(ji,:)  =   rhoi * (  rcpi  * ( ztmelts - ( t_bo_1d(ji) - rt0 ) )                     &
-                  &                      + rLfus * ( 1.0 - ztmelts / MIN( t_bo_1d(ji) - rt0, -epsi10 ) )   &
+               e_i_1d(ji,:)  =   rhoi * (  rcpi  * ( ztmelts - ( t_bo_1d(ji) - rt0 ) )                        &
+                  &                      + rLfus * ( 1.0_wp - ztmelts / MIN( t_bo_1d(ji) - rt0, -epsi10 ) )   &
                   &                      - rcp   *         ztmelts )
          END DO
