Index: NEMO/branches/2019/dev_ASINTER-01-05_merged/src/OCE/SBC/sbcblk.F90
===================================================================
--- NEMO/branches/2019/dev_ASINTER-01-05_merged/src/OCE/SBC/sbcblk.F90	(revision 12081)
+++ NEMO/branches/2019/dev_ASINTER-01-05_merged/src/OCE/SBC/sbcblk.F90	(revision 12098)
@@ -24,6 +24,6 @@
    !!   sbc_blk_init  : initialisation of the chosen bulk formulation as ocean surface boundary condition
    !!   sbc_blk       : bulk formulation as ocean surface boundary condition
-   !!   blk_oce_1     : computes pieces of momentum, heat and freshwater fluxes over ocean for ABL model  (ln_abl=TRUE)  
-   !!   blk_oce_2     : finalizes momentum, heat and freshwater fluxes computation over ocean after the ABL step  (ln_abl=TRUE) 
+   !!   blk_oce_1     : computes pieces of momentum, heat and freshwater fluxes over ocean for ABL model  (ln_abl=TRUE)
+   !!   blk_oce_2     : finalizes momentum, heat and freshwater fluxes computation over ocean after the ABL step  (ln_abl=TRUE)
    !!             sea-ice case only :
    !!   blk_ice_1   : provide the air-ice stress
@@ -209,9 +209,9 @@
          !! Some namelist sanity tests:
          IF( ln_NCAR )      &
-            & CALL ctl_stop( 'sbc_blk_init: Cool-skin/warm-layer param. not compatible with NCAR algorithm' )         
+            & CALL ctl_stop( 'sbc_blk_init: Cool-skin/warm-layer param. not compatible with NCAR algorithm' )
          IF( nn_fsbc /= 1 ) &
-            & CALL ctl_stop( 'sbc_blk_init: Please set "nn_fsbc" to 1 when using cool-skin/warm-layer param.')                  
+            & CALL ctl_stop( 'sbc_blk_init: Please set "nn_fsbc" to 1 when using cool-skin/warm-layer param.')
       END IF
-      
+
       IF( ln_skin_wl ) THEN
          !! Check if the frequency of downwelling solar flux input makes sense and if ln_dm2dc=T if it is daily!
@@ -221,5 +221,5 @@
             & CALL ctl_stop( 'sbc_blk_init: Please set ln_dm2dc=T for warm-layer param. (ln_skin_wl) to work properly' )
       END IF
-      
+
       ioptio = 0
       IF( ln_humi_sph ) THEN
@@ -254,5 +254,5 @@
       slf_i(jp_slp ) = sn_slp
       IF( ln_abl ) THEN
-        slf_i(jp_hpgi) = sn_hpgi   ;   slf_i(jp_hpgj) = sn_hpgj  
+         slf_i(jp_hpgi) = sn_hpgi   ;   slf_i(jp_hpgj) = sn_hpgj
       END IF
       !
@@ -263,7 +263,7 @@
       DO jfpr= 1, jpfld
          !
-         IF( TRIM(sf(jfpr)%clrootname) == 'NOT USED' ) THEN    !--  not used field  --!   (only now allocated and set to zero) 
+         IF( TRIM(sf(jfpr)%clrootname) == 'NOT USED' ) THEN    !--  not used field  --!   (only now allocated and set to zero)
             ALLOCATE( sf(jfpr)%fnow(jpi,jpj,1) )
