Index: /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/CONFIG/SHARED/namelist_ref
===================================================================
--- /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 8035)
+++ /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 8036)
@@ -1308,2 +1308,35 @@
    rn_htrmax         =  200.0   ! max. depth of transition range
 /
+!-----------------------------------------------------------------------
+&nambias   ! Bias pressure correctiom
+!-----------------------------------------------------------------------
+   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.        
+   fb_t_asm       = 0.0
+   fb_t_rlx       = 0.0
+   fb_t_ofl       = 1.0
+   fb_p_asm       = 1.0
+   fb_p_rlx       = 1.0
+   fb_p_ofl       = 0.0
+   eft_rlx        = 365.0
+   eft_asm        = 365.0
+   t_rlx_upd      = 0.1
+   t_asm_upd      = 0.1
+   nn_lat_ramp    = 0          
+   bias_time_unit_asm = 86400.0
+   bias_time_unit_rlx = 1.0
+   bias_time_unit_ofl = 1.0 
+   cn_bias_tot    = "bias_tot.nc" 
+   cn_bias_asm    = "bias_asm.nc"
+   cn_dir         = './'  
+   ln_bsyncro     = .FALSE. 
+   fctamp         = 1.
+   rn_maxlat_bias = 23.0      
+   rn_minlat_bias = 10.0
+   nn_bias_itwrt  = 15
+   ln_itdecay     = .FALSE.
+/
Index: /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/ASM/biaspar.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/ASM/biaspar.F90	(revision 8036)
+++ /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/ASM/biaspar.F90	(revision 8036)
@@ -0,0 +1,40 @@
+MODULE biaspar
+   !! Variables relevant to bias module
+   !!======================================================================
+   !!                 *** Module biaspar ***
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_kind, ONLY: &
+      & wp
+   USE par_oce, ONLY: &
+      & jpi, &
+      & jpj, &
+      & jpk
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !! * Shared module variables
+   LOGICAL, PUBLIC :: ln_bias        = .FALSE. !: estimate (apply) bias arrays 
+   LOGICAL, PUBLIC :: ln_bias_asm    = .FALSE. !: estimate bias from assim incr
+   LOGICAL, PUBLIC :: ln_bias_rlx    = .FALSE. !: estimate bias from relaxation 
+   LOGICAL, PUBLIC :: ln_bias_ofl    = .FALSE. !: bias estimated offline
+   LOGICAL, PUBLIC :: ln_bias_ts_app = .FALSE. !: estimate (apply) bias arrays 
+   LOGICAL, PUBLIC :: ln_bias_pc_app = .FALSE. !: estimate bias from assim incr
+   LOGICAL, PUBLIC :: lrst_bias      = .FALSE. !: estimate bias from assim incr
+
+   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE :: &
+      & tbias, &       !: Temperature bias field for T correction
+      & tbias_p, &     !:  "           "    "    "   P correction
+      & sbias, &       !: Salinity bias field    for S correction
+      & sbias_p, &     !:  "           "    "    "   P correction
+      & rhd_pc         !: Press corrtd density from online to use in dyn_hpg
+
+
+   REAL(wp), PUBLIC, DIMENSION(:,:), ALLOCATABLE :: &
+      & gru_pc, &      !: Press corrtd bottom pressure gradient (x-dir)
+      & grv_pc         !: Press corrtd bottom pressure gradient (y-dir)
+
+
+
+END MODULE biaspar
Index: /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 8035)
+++ /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 8036)
@@ -44,4 +44,5 @@
    USE wrk_nemo        ! Memory Allocation
    USE timing          ! Timing
+   USE biaspar         ! bias correction variables
 
    IMPLICIT NONE
@@ -84,4 +85,7 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   z_rhd_st  ! tmp density storage for pressure corr 
+      REAL(wp), DIMENSION(jpi,jpj)     ::   z_gru_st  ! tmp ua trends storage for pressure corr
+      REAL(wp), DIMENSION(jpi,jpj)     ::   z_grv_st  ! tmp va trends storage for pressure corr
       !!----------------------------------------------------------------------
       !
