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_isf_flx_UKESM_r9321/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/dev_isf_flx_UKESM_r9321/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90 @ 9936

Last change on this file since 9936 was 9936, checked in by mathiot, 6 years ago

variable declare twice

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