Index: /branches/devukmo2010/CONFIG/GYRE/EXP00/namelist
===================================================================
--- /branches/devukmo2010/CONFIG/GYRE/EXP00/namelist	(revision 2178)
+++ /branches/devukmo2010/CONFIG/GYRE/EXP00/namelist	(revision 2179)
@@ -214,6 +214,6 @@
    sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
    sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
-   sn_sal_rnf  = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
-   sn_tmp_rnf  = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_s_rnf    = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_t_rnf    = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
    sn_dep_rnf  = 'runoffs'          ,   0         , 'rodepth'  ,    .false.     , .true.  ,   'yearly', ''       , ''
  
@@ -221,8 +221,10 @@
    ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
    ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
-   ln_rnf_att   =   .false. !  apply temperature, salinity and depth attributes to runoff input
    rn_hrnf      =   0.e0    !  depth over which enhanced vertical mixing is used
    rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
    rn_rfact     =   1.e0    !  multiplicative factor for runoff
+   ln_rnf_depth =  .false.  !  read in depth information for runoff
+   ln_rnf_temp  =  .false.  !  read in temperature information for runoff
+   ln_rnf_sal   =  .false.  !  read in salinity information for runoff
 /
 !-----------------------------------------------------------------------
Index: /branches/devukmo2010/CONFIG/GYRE_LOBSTER/EXP00/namelist
===================================================================
--- /branches/devukmo2010/CONFIG/GYRE_LOBSTER/EXP00/namelist	(revision 2178)
+++ /branches/devukmo2010/CONFIG/GYRE_LOBSTER/EXP00/namelist	(revision 2179)
@@ -214,6 +214,6 @@
    sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
    sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
-   sn_sal_rnf  = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
-   sn_tmp_rnf  = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_s_rnf    = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_t_rnf    = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
    sn_dep_rnf  = 'runoffs'          ,   0         , 'rodepth'  ,    .false.     , .true.  ,   'yearly', ''       , ''
  
@@ -221,8 +221,10 @@
    ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
    ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
-   ln_rnf_att   =   .false. !  apply temperature, salinity and depth attributes to runoff input
    rn_hrnf      =   0.e0    !  depth over which enhanced vertical mixing is used
    rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
    rn_rfact     =   1.e0    !  multiplicative factor for runoff
+   ln_rnf_depth =  .false.  !  read in depth information for runoff
+   ln_rnf_temp  =  .false.  !  read in temperature information for runoff
+   ln_rnf_sal   =  .false.  !  read in salinity information for runoff
 /
 !-----------------------------------------------------------------------
Index: /branches/devukmo2010/CONFIG/ORCA2_LIM/EXP00/namelist
===================================================================
--- /branches/devukmo2010/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 2178)
+++ /branches/devukmo2010/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 2179)
@@ -241,6 +241,6 @@
    sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
    sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
-   sn_sal_rnf  = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
-   sn_tmp_rnf  = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_s_rnf    = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_t_rnf    = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
    sn_dep_rnf  = 'runoffs'          ,   0         , 'rodepth'  ,    .false.     , .true.  ,   'yearly', ''       , ''
 
@@ -249,8 +249,10 @@
    ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
    ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
-   ln_rnf_att   =   .false. !  apply temperature, salinity and depth attributes to runoff input  
    rn_hrnf      =  15.e0    !  depth over which enhanced vertical mixing is used
    rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
    rn_rfact     =   1.e0    !  multiplicative factor for runoff
+   ln_rnf_depth =  .false.  !  read in depth information for runoff
+   ln_rnf_temp  =  .false.  !  read in temperature information for runoff
+   ln_rnf_sal   =  .false.  !  read in salinity information for runoff
 /
 !-----------------------------------------------------------------------
Index: /branches/devukmo2010/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist
===================================================================
--- /branches/devukmo2010/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist	(revision 2178)
+++ /branches/devukmo2010/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist	(revision 2179)
@@ -241,6 +241,6 @@
    sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
    sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
-   sn_sal_rnf  = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
-   sn_tmp_rnf  = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_s_rnf    = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_t_rnf    = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
    sn_dep_rnf  = 'runoffs'          ,   0         , 'rodepth'  ,    .false.     , .true.  ,   'yearly', ''       , ''
  
@@ -248,8 +248,10 @@
    ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
    ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
-   ln_rnf_att   =   .false. !  apply temperature, salinity and depth attributes to runoff input
    rn_hrnf      =  15.e0    !  depth over which enhanced vertical mixing is used
    rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
    rn_rfact     =   1.e0    !  multiplicative factor for runoff
+   ln_rnf_depth =  .false.  !  read in depth information for runoff
+   ln_rnf_temp  =  .false.  !  read in temperature information for runoff
+   ln_rnf_sal   =  .false.  !  read in salinity information for runoff
 /
 !-----------------------------------------------------------------------
Index: /branches/devukmo2010/CONFIG/POMME/EXP00/namelist
===================================================================
--- /branches/devukmo2010/CONFIG/POMME/EXP00/namelist	(revision 2178)
+++ /branches/devukmo2010/CONFIG/POMME/EXP00/namelist	(revision 2179)
@@ -240,6 +240,6 @@
    sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
    sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