@@ -92,4 +96,13 @@
          ztrdu(:,:,:) = ua(:,:,:)
          ztrdv(:,:,:) = va(:,:,:)
+      ENDIF
+      !
+      IF ( ln_bias .AND. ln_bias_pc_app ) THEN
+         z_rhd_st(:,:,:) = rhd(:,:,:)     ! store orig density 
+         rhd(:,:,:)      = rhd_pc(:,:,:)  ! use pressure corrected density
+         z_gru_st(:,:)   = gru(:,:)
+         gru(:,:)        = gru_pc(:,:)
+         z_grv_st(:,:)   = grv(:,:)
+         grv(:,:)        = grv_pc(:,:)
       ENDIF
       !
@@ -112,4 +125,10 @@
       IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' hpg  - Ua: ', mask1=umask,   &
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+      IF ( ln_bias .AND. ln_bias_pc_app )  THEN
+         rhd(:,:,:) = z_rhd_st(:,:,:)     ! restore original density
+         gru(:,:)   = z_gru_st(:,:)
+         grv(:,:)   = z_grv_st(:,:)
+      ENDIF
       !
       IF( nn_timing == 1 )  CALL timing_stop('dyn_hpg')
Index: /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 8035)
+++ /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 8036)
@@ -466,4 +466,5 @@
                             CALL dia_hsb_init   ! heat content, salt content and volume budgets
                             CALL     trd_init   ! Mixed-layer/Vorticity/Integral constraints trends
+                            CALL     bias_init  ! Pressure correction bias
       IF( lk_diaobs     ) THEN                  ! Observation & model comparison
                             CALL dia_obs_init            ! Initialize observational data
Index: /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 8035)
+++ /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 8036)
@@ -103,4 +103,6 @@
       IF( ln_crs     )       CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" )   ! tell iom we are at time step kstp
 
+      IF( ln_bias )          CALL bias_opn( kstp )
+
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! Update data, open boundaries, surface boundary condition (including sea-ice)
@@ -269,4 +271,5 @@
       IF( lk_trabbl      )   CALL tra_bbl    ( kstp )       ! advective (and/or diffusive) bottom boundary layer scheme
       IF( ln_tradmp      )   CALL tra_dmp    ( kstp )       ! internal damping trends
+      IF( ln_bias        )   CALL tra_bias   ( kstp )
       IF( lk_bdy         )   CALL bdy_tra_dmp( kstp )       ! bdy damping trends
                              CALL tra_adv    ( kstp )       ! horizontal & vertical advection
@@ -293,4 +296,5 @@
                &                                           rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
                &                                    gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level
+            IF( ln_bias )    CALL dyn_bias( kstp )
       ELSE                                                  ! centered hpg  (eos then time stepping)
          IF ( .NOT. lk_dynspg_ts ) THEN                     ! eos already called in time-split case
@@ -307,4 +311,5 @@
          IF( ln_zdfnpc   )   CALL tra_npc( kstp )                ! update after fields by non-penetrative convection
                              CALL tra_nxt( kstp )                ! tracer fields at next time step
+         IF( ln_bias )       CALL dyn_bias( kstp )
       ENDIF
 
@@ -381,4 +386,7 @@
       ENDIF
 
+
+      IF( lrst_bias )          CALL bias_wrt     ( kstp )
+
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! Coupled mode
Index: /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/step_oce.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/step_oce.F90	(revision 8035)
+++ /branches/UKMO/dev_r5518_GO6_package_inc_asm/NEMOGCM/NEMO/OPA_SRC/step_oce.F90	(revision 8036)
@@ -100,5 +100,7 @@
 
    USE crsfld           ! Standard output on coarse grid   (crs_fld routine)
-
+   USE biaspar          ! bias param
+   USE bias             ! bias routines                    (tra_bias routine
+                        !                                   dyn_bias routine)
    USE asminc           ! assimilation increments      (tra_asm_inc routine)
    !                                                   (dyn_asm_inc routine)
