Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfparmlt.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfpar_mlt.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfparmlt.F90	(revision 11403)
@@ -1,5 +1,5 @@
 MODULE isfparmlt
    !!======================================================================
-   !!                       ***  MODULE  sbcisf  ***
+   !!                       ***  MODULE  isfparmlt  ***
    !! Surface module :  update surface ocean boundary condition under ice
    !!                   shelf
@@ -18,4 +18,5 @@
    USE iom            ! I/O library
    USE fldread
+   USE lib_fortran
 
    IMPLICIT NONE
@@ -43,7 +44,7 @@
       !!              melting and freezing 
       !!
-      !! ** Method  :  2 parameterizations are available according to XXXXX
+      !! ** Method  :  2 parameterizations are available according
+      !!                        1 : Specified melt flux
       !!                        2 : Beckmann & Goose parameterization
-      !!                        3 : Specified runoff in deptht (Mathiot & al. 2017)
       !!----------------------------------------------------------------------
       !!-------------------------- OUT -------------------------------------
@@ -60,5 +61,5 @@
          CALL isfpar_mlt_bg03(kt, pqhc, pqoce, pqfwf)
       CASE ( 'oasis' )
-         !CALL isfpar_mlt_oasis
+         CALL isfpar_mlt_oasis( kt, pqhc, pqoce, pqfwf)
       CASE DEFAULT
          CALL ctl_stop('STOP', 'unknown isf melt formulation : cn_isfpar (should not see this)')
@@ -73,10 +74,9 @@
    SUBROUTINE isfpar_mlt_spe(kt, pqhc, pqfwf, pqoce)
       !!---------------------------------------------------------------------
-      !!                  ***  ROUTINE sbc_isf_bg03  ***
+      !!                  ***  ROUTINE isfpar_mlt_spe  ***
       !!
       !! ** Purpose : prescribed ice shelf melting in case ice shelf cavities are closed.
       !!              data read into a forcing files.
       !!
-      !! ** Reference : Mathiot et al. (2017)
       !!----------------------------------------------------------------------
       !!-------------------------- OUT -------------------------------------
@@ -90,8 +90,46 @@
       !!--------------------------------------------------------------------
       !
-      ! specified runoff in depth (Mathiot et al., 2017)
+      ! 0. ------------Read specified runoff
       CALL fld_read ( kt, nn_fsbc, sf_isfpar_fwf   )
       !
       ! compute ptfrz
