New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
sbcisf.F90 in branches/UKMO/dev_r6501_GO6_package_trunk/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/dev_r6501_GO6_package_trunk/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90 @ 6507

Last change on this file since 6507 was 6507, checked in by timgraham, 8 years ago

First attempt at merging in science changes from GO6 package branch at v3.6 stable (Note-namelists not yet dealt with)

File size: 45.8 KB
Line 
1MODULE sbcisf
2   !!======================================================================
3   !!                       ***  MODULE  sbcisf  ***
4   !! Surface module :  update surface ocean boundary condition under ice
5   !!                   shelf
6   !!======================================================================
7   !! History :  3.2   !  2011-02  (C.Harris  ) Original code isf cav
8   !!            X.X   !  2006-02  (C. Wang   ) Original code bg03
9   !!            3.4   !  2013-03  (P. Mathiot) Merging + parametrization
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   sbc_isf        : update sbc under ice shelf
14   !!----------------------------------------------------------------------
15   USE oce             ! ocean dynamics and tracers
16   USE dom_oce         ! ocean space and time domain
17   USE phycst          ! physical constants
18   USE eosbn2          ! equation of state
19   USE sbc_oce         ! surface boundary condition: ocean fields
20   USE zdfbfr          !
21   !
22   USE in_out_manager  ! I/O manager
23   USE iom             ! I/O manager library
24   USE fldread         ! read input field at current time step
25   USE lbclnk          !
26   USE wrk_nemo        ! Memory allocation
27   USE timing          ! Timing
28   USE lib_fortran     ! glob_sum
29
30   IMPLICIT NONE
31   PRIVATE
32
33   PUBLIC   sbc_isf, sbc_isf_div, sbc_isf_alloc  ! routine called in sbcmod and divhor
34
35   ! public in order to be able to output then
36
37   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   risf_tsc_b, risf_tsc  !: before and now T & S isf contents [K.m/s & PSU.m/s] 
38   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qisf                  !: net heat flux from ice shelf      [W/m2]
39   REAL(wp), PUBLIC ::   rn_hisf_tbl                 !: thickness of top boundary layer [m]
40   INTEGER , PUBLIC ::   nn_isf                      !: flag to choose between explicit/param/specified 
41   INTEGER , PUBLIC ::   nn_isfblk                   !: flag to choose the bulk formulation to compute the ice shelf melting
42   INTEGER , PUBLIC ::   nn_gammablk                 !: flag to choose how the exchange coefficient is computed
43   REAL(wp), PUBLIC ::   rn_gammat0                  !: temperature exchange coeficient []
44   REAL(wp), PUBLIC ::   rn_gammas0                  !: salinity    exchange coeficient []
45
46   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  rzisf_tbl              !:depth of calving front (shallowest point) nn_isf ==2/3
47   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  rhisf_tbl, rhisf_tbl_0 !:thickness of tbl  [m]
48   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  r1_hisf_tbl            !:1/thickness of tbl
49   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  ralpha                 !:proportion of bottom cell influenced by tbl
50   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  risfLeff               !:effective length (Leff) BG03 nn_isf==2
51   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  ttbl, stbl, utbl, vtbl !:top boundary layer variable at T point
52   INTEGER,    PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)      ::  misfkt, misfkb         !:Level of ice shelf base
53
54   REAL(wp), PUBLIC, SAVE ::   rcpi     = 2000.0_wp     ! specific heat of ice shelf             [J/kg/K]
55   REAL(wp), PUBLIC, SAVE ::   rkappa   = 1.54e-6_wp    ! heat diffusivity through the ice-shelf [m2/s]
56   REAL(wp), PUBLIC, SAVE ::   rhoisf   = 920.0_wp      ! volumic mass of ice shelf              [kg/m3]
57   REAL(wp), PUBLIC, SAVE ::   tsurf    = -20.0_wp      ! air temperature on top of ice shelf    [C]
58   REAL(wp), PUBLIC, SAVE ::   rlfusisf = 0.334e6_wp    ! latent heat of fusion of ice shelf     [J/kg]
59
60!: Variable used in fldread to read the forcing file (nn_isf == 4 .OR. nn_isf == 3)
61   CHARACTER(len=100), PUBLIC           :: cn_dirisf  = './' !: Root directory for location of ssr files
62   TYPE(FLD_N)       , PUBLIC           :: sn_fwfisf         !: information about the isf melting file to be read
63   TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_fwfisf
64   TYPE(FLD_N)       , PUBLIC           :: sn_rnfisf         !: information about the isf melting param.   file to be read
65   TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_rnfisf           
66   TYPE(FLD_N)       , PUBLIC           :: sn_depmax_isf     !: information about the grounding line depth file to be read
67   TYPE(FLD_N)       , PUBLIC           :: sn_depmin_isf     !: information about the calving   line depth file to be read
68   TYPE(FLD_N)       , PUBLIC           :: sn_Leff_isf       !: information about the effective length     file to be read
69   
70   !!----------------------------------------------------------------------
71   !! NEMO/OPA 3.7 , LOCEAN-IPSL (2015)
72   !! $Id$
73   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
74   !!----------------------------------------------------------------------
75CONTAINS
76 
77  SUBROUTINE sbc_isf(kt)
78      !!---------------------------------------------------------------------
79      !!                  ***  ROUTINE sbc_isf  ***
80      !!
81      !! ** Purpose : Compute Salt and Heat fluxes related to ice_shelf
82      !!              melting and freezing
83      !!
84      !! ** Method  :  4 parameterizations are available according to nn_isf
85      !!               nn_isf = 1 : Realistic ice_shelf formulation
86      !!                        2 : Beckmann & Goose parameterization
87      !!                        3 : Specified runoff in deptht (Mathiot & al. )
88      !!                        4 : specified fwf and heat flux forcing beneath the ice shelf
89      !!----------------------------------------------------------------------
90      INTEGER, INTENT( in ) :: kt                   ! ocean time step
91      !
92      INTEGER               :: ji, jj               ! loop index
93      REAL(wp), DIMENSION (:,:), POINTER :: zt_frz, zdep ! freezing temperature (zt_frz) at depth (zdep)
94      !!---------------------------------------------------------------------
95      !
96      !                                         ! ====================== !
97      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
98         !                                      ! ====================== !
99         CALL sbc_isf_init
100      !                                         ! ---------------------------------------- !
101      ELSE                                      !          Swap of forcing fields          !
102         !                                      ! ---------------------------------------- !
103         fwfisf_b  (:,:  ) = fwfisf  (:,:  )    ! Swap the ocean forcing fields except at nit000
104         risf_tsc_b(:,:,:) = risf_tsc(:,:,:)    ! where before fields are set at the end of the routine
105         !
106      END IF
107
108      IF( MOD( kt-1, nn_fsbc) == 0 ) THEN
109         ! allocation
110         CALL wrk_alloc( jpi,jpj, zt_frz, zdep  )
111
112         ! compute salt and heat flux
113         SELECT CASE ( nn_isf )
114         CASE ( 1 )    ! realistic ice shelf formulation
115            ! compute T/S/U/V for the top boundary layer
116            CALL sbc_isf_tbl(tsn(:,:,:,jp_tem),ttbl(:,:),'T')
117            CALL sbc_isf_tbl(tsn(:,:,:,jp_sal),stbl(:,:),'T')
118            CALL sbc_isf_tbl(un(:,:,:)        ,utbl(:,:),'U')
119            CALL sbc_isf_tbl(vn(:,:,:)        ,vtbl(:,:),'V')
120            ! iom print
121            CALL iom_put('ttbl',ttbl(:,:))
122            CALL iom_put('stbl',stbl(:,:))
123            CALL iom_put('utbl',utbl(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:))
124            CALL iom_put('vtbl',vtbl(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:))
125            ! compute fwf and heat flux
126            CALL sbc_isf_cav (kt)
127
128         CASE ( 2 )    ! Beckmann and Goosse parametrisation
129            stbl(:,:)   = soce
130            CALL sbc_isf_bg03(kt)
131
132         CASE ( 3 )    ! specified runoff in depth (Mathiot et al., XXXX in preparation)
133            CALL fld_read ( kt, nn_fsbc, sf_rnfisf   )
134            fwfisf(:,:) = - sf_rnfisf(1)%fnow(:,:,1)         ! fwf  flux from the isf (fwfisf <0 mean melting)
135
136            IF( lk_oasis) THEN
137            ! ln_coupled_iceshelf_fluxes uninitialised unless lk_oasis=true
138            IF( ln_coupled_iceshelf_fluxes ) THEN
139
140              ! Adjust total iceshelf melt rates so that sum of iceberg calving and iceshelf melting in the northern
141              ! and southern hemispheres equals rate of increase of mass of greenland and antarctic ice sheets
142              ! to preserve total freshwater conservation in coupled models without an active ice sheet model.
143
144               zgreenland_fwfisf_sum = SUM( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
145               IF( lk_mpp ) CALL mpp_sum( zgreenland_fwfisf_sum )
146               ! use ABS function because we need to preserve the sign of fwfisf
147               WHERE( greenland_icesheet_mask(:,:) == 1.0 )                                                                  &
148              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( greenland_icesheet_mass_rate_of_change * (1.0-rn_greenland_calving_fraction) &
149              &                           / ( zgreenland_fwfisf_sum + 1.0e-10_wp ) )
150
151               ! check
152               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting climatology (kg/s) : ',zgreenland_fwfisf_sum
153               zgreenland_fwfisf_sum = SUM( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
154               IF( lk_mpp ) CALL mpp_sum( zgreenland_fwfisf_sum )
155               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting adjusted value (kg/s) : ',zgreenland_fwfisf_sum
156
157               zantarctica_fwfisf_sum = SUM( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
158               IF( lk_mpp ) CALL mpp_sum( zantarctica_fwfisf_sum )
159               ! use ABS function because we need to preserve the sign of fwfisf
160               WHERE( antarctica_icesheet_mask(:,:) == 1.0 ) &
161              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( antarctica_icesheet_mass_rate_of_change * (1.0-rn_antarctica_calving_fraction) &
162              &                           / ( zantarctica_fwfisf_sum + 1.0e-10_wp ) )
163     
164               ! check
165               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting climatology (kg/s) : ',zantarctica_fwfisf_sum
166               zantarctica_fwfisf_sum = SUM( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
167               IF( lk_mpp ) CALL mpp_sum( zantarctica_fwfisf_sum )
168               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting adjusted value (kg/s) : ',zantarctica_fwfisf_sum
169
170            ENDIF
171            ENDIF
172
173            qisf(:,:)   = fwfisf(:,:) * rlfusisf             ! heat flux
174            stbl(:,:)   = soce
175
176         CASE ( 4 )    ! specified fwf and heat flux forcing beneath the ice shelf
177            CALL fld_read ( kt, nn_fsbc, sf_fwfisf   )
178            fwfisf(:,:) = - sf_fwfisf(1)%fnow(:,:,1)           ! fwf  flux from the isf (fwfisf <0 mean melting)
179
180            IF( lk_oasis) THEN
181            ! ln_coupled_iceshelf_fluxes uninitialised unless lk_oasis=true
182            IF( ln_coupled_iceshelf_fluxes ) THEN
183
184              ! Adjust total iceshelf melt rates so that sum of iceberg calving and iceshelf melting in the northern
185              ! and southern hemispheres equals rate of increase of mass of greenland and antarctic ice sheets
186              ! to preserve total freshwater conservation in coupled models without an active ice sheet model.
187
188               zgreenland_fwfisf_sum = SUM( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
189               IF( lk_mpp ) CALL mpp_sum( zgreenland_fwfisf_sum )
190               ! use ABS function because we need to preserve the sign of fwfisf
191               WHERE( greenland_icesheet_mask(:,:) == 1.0 )                                                                  &
192              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( greenland_icesheet_mass_rate_of_change * (1.0-rn_greenland_calving_fraction) &
193              &                           / ( zgreenland_fwfisf_sum + 1.0e-10_wp ) )
194
195               ! check
196               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting climatology (kg/s) : ',zgreenland_fwfisf_sum
197               zgreenland_fwfisf_sum = SUM( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
198               IF( lk_mpp ) CALL mpp_sum( zgreenland_fwfisf_sum )
199               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting adjusted value (kg/s) : ',zgreenland_fwfisf_sum
200
201               zantarctica_fwfisf_sum = SUM( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
202               IF( lk_mpp ) CALL mpp_sum( zantarctica_fwfisf_sum )
203               ! use ABS function because we need to preserve the sign of fwfisf
204               WHERE( antarctica_icesheet_mask(:,:) == 1.0 ) &
205              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( antarctica_icesheet_mass_rate_of_change * (1.0-rn_antarctica_calving_fraction) &
206              &                           / ( zantarctica_fwfisf_sum + 1.0e-10_wp ) )
207     
208               ! check
209               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting climatology (kg/s) : ',zantarctica_fwfisf_sum
210               zantarctica_fwfisf_sum = SUM( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
211               IF( lk_mpp ) CALL mpp_sum( zantarctica_fwfisf_sum )
212               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting adjusted value (kg/s) : ',zantarctica_fwfisf_sum
213
214            ENDIF
215            ENDIF
216
217            qisf(:,:)   = fwfisf(:,:) * rlfusisf               ! heat flux
218            stbl(:,:)   = soce
219
220         END SELECT
221
222         ! compute tsc due to isf
223         ! isf melting implemented as a volume flux and we assume that melt water is at 0 PSU.
224         ! WARNING water add at temp = 0C, need to add a correction term (fwfisf * tfreez / rau0).
225         ! compute freezing point beneath ice shelf (or top cell if nn_isf = 3)
226         DO jj = 1,jpj
227            DO ji = 1,jpi
228               zdep(ji,jj)=gdepw_n(ji,jj,misfkt(ji,jj))
229            END DO
230         END DO
231         CALL eos_fzp( stbl(:,:), zt_frz(:,:), zdep(:,:) )
232         
233         ! if apply only on the trend and not as a volume flux (rdivisf = 0), fwfisf have to be set to 0 now
234         fwfisf(:,:) = rdivisf * fwfisf(:,:)         
235 
236         risf_tsc(:,:,jp_tem) = qisf(:,:) * r1_rau0_rcp - fwfisf(:,:) * zt_frz(:,:) * r1_rau0 !
237         risf_tsc(:,:,jp_sal) = 0.0_wp
238
239         ! lbclnk
240         CALL lbc_lnk(risf_tsc(:,:,jp_tem),'T',1.)
241         CALL lbc_lnk(risf_tsc(:,:,jp_sal),'T',1.)
242         CALL lbc_lnk(fwfisf(:,:)         ,'T',1.)
243         CALL lbc_lnk(qisf(:,:)           ,'T',1.)
244
245         IF( kt == nit000 ) THEN                         !   set the forcing field at nit000 - 1    !
246            IF( ln_rstart .AND.    &                     ! Restart: read in restart file
247                 & iom_varid( numror, 'fwf_isf_b', ldstop = .FALSE. ) > 0 ) THEN
248               IF(lwp) WRITE(numout,*) '          nit000-1 isf tracer content forcing fields read in the restart file'
249               CALL iom_get( numror, jpdom_autoglo, 'fwf_isf_b', fwfisf_b(:,:) )   ! before salt content isf_tsc trend
250               CALL iom_get( numror, jpdom_autoglo, 'isf_sc_b', risf_tsc_b(:,:,jp_sal) )   ! before salt content isf_tsc trend
251               CALL iom_get( numror, jpdom_autoglo, 'isf_hc_b', risf_tsc_b(:,:,jp_tem) )   ! before salt content isf_tsc trend
252            ELSE
253               fwfisf_b(:,:)    = fwfisf(:,:)
254               risf_tsc_b(:,:,:)= risf_tsc(:,:,:)
255            END IF
256         END IF
257         !
258         ! output
259         CALL iom_put('qisf'  , qisf)
260         CALL iom_put('fwfisf', fwfisf)
261
262         ! deallocation
263         CALL wrk_dealloc( jpi,jpj, zt_frz, zdep  )
264      END IF
265     
266  END SUBROUTINE sbc_isf
267
268
269  INTEGER FUNCTION sbc_isf_alloc()
270      !!----------------------------------------------------------------------
271      !!               ***  FUNCTION sbc_isf_rnf_alloc  ***
272      !!----------------------------------------------------------------------
273      sbc_isf_alloc = 0       ! set to zero if no array to be allocated
274      IF( .NOT. ALLOCATED( qisf ) ) THEN
275         ALLOCATE(  risf_tsc(jpi,jpj,jpts), risf_tsc_b(jpi,jpj,jpts), qisf(jpi,jpj)   , &
276               &    rhisf_tbl(jpi,jpj)    , r1_hisf_tbl(jpi,jpj), rzisf_tbl(jpi,jpj)  , &
277               &    ttbl(jpi,jpj)         , stbl(jpi,jpj)       , utbl(jpi,jpj)       , &
278               &    vtbl(jpi, jpj)        , risfLeff(jpi,jpj)   , rhisf_tbl_0(jpi,jpj), &
279               &    ralpha(jpi,jpj)       , misfkt(jpi,jpj)     , misfkb(jpi,jpj)     , &
280               &    STAT= sbc_isf_alloc )
281         !
282         IF( lk_mpp             )   CALL mpp_sum ( sbc_isf_alloc )
283         IF( sbc_isf_alloc /= 0 )   CALL ctl_warn('sbc_isf_alloc: failed to allocate arrays.')
284         !
285      END IF
286  END FUNCTION
287
288  SUBROUTINE sbc_isf_init
289      !!---------------------------------------------------------------------
290      !!                  ***  ROUTINE sbc_isf_init  ***
291      !!
292      !! ** Purpose : Initialisation of variables for iceshelf fluxes formulation
293      !!
294      !! ** Method  :  4 parameterizations are available according to nn_isf
295      !!               nn_isf = 1 : Realistic ice_shelf formulation
296      !!                        2 : Beckmann & Goose parameterization
297      !!                        3 : Specified runoff in deptht (Mathiot & al. )
298      !!                        4 : specified fwf and heat flux forcing beneath the ice shelf
299      !!----------------------------------------------------------------------
300      INTEGER               :: ji, jj, jk           ! loop index
301      INTEGER               :: ik                   ! current level index
302      INTEGER               :: ikt, ikb             ! top and bottom level of the isf boundary layer
303      INTEGER               :: inum, ierror
304      INTEGER               :: ios                  ! Local integer output status for namelist read
305      REAL(wp)              :: zhk
306      CHARACTER(len=256)    :: cvarzisf, cvarhisf   ! name for isf file
307      CHARACTER(LEN=32 )    :: cvarLeff             ! variable name for efficient Length scale
308      !!----------------------------------------------------------------------
309      NAMELIST/namsbc_isf/ nn_isfblk, rn_hisf_tbl, rn_gammat0, rn_gammas0, nn_gammablk, nn_isf, &
310                         & sn_fwfisf, sn_rnfisf, sn_depmax_isf, sn_depmin_isf, sn_Leff_isf
311      !!----------------------------------------------------------------------
312
313      REWIND( numnam_ref )              ! Namelist namsbc_rnf in reference namelist : Runoffs
314      READ  ( numnam_ref, namsbc_isf, IOSTAT = ios, ERR = 901)
315901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_isf in reference namelist', lwp )
316
317      REWIND( numnam_cfg )              ! Namelist namsbc_rnf in configuration namelist : Runoffs
318      READ  ( numnam_cfg, namsbc_isf, IOSTAT = ios, ERR = 902 )
319902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_isf in configuration namelist', lwp )
320      IF(lwm) WRITE ( numond, namsbc_isf )
321
322      IF ( lwp ) WRITE(numout,*)
323      IF ( lwp ) WRITE(numout,*) 'sbc_isf: heat flux of the ice shelf'
324      IF ( lwp ) WRITE(numout,*) '~~~~~~~~~'
325      IF ( lwp ) WRITE(numout,*) 'sbcisf :' 
326      IF ( lwp ) WRITE(numout,*) '~~~~~~~~'
327      IF ( lwp ) WRITE(numout,*) '        nn_isf      = ', nn_isf
328      IF ( lwp ) WRITE(numout,*) '        nn_isfblk   = ', nn_isfblk
329      IF ( lwp ) WRITE(numout,*) '        rn_hisf_tbl = ', rn_hisf_tbl
330      IF ( lwp ) WRITE(numout,*) '        nn_gammablk = ', nn_gammablk 
331      IF ( lwp ) WRITE(numout,*) '        rn_gammat0  = ', rn_gammat0 
332      IF ( lwp ) WRITE(numout,*) '        rn_gammas0  = ', rn_gammas0 
333      IF ( lwp ) WRITE(numout,*) '        rn_tfri2    = ', rn_tfri2 
334      !
335      ! Allocate public variable
336      IF ( sbc_isf_alloc()  /= 0 )         CALL ctl_stop( 'STOP', 'sbc_isf : unable to allocate arrays' )
337      !
338      ! initialisation
339      qisf(:,:)        = 0._wp  ; fwfisf  (:,:) = 0._wp
340      risf_tsc(:,:,:)  = 0._wp  ; fwfisf_b(:,:) = 0._wp
341      !
342      ! define isf tbl tickness, top and bottom indice
343      SELECT CASE ( nn_isf )
344      CASE ( 1 ) 
345         rhisf_tbl(:,:) = rn_hisf_tbl
346         misfkt(:,:)    = mikt(:,:)         ! same indice for bg03 et cav => used in isfdiv
347
348      CASE ( 2 , 3 )
349         ALLOCATE( sf_rnfisf(1), STAT=ierror )
350         ALLOCATE( sf_rnfisf(1)%fnow(jpi,jpj,1), sf_rnfisf(1)%fdta(jpi,jpj,1,2) )
351         CALL fld_fill( sf_rnfisf, (/ sn_rnfisf /), cn_dirisf, 'sbc_isf_init', 'read fresh water flux isf data', 'namsbc_isf' )
352
353         !  read effective lenght (BG03)
354         IF (nn_isf == 2) THEN
355            CALL iom_open( sn_Leff_isf%clname, inum )
356            cvarLeff = TRIM(sn_Leff_isf%clvar)
357            CALL iom_get( inum, jpdom_data, cvarLeff, risfLeff , 1)
358            CALL iom_close(inum)
359            !
360            risfLeff = risfLeff*1000.0_wp           !: convertion in m
361         END IF
362
363         ! read depth of the top and bottom of the isf top boundary layer (in this case, isf front depth and grounding line depth)
364         CALL iom_open( sn_depmax_isf%clname, inum )
365         cvarhisf = TRIM(sn_depmax_isf%clvar)
366         CALL iom_get( inum, jpdom_data, cvarhisf, rhisf_tbl, 1) !: depth of deepest point of the ice shelf base
367         CALL iom_close(inum)
368         !
369         CALL iom_open( sn_depmin_isf%clname, inum )
370         cvarzisf = TRIM(sn_depmin_isf%clvar)
371         CALL iom_get( inum, jpdom_data, cvarzisf, rzisf_tbl, 1) !: depth of shallowest point of the ice shelves base
372         CALL iom_close(inum)
373         !
374         rhisf_tbl(:,:) = rhisf_tbl(:,:) - rzisf_tbl(:,:)        !: tickness isf boundary layer
375
376         !! compute first level of the top boundary layer
377         DO ji = 1, jpi
378            DO jj = 1, jpj
379                ik = 2
380                DO WHILE ( ik <= mbkt(ji,jj) .AND. gdepw_n(ji,jj,ik) < rzisf_tbl(ji,jj) ) ;  ik = ik + 1 ;  END DO
381                misfkt(ji,jj) = ik-1
382            END DO
383         END DO
384
385      CASE ( 4 ) 
386         ! as in nn_isf == 1
387         rhisf_tbl(:,:) = rn_hisf_tbl
388         misfkt(:,:)    = mikt(:,:)         ! same indice for bg03 et cav => used in isfdiv
389         
390         ! load variable used in fldread (use for temporal interpolation of isf fwf forcing)
391         ALLOCATE( sf_fwfisf(1), STAT=ierror )
392         ALLOCATE( sf_fwfisf(1)%fnow(jpi,jpj,1), sf_fwfisf(1)%fdta(jpi,jpj,1,2) )
393         CALL fld_fill( sf_fwfisf, (/ sn_fwfisf /), cn_dirisf, 'sbc_isf_init', 'read fresh water flux isf data', 'namsbc_isf' )
394
395      END SELECT
396         
397      rhisf_tbl_0(:,:) = rhisf_tbl(:,:)
398
399      ! compute bottom level of isf tbl and thickness of tbl below the ice shelf
400      DO jj = 1,jpj
401         DO ji = 1,jpi
402            ikt = misfkt(ji,jj)
403            ikb = misfkt(ji,jj)
404            ! thickness of boundary layer at least the top level thickness
405            rhisf_tbl(ji,jj) = MAX(rhisf_tbl_0(ji,jj), e3t_n(ji,jj,ikt))
406
407            ! determine the deepest level influenced by the boundary layer
408            DO jk = ikt+1, mbkt(ji,jj)
409               IF ( (SUM(e3t_n(ji,jj,ikt:jk-1)) < rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) ) ikb = jk
410            END DO
411            rhisf_tbl(ji,jj) = MIN(rhisf_tbl(ji,jj), SUM(e3t_n(ji,jj,ikt:ikb))) ! limit the tbl to water thickness.
412            misfkb(ji,jj) = ikb                                                   ! last wet level of the tbl
413            r1_hisf_tbl(ji,jj) = 1._wp / rhisf_tbl(ji,jj)
414
415            zhk           = SUM( e3t_n(ji, jj, ikt:ikb - 1)) * r1_hisf_tbl(ji,jj) ! proportion of tbl cover by cell from ikt to ikb - 1
416            ralpha(ji,jj) = rhisf_tbl(ji,jj) * (1._wp - zhk ) / e3t_n(ji,jj,ikb)  ! proportion of bottom cell influenced by boundary layer
417         END DO
418      END DO
419
420  END SUBROUTINE sbc_isf_init
421
422  SUBROUTINE sbc_isf_bg03(kt)
423      !!---------------------------------------------------------------------
424      !!                  ***  ROUTINE sbc_isf_bg03  ***
425      !!
426      !! ** Purpose : add net heat and fresh water flux from ice shelf melting
427      !!          into the adjacent ocean
428      !!
429      !! ** Method  :   See reference
430      !!
431      !! ** Reference : Beckmann and Goosse (2003), "A parameterization of ice shelf-ocean
432      !!         interaction for climate models", Ocean Modelling 5(2003) 157-170.
433      !!         (hereafter BG)
434      !! History :
435      !!         06-02  (C. Wang) Original code
436      !!----------------------------------------------------------------------
437      INTEGER, INTENT ( in ) :: kt
438      !
439      INTEGER  :: ji, jj, jk ! dummy loop index
440      INTEGER  :: ik         ! current level
441      REAL(wp) :: zt_sum     ! sum of the temperature between 200m and 600m
442      REAL(wp) :: zt_ave     ! averaged temperature between 200m and 600m
443      REAL(wp) :: zt_frz     ! freezing point temperature at depth z
444      REAL(wp) :: zpress     ! pressure to compute the freezing point in depth
445      !!----------------------------------------------------------------------
446
447      IF ( nn_timing == 1 ) CALL timing_start('sbc_isf_bg03')
448      !
449      DO ji = 1, jpi
450         DO jj = 1, jpj
451            ik = misfkt(ji,jj)
452            !! Initialize arrays to 0 (each step)
453            zt_sum = 0.e0_wp
454            IF ( ik > 1 ) THEN
455               ! 1. -----------the average temperature between 200m and 600m ---------------------
456               DO jk = misfkt(ji,jj),misfkb(ji,jj)
457                  ! freezing point temperature  at ice shelf base BG eq. 2 (JMM sign pb ??? +7.64e-4 !!!)
458                  ! after verif with UNESCO, wrong sign in BG eq. 2
459                  ! Calculate freezing temperature
460                  CALL eos_fzp(stbl(ji,jj), zt_frz, zpress) 
461                  zt_sum = zt_sum + (tsn(ji,jj,jk,jp_tem)-zt_frz) * e3t_n(ji,jj,jk) * tmask(ji,jj,jk)  ! sum temp
462               END DO
463               zt_ave = zt_sum/rhisf_tbl(ji,jj) ! calcul mean value
464               ! 2. ------------Net heat flux and fresh water flux due to the ice shelf
465               ! For those corresponding to zonal boundary   
466               qisf(ji,jj) = - rau0 * rcp * rn_gammat0 * risfLeff(ji,jj) * e1t(ji,jj) * zt_ave  &
467                           & * r1_e1e2t(ji,jj) * tmask(ji,jj,jk)
468             
469               fwfisf(ji,jj) = qisf(ji,jj) / rlfusisf          !fresh water flux kg/(m2s)                 
470               fwfisf(ji,jj) = fwfisf(ji,jj) * ( soce / stbl(ji,jj) )
471               !add to salinity trend
472            ELSE
473               qisf(ji,jj) = 0._wp ; fwfisf(ji,jj) = 0._wp
474            END IF
475         END DO
476      END DO
477      !
478      IF( nn_timing == 1 )  CALL timing_stop('sbc_isf_bg03')
479      !
480  END SUBROUTINE sbc_isf_bg03
481
482  SUBROUTINE sbc_isf_cav( kt )
483      !!---------------------------------------------------------------------
484      !!                     ***  ROUTINE sbc_isf_cav  ***
485      !!
486      !! ** Purpose :   handle surface boundary condition under ice shelf
487      !!
488      !! ** Method  : -
489      !!
490      !! ** Action  :   utau, vtau : remain unchanged
491      !!                taum, wndm : remain unchanged
492      !!                qns        : update heat flux below ice shelf
493      !!                emp, emps  : update freshwater flux below ice shelf
494      !!---------------------------------------------------------------------
495      INTEGER, INTENT(in)          ::   kt         ! ocean time step
496      !
497      INTEGER  ::   ji, jj     ! dummy loop indices
498      INTEGER  ::   nit
499      REAL(wp) ::   zlamb1, zlamb2, zlamb3
500      REAL(wp) ::   zeps1,zeps2,zeps3,zeps4,zeps6,zeps7
501      REAL(wp) ::   zaqe,zbqe,zcqe,zaqer,zdis,zsfrz,zcfac
502      REAL(wp) ::   zeps = 1.e-20_wp       
503      REAL(wp) ::   zerr
504      REAL(wp), DIMENSION(:,:), POINTER ::   zfrz
505      REAL(wp), DIMENSION(:,:), POINTER ::   zgammat, zgammas 
506      REAL(wp), DIMENSION(:,:), POINTER ::   zfwflx, zhtflx, zhtflx_b
507      LOGICAL  ::   lit
508      !!---------------------------------------------------------------------
509      ! coeficient for linearisation of potential tfreez
510      ! Crude approximation for pressure (but commonly used)
511      zlamb1 =-0.0573_wp
512      zlamb2 = 0.0832_wp
513      zlamb3 =-7.53e-08_wp * grav * rau0
514      IF( nn_timing == 1 )  CALL timing_start('sbc_isf_cav')
515      !
516      CALL wrk_alloc( jpi,jpj, zfrz  , zgammat, zgammas  )
517      CALL wrk_alloc( jpi,jpj, zfwflx, zhtflx , zhtflx_b )
518
519      ! initialisation
520      zgammat(:,:) = rn_gammat0 ; zgammas (:,:) = rn_gammas0
521      zhtflx (:,:) = 0.0_wp     ; zhtflx_b(:,:) = 0.0_wp   
522      zfwflx (:,:) = 0.0_wp
523
524      ! compute ice shelf melting
525      nit = 1 ; lit = .TRUE.
526      DO WHILE ( lit )    ! maybe just a constant number of iteration as in blk_core is fine
527         SELECT CASE ( nn_isfblk )
528         CASE ( 1 )   !  ISOMIP formulation (2 equations) for volume flux (Hunter et al., 2006)
529            ! Calculate freezing temperature
530            CALL eos_fzp( stbl(:,:), zfrz(:,:), risfdep(:,:) )
531
532            ! compute gammat every where (2d)
533            CALL sbc_isf_gammats(zgammat, zgammas, zhtflx, zfwflx)
534           
535            ! compute upward heat flux zhtflx and upward water flux zwflx
536            DO jj = 1, jpj
537               DO ji = 1, jpi
538                  zhtflx(ji,jj) =   zgammat(ji,jj)*rcp*rau0*(ttbl(ji,jj)-zfrz(ji,jj))
539                  zfwflx(ji,jj) = - zhtflx(ji,jj)/rlfusisf
540               END DO
541            END DO
542
543            ! Compute heat flux and upward fresh water flux
544            qisf  (:,:) = - zhtflx(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:)
545            fwfisf(:,:) =   zfwflx(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:)
546
547         CASE ( 2 )  ! ISOMIP+ formulation (3 equations) for volume flux (Asay-Davis et al., 2015)
548            ! compute gammat every where (2d)
549            CALL sbc_isf_gammats(zgammat, zgammas, zhtflx, zfwflx)
550
551            ! compute upward heat flux zhtflx and upward water flux zwflx
552            ! Resolution of a 2d equation from equation 21, 22 and 23 to find Sb (Asay-Davis et al., 2015)
553            DO jj = 1, jpj
554               DO ji = 1, jpi
555                  ! compute coeficient to solve the 2nd order equation
556                  zeps1 = rcp*rau0*zgammat(ji,jj)
557                  zeps2 = rlfusisf*rau0*zgammas(ji,jj)
558                  zeps3 = rhoisf*rcpi*rkappa/MAX(risfdep(ji,jj),zeps)
559                  zeps4 = zlamb2+zlamb3*risfdep(ji,jj)
560                  zeps6 = zeps4-ttbl(ji,jj)
561                  zeps7 = zeps4-tsurf
562                  zaqe  = zlamb1 * (zeps1 + zeps3)
563                  zaqer = 0.5_wp/MIN(zaqe,-zeps)
564                  zbqe  = zeps1*zeps6+zeps3*zeps7-zeps2
565                  zcqe  = zeps2*stbl(ji,jj)
566                  zdis  = zbqe*zbqe-4.0_wp*zaqe*zcqe               
567
568                  ! Presumably zdis can never be negative because gammas is very small compared to gammat
569                  ! compute s freeze
570                  zsfrz=(-zbqe-SQRT(zdis))*zaqer
571                  IF ( zsfrz < 0.0_wp ) zsfrz=(-zbqe+SQRT(zdis))*zaqer
572
573                  ! compute t freeze (eq. 22)
574                  zfrz(ji,jj)=zeps4+zlamb1*zsfrz
575 
576                  ! zfwflx is upward water flux
577                  ! zhtflx is upward heat flux (out of ocean)
578                  ! compute the upward water and heat flux (eq. 28 and eq. 29)
579                  zfwflx(ji,jj) = rau0 * zgammas(ji,jj) * (zsfrz-stbl(ji,jj)) / MAX(zsfrz,zeps)
580                  zhtflx(ji,jj) = zgammat(ji,jj) * rau0 * rcp * (ttbl(ji,jj) - zfrz(ji,jj) ) 
581               END DO
582            END DO
583
584            ! compute heat and water flux
585            qisf  (:,:) = - zhtflx(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:)
586            fwfisf(:,:) =   zfwflx(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:)
587
588         END SELECT
589
590         ! define if we need to iterate (nn_gammablk 0/1 do not need iteration)
591         IF ( nn_gammablk <  2 ) THEN ; lit = .FALSE.
592         ELSE                           
593            ! check total number of iteration
594            IF (nit >= 100) THEN ; CALL ctl_stop( 'STOP', 'sbc_isf_hol99 : too many iteration ...' )
595            ELSE                 ; nit = nit + 1
596            END IF
597
598            ! compute error between 2 iterations
599            ! if needed save gammat and compute zhtflx_b for next iteration
600            zerr = MAXVAL(ABS(zhtflx-zhtflx_b))
601            IF ( zerr <= 0.01_wp ) THEN ; lit = .FALSE.
602            ELSE                        ; zhtflx_b(:,:) = zhtflx(:,:)
603            END IF
604         END IF
605      END DO
606      !
607      CALL iom_put('isfgammat', zgammat)
608      CALL iom_put('isfgammas', zgammas)
609      !
610      CALL wrk_dealloc( jpi,jpj, zfrz  , zgammat, zgammas  )
611      CALL wrk_dealloc( jpi,jpj, zfwflx, zhtflx , zhtflx_b )
612      !
613      IF( nn_timing == 1 )  CALL timing_stop('sbc_isf_cav')
614      !
615   END SUBROUTINE sbc_isf_cav
616
617   SUBROUTINE sbc_isf_gammats(pgt, pgs, pqhisf, pqwisf )
618      !!----------------------------------------------------------------------
619      !! ** Purpose    : compute the coefficient echange for heat flux
620      !!
621      !! ** Method     : gamma assume constant or depends of u* and stability
622      !!
623      !! ** References : Holland and Jenkins, 1999, JPO, p1787-1800, eq 14
624      !!                Jenkins et al., 2010, JPO, p2298-2312
625      !!---------------------------------------------------------------------
626      REAL(wp), DIMENSION(:,:), INTENT(out) :: pgt, pgs
627      REAL(wp), DIMENSION(:,:), INTENT(in ) :: pqhisf, pqwisf
628      !
629      INTEGER  :: ikt                       
630      INTEGER  :: ji, jj                     ! loop index
631      REAL(wp), DIMENSION(:,:), POINTER :: zustar           ! U, V at T point and friction velocity
632      REAL(wp) :: zdku, zdkv                 ! U, V shear
633      REAL(wp) :: zPr, zSc, zRc              ! Prandtl, Scmidth and Richardson number
634      REAL(wp) :: zmob, zmols                ! Monin Obukov length, coriolis factor at T point
635      REAL(wp) :: zbuofdep, zhnu             ! Bouyancy length scale, sublayer tickness
636      REAL(wp) :: zhmax                      ! limitation of mol
637      REAL(wp) :: zetastar                   ! stability parameter
638      REAL(wp) :: zgmolet, zgmoles, zgturb   ! contribution of modelecular sublayer and turbulence
639      REAL(wp) :: zcoef                      ! temporary coef
640      REAL(wp) :: zdep
641      REAL(wp) :: zeps = 1.0e-20_wp   
642      REAL(wp), PARAMETER :: zxsiN = 0.052_wp   ! dimensionless constant
643      REAL(wp), PARAMETER :: znu   = 1.95e-6_wp ! kinamatic viscosity of sea water (m2.s-1)
644      REAL(wp), DIMENSION(2) :: zts, zab
645      !!---------------------------------------------------------------------
646      CALL wrk_alloc( jpi,jpj, zustar )
647      !
648      SELECT CASE ( nn_gammablk )
649      CASE ( 0 ) ! gamma is constant (specified in namelist)
650         !! ISOMIP formulation (Hunter et al, 2006)
651         pgt(:,:) = rn_gammat0
652         pgs(:,:) = rn_gammas0
653
654      CASE ( 1 ) ! gamma is assume to be proportional to u*
655         !! Jenkins et al., 2010, JPO, p2298-2312
656         !! Adopted by Asay-Davis et al. (2015)
657
658         !! compute ustar (eq. 24)
659         zustar(:,:) = SQRT( rn_tfri2 * (utbl(:,:) * utbl(:,:) + vtbl(:,:) * vtbl(:,:) + rn_tfeb2) )
660
661         !! Compute gammats
662         pgt(:,:) = zustar(:,:) * rn_gammat0
663         pgs(:,:) = zustar(:,:) * rn_gammas0
664     
665      CASE ( 2 ) ! gamma depends of stability of boundary layer
666         !! Holland and Jenkins, 1999, JPO, p1787-1800, eq 14
667         !! as MOL depends of flux and flux depends of MOL, best will be iteration (TO DO)
668         !! compute ustar
669         zustar(:,:) = SQRT( rn_tfri2 * (utbl(:,:) * utbl(:,:) + vtbl(:,:) * vtbl(:,:) + rn_tfeb2) )
670
671         !! compute Pr and Sc number (can be improved)
672         zPr =   13.8_wp
673         zSc = 2432.0_wp
674
675         !! compute gamma mole
676         zgmolet = 12.5_wp * zPr ** (2.0/3.0) - 6.0_wp
677         zgmoles = 12.5_wp * zSc ** (2.0/3.0) - 6.0_wp
678
679         !! compute gamma
680         DO ji=2,jpi
681            DO jj=2,jpj
682               ikt = mikt(ji,jj)
683
684               IF (zustar(ji,jj) == 0._wp) THEN           ! only for kt = 1 I think
685                  pgt = rn_gammat0
686                  pgs = rn_gammas0
687               ELSE
688                  !! compute Rc number (as done in zdfric.F90)
689                  zcoef = 0.5_wp / e3w_n(ji,jj,ikt)
690                  !                                            ! shear of horizontal velocity
691                  zdku = zcoef * (  un(ji-1,jj  ,ikt  ) + un(ji,jj,ikt  )  &
692                     &             -un(ji-1,jj  ,ikt+1) - un(ji,jj,ikt+1)  )
693                  zdkv = zcoef * (  vn(ji  ,jj-1,ikt  ) + vn(ji,jj,ikt  )  &
694                     &             -vn(ji  ,jj-1,ikt+1) - vn(ji,jj,ikt+1)  )
695                  !                                            ! richardson number (minimum value set to zero)
696                  zRc = rn2(ji,jj,ikt+1) / MAX( zdku*zdku + zdkv*zdkv, zeps )
697
698                  !! compute bouyancy
699                  zts(jp_tem) = ttbl(ji,jj)
700                  zts(jp_sal) = stbl(ji,jj)
701                  zdep        = gdepw_n(ji,jj,ikt)
702                  !
703                  CALL eos_rab( zts, zdep, zab )
704                  !
705                  !! compute length scale
706                  zbuofdep = grav * ( zab(jp_tem) * pqhisf(ji,jj) - zab(jp_sal) * pqwisf(ji,jj) )  !!!!!!!!!!!!!!!!!!!!!!!!!!!!
707
708                  !! compute Monin Obukov Length
709                  ! Maximum boundary layer depth
710                  zhmax = gdept_n(ji,jj,mbkt(ji,jj)) - gdepw_n(ji,jj,mikt(ji,jj)) -0.001_wp
711                  ! Compute Monin obukhov length scale at the surface and Ekman depth:
712                  zmob   = zustar(ji,jj) ** 3 / (vkarmn * (zbuofdep + zeps))
713                  zmols  = SIGN(1._wp, zmob) * MIN(ABS(zmob), zhmax) * tmask(ji,jj,ikt)
714
715                  !! compute eta* (stability parameter)
716                  zetastar = 1._wp / ( SQRT(1._wp + MAX(zxsiN * zustar(ji,jj) / ( ABS(ff(ji,jj)) * zmols * zRc ), 0.0_wp)))
717
718                  !! compute the sublayer thickness
719                  zhnu = 5 * znu / zustar(ji,jj)
720
721                  !! compute gamma turb
722                  zgturb = 1._wp / vkarmn * LOG(zustar(ji,jj) * zxsiN * zetastar * zetastar / ( ABS(ff(ji,jj)) * zhnu )) &
723                  &      + 1._wp / ( 2 * zxsiN * zetastar ) - 1._wp / vkarmn
724
725                  !! compute gammats
726                  pgt(ji,jj) = zustar(ji,jj) / (zgturb + zgmolet)
727                  pgs(ji,jj) = zustar(ji,jj) / (zgturb + zgmoles)
728               END IF
729            END DO
730         END DO
731         CALL lbc_lnk(pgt(:,:),'T',1.)
732         CALL lbc_lnk(pgs(:,:),'T',1.)
733      END SELECT
734      CALL wrk_dealloc( jpi,jpj, zustar )
735      !
736   END SUBROUTINE sbc_isf_gammats
737
738   SUBROUTINE sbc_isf_tbl( pvarin, pvarout, cd_ptin )
739      !!----------------------------------------------------------------------
740      !!                  ***  SUBROUTINE sbc_isf_tbl  ***
741      !!
742      !! ** Purpose : compute mean T/S/U/V in the boundary layer at T- point
743      !!
744      !!----------------------------------------------------------------------
745      REAL(wp), DIMENSION(:,:,:), INTENT( in  ) :: pvarin
746      REAL(wp), DIMENSION(:,:)  , INTENT( out ) :: pvarout
747      CHARACTER(len=1),           INTENT( in  ) :: cd_ptin ! point of variable in/out
748      !
749      REAL(wp) :: ze3, zhk
750      REAL(wp), DIMENSION(:,:), POINTER :: zhisf_tbl ! thickness of the tbl
751
752      INTEGER :: ji, jj, jk                  ! loop index
753      INTEGER :: ikt, ikb                    ! top and bottom index of the tbl
754      !!----------------------------------------------------------------------
755      ! allocation
756      CALL wrk_alloc( jpi,jpj, zhisf_tbl)
757     
758      ! initialisation
759      pvarout(:,:)=0._wp
760   
761      SELECT CASE ( cd_ptin )
762      CASE ( 'U' ) ! compute U in the top boundary layer at T- point
763         DO jj = 1,jpj
764            DO ji = 1,jpi
765               ikt = miku(ji,jj) ; ikb = miku(ji,jj)
766               ! thickness of boundary layer at least the top level thickness
767               zhisf_tbl(ji,jj) = MAX(rhisf_tbl_0(ji,jj), e3u_n(ji,jj,ikt))
768
769               ! determine the deepest level influenced by the boundary layer
770               DO jk = ikt+1, mbku(ji,jj)
771                  IF ( (SUM(e3u_n(ji,jj,ikt:jk-1)) < zhisf_tbl(ji,jj)) .AND. (umask(ji,jj,jk) == 1) ) ikb = jk
772               END DO
773               zhisf_tbl(ji,jj) = MIN(zhisf_tbl(ji,jj), SUM(e3u_n(ji,jj,ikt:ikb)))  ! limit the tbl to water thickness.
774
775               ! level fully include in the ice shelf boundary layer
776               DO jk = ikt, ikb - 1
777                  ze3 = e3u_n(ji,jj,jk)
778                  pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,jk) / zhisf_tbl(ji,jj) * ze3
779               END DO
780
781               ! level partially include in ice shelf boundary layer
782               zhk = SUM( e3u_n(ji, jj, ikt:ikb - 1)) / zhisf_tbl(ji,jj)
783               pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,ikb) * (1._wp - zhk)
784            END DO
785         END DO
786         DO jj = 2,jpj
787            DO ji = 2,jpi
788               pvarout(ji,jj) = 0.5_wp * (pvarout(ji,jj) + pvarout(ji-1,jj))
789            END DO
790         END DO
791         CALL lbc_lnk(pvarout,'T',-1.)
792     
793      CASE ( 'V' ) ! compute V in the top boundary layer at T- point
794         DO jj = 1,jpj
795            DO ji = 1,jpi
796               ikt = mikv(ji,jj) ; ikb = mikv(ji,jj)
797               ! thickness of boundary layer at least the top level thickness
798               zhisf_tbl(ji,jj) = MAX(rhisf_tbl_0(ji,jj), e3v_n(ji,jj,ikt))
799
800               ! determine the deepest level influenced by the boundary layer
801               DO jk = ikt+1, mbkv(ji,jj)
802                  IF ( (SUM(e3v_n(ji,jj,ikt:jk-1)) < zhisf_tbl(ji,jj)) .AND. (vmask(ji,jj,jk) == 1) ) ikb = jk
803               END DO
804               zhisf_tbl(ji,jj) = MIN(zhisf_tbl(ji,jj), SUM(e3v_n(ji,jj,ikt:ikb)))  ! limit the tbl to water thickness.
805
806               ! level fully include in the ice shelf boundary layer
807               DO jk = ikt, ikb - 1
808                  ze3 = e3v_n(ji,jj,jk)
809                  pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,jk) / zhisf_tbl(ji,jj) * ze3
810               END DO
811
812               ! level partially include in ice shelf boundary layer
813               zhk = SUM( e3v_n(ji, jj, ikt:ikb - 1)) / zhisf_tbl(ji,jj)
814               pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,ikb) * (1._wp - zhk)
815            END DO
816         END DO
817         DO jj = 2,jpj
818            DO ji = 2,jpi
819               pvarout(ji,jj) = 0.5_wp * (pvarout(ji,jj) + pvarout(ji,jj-1))
820            END DO
821         END DO
822         CALL lbc_lnk(pvarout,'T',-1.)
823
824      CASE ( 'T' ) ! compute T in the top boundary layer at T- point
825         DO jj = 1,jpj
826            DO ji = 1,jpi
827               ikt = misfkt(ji,jj)
828               ikb = misfkb(ji,jj)
829
830               ! level fully include in the ice shelf boundary layer
831               DO jk = ikt, ikb - 1
832                  ze3 = e3t_n(ji,jj,jk)
833                  pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,jk) * r1_hisf_tbl(ji,jj) * ze3
834               END DO
835
836               ! level partially include in ice shelf boundary layer
837               zhk = SUM( e3t_n(ji, jj, ikt:ikb - 1)) * r1_hisf_tbl(ji,jj)
838               pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,ikb) * (1._wp - zhk)
839            END DO
840         END DO
841      END SELECT
842
843      ! mask mean tbl value
844      pvarout(:,:) = pvarout(:,:) * ssmask(:,:)
845
846      ! deallocation
847      CALL wrk_dealloc( jpi,jpj, zhisf_tbl )     
848      !
849   END SUBROUTINE sbc_isf_tbl
850     
851
852   SUBROUTINE sbc_isf_div( phdivn )
853      !!----------------------------------------------------------------------
854      !!                  ***  SUBROUTINE sbc_isf_div  ***
855      !!       
856      !! ** Purpose :   update the horizontal divergence with the runoff inflow
857      !!
858      !! ** Method  :   
859      !!                CAUTION : risf_tsc(:,:,jp_sal) is negative (outflow) increase the
860      !!                          divergence and expressed in m/s
861      !!
862      !! ** Action  :   phdivn   decreased by the runoff inflow
863      !!----------------------------------------------------------------------
864      REAL(wp), DIMENSION(:,:,:), INTENT( inout ) ::   phdivn   ! horizontal divergence
865      !
866      INTEGER  ::   ji, jj, jk   ! dummy loop indices
867      INTEGER  ::   ikt, ikb 
868      REAL(wp) ::   zhk
869      REAL(wp) ::   zfact     ! local scalar
870      !!----------------------------------------------------------------------
871      !
872      zfact   = 0.5_wp
873      !
874      IF(.NOT.ln_linssh ) THEN     ! need to re compute level distribution of isf fresh water
875         DO jj = 1,jpj
876            DO ji = 1,jpi
877               ikt = misfkt(ji,jj)
878               ikb = misfkt(ji,jj)
879               ! thickness of boundary layer at least the top level thickness
880               rhisf_tbl(ji,jj) = MAX(rhisf_tbl_0(ji,jj), e3t_n(ji,jj,ikt))
881
882               ! determine the deepest level influenced by the boundary layer
883               DO jk = ikt, mbkt(ji,jj)
884                  IF ( (SUM(e3t_n(ji,jj,ikt:jk-1)) .LT. rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) ) ikb = jk
885               END DO
886               rhisf_tbl(ji,jj) = MIN(rhisf_tbl(ji,jj), SUM(e3t_n(ji,jj,ikt:ikb)))  ! limit the tbl to water thickness.
887               misfkb(ji,jj) = ikb                                                  ! last wet level of the tbl
888               r1_hisf_tbl(ji,jj) = 1._wp / rhisf_tbl(ji,jj)
889
890               zhk           = SUM( e3t_n(ji, jj, ikt:ikb - 1)) * r1_hisf_tbl(ji,jj)  ! proportion of tbl cover by cell from ikt to ikb - 1
891               ralpha(ji,jj) = rhisf_tbl(ji,jj) * (1._wp - zhk ) / e3t_n(ji,jj,ikb)  ! proportion of bottom cell influenced by boundary layer
892            END DO
893         END DO
894      END IF 
895      !
896      !==   ice shelf melting distributed over several levels   ==!
897      DO jj = 1,jpj
898         DO ji = 1,jpi
899               ikt = misfkt(ji,jj)
900               ikb = misfkb(ji,jj)
901               ! level fully include in the ice shelf boundary layer
902               DO jk = ikt, ikb - 1
903                  phdivn(ji,jj,jk) = phdivn(ji,jj,jk) + ( fwfisf(ji,jj) + fwfisf_b(ji,jj) ) &
904                    &              * r1_hisf_tbl(ji,jj) * r1_rau0 * zfact
905               END DO
906               ! level partially include in ice shelf boundary layer
907               phdivn(ji,jj,ikb) = phdivn(ji,jj,ikb) + ( fwfisf(ji,jj) &
908                    &            + fwfisf_b(ji,jj) ) * r1_hisf_tbl(ji,jj) * r1_rau0 * zfact * ralpha(ji,jj) 
909         END DO
910      END DO
911      !
912   END SUBROUTINE sbc_isf_div
913   !!======================================================================
914END MODULE sbcisf
Note: See TracBrowser for help on using the repository browser.