-   sn_sal_rnf  = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
-   sn_tmp_rnf  = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_s_rnf    = 'runoffs'          ,  24         , 'rosaline' ,    .true.      , .true.  ,   'yearly', ''       , ''
+   sn_t_rnf    = 'runoffs'          ,  24         , 'rotemper' ,    .true.      , .true.  ,   'yearly', ''       , ''
    sn_dep_rnf  = 'runoffs'          ,   0         , 'rodepth'  ,    .false.     , .true.  ,   'yearly', ''       , ''
  
@@ -247,8 +247,10 @@
    ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
    ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
-   ln_rnf_att   =   .false. !  apply temperature, salinity and depth attributes to runoff input
    rn_hrnf      =  0.e0    !  depth over which enhanced vertical mixing is used
    rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
    rn_rfact     =   1.e0    !  multiplicative factor for runoff
+   ln_rnf_depth =  .false.  !  read in depth information for runoff
+   ln_rnf_temp  =  .false.  !  read in temperature information for runoff
+   ln_rnf_sal   =  .false.  !  read in salinity information for runoff
 /
 !-----------------------------------------------------------------------
Index: /branches/devukmo2010/DOC/TexFiles/Chapters/Chap_SBC.tex
===================================================================
--- /branches/devukmo2010/DOC/TexFiles/Chapters/Chap_SBC.tex	(revision 2178)
+++ /branches/devukmo2010/DOC/TexFiles/Chapters/Chap_SBC.tex	(revision 2179)
@@ -36,6 +36,6 @@
 term to observed SST and/or SSS (\np{ln\_ssr}=true); the modification of fluxes 
 below ice-covered areas (using observed ice-cover or a sea-ice model) 
-(\np{nn\_ice}=0,1, 2 or 3); the addition of river runoffs as surface freshwater 
-fluxes (\np{ln\_rnf}=true); the addition of a freshwater flux adjustment in 
+(\np{nn\_ice}=0,1, 2 or 3); the addition of river runoffs (\np{ln\_rnf}=true);
+ the addition of a freshwater flux adjustment in 
 order to avoid a mean sea-level drift (\np{nn\_fwb}= 0, 1 or 2); and the 
 transformation of the solar radiation (if provided as daily mean) into a diurnal 
@@ -574,6 +574,6 @@
 
 It is convenient to introduce the river runoff in the model as a surface 
-fresh water flux. 
-
+fresh water flux. This is the defualt option within NEMO, and there is then
+ the option for the user to increase vertical mixing in the vicinity of the rivermouth.
 
 %Griffies:  River runoff generally enters the ocean at a nonzero depth rather than through the surface. Many global models, however, have traditionally inserted river runoff to the top model cell. Such can become problematic numerically and physically when the top grid cells are reÞned to levels common in coastal modelling. Hence, more applications are now considering the input of runoff throughout a nonzero depth. Likewise, sea ice can melt at depth, thus necessitating a mass transport to occur within the ocean between the liquid and solid water masses.
@@ -587,4 +587,27 @@
 %ENDIF
 
+However, this method is not very appropriate for coastal modelling.  As such its now possible
+ to specify, in a netcdf input file, the temperature and salinity of the river, along with the 
+depth (in metres) which the river should be added to.  This enables to river to be correctly 
+added through the water column, instead of as a surface flux, and also means the temperature 
+or salinity (for low salinity outflow) of the river impacts the surrounding ocean.
+
+For temperature -999 is taken as missing data and the river temperature is taken to be the 
+surface temperatue at the river point.  For the depth parameter a value of -1 means the 
+river is added to the surface box only, and a value of -999 means the river is added through 
+the entire water column.
+
+Namelist options, ln_rnf_depth, ln_rnf_sal and ln_rnf_temp control whether the river attributes 
+(depth, salinity and temperature) are read in and used.  If these are set as false the river is 
+added to the surface box only, assumed to be fresh (0psu), and/or taken as surface temperature 
+respectively.
+
+It is also possible for runnoff to be specified as a negative value for modelling flow through 
+straits, ie, modelling the baltic flow in and out of the north sea.  When the flow is out of the 
+domain there is no change in temperature and salinity, regardless of the namelist options used.
+
+The runoff value and attributes are read in in sbcrnf.  The mass/volume addition is added to the 
+divergence term in sbc_rnf_div.  The dilution effect of the river is automatically applied through 
+the vertical tracer advection, and the direct flux of tracers into the domain is done in trasbc.
 
 
Index: /branches/devukmo2010/DOC/TexFiles/Namelist/namsbc_rnf
===================================================================
--- /branches/devukmo2010/DOC/TexFiles/Namelist/namsbc_rnf	(revision 2178)
+++ /branches/devukmo2010/DOC/TexFiles/Namelist/namsbc_rnf	(revision 2179)
@@ -6,4 +6,7 @@
    sn_rnf     = 'runoff_1m_nomask.nc' ,      -12.        ,  'sorunoff',      .true.        ,    1   ,    0     , ''       , ''
    sn_cnf     = 'runoff_1m_nomask.nc' ,        0.        ,  'socoefr' ,      .false.       ,    1   ,    0     , ''       , ''
