Index: NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/README.rst
===================================================================
--- NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/README.rst	(revision 10744)
+++ NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/README.rst	(revision 12065)
@@ -2,4 +2,8 @@
 On line biogeochemistry coarsening
 **********************************
+
+.. todo::
+
+
 
 .. contents::
@@ -63,6 +67,6 @@
 	                           ! 1, MAX of KZ
 	                           ! 2, MIN of KZ
-	                           ! 3, 10^(MEAN(LOG(KZ)) 
-	                           ! 4, MEDIANE of KZ 
+	                           ! 3, 10^(MEAN(LOG(KZ))
+	                           ! 4, MEDIANE of KZ
 	   ln_crs_wn   = .false.   ! wn coarsened (T) or computed using horizontal divergence ( F )
 	                           !                           !
@@ -73,5 +77,5 @@
   the north-fold lateral boundary condition (ORCA025, ORCA12, ORCA36, ...).
 - ``nn_msh_crs = 1`` will activate the generation of the coarsened grid meshmask.
-- ``nn_crs_kz`` is the operator to coarsen the vertical mixing coefficient. 
+- ``nn_crs_kz`` is the operator to coarsen the vertical mixing coefficient.
 - ``ln_crs_wn``
 
@@ -80,5 +84,5 @@
   - when ``key_vvl`` is not activated,
 
-    - coarsened vertical velocities are computed using horizontal divergence (``ln_crs_wn = .false.``) 
+    - coarsened vertical velocities are computed using horizontal divergence (``ln_crs_wn = .false.``)
     - or coarsened vertical velocities are computed with an average operator (``ln_crs_wn = .true.``)
 - ``ln_crs_top = .true.``: should be activated to run BCG model in coarsened space;
@@ -97,5 +101,5 @@
 
 In the [attachment:iodef.xml iodef.xml]  file, a "nemo" context is defined and
-some variable defined in [attachment:file_def.xml file_def.xml] are writted on the ocean-dynamic grid.  
+some variable defined in [attachment:file_def.xml file_def.xml] are writted on the ocean-dynamic grid.
 To write variables on the coarsened grid, and in particular the passive tracers,
 a "nemo_crs" context should be defined in [attachment:iodef.xml iodef.xml] and
@@ -111,5 +115,5 @@
   interpolated `on-the-fly <http://forge.ipsl.jussieu.fr/nemo/wiki/Users/SetupNewConfiguration/Weight-creator>`_.
   Example of namelist for PISCES :
-  
+
 	.. code-block:: fortran
 
@@ -134,5 +138,5 @@
 	   	rn_trfac(14)  =   1.0e-06  !  -      -      -     -
 		   rn_trfac(23)  =   7.6e-06  !  -      -      -     -
-		
+
 	   	cn_dir        =  './'      !  root directory for the location of the data files
 
Index: NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/crsdom.F90
===================================================================
--- NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/crsdom.F90	(revision 10744)
+++ NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/crsdom.F90	(revision 12065)
@@ -296,6 +296,6 @@
       ENDDO
 
-      CALL crs_lbc_lnk( p_e1_crs, cd_type, 1.0, pval=1.0 )
-      CALL crs_lbc_lnk( p_e2_crs, cd_type, 1.0, pval=1.0 )
+      CALL crs_lbc_lnk( p_e1_crs, cd_type, 1.0, pfillval=1.0 )
+      CALL crs_lbc_lnk( p_e2_crs, cd_type, 1.0, pfillval=1.0 )
 
    END SUBROUTINE crs_dom_hgr
@@ -579,5 +579,5 @@
                   ENDDO  
                CASE DEFAULT
-                    STOP
+                  CALL ctl_stop( 'STOP', 'error from crs_dom_ope_3d, you should not be there...' )
                END SELECT
 
@@ -1748,6 +1748,6 @@
        ENDDO
                   
-       CALL crs_lbc_lnk( p_e3_crs    , cd_type, 1.0, pval=1.0 )  
-       CALL crs_lbc_lnk( p_e3_max_crs, cd_type, 1.0, pval=1.0 )  
+       CALL crs_lbc_lnk( p_e3_crs    , cd_type, 1.0, pfillval=1.0 )  
+       CALL crs_lbc_lnk( p_e3_max_crs, cd_type, 1.0, pfillval=1.0 )  
        !              
        !
@@ -1857,6 +1857,6 @@
       ENDDO   
 
-      CALL crs_lbc_lnk( p_surf_crs    , cd_type, 1.0, pval=1.0 )
-      CALL crs_lbc_lnk( p_surf_crs_msk, cd_type, 1.0, pval=1.0 )
+      CALL crs_lbc_lnk( p_surf_crs    , cd_type, 1.0, pfillval=1.0 )
+      CALL crs_lbc_lnk( p_surf_crs_msk, cd_type, 1.0, pfillval=1.0 )
 
    END SUBROUTINE crs_dom_sfc
@@ -1947,5 +1947,5 @@
                 
               CASE DEFAULT
-                 STOP
+                 CALL ctl_stop( 'STOP', 'error from crs_dom_def, you should not be there (1) ...' )
            END SELECT
            IF( nlcjt_crs(jn) > jpj_crs )     jpj_crs = jpj_crs + 1
@@ -1996,5 +1996,5 @@
 
               CASE DEFAULT
-                 STOP
+                 CALL ctl_stop( 'STOP', 'error from crs_dom_def, you should not be there (2) ...' )
            END SELECT
 
Index: NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/crsini.F90
===================================================================
--- NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/crsini.F90	(revision 10744)
+++ NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/crsini.F90	(revision 12065)
@@ -82,8 +82,8 @@
       REWIND( numnam_ref )              ! Namelist namrun in reference namelist : Parameters of the run
       READ  ( numnam_ref, namcrs, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcrs in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcrs in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namrun in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namcrs, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcrs in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcrs in configuration namelist' )
       IF(lwm) WRITE ( numond, namcrs )
 
Index: NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/crslbclnk.F90
===================================================================
--- NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/crslbclnk.F90	(revision 10744)
+++ NEMO/branches/2019/dev_r10742_ENHANCE-12_SimonM-Tides/src/OCE/CRS/crslbclnk.F90	(revision 12065)
@@ -27,5 +27,5 @@
 CONTAINS
 
-   SUBROUTINE crs_lbc_lnk_3d( pt3d1, cd_type1, psgn, cd_mpp, pval )
+   SUBROUTINE crs_lbc_lnk_3d( pt3d1, cd_type1, psgn, kfillmode, pfillval  )
       !!---------------------------------------------------------------------
       !!                  ***  SUBROUTINE crs_lbc_lnk  ***
@@ -40,22 +40,15 @@
       REAL(wp)                                , INTENT(in   ) ::   psgn     ! control of the sign
       REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(inout) ::   pt3d1    ! 3D array on which the lbc is applied
-      REAL(wp)                      , OPTIONAL, INTENT(in   ) ::   pval     ! valeur sur les halo
-      CHARACTER(len=3)              , OPTIONAL, INTENT(in   ) ::   cd_mpp   ! MPP only (here do nothing)
+      INTEGER                     , OPTIONAL  , INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = cst)
+      REAL(wp)                    , OPTIONAL  , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
       !
       LOGICAL  ::   ll_grid_crs
-      REAL(wp) ::   zval   ! valeur sur les halo
       !!----------------------------------------------------------------------
       !
       ll_grid_crs = ( jpi == jpi_crs )
       !
-      IF( PRESENT(pval) ) THEN   ;   zval = pval
-      ELSE                       ;   zval = 0._wp
-      ENDIF
-      !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
       !
-      IF( PRESENT( cd_mpp ) ) THEN   ;   CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn, cd_mpp, pval=zval  )
-      ELSE                           ;   CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn        , pval=zval  )
-      ENDIF
+      CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn, kfillmode, pfillval )
       !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_glo   ! Return to parent grid domain