-            sf(jfpr)%fnow(:,:,1) = 0._wp                 
+            sf(jfpr)%fnow(:,:,1) = 0._wp
          ELSE                                                  !-- used field  --!
             IF(   ln_abl    .AND.                                                      &
@@ -304,5 +304,5 @@
       ENDIF
       !
-      IF( ln_abl ) THEN       ! ABL: read 3D fields for wind, temperature, humidity and pressure gradient    
+      IF( ln_abl ) THEN       ! ABL: read 3D fields for wind, temperature, humidity and pressure gradient
          rn_zqt = ght_abl(2)          ! set the bulk altitude to ABL first level
          rn_zu  = ght_abl(2)
@@ -364,5 +364,5 @@
       !!              (momentum, heat, freshwater and runoff)
       !!
-      !! ** Method  : 
+      !! ** Method  :
       !!              (1) READ each fluxes in NetCDF files:
       !!      the wind velocity (i-component) at z=rn_zu  (m/s) at T-point
@@ -374,5 +374,5 @@
       !!      the total precipitation (rain+snow)         (Kg/m2/s)
       !!      the snow (solid precipitation)              (kg/m2/s)
-      !!      ABL dynamical forcing (i/j-components of either hpg or geostrophic winds) 
+      !!      ABL dynamical forcing (i/j-components of either hpg or geostrophic winds)
       !!              (2) CALL blk_oce_1 and blk_oce_2
       !!
@@ -402,4 +402,7 @@
       IF( kt == nit000 ) THEN
          WRITE(numout,*) ''
+#if defined key_agrif
+         WRITE(numout,*) ' === AGRIF => Sanity/consistence test on air humidity SKIPPED! :( ==='
+#else
          ztmp = SUM(tmask(:,:,1)) ! number of ocean points on local proc domain
          IF( ztmp > 8._wp ) THEN ! test only on proc domains with at least 8 ocean points!
@@ -422,7 +425,7 @@
          END IF
          WRITE(numout,*) ' === Sanity/consistence test on air humidity sucessfuly passed! ==='
+#endif
          WRITE(numout,*) ''
       END IF !IF( kt == nit000 )
-
       !                                            ! compute the surface ocean fluxes using bulk formulea
       IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN
@@ -432,5 +435,5 @@
             &                sf(jp_qsr )%fnow(:,:,1), sf(jp_qlw )%fnow(:,:,1),   &   !   <<= in (wl/cs)
             &                zssq, zcd_du, zsen, zevp )                              !   =>> out
-         
+
          CALL blk_oce_2(     sf(jp_tair)%fnow(:,:,1), sf(jp_qsr )%fnow(:,:,1),   &   !   <<= in
             &                sf(jp_qlw )%fnow(:,:,1), sf(jp_prec)%fnow(:,:,1),   &   !   <<= in
@@ -469,7 +472,7 @@
 
    SUBROUTINE blk_oce_1( kt, pwndi, pwndj , ptair, phumi, &  ! inp
-              &              pslp , pst   , pu   , pv,    &  ! inp
-              &              pqsr , pqlw  ,               &  ! inp
-              &              pssq , pcd_du, psen , pevp   )  ! out
+      &              pslp , pst   , pu   , pv,    &  ! inp
+      &              pqsr , pqlw  ,               &  ! inp
+      &              pssq , pcd_du, psen , pevp   )  ! out
       !!---------------------------------------------------------------------
       !!                     ***  ROUTINE blk_oce_1  ***
@@ -496,6 +499,6 @@
       REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pu     ! surface current at U-point (i-component) [m/s]
       REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pv     ! surface current at V-point (j-component) [m/s]
-      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pqsr   ! 
-      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pqlw   ! 
+      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pqsr   !
+      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pqlw   !
       REAL(wp), INTENT(  out), DIMENSION(:,:) ::   pssq   ! specific humidity at pst                 [kg/kg]
       REAL(wp), INTENT(  out), DIMENSION(:,:) ::   pcd_du ! Cd x |dU| at T-points                    [m/s]
@@ -604,26 +607,26 @@
       !! Time to call the user-selected bulk parameterization for
       !!  ==  transfer coefficients  ==!   Cd, Ch, Ce at T-point, and more...