+   sn_s_rnf   = 'runoffs'             ,  24              , 'rosaline' ,    .true.          , .true. ,  'yearly', ''       , ''
+   sn_t_rnf   = 'runoffs'             ,  24              , 'rotemper' ,    .true.          , .true. ,  'yearly', ''       , ''
+   sn_dep_rnf = 'runoffs'             ,   0              , 'rodepth'  ,    .false.         , .true. ,  'yearly', ''       , ''
 !
    cn_dir       = './'       ! directory in which the model is executed
@@ -12,3 +15,7 @@
    rn_hrnf      =   0.e0    !  depth over which enhanced vertical mixing is used
    rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
+   rn_rfact     =   1.e0    !  multiplicative factor for runoff
+   ln_rnf_depth =  .false.  !  read in depth information for runoff
+   ln_rnf_temp  =  .false.  !  read in temperature information for runoff
+   ln_rnf_sal   =  .false.  !  read in salinity information for runoff
 /
Index: /branches/devukmo2010/NEMO/OPA_SRC/DYN/divcur.F90
===================================================================
--- /branches/devukmo2010/NEMO/OPA_SRC/DYN/divcur.F90	(revision 2178)
+++ /branches/devukmo2010/NEMO/OPA_SRC/DYN/divcur.F90	(revision 2179)
@@ -15,7 +15,6 @@
    USE obc_oce         ! ocean lateral open boundary condition
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE sbcrnf, ONLY  : rnf_dep, rnf_mod_dep  ! River runoff
-   USE phycst,  ONLY : rau0                  ! physical constant
-   USE sbc_oce, ONLY : ln_rnf, rnf           ! surface boundary condition: ocean
+   USE sbcrnf         ! river runoff 
+   USE sbc_oce, ONLY : ln_rnf   ! surface boundary condition: ocean
 
    IMPLICIT NONE
@@ -92,5 +91,4 @@
       REAL(wp), DIMENSION(   jpi  ,1:jpj+2) ::   zwu   ! workspace
       REAL(wp), DIMENSION(-1:jpi+2,  jpj  ) ::   zwv   ! workspace
-      REAL(wp) ::  zraur,  zdep   ! temporary scalar
       !!----------------------------------------------------------------------
 
@@ -241,15 +239,5 @@
       !                                                ! ===============
 
-      IF ( ln_rnf ) THEN
-      zraur = 1. / rau0
-        DO ji=1,jpi
-          DO jj=1,jpj
-            zdep = 1. / rnf_dep(ji,jj)
-            DO jk=1,rnf_mod_dep(ji,jj)
-              hdivn(ji,jj,jk) = hdivn(ji,jj,jk) - rnf(ji,jj)*zraur*zdep
-            ENDDO
-          ENDDO
-        ENDDO
-      ENDIF
+      IF( ln_rnf )  CALL sbc_rnf_div( hdivn )          ! runoffs (update hdivn field)
       
       ! 4. Lateral boundary conditions on hdivn and rotn
@@ -309,5 +297,4 @@
       !! * Local declarations
       INTEGER  ::   ji, jj, jk          ! dummy loop indices
-      REAL(wp) ::  zraur,  zdep   ! temporary scalar
       !!----------------------------------------------------------------------
 
@@ -374,15 +361,5 @@
       !                                                ! ===============
 
-      IF ( ln_rnf ) THEN
-      zraur = 1. / rau0
-        DO ji=1,jpi
-          DO jj=1,jpj
-            zdep = 1. / rnf_dep(ji,jj)
-            DO jk=1,rnf_mod_dep(ji,jj)
-              hdivn(ji,jj,jk) = hdivn(ji,jj,jk) - rnf(ji,jj)*zraur*zdep
-            ENDDO
-          ENDDO
-        ENDDO
-      ENDIF
+      IF( ln_rnf )  CALL sbc_rnf_div( hdivn )          ! runoffs (update hdivn field)
 
       ! 4. Lateral boundary conditions on hdivn and rotn
Index: /branches/devukmo2010/NEMO/OPA_SRC/DYN/sshwzv.F90
===================================================================
--- /branches/devukmo2010/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 2178)
+++ /branches/devukmo2010/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 2179)
@@ -30,5 +30,5 @@
    USE diaar5, ONLY :   lk_diaar5
    USE iom
-   USE sbcrnf, ONLY  : rnf_dep, rnf_mod_dep  ! River runoff 
+   USE sbcrnf, ONLY  : h_rnf, nk_rnf  ! River runoff 
 #if defined key_asminc   
    USE asminc          ! Assimilation increment
@@ -140,13 +140,4 @@
          hur(:,:) = umask(:,:,1) / ( hu(:,:) + 1.e0 - umask(:,:,1) )
          hvr(:,:) = vmask(:,:,1) / ( hv(:,:) + 1.e0 - vmask(:,:,1) )
-         !
-         DO jj=1,jpj  
-           DO ji=1,jpi  
-             rnf_dep(ji,jj)=0 
-             DO jk=1,rnf_mod_dep(ji,jj)                          ! recalculates rnf_dep to be the depth 
-               rnf_dep(ji,jj)=rnf_dep(ji,jj)+fse3t(ji,jj,jk)    ! in metres to the bottom of the relevant grid box 
-             ENDDO 
-           ENDDO 
-         ENDDO 
          ! 
       ENDIF