@@ -64,5 +57,5 @@
    
    
-   SUBROUTINE crs_lbc_lnk_2d(pt2d, cd_type, psgn, cd_mpp, pval)
+   SUBROUTINE crs_lbc_lnk_2d(pt2d, cd_type, psgn, kfillmode, pfillval )
       !!---------------------------------------------------------------------
       !!                  ***  SUBROUTINE crs_lbc_lnk  ***
@@ -77,22 +70,15 @@
       REAL(wp)                            , INTENT(in   ) ::   psgn     ! control of the sign
       REAL(wp), DIMENSION(jpi_crs,jpj_crs), INTENT(inout) ::   pt2d     ! 2D array on which the lbc is applied
-      REAL(wp)                  , OPTIONAL, INTENT(in   ) ::   pval     ! valeur sur les halo
-      CHARACTER(len=3)          , OPTIONAL, INTENT(in   ) ::   cd_mpp   ! MPP only (here do nothing)
+      INTEGER                 , OPTIONAL  , INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
+      REAL(wp)                , OPTIONAL  , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
       !      
       LOGICAL  ::   ll_grid_crs
-      REAL(wp) ::   zval     ! valeur sur les halo
       !!----------------------------------------------------------------------
       !
       ll_grid_crs = ( jpi == jpi_crs )
       !
-      IF( PRESENT(pval) ) THEN   ;   zval = pval
-      ELSE                       ;   zval = 0._wp
-      ENDIF
-      !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
       !
-      IF( PRESENT( cd_mpp ) ) THEN   ;   CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn, cd_mpp, pval=zval  )
-      ELSE                           ;   CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn        , pval=zval  )
-      ENDIF
+      CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn, kfillmode, pfillval )
       !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_glo   ! Return to parent grid domain