+      ! 1. ------------Mean freezing point
+      DO jk = 1,jpk
+         CALL eos_fzp(tsn(:,:,jk,jp_sal), ztfrz3d(:,:,jk), gdept_n(:,:,jk))
+      END DO
+      CALL isf_tbl(ztfrz3d, ztfrz, 'T', misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
+      !
+      pqfwf(:,:) = - sf_isfpar_fwf(1)%fnow(:,:,1)      ! fresh water flux from the isf (fwfisf <0 mean melting) 
+      pqoce(:,:) =   pqfwf(:,:) * rLfusisf             ! ocean/ice shelf flux assume to be equal to latent heat flux
+      pqhc (:,:) =   pqfwf(:,:) * ztfrz(:,:) * rcp     ! heat content flux 
+      !
+   END SUBROUTINE isfpar_mlt_spe
+
+   SUBROUTINE isfpar_mlt_bg03(kt, pqhc, pqoce, pqfwf)
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isfpar_mlt_bg03  ***
+      !!
+      !! ** Purpose : compute an estimate of ice shelf melting and 
+      !!              latent, ocean-ice and heat content heat fluxes
+      !!              in case cavities are closed based on the far fields T and S properties. 
+      !!
+      !! ** Method  : The ice shelf melt is computed as proportional to the differences between the 
+      !!              mean temperature and mean freezing point in front of the ice shelf averaged 
+      !!              over the ice shelf min ice shelf draft and max ice shelf draft and the freezing point
+      !!
+      !! ** Reference : Beckmann and Goosse (2003), "A parameterization of ice shelf-ocean
+      !!                interaction for climate models", Ocean Modelling 5(2003) 157-170.
+      !!----------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pqhc, pqfwf,pqoce  ! fresh water and ice-ocean heat fluxes
+      !!-------------------------- IN  -------------------------------------
+      INTEGER,  INTENT(in) :: kt
+      !!--------------------------------------------------------------------
+      INTEGER :: jk
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: ztfrz3d        ! freezing point
+      REAL(wp), DIMENSION(jpi,jpj)     :: ztfrz          ! freezing point
+      REAL(wp), DIMENSION(jpi,jpj)     :: ztavg          ! temperature avg
+      !!----------------------------------------------------------------------
+      !
       ! 0. ------------Mean freezing point
       DO jk = 1,jpk
@@ -100,35 +138,49 @@
       CALL isf_tbl(ztfrz3d, ztfrz, 'T', misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
       !
-      pqfwf(:,:) = - sf_isfpar_fwf(1)%fnow(:,:,1)      ! fresh water flux from the isf (fwfisf <0 mean melting) 
-      pqoce(:,:) =   pqfwf(:,:) * rLfusisf             ! ocean/ice shelf flux assume to be equal to latent heat flux
+      ! 1. ------------Mean temperature
+      CALL isf_tbl(tsn(:,:,jk,jp_tem), ztavg, 'T', misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
+      !
+      ! 2. ------------Net heat flux and fresh water flux due to the ice shelf
+      pqoce(:,:) =   rau0 * rcp * rn_gammat0 * risfLeff(:,:) * e1t(:,:) * ( ztavg(:,:) - ztfrz(:,:) ) * r1_e1e2t(:,:)
+      pqfwf(:,:) = - pqoce(:,:) * r1_Lfusisf           ! derived from the latent heat flux
       pqhc (:,:) =   pqfwf(:,:) * ztfrz(:,:) * rcp     ! heat content flux 
       !
-   END SUBROUTINE isfpar_mlt_spe
-
-   SUBROUTINE isfpar_mlt_bg03(kt, pqhc, pqoce, pqfwf)
-      !!---------------------------------------------------------------------
-      !!                  ***  ROUTINE sbc_isf_bg03  ***
-      !!
-      !! ** Purpose : compute an estimate of ice shelf melting in case cavities are closed
-      !!              based on the far fields T and S properties. 
-      !!
-      !! ** Method  :   See reference
-      !!
-      !! ** Reference : Beckmann and Goosse (2003), "A parameterization of ice shelf-ocean
-      !!         interaction for climate models", Ocean Modelling 5(2003) 157-170.
-      !!         (hereafter BG)
-      !!----------------------------------------------------------------------
-      !!-------------------------- OUT -------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pqhc, pqfwf,pqoce  ! fresh water and ice-ocean heat fluxes
-      !!-------------------------- IN  -------------------------------------
-      INTEGER,  INTENT(in) :: kt
-      !!--------------------------------------------------------------------
-      INTEGER :: jk
-      REAL(wp), DIMENSION(jpi,jpj,jpk) :: ztfrz3d        ! freezing point
-      REAL(wp), DIMENSION(jpi,jpj)     :: ztfrz          ! freezing point
-      REAL(wp), DIMENSION(jpi,jpj)     :: ztavg          ! temperature avg
-      !!----------------------------------------------------------------------
-      !
-      ! 0. ------------Mean freezing point
+      ! 3. ------------BG03 output
+      ! output ttbl
+      CALL iom_put('ttbl_par', ztavg(:,:) )
+      !
+      ! output thermal driving
+      CALL iom_put('isfthermald_par',( ztfrz(:,:) - ztavg(:,:) ))
+      !
+      !
+   END SUBROUTINE isfpar_mlt_bg03
+
+   SUBROUTINE isfpar_mlt_oasis(kt, pqhc , pqoce, pqfwf )
+      !!----------------------------------------------------------------------
+      !!
+      !! ** Purpose    : scale the fwf read from input file by the total amount received by the sbccpl interface
+      !!
+      !! ** Purpose    : - read ice shelf melt from forcing file => pattern
+      !!                 - total amount of fwf is given by sbccpl (fwfisf_cpl)
+      !!                 - scale fwf and compute heat fluxes
+      !!
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) :: pqhc, pqoce, pqfwf  ! heat content, latent heat and fwf fluxes
+      !!-------------------------- IN  -------------------------------------
+      INTEGER                     , INTENT(in   ) :: kt                  ! current time step
+      !!--------------------------------------------------------------------
+      INTEGER                           :: jk                            ! loop index
+      REAL(wp)                          :: zfwf_fld, zfwf_cpl            ! total fwf in the forcing fields (pattern) and from the cpl interface (amount)
+      REAL(wp), DIMENSION(jpi,jpj)      :: ztfrz                         ! tbl freezing temperature
+      REAL(wp), DIMENSION(jpi,jpj)      :: zfwf                          ! 2d fwf map after scaling
+      REAL(wp), DIMENSION(jpi,jpj,jpk)  :: ztfrz3d
+      !!--------------------------------------------------------------------
+      !
+      ! 0. ------------Read specified runoff
+      CALL fld_read ( kt, nn_fsbc, sf_isfpar_fwf   )
+      !
+      ! compute ptfrz
+      ! 1. ------------Mean freezing point
       DO jk = 1,jpk
          CALL eos_fzp(tsn(:,:,jk,jp_sal), ztfrz3d(:,:,jk), gdept_n(:,:,jk))
@@ -136,23 +188,22 @@
       CALL isf_tbl(ztfrz3d, ztfrz, 'T', misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
       !
-      ! 1. ------------Mean temperature
-      CALL isf_tbl(tsn(:,:,jk,jp_tem), ztavg, 'T', misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
-      !
-      ! 2. ------------Net heat flux and fresh water flux due to the ice shelf
-      pqoce(:,:) = - rau0 * rcp * rn_gammat0 * risfLeff(:,:) * e1t(:,:) * ( ztfrz(:,:) - ztavg(:,:) ) * r1_e1e2t(:,:)
-      pqfwf(:,:) =   pqoce(:,:) / rLfusisf
-      pqhc (:,:) =   pqfwf(:,:) * ztfrz(:,:) * rcp     ! heat content flux 
-      !
-      ! output ttbl
-      CALL iom_put('ttbl_par', ztavg(:,:) )
-      !
-      ! output thermal driving
-      CALL iom_put('isfthermald_par',( ztfrz(:,:) - ztavg(:,:) ))
-      !
-      !
-   END SUBROUTINE isfpar_mlt_bg03
-
-   SUBROUTINE isfpar_mlt_oasis
-   !TODO
+      ! ice shelf 2d map
+      zfwf(:,:) = - sf_isfpar_fwf(1)%fnow(:,:,1)
+      !
+      ! compute glob sum from input file
+      zfwf_fld = glob_sum('isfcav_mlt', zfwf(:,:))
+      !
+      ! compute glob sum from atm->oce ice shelf fwf
+      zfwf_cpl = glob_sum('isfcav_mlt', fwfisf_cpl(:,:))
+      !
+      ! scale fwf
+      zfwf(:,:) = zfwf(:,:) * zfwf_cpl / zfwf_fld
+      ! 
+      ! define fwf and qoce
+      ! ocean heat flux is assume to be equal to the latent heat
+      pqfwf(:,:) =   zfwf(:,:)                         ! fwf                ( >0 out )
+      pqoce(:,:) = - pqfwf(:,:) * rLfusisf             ! ocean heat flux    ( >0 out ) (assumed to be the latent heat flux)
+      pqhc (:,:) =   pqfwf(:,:) * ztfrz(:,:) * rcp     ! heat content flux  ( >0 out )
+      !
    END SUBROUTINE isfpar_mlt_oasis
 