Index: /branches/devukmo2010/NEMO/OPA_SRC/SBC/sbcrnf.F90
===================================================================
--- /branches/devukmo2010/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 2178)
+++ /branches/devukmo2010/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 2179)
@@ -25,33 +25,42 @@
    PRIVATE
 
-   PUBLIC sbc_rnf          ! routine call in step module
-
-   !                                                     !!* namsbc_rnf namelist *
+   PUBLIC sbc_rnf          ! routine call in sbcmod module
+   PUBLIC sbc_rnf_div      ! routine called in sshwzv module
+
+   !                                                      !!* namsbc_rnf namelist *
    CHARACTER(len=100), PUBLIC ::   cn_dir       = './'    !: Root directory for location of ssr files
+   LOGICAL           , PUBLIC ::   ln_rnf_depth = .false. !: depth       river runoffs attribute specified in a file
+   LOGICAL           , PUBLIC ::   ln_rnf_temp  = .false. !: temperature river runoffs attribute specified in a file 
+   LOGICAL           , PUBLIC ::   ln_rnf_sal   = .false. !: salinity    river runoffs attribute specified in a file 
    LOGICAL           , PUBLIC ::   ln_rnf_emp   = .false. !: runoffs into a file to be read or already into precipitation
    TYPE(FLD_N)       , PUBLIC ::   sn_rnf                 !: information about the runoff file to be read
    TYPE(FLD_N)       , PUBLIC ::   sn_cnf                 !: information about the runoff mouth file to be read
-   TYPE(FLD_N)                ::   sn_sal_rnf             !: information about the salinities of runoff file to be read  
-   TYPE(FLD_N)                ::   sn_tmp_rnf             !: information about the temperatures of runoff file to be read  
+   TYPE(FLD_N)                ::   sn_s_rnf               !: information about the salinities of runoff file to be read  
+   TYPE(FLD_N)                ::   sn_t_rnf               !: information about the temperatures of runoff file to be read  
    TYPE(FLD_N)                ::   sn_dep_rnf             !: information about the depth which river inflow affects
    LOGICAL           , PUBLIC ::   ln_rnf_mouth = .false. !: specific treatment in mouths vicinity
    REAL(wp)          , PUBLIC ::   rn_hrnf      = 0.e0    !: runoffs, depth over which enhanced vertical mixing is used
    REAL(wp)          , PUBLIC ::   rn_avt_rnf   = 0.e0    !: runoffs, value of the additional vertical mixing coef. [m2/s]
-   LOGICAL           , PUBLIC ::   ln_rnf_att   = .false. !: river runoffs attributes (temp, sal & depth) are specified in a file 
    REAL(wp)          , PUBLIC ::   rn_rfact     = 1.e0    !: multiplicative factor for runoff
 
-   INTEGER , PUBLIC                     ::   nkrnf = 0   !: number of levels over which Kz is increased at river mouths
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnfmsk      !: river mouth mask (hori.)
-   REAL(wp), PUBLIC, DIMENSION(jpk)     ::   rnfmsk_z    !: river mouth mask (vert.)
-
-   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_rnf        !: structure of input river runoff (file information, fields read)
-
-   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_sal_rnf    !: structure of input river runoff salinity (file information, fields read)  
-   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_tmp_rnf    !: structure of input river runoff temperature (file information, fields read)  
+   INTEGER , PUBLIC                     ::   nkrnf = 0    !: number of levels over which Kz is increased at river mouths
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnfmsk       !: river mouth mask (hori.)
+   REAL(wp), PUBLIC, DIMENSION(jpk)     ::   rnfmsk_z     !: river mouth mask (vert.)
+
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_rnf       !: structure of input river runoff (file information, fields read)
+
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_s_rnf     !: structure of input river runoff salinity (file information, fields read)  
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_t_rnf     !: structure of input river runoff temperature (file information, fields read)  
  
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  rnf_dep         !: depth of runoff in m
-   INTEGER,  PUBLIC, DIMENSION(jpi,jpj) ::  rnf_mod_dep     !: depth of runoff in model levels
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  rnf_sal         !: salinity of river runoff
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  rnf_tmp         !: temperature of river runoff
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   h_rnf        !: depth of runoff in m
+   INTEGER,  PUBLIC, DIMENSION(jpi,jpj) ::   nk_rnf       !: depth of runoff in model levels
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,2) ::  tsc_rnf  !: temperature & salinity content of river runoffs   [K.m/s & PSU.m/s]
+
+   INTEGER, PUBLIC                      :: jp_sal=1
+   INTEGER, PUBLIC                      :: jp_tem=2
+
+!   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnf_sal      !: salinity of river runoff
+!   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnf_tmp      !: temperature of river runoff
   
    INTEGER  ::  ji, jj ,jk    ! dummy loop indices  
@@ -84,4 +93,5 @@
       !!
       INTEGER  ::   ji, jj   ! dummy loop indices
+      REAL(wp) ::   z1_rau0  ! local scalar
       !!----------------------------------------------------------------------
       !                                   
@@ -94,10 +104,7 @@
          !                                                !-------------------!
          !