-      SELECT CASE( nblk )        
-
-         CASE( np_NCAR      )
-            CALL turb_ncar    ( rn_zqt, rn_zu, zst, ztpot, pssq, zqair, wndm,                              &
-               &                zcd_oce, zch_oce, zce_oce, t_zu, q_zu, zU_zu, cdn_oce, chn_oce, cen_oce )
-
-         CASE( np_COARE_3p0 )
-            CALL turb_coare3p0 ( kt, rn_zqt, rn_zu, zst, ztpot, pssq, zqair, wndm, ln_skin_cs, ln_skin_wl, &
-               &                zcd_oce, zch_oce, zce_oce, t_zu, q_zu, zU_zu, cdn_oce, chn_oce, cen_oce,   &
-               &                Qsw=qsr(:,:), rad_lw=pqlw(:,:), slp=pslp(:,:) )
-
-         CASE( np_COARE_3p6 )
-            CALL turb_coare3p6 ( kt, rn_zqt, rn_zu, zst, ztpot, pssq, zqair, wndm, ln_skin_cs, ln_skin_wl, &
-               &                zcd_oce, zch_oce, zce_oce, t_zu, q_zu, zU_zu, cdn_oce, chn_oce, cen_oce,   &
-               &                Qsw=qsr(:,:), rad_lw=pqlw(:,:), slp=pslp(:,:) )
-
-         CASE( np_ECMWF     )
-            CALL turb_ecmwf   ( kt, rn_zqt, rn_zu, zst, ztpot, pssq, zqair, wndm, ln_skin_cs, ln_skin_wl,  &
-               &                zcd_oce, zch_oce, zce_oce, t_zu, q_zu, zU_zu, cdn_oce, chn_oce, cen_oce,   &
-               &                Qsw=qsr(:,:), rad_lw=pqlw(:,:), slp=pslp(:,:) )
-
-         CASE DEFAULT
+      SELECT CASE( nblk )
+
+      CASE( np_NCAR      )
+         CALL turb_ncar    ( rn_zqt, rn_zu, zst, ztpot, pssq, zqair, wndm,                              &
+            &                zcd_oce, zch_oce, zce_oce, t_zu, q_zu, zU_zu, cdn_oce, chn_oce, cen_oce )
+
+      CASE( np_COARE_3p0 )
+         CALL turb_coare3p0 ( kt, rn_zqt, rn_zu, zst, ztpot, pssq, zqair, wndm, ln_skin_cs, ln_skin_wl, &
+            &                zcd_oce, zch_oce, zce_oce, t_zu, q_zu, zU_zu, cdn_oce, chn_oce, cen_oce,   &
+            &                Qsw=qsr(:,:), rad_lw=pqlw(:,:), slp=pslp(:,:) )
+
+      CASE( np_COARE_3p6 )
+         CALL turb_coare3p6 ( kt, rn_zqt, rn_zu, zst, ztpot, pssq, zqair, wndm, ln_skin_cs, ln_skin_wl, &
+            &                zcd_oce, zch_oce, zce_oce, t_zu, q_zu, zU_zu, cdn_oce, chn_oce, cen_oce,   &
+            &                Qsw=qsr(:,:), rad_lw=pqlw(:,:), slp=pslp(:,:) )
+
+      CASE( np_ECMWF     )
+         CALL turb_ecmwf   ( kt, rn_zqt, rn_zu, zst, ztpot, pssq, zqair, wndm, ln_skin_cs, ln_skin_wl,  &
+            &                zcd_oce, zch_oce, zce_oce, t_zu, q_zu, zU_zu, cdn_oce, chn_oce, cen_oce,   &
+            &                Qsw=qsr(:,:), rad_lw=pqlw(:,:), slp=pslp(:,:) )
+
+      CASE DEFAULT
          CALL ctl_stop( 'STOP', 'sbc_oce: non-existing bulk formula selected' )
 
@@ -645,5 +648,5 @@
       !!      CALL iom_put( "Cd_oce", zcd_oce)  ! output value of pure ocean-atm. transfer coef.
       !!      CALL iom_put( "Ch_oce", zch_oce)  ! output value of pure ocean-atm. transfer coef.
