Index: branches/UKMO/dev_r5518_pcbias/NEMOGCM/NEMO/OPA_SRC/ASM/bias.F90
===================================================================
--- branches/UKMO/dev_r5518_pcbias/NEMOGCM/NEMO/OPA_SRC/ASM/bias.F90	(revision 6300)
+++ branches/UKMO/dev_r5518_pcbias/NEMOGCM/NEMO/OPA_SRC/ASM/bias.F90	(revision 6328)
@@ -113,9 +113,4 @@
       &   bias_wrt
 
-#if defined key_bias
-    LOGICAL, PUBLIC, PARAMETER :: lk_bias = .TRUE.   !: Logical switch for bias correction
-#else
-    LOGICAL, PUBLIC, PARAMETER :: lk_bias = .FALSE.  !: No bias correction
-#endif
  
    !! * Shared variables
@@ -138,6 +133,6 @@
       & fb_p_ofl,             &  !: parition of bias in P for ofl bias term
       & fctamp,               &  !: amplification factor for T if inertial
-      & rn_maxlat,              &  !: Max lat for latitudinal ramp
-      & rn_minlat                  !: Min lat for latitudinal ramp
+      & rn_maxlat_bias,         &  !: Max lat for latitudinal ramp
+      & rn_minlat_bias             !: Min lat for latitudinal ramp
 
    LOGICAL,  PRIVATE :: lalloc
@@ -218,54 +213,22 @@
          & bias_time_unit_asm, bias_time_unit_rlx, bias_time_unit_ofl,    &
          & cn_bias_tot, cn_bias_asm, cn_dir, sn_tbias_ofl, sn_sbias_ofl,  &
-         & ln_bsyncro, fctamp, rn_maxlat, rn_minlat, nn_bias_itwrt, ln_itdecay
+         & ln_bsyncro, fctamp, rn_maxlat_bias, rn_minlat_bias,            &
+         & nn_bias_itwrt, ln_itdecay
  
 
       !-----------------------------------------------------------------------
-      ! Read Namelist nam_bias : bias interface
+      ! Read Namelist : bias interface
       !-----------------------------------------------------------------------