-         CALL fld_read( kt, nn_fsbc, sf_rnf )   ! Read Runoffs data and provides it
-         !                                      ! at the current time-step
-         IF ( ln_rnf_att ) THEN  
-            CALL fld_read ( kt, nn_fsbc, sf_sal_rnf )  
-            CALL fld_read ( kt, nn_fsbc, sf_tmp_rnf )  
-         ENDIF  
+                             CALL fld_read ( kt, nn_fsbc, sf_rnf )      ! Read Runoffs data and provide it at kt 
+         IF( ln_rnf_temp )   CALL fld_read ( kt, nn_fsbc, sf_t_rnf )    ! idem for runoffs temperature if required
+         IF( ln_rnf_sal  )   CALL fld_read ( kt, nn_fsbc, sf_s_rnf )    ! idem for runoffs salinity    if required
 
          ! Runoff reduction only associated to the ORCA2_LIM configuration
@@ -115,12 +122,27 @@
          IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
             rnf(:,:)  = rn_rfact * ( sf_rnf(1)%fnow(:,:) )  
-            IF ( ln_rnf_att ) THEN  
-               rnf_sal(:,:) = ( sf_sal_rnf(1)%fnow(:,:) )  
-               rnf_tmp(:,:) = ( sf_tmp_rnf(1)%fnow(:,:) )  
-            ELSE  
-               rnf_sal(:,:) = 0.0
-               rnf_tmp(:,:) = -999  
+            !
+            z1_rau0 = 1.e0 / rau0
+            !                                                              ! set temperature & salinity content of runoffs
+            IF( ln_rnf_temp )   THEN                                       ! use runoffs temperature data
+               tsc_rnf(:,:,jp_tem) = ( sf_t_rnf(1)%fnow(:,:) ) * rnf(:,:) * z1_rau0
+               WHERE( sf_t_rnf(1)%fnow(:,:) == -999 )                      ! if missing data value use SST as runoffs temperature  
+                   tsc_rnf(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * z1_rau0
+               ENDWHERE
+            ELSE                                                           ! use SST as runoffs temperature
+               tsc_rnf(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * z1_rau0
             ENDIF  
-            CALL iom_put( "runoffs", rnf )         ! runoffs
+            !                                                              ! use runoffs salinity data 
+            IF( ln_rnf_sal ) tsc_rnf(:,:,jp_sal) = ( sf_s_rnf(1)%fnow(:,:) ) * rnf(:,:) * z1_rau0
+            !                                                              ! else use S=0 for runoffs (done one for all in the init)
+            !
+            IF( ln_rnf_temp .OR. ln_rnf_sal ) THEN                         ! runoffs as outflow: use ocean SST and SSS
+               WHERE( rnf(:,:) < 0.e0 )                                    ! example baltic model when flow is out of domain 
+                  tsc_rnf(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * z1_rau0
+                  tsc_rnf(:,:,jp_sal) = sss_m(:,:) * rnf(:,:) * z1_rau0
+               ENDWHERE
+            ENDIF
+
+            CALL iom_put( "runoffs", rnf )         ! output runoffs arrays
          ENDIF
          !
@@ -128,4 +150,52 @@
       !
    END SUBROUTINE sbc_rnf
+
+   SUBROUTINE sbc_rnf_div( phdivn )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_rnf  ***
+      !!       
+      !! ** Purpose :   update the horizontal divergence with the runoff inflow
+      !!
+      !! ** Method  :   
+      !!                CAUTION : rnf is positive (inflow) decreasing the 
+      !!                          divergence and expressed in m/s
+      !!
+      !! ** Action  :   phdivn   decreased by the runoff inflow
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   phdivn   ! horizontal divergence
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   z1_rau0   ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      z1_rau0 = 1.e0 / rau0
+      IF( ln_rnf_depth ) THEN      !==   runoff distributed over several levels   ==!
+         IF( lk_vvl ) THEN             ! variable volume case 
+            DO jj = 1, jpj                   ! update the depth over which runoffs are distributed
+               DO ji = 1, jpi
+                  h_rnf(ji,jj) = 0.e0 
+                  DO jk = 1, nk_rnf(ji,jj)                           ! recalculates h_rnf to be the depth in metres
+                     h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk)   ! to the bottom of the relevant grid box 
+                  END DO 
+                  !                          ! apply the runoff input flow
+                  DO jk = 1, nk_rnf(ji,jj)
+                     phdivn(ji,jj,jk) = phdivn(ji,jj,jk) - rnf(ji,jj) * z1_rau0 / h_rnf(ji,jj)
+                  END DO
+               END DO
+            END DO
+         ELSE                          ! constant volume case : just apply the runoff input flow
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  DO jk = 1, nk_rnf(ji,jj)
+                     phdivn(ji,jj,jk) = phdivn(ji,jj,jk) - rnf(ji,jj) * z1_rau0 / h_rnf(ji,jj)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+      ELSE                       !==   runoff put only at the surface   ==!
+         phdivn(:,:,1) = phdivn(:,:,1) - rnf(:,:) * z1_rau0 / fse3t(:,:,1)
+      ENDIF
+      !
+   END SUBROUTINE sbc_rnf_div
 
 
@@ -143,6 +213,7 @@
       INTEGER  ::   ierror   ! temporary integer
       !! 
-      NAMELIST/namsbc_rnf/ cn_dir, ln_rnf_emp, sn_rnf, sn_cnf, sn_sal_rnf, sn_tmp_rnf, sn_dep_rnf,   &  
-         &                 ln_rnf_mouth, ln_rnf_att, rn_hrnf, rn_avt_rnf, rn_rfact  
+      NAMELIST/namsbc_rnf/ cn_dir, ln_rnf_emp, ln_rnf_depth, ln_rnf_temp, ln_rnf_sal,   &
+         &                 sn_rnf, sn_cnf    , sn_s_rnf    , sn_t_rnf   , sn_dep_rnf,   &  
+         &                 ln_rnf_mouth      , rn_hrnf     , rn_avt_rnf , rn_rfact  
       !!----------------------------------------------------------------------
 
@@ -156,6 +227,6 @@
       sn_cnf = FLD_N( 'runoffs',     0     , 'sorunoff' ,  .FALSE.   , .true. ,   'yearly'  , ''       , ''         )
 
-      sn_sal_rnf = FLD_N( 'runoffs',  24.  , 'rosaline' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  )  
-      sn_tmp_rnf = FLD_N( 'runoffs',  24.  , 'rotemper' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  )  
+      sn_s_rnf = FLD_N( 'runoffs',  24.  , 'rosaline' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  )  
+      sn_t_rnf = FLD_N( 'runoffs',  24.  , 'rotemper' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  )  
       sn_dep_rnf = FLD_N( 'runoffs',   0.  , 'rodepth'  ,  .FALSE.   , .true. ,   'yearly'  , ''    , ''  )  
       !
@@ -180,61 +251,65 @@
       !                                   ! ==================
       !
-      IF( ln_rnf_emp ) THEN                     ! runoffs directly provided in the precipitations
+      IF( ln_rnf_emp ) THEN                     !==  runoffs directly provided in the precipitations  ==!
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) '          runoffs directly provided in the precipitations'
-         IF ( ln_rnf_att ) THEN
-           CALL ctl_warn( 'runoffs already included in precipitations & so runoff attributes will not be used' ) 
-           ln_rnf_att = .FALSE.
-         ENDIF
-         !
-      ELSE                                      ! runoffs read in a file : set sf_rnf structure 
-         !
-         ! Allocate sf_rnf structure and (if required) sf_sal_rnf and sf_tmp_rnf structures
-         ALLOCATE( sf_rnf(1), STAT=ierror )
+         IF( ln_rnf_depth .OR. ln_rnf_temp .OR. ln_rnf_sal ) THEN
+           CALL ctl_warn( 'runoffs already included in precipitations, so runoff (T,S, depth) attributes will not be used' ) 
+           ln_rnf_depth = .FALSE.   ;   ln_rnf_temp = .FALSE.   ;   ln_rnf_sal = .FALSE.
+         ENDIF
+         !
+      ELSE                                      !==  runoffs read in a file : set sf_rnf structure  ==!
+         !
+         ALLOCATE( sf_rnf(1), STAT=ierror )         ! Create sf_rnf structure (runoff inflow)
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          runoffs inflow read in a file'
          IF( ierror > 0 ) THEN
             CALL ctl_stop( 'sbc_rnf: unable to allocate sf_rnf structure' )   ;   RETURN
          ENDIF
-         ALLOCATE( sf_rnf(1)%fnow(jpi,jpj) )
-         ALLOCATE( sf_rnf(1)%fdta(jpi,jpj,2) )
-
-         IF( ln_rnf_att ) THEN
-            ALLOCATE( sf_sal_rnf(1), STAT=ierror )
+         ALLOCATE( sf_rnf(1)%fnow(jpi,jpj)   )   ;   ALLOCATE( sf_rnf(1)%fdta(jpi,jpj,2) )
+         !                                          ! fill sf_rnf with the namelist (sn_rnf) and control print
+         CALL fld_fill( sf_rnf, (/ sn_rnf /), cn_dir, 'sbc_rnf_init', 'read runoffs data', 'namsbc_rnf' )
+         !
+         IF( ln_rnf_temp ) THEN                     ! Create (if required) sf_t_rnf structure
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '          runoffs temperatures read in a file'
+            ALLOCATE( sf_t_rnf(1), STAT=ierror  )
             IF( ierror > 0 ) THEN
-               CALL ctl_stop( 'sbc_sal_rnf: unable to allocate sf_sal_rnf structure' )   ;   RETURN
+               CALL ctl_stop( 'sbc_rnf_init: unable to allocate sf_t_rnf structure' )   ;   RETURN
             ENDIF
-            ALLOCATE( sf_sal_rnf(1)%fnow(jpi,jpj) )
-            ALLOCATE( sf_sal_rnf(1)%fdta(jpi,jpj,2) )
-
-            ALLOCATE( sf_tmp_rnf(1), STAT=ierror )
+            ALLOCATE( sf_t_rnf(1)%fnow(jpi,jpj)   )   ;   ALLOCATE( sf_t_rnf(1)%fdta(jpi,jpj,2) )
+            CALL fld_fill (sf_t_rnf, (/ sn_t_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff temperature data', 'namsbc_rnf' )  
+         ENDIF
+         !
+         IF( ln_rnf_sal  ) THEN                     ! Create (if required) sf_s_rnf and sf_t_rnf structures
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '          runoffs salinities read in a file'
+            ALLOCATE( sf_s_rnf(1), STAT=ierror  )
             IF( ierror > 0 ) THEN
-                CALL ctl_stop( 'sbc_tmp_rnf: unable to allocate sf_tmp_rnf structure' )   ;   RETURN
+               CALL ctl_stop( 'sbc_rnf_init: unable to allocate sf_s_rnf structure' )   ;   RETURN
             ENDIF
-            ALLOCATE( sf_tmp_rnf(1)%fnow(jpi,jpj) )
-            ALLOCATE( sf_tmp_rnf(1)%fdta(jpi,jpj,2) )
-         ENDIF
-         ! fill sf_rnf with sn_rnf and control print
-         CALL fld_fill( sf_rnf, (/ sn_rnf /), cn_dir, 'sbc_rnf_init', 'read runoffs data', 'namsbc_rnf' )
+            ALLOCATE( sf_s_rnf(1)%fnow(jpi,jpj)   )   ;   ALLOCATE( sf_s_rnf(1)%fdta(jpi,jpj,2) )
+            CALL fld_fill (sf_s_rnf, (/ sn_s_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff salinity data', 'namsbc_rnf' )  
+         ENDIF
+
  
-         IF ( ln_rnf_att ) THEN  
-            CALL fld_fill (sf_sal_rnf, (/ sn_sal_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff salinity data', 'namsbc_rnf' )  
-            CALL fld_fill (sf_tmp_rnf, (/ sn_tmp_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff temperature data', 'namsbc_rnf' )  
-  
+         IF ( ln_rnf_depth ) THEN                     ! depth of runoffs set from a file 
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '          runoffs depth read in a file'
             rn_dep_file = TRIM( cn_dir )//TRIM( sn_dep_rnf%clname )  
             CALL iom_open ( rn_dep_file, inum )                           ! open file  
-            CALL iom_get  ( inum, jpdom_data, sn_dep_rnf%clvar, rnf_dep )    ! read the river mouth array  
+            CALL iom_get  ( inum, jpdom_data, sn_dep_rnf%clvar, h_rnf )    ! read the river mouth array  
             CALL iom_close( inum )                                      ! close file  
   
-            rnf_mod_dep(:,:)=0  
+            nk_rnf(:,:)=0                              ! set the number of level over which river runoffs are applied
             DO jj=1,jpj  
               DO ji=1,jpi  
-                IF ( rnf_dep(ji,jj) > 0.e0 ) THEN  
+                IF ( h_rnf(ji,jj) > 0.e0 ) THEN  
                   jk=2  
-                  DO WHILE ( jk/=(mbathy(ji,jj)-1) .AND. fsdept(ji,jj,jk) < rnf_dep(ji,jj) );  jk=jk+1;   ENDDO  
-                  rnf_mod_dep(ji,jj)=jk  
-                ELSE IF ( rnf_dep(ji,jj) .eq. -1 ) THEN  
-                  rnf_mod_dep(ji,jj)=1  
-                ELSE IF ( rnf_dep(ji,jj) .eq. -999 ) THEN  
-                  rnf_mod_dep(ji,jj)=mbathy(ji,jj)-1
-                ELSE IF ( rnf_dep(ji,jj) /= 0 ) THEN  
+                  DO WHILE ( jk/=(mbathy(ji,jj)-1) .AND. fsdept(ji,jj,jk) < h_rnf(ji,jj) );  jk=jk+1;   ENDDO  
+                  nk_rnf(ji,jj)=jk  
+                ELSE IF ( h_rnf(ji,jj) == -1   ) THEN   ;  nk_rnf(ji,jj)=1  
+                ELSE IF ( h_rnf(ji,jj) == -999 ) THEN   ;  nk_rnf(ji,jj)=mbathy(ji,jj)-1
+                ELSE IF ( h_rnf(ji,jj) /= 0 ) THEN  
                   CALL ctl_stop( 'runoff depth not positive, and not -999 or -1, rnf value in file fort.999'  )  
                   WRITE(999,*) 'ji, jj, rnf(ji,jj) :', ji, jj, rnf(ji,jj)  
@@ -242,19 +317,20 @@
               ENDDO  
             ENDDO  
-         ELSE  
-            rnf_mod_dep(:,:)=1  
+            DO jj=1,jpj                               ! set the associated depth 
+              DO ji=1,jpi 
+                h_rnf(ji,jj)=0.e0
+                DO jk=1,nk_rnf(ji,jj)                        
+                   h_rnf(ji,jj)=h_rnf(ji,jj)+fse3t(ji,jj,jk)  
+                ENDDO
+              ENDDO
+            ENDDO
+         ELSE                                       ! runoffs applied at the surface 
+            nk_rnf(:,:)=1  
+            h_rnf(:,:)=fse3t(:,:,1)
          ENDIF  
       ! 
       ENDIF
-      
-      ! recalculate rnf_dep to be the depth in metres to the bottom of the relevant grid box
-      DO jj=1,jpj 
-        DO ji=1,jpi 
-          rnf_dep(ji,jj)=0
-          DO jk=1,rnf_mod_dep(ji,jj)                        
-            rnf_dep(ji,jj)=rnf_dep(ji,jj)+fse3t(ji,jj,jk)  
-          ENDDO
-        ENDDO
-      ENDDO
+
+      tsc_rnf(:,:,:) = 0.e0                 ! runoffs temperature & salinty contents initilisation
       !                                   ! ========================
       !                                   !   River mouth vicinity
@@ -266,8 +342,8 @@
          !                                      !    - mixed upstream-centered (ln_traadv_cen2=T)
          !
-         !                                          ! Number of level over which Kz increase
-         IF ( ln_rnf_att )  &  
-              &  CALL ctl_warn( 'increased mixing turned on but effects may already be spread through depth by ln_rnf_att' ) 
-         nkrnf = 0
+         IF ( ln_rnf_depth )   CALL ctl_warn( 'sbc_rnf_init: increased mixing turned on but effects may already',   &
+            &                                              'be spread through depth by ln_rnf_depth'               ) 
+         !
+         nkrnf = 0                                  ! Number of level over which Kz increase
          IF( rn_hrnf > 0.e0 ) THEN
             nkrnf = 2
Index: /branches/devukmo2010/NEMO/OPA_SRC/TRA/trasbc.F90
===================================================================
--- /branches/devukmo2010/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 2178)
+++ /branches/devukmo2010/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 2179)
@@ -21,4 +21,5 @@
    USE in_out_manager  ! I/O manager
    USE prtctl          ! Print control
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE sbcrnf          ! River runoff  
    USE sbcmod          ! ln_rnf  
@@ -106,7 +107,7 @@
       !!
       INTEGER  ::   ji, jj, jk           ! dummy loop indices  
-      REAL(wp) ::   zta, zsa             ! temporary scalars, adjustment to temperature and salinity  
-      REAL(wp) ::   zata, zasa           ! temporary scalars, calculations of automatic change to temp & sal due to vvl (done elsewhere)  
-      REAL(wp) ::   zsrau, zse3t, zdep   ! temporary scalars, 1/density, 1/height of box, 1/height of effected water column  
+      REAL(wp) ::   zta, zsa             ! local scalars, adjustment to temperature and salinity  
+      REAL(wp) ::   zata, zasa           ! local scalars, calculations of automatic change to temp & sal due to vvl (done elsewhere)  
+      REAL(wp) ::   zsrau, zse3t, zdep   ! local scalars, 1/density, 1/height of box, 1/height of effected water column  
       REAL(wp) ::   zdheat, zdsalt       ! total change of temperature and salinity  
       !!----------------------------------------------------------------------
@@ -151,31 +152,21 @@
       END DO
 
-      IF ( ln_rnf ) THEN  
+      !                             !==  Runoffs  ==!
+      ! Effect on (t,s) due to river runoff (dilution effect automatically applied via vertical tracer advection) 
+      IF( ln_rnf ) THEN  
+         DO jj = 2, jpj 
+            DO ji = fs_2, fs_jpim1
+               zdep = 1. / h_rnf(ji,jj)  
+               IF ( rnf(ji,jj) .ne. 0.0 ) THEN
+                  DO jk = 1, nk_rnf(ji,jj)
+                                        ta(ji,jj,jk) = ta(ji,jj,jk) + tsc_rnf(ji,jj,jp_tem) * zdep
+                     IF( ln_rnf_sal )   sa(ji,jj,jk) = sa(ji,jj,jk) + tsc_rnf(ji,jj,jp_sal) * zdep
+                  ENDDO
+               ENDIF
+            ENDDO  
+         ENDDO  
+      ENDIF  
 
-      ! Effect on (t,s) due to river runoff (dilution effect automatically applied via vertical tracer advection) 
-        DO jj=1,jpj  
-           DO ji=1,jpi  
-              zdep = 1. / rnf_dep(ji,jj)  
-              zse3t= 1. / fse3t(ji,jj,1)  
-
-              IF ( rnf(ji,jj) .gt. 0.0 ) THEN
-                 ! ammend t and s due to direct tracer flux
-                 IF ( rnf_tmp(ji,jj) == -999 )   rnf_tmp(ji,jj)=tn(ji,jj,1)        ! if not specified set runoff temp to be sst
-                 DO jk=1, rnf_mod_dep(ji,jj)
-                    ta(ji,jj,jk) = ta(ji,jj,jk) + rnf_tmp(ji,jj) * rnf(ji,jj) * zsrau * zdep
-                    sa(ji,jj,jk) = sa(ji,jj,jk) + rnf_sal(ji,jj) * rnf(ji,jj) * zsrau * zdep
-                 ENDDO
-              ELSEIF (rnf(ji,jj) .lt. 0.) THEN   !! for use in baltic when flow is out of domain, want no change in temp and sal
-                 ! negate concentration/dilution effect from traadv, as the tracer leaves domain
-                 DO jk=1, rnf_mod_dep(ji,jj)
-                    ta(ji,jj,jk) = ta(ji,jj,jk) + tn(ji,jj,jk) * rnf(ji,jj) * zsrau * zdep
-                    sa(ji,jj,jk) = sa(ji,jj,jk) + sn(ji,jj,jk) * rnf(ji,jj) * zsrau * zdep
-                 ENDDO
-              ENDIF
-
-           ENDDO  
-        ENDDO  
-
-      ENDIF  
+      CALL lbc_lnk( ta, 'T', 1. )    ;    CALL lbc_lnk( sa, 'T', 1. )
 
       IF( l_trdtra ) THEN      ! save the sbc trends for diagnostic