-      
+
       IF( ABS(rn_zu - rn_zqt) < 0.1_wp ) THEN
          !! If zu == zt, then ensuring once for all that:
@@ -651,18 +654,18 @@
          q_zu(:,:) = zqair(:,:)
       ENDIF
-      
+
 
       !  Turbulent fluxes over ocean  => BULK_FORMULA @ sbcblk_phy.F90
       ! -------------------------------------------------------------
-      
+
       IF( ln_abl ) THEN         !==  ABL formulation  ==!   multiplication by rho_air and turbulent fluxes computation done in ablstp
-!! FL do we need this multiplication by tmask ... ???
+         !! FL do we need this multiplication by tmask ... ???
          DO jj = 1, jpj
             DO ji = 1, jpi
                zztmp = zU_zu(ji,jj) !* tmask(ji,jj,1)
-               wndm(ji,jj)   = zztmp                   ! Store zU_zu in wndm to compute ustar2 in ablmod 
+               wndm(ji,jj)   = zztmp                   ! Store zU_zu in wndm to compute ustar2 in ablmod
                pcd_du(ji,jj) = zztmp * zcd_oce(ji,jj)
                psen(ji,jj)   = zztmp * zch_oce(ji,jj)
-               pevp(ji,jj)   = zztmp * zce_oce(ji,jj)       
+               pevp(ji,jj)   = zztmp * zce_oce(ji,jj)
             END DO
          END DO
@@ -678,13 +681,13 @@
          taum(:,:) = taum(:,:) * tmask(:,:,1)
          pevp(:,:) = pevp(:,:) * tmask(:,:,1)
-         
+
          ! Tau i and j component on T-grid points, using array "zcd_oce" as a temporary array...
          zcd_oce = 0._wp
          WHERE ( wndm > 0._wp ) zcd_oce = taum / wndm
          zwnd_i = zcd_oce * zwnd_i
-         zwnd_j = zcd_oce * zwnd_j      
+         zwnd_j = zcd_oce * zwnd_j
 
          CALL iom_put( "taum_oce", taum )   ! output wind stress module
-   
+
          ! ... utau, vtau at U- and V_points, resp.
          !     Note the use of 0.5*(2-umask) in order to unmask the stress along coastlines
@@ -718,10 +721,10 @@
 
    SUBROUTINE blk_oce_2( ptair, pqsr, pqlw, pprec,   &   ! <<= in
-              &          psnow, pst , psen, pevp     )   ! <<= in
+      &          psnow, pst , psen, pevp     )   ! <<= in
       !!---------------------------------------------------------------------
       !!                     ***  ROUTINE blk_oce_2  ***
       !!
-      !! ** Purpose :   finalize the momentum, heat and freshwater fluxes computation 
-      !!                at the ocean surface at each time step knowing Cd, Ch, Ce and 
+      !! ** Purpose :   finalize the momentum, heat and freshwater fluxes computation
+      !!                at the ocean surface at each time step knowing Cd, Ch, Ce and
       !!                atmospheric variables (from ABL or external data)
       !!
@@ -829,5 +832,5 @@
    END SUBROUTINE blk_oce_2
 
-   
+
 #if defined key_si3
    !!----------------------------------------------------------------------
@@ -856,5 +859,5 @@
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pwndj   ! atmospheric wind at T-point [m/s]
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   ptair   ! atmospheric wind at T-point [m/s]
-      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   phumi   ! atmospheric wind at T-point [m/s]      
+      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   phumi   ! atmospheric wind at T-point [m/s]
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   puice   ! sea-ice velocity on I or C grid [m/s]
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pvice   ! "
@@ -865,5 +868,5 @@
       REAL(wp) , INTENT(  out), DIMENSION(:,:  ), OPTIONAL ::   pevpi   ! if ln_abl
       REAL(wp) , INTENT(  out), DIMENSION(:,:  ), OPTIONAL ::   pssqi   ! if ln_abl