-      
-      ! Set default values
-      log2           = LOG( 2.0_wp )
-      ln_bias        = .FALSE.
-      ln_bias_asm    = .FALSE.
-      ln_bias_rlx    = .FALSE.
-      ln_bias_ofl    = .FALSE.
-      ln_bias_ts_app = .FALSE.
-      ln_bias_pc_app = .FALSE.
-
-      bias_time_unit_asm = 10.*86400.0_wp ! time unit for bias term
-      bias_time_unit_rlx = 1.0_wp     ! same as rlx terms, i.e. seconds. 
-      bias_time_unit_ofl = 1.0_wp     ! same as ofl terms, i.e. seconds. 
-
-      eft_rlx        = 365.0_wp  !efolding time for bias estimation
-      eft_asm        = 365.0_wp  !efolding time for bias estimation
-!      t_rlx_mem      = 1. - log2 * rdt / (eft_rlx * rday)
-      t_rlx_mem      = EXP( - log2 * rdt / ( eft_rlx * rday ) )
-      t_rlx_upd      = 0.1_wp
-      t_asm_mem      = EXP( - log2 * bias_time_unit_asm / ( eft_asm * rday ) )
-      t_asm_upd      = 0.1_wp
-      fctamp         = 1.
-      fb_t_rlx       = 0.0_wp
-      fb_t_asm       = 0.0_wp
-      fb_t_ofl       = 1.0_wp
-      fb_p_rlx       = 1.0_wp
-      fb_p_asm       = 1.0_wp
-      fb_p_ofl       = 0.0_wp
-      nn_lat_ramp    = 0
-      ln_bsyncro     = .FALSE.
-      ln_itdecay     = .FALSE.
-      rn_maxlat      = 23.0_wp
-      rn_minlat      = 10.0_wp
-      
-      IF ( lk_asminc ) THEN
-         nn_bias_itwrt = nitiaufin
-      ELSE
-         nn_bias_itwrt = nitend
-      ENDIF
-
-
-      cn_bias_asm = "bias_asm.nc"
-      cn_bias_tot = "bias_tot.nc"
-      cn_dir = './'       ! directory in which the model is executed
+
+
+      REWIND( numnam_ref )              ! Namelist nambias in reference namelist : Bias pressure correction
+      READ  ( numnam_ref, nambias, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nambias in reference namelist', lwp )
+
+
+      ! Set additional default values (note that most values are set in the reference namelist)
+      
+      IF ( ln_asmiau ) nn_bias_itwrt = nitiaufin
+      
       ! ... default values (NB: frequency positive => hours, negative => months)
       !            !   file    ! frequency !  variable  ! time intep !  clim   ! 'yearly' or !
@@ -273,9 +236,5 @@
       sn_tbias_ofl = FLD_N( 'tbias_ofl'    ,    -1.    ,  'tbias'     ,  .TRUE.   , .FALSE. ,   'yearly', '', '', ''  )
       sn_sbias_ofl = FLD_N( 'sbias_ofl'    ,    -1.    ,  'sbias'     ,  .TRUE.   , .FALSE. ,   'yearly', '', '', ''  )
-      lrst_bias    = .FALSE.
-      
-      REWIND( numnam_ref )              ! Namelist nambias in reference namelist : Bias pressure correction
-      READ  ( numnam_ref, nambias, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nambias in reference namelist', lwp )
+
 
       REWIND( numnam_cfg )              ! Namelist nambias in configuration namelist : Bias pressure correction
@@ -290,7 +249,10 @@
          ln_bias        = .FALSE.
       ENDIF
-
+      
+      ! set up decay scales
+      log2           = LOG( 2.0_wp )
       t_rlx_mem      = EXP( - log2 * rdt / ( eft_rlx * rday ) )
       t_asm_mem      = EXP( - log2 * bias_time_unit_asm/ ( eft_asm * rday ) )
+      
       ! Control print
       IF(lwp) THEN
@@ -498,25 +460,23 @@
       !latitudinal dependence of partition coeficients. Adhoc
       IF ( nn_lat_ramp == 1 ) THEN
-         !!!fbcoef(:,:) = SIN( rad * gphit(:,:) )**2
-         !!! Introduce the (also adhoc) FOAM parameterisation for latitudinal dependence.
-         !!! This should be added as a different namelist option later. MM. 08/2011.
-         lenscl_bias = ( rn_maxlat - rn_minlat )*2._wp
-         WHERE ( abs( gphit(:,:) ) <= rn_minlat )         
+         ! Use the inertial ramp.
+         lenscl_bias = ( rn_maxlat_bias - rn_minlat_bias )*2._wp
+         WHERE ( abs( gphit(:,:) ) <= rn_minlat_bias )         
             fbcoef(:,:) = 0._wp          
-         ELSEWHERE ( abs( gphit(:,:) ) >= rn_maxlat )         
+         ELSEWHERE ( abs( gphit(:,:) ) >= rn_maxlat_bias )         
             fbcoef(:,:) = 1._wp                    
          ELSEWHERE        
-            fbcoef(:,:) = 1._wp - exp( -( abs( gphit(:,:) ) - rn_minlat ) &
-                           * ( abs( gphit(:,:) ) - rn_minlat ) / lenscl_bias )                         
+            fbcoef(:,:) = 1._wp - exp( -( abs( gphit(:,:) ) - rn_minlat_bias ) &
+                           * ( abs( gphit(:,:) ) - rn_minlat_bias ) / lenscl_bias )                         
          ENDWHERE 
       ELSEIF ( nn_lat_ramp == 2 ) THEN   
          ! Use a linear ramp consist with the geostrophic velocity balance ramp in NEMOVAR
      
-         WHERE ( abs( gphit(:,:) ) <= rn_minlat )
+         WHERE ( abs( gphit(:,:) ) <= rn_minlat_bias )
             fbcoef(:,:) = 0._wp
-         ELSEWHERE ( abs( gphit(:,:) ) >= rn_maxlat ) 
+         ELSEWHERE ( abs( gphit(:,:) ) >= rn_maxlat_bias ) 
             fbcoef(:,:) = 1._wp
          ELSEWHERE
-            fbcoef(:,:) = 1._wp - ((rn_maxlat - abs( gphit(:,:)))/(rn_maxlat - rn_minlat))
+            fbcoef(:,:) = 1._wp - ((rn_maxlat_bias - abs( gphit(:,:)))/(rn_maxlat_bias - rn_minlat_bias))
          ENDWHERE
       ELSE
@@ -696,6 +656,6 @@
             ! if last outer loop (lk_asminc=true and ln_trainc=true). t/sbias_asm
             ! is updated, only once (end of run) taking into account units.
-               IF ( (kt == nn_bias_itwrt) .and. lrst_bias) THEN
-                 IF(lwp) WRITE(numout,*)' estimating asm bias at last timestep: ',kt
+               IF ( kt == nn_bias_itwrt ) THEN
+                 IF(lwp) WRITE(numout,*)' estimating asm bias at timestep: ',kt
                  DO jk = 1, jpkm1
                    tbias_asm_out(:,:,jk) = t_asm_mem * tbias_asm(:,:,jk)  +             &