-      REAL(wp) , INTENT(  out), DIMENSION(:,:  ), OPTIONAL ::   pcd_dui ! if ln_abl 
+      REAL(wp) , INTENT(  out), DIMENSION(:,:  ), OPTIONAL ::   pcd_dui ! if ln_abl
       !
       INTEGER  ::   ji, jj    ! dummy loop indices
@@ -894,5 +897,5 @@
          Ce_ice(:,:) = Cd_ice(:,:)
       ELSEIF( ln_Cd_L15 ) THEN   ! calculate new drag from Lupkes(2015) equations
-         CALL Cdn10_Lupkes2015( ptsui, pslp, Cd_ice, Ch_ice ) 
+         CALL Cdn10_Lupkes2015( ptsui, pslp, Cd_ice, Ch_ice )
          Ce_ice(:,:) = Ch_ice(:,:)       ! sensible and latent heat transfer coef. are considered identical
       ENDIF
@@ -904,6 +907,6 @@
       !IF (ln_abl) rhoa  (:,:)  = rho_air( ptair(:,:), phumi(:,:), pslp(:,:) ) !!GS: rhoa must be (re)computed here with ABL to avoid division by zero after (TBI)
       zcd_dui(:,:) = wndm_ice(:,:) * Cd_ice(:,:)
-      
-      IF( ln_blk ) THEN 
+
+      IF( ln_blk ) THEN
          ! ------------------------------------------------------------ !
          !    Wind stress relative to the moving ice ( U10m - U_ice )   !
@@ -926,5 +929,5 @@
       ELSE
          zztmp1 = 11637800.0_wp
-	 zztmp2 =    -5897.8_wp
+         zztmp2 =    -5897.8_wp
          DO jj = 1, jpj
             DO ji = 1, jpi
@@ -1082,5 +1085,5 @@
       ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- !
       qprec_ice(:,:) = rhos * ( ( MIN( ptair(:,:), rt0 ) - rt0 ) * rcpi * tmask(:,:,1) - rLfus )
-      
+
       ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) ---
       DO jl = 1, jpl
@@ -1256,5 +1259,5 @@
       ! ice-atm drag
       pcd(:,:) = rCd_ice +  &                                                         ! pure ice drag
-          &      zCe     * ( 1._wp - at_i_b(:,:) )**zcoef * at_i_b(:,:)**(zmu-1._wp)  ! change due to sea-ice morphology
+         &      zCe     * ( 1._wp - at_i_b(:,:) )**zcoef * at_i_b(:,:)**(zmu-1._wp)  ! change due to sea-ice morphology
 
    END SUBROUTINE Cdn10_Lupkes2012
@@ -1365,9 +1368,9 @@
             ! Momentum Transfert Coefficients (Eq. 38)
             pcd(ji,jj) = zCdn_skin_ice *   zfmi +  &
-                &        zCdn_form_ice * ( zfmi * at_i_b(ji,jj) + zfmw * ( 1._wp - at_i_b(ji,jj) ) ) / MAX( 1.e-06, at_i_b(ji,jj) )
+               &        zCdn_form_ice * ( zfmi * at_i_b(ji,jj) + zfmw * ( 1._wp - at_i_b(ji,jj) ) ) / MAX( 1.e-06, at_i_b(ji,jj) )
 
             ! Heat Transfert Coefficients (Eq. 49)
             pch(ji,jj) = zChn_skin_ice *   zfhi +  &
-                &        zChn_form_ice * ( zfhi * at_i_b(ji,jj) + zfhw * ( 1._wp - at_i_b(ji,jj) ) ) / MAX( 1.e-06, at_i_b(ji,jj) )
+               &        zChn_form_ice * ( zfhi * at_i_b(ji,jj) + zfhw * ( 1._wp - at_i_b(ji,jj) ) ) / MAX( 1.e-06, at_i_b(ji,jj) )
             !
          END DO
