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.
limmp.F90 in branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3 – NEMO

source: branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limmp.F90 @ 8063

Last change on this file since 8063 was 8063, checked in by vancop, 7 years ago

a few more melt pond corrections

File size: 88.9 KB
RevLine 
[7293]1MODULE limmp 
2   !!======================================================================
3   !!                     ***  MODULE  limmp   ***
4   !!   Melt ponds
5   !!======================================================================
6   !! history :       ! Original code by Daniela Flocco and Adrian Turner
7   !!            1.0  ! 2012    (O. Lecomte) Adaptation for scientific tests (NEMO3.1)
8   !!            2.0  ! 2016    (O. Lecomte, C. Rousset, M. Vancoppenolle) Implementation in NEMO3.6
9   !!----------------------------------------------------------------------
10#if defined key_lim3
11   !!----------------------------------------------------------------------
12   !!   'key_lim3' :                                 LIM3 sea-ice model
13   !!----------------------------------------------------------------------
14   !!   lim_mp_init      : some initialization and namelist read
15   !!   lim_mp           : main calling routine
[7325]16   !!   lim_mp_topo      : main melt pond routine for the "topographic" formulation (FloccoFeltham)
17   !!   lim_mp_area      : ??? compute melt pond fraction per category
18   !!   lim_mp_perm      : computes permeability (should be a FUNCTION!)
[7293]19   !!   calc_hpond       : computes melt pond depth
20   !!   permeability_phy : computes permeability
21
22   !!----------------------------------------------------------------------
[7325]23   USE phycst           ! physical constants
24   USE dom_oce          ! ocean space and time domain
[7293]25!  USE sbc_ice          ! Surface boundary condition: ice   fields
26   USE ice              ! LIM-3 variables
27   USE lbclnk           ! lateral boundary conditions - MPP exchanges
28   USE lib_mpp          ! MPP library
29   USE wrk_nemo         ! work arrays
30   USE in_out_manager   ! I/O manager
31   USE lib_fortran      ! glob_sum
32   USE timing           ! Timing
33!  USE limcons          ! conservation tests
34!  USE limctl           ! control prints
35!  USE limvar
36
37!OLI_CODE    USE ice_oce, ONLY: rdt_ice, tatm_ice
38!OLI_CODE    USE phycst
39!OLI_CODE    USE dom_ice
40!OLI_CODE    USE dom_oce
41!OLI_CODE    USE sbc_oce
42!OLI_CODE    USE sbc_ice
43!OLI_CODE    USE par_ice
44!OLI_CODE    USE par_oce
45!OLI_CODE    USE ice
46!OLI_CODE    USE thd_ice
47!OLI_CODE    USE in_out_manager
48!OLI_CODE    USE lbclnk
49!OLI_CODE    USE lib_mpp
50!OLI_CODE
51!OLI_CODE    IMPLICIT NONE
52!OLI_CODE    PRIVATE
53!OLI_CODE
54!OLI_CODE    PUBLIC   lim_mp_init
55!OLI_CODE    PUBLIC   lim_mp
56
57   IMPLICIT NONE
58   PRIVATE
59
60   PUBLIC   lim_mp_init    ! routine called by sbcice_lim.F90
[7325]61   PUBLIC   lim_mp         ! routine called by sbcice_lim.F90
[7293]62
63   !! * Substitutions
64#  include "vectopt_loop_substitute.h90"
65   !!----------------------------------------------------------------------
66   !! NEMO/LIM3 4.0 , UCL - NEMO Consortium (2011)
67   !! $Id: limdyn.F90 6994 2016-10-05 13:07:10Z clem $
68   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
69   !!----------------------------------------------------------------------
70CONTAINS
71
72   SUBROUTINE lim_mp_init 
73      !!-------------------------------------------------------------------
74      !!                  ***  ROUTINE lim_mp_init   ***
75      !!
76      !! ** Purpose : Physical constants and parameters linked to melt ponds
77      !!      over sea ice
78      !!
79      !! ** Method  :  Read the namicemp  namelist and check the melt pond 
80      !!       parameter values called at the first timestep (nit000)
81      !!
82      !! ** input   :   Namelist namicemp 
83      !!-------------------------------------------------------------------
84      INTEGER  ::   ios                 ! Local integer output status for namelist read
[8061]85      NAMELIST/namicemp/  ln_pnd, nn_pnd_scheme, nn_pnd_cpl, rn_apnd
[7293]86      !!-------------------------------------------------------------------
87
88      REWIND( numnam_ice_ref )              ! Namelist namicemp  in reference namelist : Melt Ponds 
89      READ  ( numnam_ice_ref, namicemp, IOSTAT = ios, ERR = 901)
90901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namicemp  in reference namelist', lwp )
91
92      REWIND( numnam_ice_cfg )              ! Namelist namicemp  in configuration namelist : Melt Ponds
93      READ  ( numnam_ice_cfg, namicemp, IOSTAT = ios, ERR = 902 )
94902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namicemp in configuration namelist', lwp )
95      IF(lwm) WRITE ( numoni, namicemp )
96     
97      IF(lwp) THEN                        ! control print
98         WRITE(numout,*)
99         WRITE(numout,*) 'lim_mp_init : ice parameters for melt ponds'
100         WRITE(numout,*) '~~~~~~~~~~~~'
[8061]101         WRITE(numout,*)'    Activate melt ponds                                         ln_pnd        = ', ln_pnd
102         WRITE(numout,*)'    Type of melt pond scheme =0 presc, =1 empirical = 2 topo    nn_pnd_scheme = ', nn_pnd_scheme
103         WRITE(numout,*)'    Type of melt pond coupling =0 pass., =1 full, =2 rad, 3=fw  nn_pnd_cpl    = ', nn_pnd_cp
104         WRITE(numout,*)'    Prescribed pond fraction                                    rn_apnd       = ', rn_apnd
[7293]105      ENDIF
106      !
107   END SUBROUTINE lim_mp_init
108
[8061]109
110
[7325]111   SUBROUTINE lim_mp( kt )
112      !!-------------------------------------------------------------------
113      !!               ***  ROUTINE lim_mp   ***
114      !!               
115      !! ** Purpose :   change melt pond fraction
116      !!               
117      !! ** Method  :   brutal force
118      !!
119      !! ** Action  : -
120      !!              -
121      !!------------------------------------------------------------------------------------
[7293]122
[7325]123      INTEGER, INTENT(in) :: kt    ! number of iteration
124      INTEGER  ::   ji, jj, jl     ! dummy loop indices
[7293]125
[7325]126!     REAL(wp), POINTER, DIMENSION(:,:) ::   zfsurf  ! surface heat flux(obsolete, should be droped)
127      !
128      !!-------------------------------------------------------------------
[7293]129
[7325]130      IF( nn_timing == 1 )  CALL timing_start('limthd')
[7293]131
[7325]132      IF( nn_timing == 1 )  CALL timing_start('lim_mp')
[7293]133
[8061]134      SELECT CASE ( nn_pnd_scheme )
[7325]135
[8061]136          CASE (1)
[8060]137
[8061]138             CALL lim_mp_cesm ! empirical melt ponds
[8060]139
[8061]140          CASE (2)
141
142             CALL lim_mp_topo    (at_i, a_i,                                       &
143                       &          vt_i, v_i, v_s,            t_i, s_i, a_ip_frac,  &
144                       &          h_ip,     t_su)
145
146      END SELECT
147
[7325]148      ! we should probably not aggregate here since we do it in lim_var_agg
149      ! before output, unless we need the total volume and faction else where
150
151      ! we should also make sure a_ip and v_ip are properly updated at the end
152      ! of the routine
153
154   END SUBROUTINE lim_mp 
155
[8061]156
157
[8060]158   SUBROUTINE lim_mp_cesm
159       !!-------------------------------------------------------------------
160       !!                ***  ROUTINE lim_mp_cesm  ***
161       !!
162       !! ** Purpose    : Compute melt pond evolution
163       !!
[8061]164       !! ** Method     : Empirical method. A fraction of meltwater is accumulated
165       !!                 in pond volume. It is then released exponentially when
166       !!                 surface is freezingAccumulation of meltwater and exponential release
[8060]167       !!
168       !! ** Tunable parameters :
169       !!               
170       !!
171       !! ** Note       : Stolen from CICE for quick test of the melt pond
[8061]172       !!                 radiation and freshwater interfaces
[8060]173       !!
174       !! ** References : Holland, M. M. et al (J Clim 2012)
175       !!   
176       !!-------------------------------------------------------------------
177
[8061]178       INTEGER, POINTER, DIMENSION(:)      :: indxi             ! compressed indices for cells with ice melting
179       INTEGER, POINTER, DIMENSION(:)      :: indxj             !
[8060]180
181       REAL(wp), POINTER, DIMENSION(:,:)   :: zwfx_mlw          ! available meltwater for melt ponding
182       REAL(wp), POINTER, DIMENSION(:,:,:) :: zrfrac            ! fraction of available meltwater retained for melt ponding
183
184       REAL(wp), PARAMETER                 :: zrmin  = 0.15_wp  ! minimum fraction of available meltwater retained for melt ponding
185       REAL(wp), PARAMETER                 :: zrmax  = 0.70_wp  ! maximum   ''           ''       ''        ''            ''
186       REAL(wp), PARAMETER                 :: zrexp  = 0.01_wp  ! rate constant to refreeze melt ponds
187       REAL(wp), PARAMETER                 :: zpnd_aspect = 0.8_wp ! pond aspect ratio
188
189       REAL(wp)                            :: zhi               ! dummy ice thickness
190       REAL(wp)                            :: zhs               ! dummy snow depth
191       REAL(wp)                            :: zTp               ! reference temperature
192       REAL(wp)                            :: zdTs              ! dummy temperature difference
193       REAL(wp)                            :: z1_rhofw          ! inverse freshwater density
194       REAL(wp)                            :: z1_zpnd_aspect    ! inverse pond aspect ratio
[8063]195       REAL(wp)                            :: zvold             ! dummy pond volume
[8060]196
[8061]197       INTEGER                             :: ji, jj, jl, ij    ! loop indices
198       INTEGER                             :: icells            ! size of dummy array
199
[8060]200       !!-------------------------------------------------------------------
201
202       CALL wrk_alloc( jpi*jpj, indxi, indxj)
[8061]203       CALL wrk_alloc( jpi,jpj,     zwfx_mlw )
204       CALL wrk_alloc( jpi,jpj,jpl, zrfrac   )
[8060]205
206       z1_rhofw       = 1. / rhofw 
207       z1_zpnd_aspect = 1. / zpnd_aspect
[8061]208       zTp            = -2. 
[8060]209
210       !------------------------------------------------------------------
211       ! Available melt water for melt ponding and corresponding fraction
212       !------------------------------------------------------------------
213
214       zwfx_mlw(:,:) = wfx_sum(:,:) + wfx_snw(:,:)        ! available meltwater for melt ponding
215
216       zrfrac(:,:,:) = zrmin + ( zrmax - zrmin ) * a_i(:,:,:) 
217
218       DO jl = 1, jpl   
219
220          ! v_ip(:,:,jl) ! Initialize things
221          ! a_ip(:,:,jl)
222          ! volpn(:,:) = hpnd(:,:) * apnd(:,:) * aicen(:,:)
223
224          !------------------------------------------------------------------------------
225          ! Identify grid cells where ponds should be updated (can probably be improved)
226          !------------------------------------------------------------------------------
227
228          indxi(:) = 0
229          indxj(:) = 0
230          icells   = 0
231
232          DO jj = 1, jpj
233            DO ji = 1, jpi
234               IF ( a_i(ji,jj,jl) > epsi10 ) THEN
235                  icells = icells + 1
[8061]236                  indxi(icells) = ji
237                  indxj(icells) = jj
[8060]238               ENDIF
239            END DO                 ! ji
240         END DO                    ! jj
241
242         DO ij = 1, icells
243
244            ji = indxi(ij)
245            jj = indxj(ij)
246
247            zhi = v_i(ji,jj,jl) / a_i(ji,jj,jl)
248            zhs = v_s(ji,jj,jl) / a_i(ji,jj,jl)
249
250            IF ( zhi < rn_himin) THEN   !--- Remove ponds on thin ice if ice is too thin
251
[8061]252               a_ip(ji,jj,jl)      = 0._wp                               !--- Dump ponds
[8060]253               v_ip(ji,jj,jl)      = 0._wp
254               a_ip_frac(ji,jj,jl) = 0._wp
255               h_ip(ji,jj,jl)      = 0._wp
256
[8063]257               IF ( ( nn_pnd_cpl == 1 ) .OR. ( nn_pnd_cpl == 3 ) ) & !--- Give freshwater to the ocean
[8061]258                  wfx_pnd(ji,jj)   = wfx_pnd(ji,jj) + v_ip(ji,jj,jl) 
259
260
[8060]261            ELSE                        !--- Update pond characteristics
262
263               !--- Add retained melt water
[8061]264               v_ip(ji,jj,jl)      = v_ip(ji,jj,jl) + zrfrac(ji,jj,jl) * z1_rhofw * zwfx_mlw(ji,jj) * a_i(ji,jj,jl) * rdt_ice
[8060]265
266               !--- Shrink pond due to refreezing
[8061]267               zdTs                = MAX ( zTp - t_su(ji,jj,jl) + rt0 , 0. )
[8060]268               
[8061]269               zvpold              = v_ip(ji,jj,jl)
270
271               v_ip(ji,jj,jl)      = v_ip(ji,jj,jl) * EXP( zrexp * zdTs / zTp )
272
273               !--- Dump meltwater due to refreezing ( of course this is wrong
274               !--- but this parameterization is too simple )
[8063]275               IF ( ( nn_pnd_cpl == 1 ) .OR. ( nn_pnd_cpl == 3 ) ) THEN
[8061]276
277                  wfx_pnd(ji,jj)   = wfx_pnd(ji,jj) + rhofw * ( v_ip(ji,jj,jl) - zvpold ) * r1_rdtice
278
279               ENDIF
280
[8060]281               a_ip_frac(ji,jj,jl) = MIN( 1._wp , SQRT( v_ip(ji,jj,jl) * z1_zpnd_aspect / a_i(ji,jj,jl) ) )
282
283               h_ip(ji,jj,jl)      = zpnd_aspect * a_ip_frac(ji,jj,jl)
284
285               a_ip(ji,jj,jl)      = a_ip_frac(ji,jj,jl) * a_i(ji,jj,jl)
286
287            !-----------------------------------------------------------
288            ! Limit pond depth
289            !-----------------------------------------------------------
290            ! hpondn = min(hpondn, dpthhi*hi)
291
292            !--- Give freshwater to the ocean ?
293
294            ENDIF
295
[8061]296          END DO
[8060]297
[8061]298       END DO ! jpl
[8060]299
[8061]300       !--- Remove retained meltwater from surface fluxes
301
302       IF ( ( nn_pnd_cpl .EQ. 1 ) .OR. ( nn_pnd_cpl .EQ. 3 ) ) THEN
303
304           wfx_snw(:,:) = wfx_snw(:,:) *  ( 1. - zrmin - ( zrmax - zrmin ) * at_i(:,:) )
305
306           wfx_sum(:,:) = wfx_sum(:,:) *  ( 1. - zrmin - ( zrmax - zrmin ) * at_i(:,:) )
307
308       ENDIF
309
[8060]310   END SUBROUTINE lim_mp_cesm
311
[7325]312   SUBROUTINE lim_mp_topo    (aice,      aicen,     &
313                              vice,      vicen,     &
314                              vsnon,                &
315                              ticen,     salin,     &
316                              a_ip_frac, h_ip,      &
317                                         Tsfc )
318       !!-------------------------------------------------------------------
319       !!                ***  ROUTINE lim_mp_topo  ***
320       !!
321       !! ** Purpose :   Compute melt pond evolution based on the ice
322       !!                topography as inferred from the ice thickness
323       !!                distribution. 
324       !!
325       !! ** Method  :   This code is initially based on Flocco and Feltham
326       !!                (2007) and Flocco et al. (2010). More to come...
327       !!
328       !! ** Tunable parameters :
329       !!
330       !! ** Note :
331       !!
332       !! ** References
333       !!    Flocco, D. and D. L. Feltham, 2007.  A continuum model of melt pond
334       !!    evolution on Arctic sea ice.  J. Geophys. Res. 112, C08016, doi:
335       !!    10.1029/2006JC003836.
336       !!    Flocco, D., D. L. Feltham and A. K. Turner, 2010.  Incorporation of
337       !!    a physically based melt pond scheme into the sea ice component of a
338       !!    climate model.  J. Geophys. Res. 115, C08012,
339       !!    doi: 10.1029/2009JC005568.
340       !!   
341       !!-------------------------------------------------------------------
342 
343       REAL (wp), DIMENSION (jpi,jpj), &
344          INTENT(IN) :: &
345          aice, &    ! total ice area fraction
346          vice       ! total ice volume (m)
347 
348       REAL (wp), DIMENSION (jpi,jpj,jpl), &
349          INTENT(IN) :: &
350          aicen, &   ! ice area fraction, per category
351          vsnon, &   ! snow volume, per category (m)
352          vicen      ! ice volume, per category (m)
353 
354       REAL (wp), DIMENSION (jpi,jpj,nlay_i,jpl), &
355          INTENT(IN) :: &
356          ticen, &   ! ice enthalpy, per category
357          salin
358 
359       REAL (wp), DIMENSION (jpi,jpj,jpl), &
360          INTENT(INOUT) :: &
361          a_ip_frac , &   ! pond area fraction of ice, per ice category
362          h_ip       ! pond depth, per ice category (m)
363 
364       REAL (wp), DIMENSION (jpi,jpj,jpl), &
365          INTENT(IN) :: &
366          Tsfc       ! snow/sea ice surface temperature
367 
368       ! local variables
369       REAL (wp), DIMENSION (jpi,jpj,jpl) :: &
370          zTsfcn, & ! ice/snow surface temperature (C)
371          zvolpn, & ! pond volume per unit area, per category (m)
372          zvuin     ! water-equivalent volume of ice lid on melt pond ('upper ice', m)
373 
374       REAL (wp), DIMENSION (jpi,jpj,jpl) :: &
375          zapondn,& ! pond area fraction, per category
376          zhpondn   ! pond depth, per category (m)
377 
378       REAL (wp), DIMENSION (jpi,jpj) :: &
379          zvolp       ! total volume of pond, per unit area of pond (m)
380 
381       REAL (wp) :: &
382          zhi,    & ! ice thickness (m)
383          zdHui,  & ! change in thickness of ice lid (m)
384          zomega, & ! conduction
385          zdTice, & ! temperature difference across ice lid (C)
386          zdvice, & ! change in ice volume (m)
387          zTavg,  & ! mean surface temperature across categories (C)
388          zTp,    & ! pond freezing temperature (C)
389          zdvn      ! change in melt pond volume for fresh water budget
390       INTEGER, DIMENSION (jpi*jpj) :: &
391          indxi, indxj    ! compressed indices for cells with ice melting
392 
393       INTEGER :: n,k,i,j,ij,icells,indxij ! loop indices
394 
395       INTEGER, DIMENSION (jpl) :: &
396          kcells          ! cells where ice lid combines with vice
397 
398       INTEGER, DIMENSION (jpi*jpj,jpl) :: &
399          indxii, indxjj  ! i,j indices for kcells loop
400 
401       REAL (wp), parameter :: &
402          zhicemin  = 0.1_wp , & ! minimum ice thickness with ponds (m)
403          zTd       = 0.15_wp, & ! temperature difference for freeze-up (C)
404          zr1_rlfus = 1._wp / 0.334e+6 / 917._wp , & ! (J/m^3)
405          zmin_volp = 1.e-4_wp, & ! minimum pond volume (m)
406          z0       = 0._wp,    & 
407          zTimelt   = 0._wp,    &
408          z01      = 0.01_wp,  &
409          z25      = 0.25_wp,  &
410          z5       = 0.5_wp
411
412       !---------------------------------------------------------------
413       ! Initialization
414       !---------------------------------------------------------------
415 
416       zhpondn(:,:,:) = 0._wp
417       zapondn(:,:,:) = 0._wp
418       indxii(:,:) = 0
419       indxjj(:,:) = 0
420       kcells(:)   = 0
421
422       zvolp(:,:) = wfx_sum(:,:) + wfx_snw(:,:) + vt_ip(:,:) ! Total available melt water, to be distributed as melt ponds
423       zTsfcn(:,:,:) = zTsfcn(:,:,:) - rt0                   ! Convert in Celsius
424 
425       ! The freezing temperature for meltponds is assumed slightly below 0C,
426       ! as if meltponds had a little salt in them.  The salt budget is not
427       ! altered for meltponds, but if it were then an actual pond freezing
428       ! temperature could be computed.
429 
430       ! zTp = zTimelt - zTd  ---> for lids
431 
432       !-----------------------------------------------------------------
433       ! Identify grid cells with ponds
434       !-----------------------------------------------------------------
435 
436       icells = 0
437       DO j = 1, jpj
438       DO i = 1, jpi
439          zhi = z0
440          IF (aice(i,j) > epsi10 ) zhi = vice(i,j)/aice(i,j)
441          IF ( aice(i,j) > z01 .and. zhi > zhicemin .and. &
442             zvolp(i,j) > zmin_volp*aice(i,j)) THEN
443             icells = icells + 1
444             indxi(icells) = i
445             indxj(icells) = j
446          ELSE  ! remove ponds on thin ice
447             !fpond(i,j) = fpond(i,j) - zvolp(i,j)
448             zvolpn(i,j,:) = z0
449             zvuin (i,j,:) = z0
450             zvolp (i,j) = z0
451          END IF
452       END DO                     ! i
453       END DO                     ! j
454 
455       DO ij = 1, icells
456          i = indxi(ij)
457          j = indxj(ij)
458 
459          !--------------------------------------------------------------
460          ! calculate pond area and depth
461          !--------------------------------------------------------------
462          CALL lim_mp_area(aice(i,j),vice(i,j), &
463                    aicen(i,j,:), vicen(i,j,:), vsnon(i,j,:), &
464                    ticen(i,j,:,:), salin(i,j,:,:), &
465                    zvolpn(i,j,:), zvolp(i,j), &
466                    zapondn(i,j,:),zhpondn(i,j,:), zdvn)
467         ! outputs are
468         ! - zdvn
469         ! - zvolpn
470         ! - zvolp
471         ! - zapondn
472         ! - zhpondn
473
474          wfx_pnd(i,j) = wfx_pnd(i,j) + zdvn ! update flux from ponds to ocean
475 
[8060]476          ! mean surface temperature MV - why do we need that ? --> for the lid
477
478          ! zTavg = z0
479          ! DO n = 1, jpl
480          !   zTavg = zTavg + zTsfcn(i,j,n)*aicen(i,j,n)
481          ! END DO
482          ! zTavg = zTavg / aice(i,j)
[7325]483 
484       END DO ! ij
485 
486       !---------------------------------------------------------------
487       ! Update pond volume and fraction
488       !---------------------------------------------------------------
489 
490       a_ip(:,:,:) = zapondn(:,:,:)
491       v_ip(:,:,:) = zapondn(:,:,:) * zhpondn(:,:,:)
492       a_ip_frac(:,:,:) = 0._wp
493       h_ip     (:,:,:) = 0._wp
494
495    END SUBROUTINE lim_mp_topo
496
497    SUBROUTINE lim_mp_area(aice,vice, &
498                         aicen, vicen, vsnon, ticen, &
499                         salin, zvolpn, zvolp,         &
500                         zapondn,zhpondn,dvolp)
501
502       !!-------------------------------------------------------------------
503       !!                ***  ROUTINE lim_mp_area ***
504       !!
505       !! ** Purpose : Given the total volume of meltwater, update
506       !!              pond fraction (a_ip) and depth (should be volume)
507       !!
508       !! **
509       !!             
510       !!------------------------------------------------------------------
511
512       REAL (wp), INTENT(IN) :: &
513          aice,vice
514 
515       REAL (wp), DIMENSION(jpl), INTENT(IN) :: &
516          aicen, vicen, vsnon
517 
518       REAL (wp), DIMENSION(nlay_i,jpl), INTENT(IN) :: &
519          ticen, salin
520 
521       REAL (wp), DIMENSION(jpl), INTENT(INOUT) :: &
522          zvolpn
523 
524       REAL (wp), INTENT(INOUT) :: &
525          zvolp, dvolp
526 
527       REAL (wp), DIMENSION(jpl), INTENT(OUT) :: &
528          zapondn, zhpondn
529 
530       INTEGER :: &
531          n, ns,   &
532          m_index, &
533          permflag
534 
535       REAL (wp), DIMENSION(jpl) :: &
536          hicen, &
537          hsnon, &
538          asnon, &
539          alfan, &
540          betan, &
541          cum_max_vol, &
542          reduced_aicen       
543 
544       REAL (wp), DIMENSION(0:jpl) :: &
545          cum_max_vol_tmp
546 
547       REAL (wp) :: &
548          hpond, &
549          drain, &
550          floe_weight, &
551          pressure_head, &
552          hsl_rel, &
553          deltah, &
554          perm, &
555          msno
556 
557       REAL (wp), parameter :: & 
558          viscosity = 1.79e-3_wp, &  ! kinematic water viscosity in kg/m/s
559          z0        = 0.0_wp    , &
560          c1        = 1.0_wp    , &
561          p4        = 0.4_wp    , &
562          p6        = 0.6_wp    , &
563          epsi10      = 1.0e-11_wp
564         
565      !-----------|
566      !           |
567      !           |-----------|
568      !___________|___________|______________________________________sea-level
569      !           |           |
570      !           |           |---^--------|
571      !           |           |   |        |
572      !           |           |   |        |-----------|              |-------
573      !           |           |   |alfan(n)|           |              |
574      !           |           |   |        |           |--------------|
575      !           |           |   |        |           |              |
576      !---------------------------v-------------------------------------------
577      !           |           |   ^        |           |              |
578      !           |           |   |        |           |--------------|
579      !           |           |   |betan(n)|           |              |
580      !           |           |   |        |-----------|              |-------
581      !           |           |   |        |
582      !           |           |---v------- |
583      !           |           |
584      !           |-----------|
585      !           |
586      !-----------|
587     
588       !-------------------------------------------------------------------
589       ! initialize
590       !-------------------------------------------------------------------
591 
592       DO n = 1, jpl
593 
594          zapondn(n) = z0
595          zhpondn(n) = z0
596 
597          !----------------------------------------
598          ! X) compute the effective snow fraction
599          !----------------------------------------
600          IF (aicen(n) < epsi10)  THEN
601             hicen(n) =  z0 
602             hsnon(n) = z0
603             reduced_aicen(n) = z0
604          ELSE
605             hicen(n) = vicen(n) / aicen(n)
606             hsnon(n) = vsnon(n) / aicen(n)
607             reduced_aicen(n) = c1 ! n=jpl
608             IF (n < jpl) reduced_aicen(n) = aicen(n) &
609                                  * (-0.024_wp*hicen(n) + 0.832_wp) 
610             asnon(n) = reduced_aicen(n)  ! effective snow fraction (empirical)
[8060]611             ! MV should check whether this makes sense to have the same effective snow fraction in here
[7325]612          END IF
613 
614 ! This choice for alfa and beta ignores hydrostatic equilibium of categories.
615 ! Hydrostatic equilibium of the entire ITD is accounted for below, assuming
616 ! a surface topography implied by alfa=0.6 and beta=0.4, and rigidity across all
617 ! categories.  alfa and beta partition the ITD - they are areas not thicknesses!
618 ! Multiplying by hicen, alfan and betan (below) are thus volumes per unit area.
619 ! Here, alfa = 60% of the ice area (and since hice is constant in a category,
620 ! alfan = 60% of the ice volume) in each category lies above the reference line,
621 ! and 40% below. Note: p6 is an arbitrary choice, but alfa+beta=1 is required.
[8060]622
623 ! MV: 
624 ! Note that this choice is not in the original FF07 paper and has been adopted in CICE
625 ! No reason why is explained in the doc, but I guess there is a reason. I'll try to investigate, maybe
626
627 ! Where does that choice come from
[7325]628 
[8060]629          alfan(n) = 0.6 * hicen(n)
630          betan(n) = 0.4 * hicen(n)
[7325]631       
632          cum_max_vol(n)     = z0
633          cum_max_vol_tmp(n) = z0
634     
635       END DO ! jpl
636 
637       cum_max_vol_tmp(0) = z0
638       drain = z0
639       dvolp = z0
640
641       !----------------------------------------------------------
642       ! x) Drain overflow water, update pond fraction and volume
643       !----------------------------------------------------------
644       
645       !--------------------------------------------------------------------------
646       ! the maximum amount of water that can be contained up to each ice category
647       !--------------------------------------------------------------------------
648
649       ! MV
650       ! If melt ponds are too deep to be sustainable given the ITD (OVERFLOW)
651       ! Then the excess volume cum_max_vol(jl) drains out of the system
652       ! It should be added to wfx_pnd
653       ! END MV
654     
655       DO n = 1, jpl-1 ! last category can not hold any volume
656 
657          IF (alfan(n+1) >= alfan(n) .and. alfan(n+1) > z0) THEN
658 
659             ! total volume in level including snow
660             cum_max_vol_tmp(n) = cum_max_vol_tmp(n-1) + &
661                (alfan(n+1) - alfan(n)) * sum(reduced_aicen(1:n)) 
662 
663             ! subtract snow solid volumes from lower categories in current level
664             DO ns = 1, n 
665                cum_max_vol_tmp(n) = cum_max_vol_tmp(n) &
666                   - rhosn/rhofw * &   ! free air fraction that can be filled by water
667                     asnon(ns)  * &    ! effective areal fraction of snow in that category
668                     max(min(hsnon(ns)+alfan(ns)-alfan(n), alfan(n+1)- &
669                                   alfan(n)), z0) 
670             END DO
671
672          ELSE ! assume higher categories unoccupied
673             cum_max_vol_tmp(n) = cum_max_vol_tmp(n-1)
674          END IF
675          !IF (cum_max_vol_tmp(n) < z0) THEN
676          !   call abort_ice('negative melt pond volume')
677          !END IF
678       END DO
679       cum_max_vol_tmp(jpl) = cum_max_vol_tmp(jpl-1)  ! last category holds no volume
680       cum_max_vol  (1:jpl) = cum_max_vol_tmp(1:jpl)
681     
682       !----------------------------------------------------------------
683       ! is there more meltwater than can be held in the floe?
684       !----------------------------------------------------------------
685       IF (zvolp >= cum_max_vol(jpl)) THEN
686          drain = zvolp - cum_max_vol(jpl) + epsi10
687          zvolp = zvolp - drain ! update meltwater volume available
688          dvolp = drain         ! this is the drained water
689          IF (zvolp < epsi10) THEN
690             dvolp = dvolp + zvolp
691             zvolp = z0
692          END IF
693       END IF
694     
695       ! height and area corresponding to the remaining volume
696 
697!      call calc_hpond(reduced_aicen, asnon, hsnon, rhos, alfan, &
698!           zvolp, cum_max_vol, hpond, m_index)
699     
700       DO n=1, m_index
701          zhpondn(n) = hpond - alfan(n) + alfan(1) ! here oui choulde update
702                                                   !  volume instead, no ?
703          zapondn(n) = reduced_aicen(n) 
704          ! in practise, pond fraction depends on the empirical snow fraction
705          ! so in turn on ice thickness
706       END DO
707     
708       !------------------------------------------------------------------------
709       ! Drainage through brine network (permeability)
710       !------------------------------------------------------------------------
711       !!! drainage due to ice permeability - Darcy's law
712     
713       ! sea water level
714       msno = z0
715       DO n=1,jpl
716         msno = msno + vsnon(n) * rhosn
717       END DO
718       floe_weight = (msno + rhoic*vice + rau0*zvolp) / aice
719       hsl_rel = floe_weight / rau0 &
720               - ((sum(betan(:)*aicen(:))/aice) + alfan(1))
721     
722       deltah = hpond - hsl_rel
723       pressure_head = grav * rau0 * max(deltah, z0)
724 
725       ! drain IF ice is permeable   
726       permflag = 0
727       IF (pressure_head > z0) THEN
728       DO n = 1, jpl-1
729          IF (hicen(n) /= z0) THEN
730             perm = 0. ! MV ugly dummy patch
731             CALL lim_mp_perm(ticen(:,n), salin(:,n), vicen(n), perm)
732             IF (perm > z0) permflag = 1
733
734             drain = perm*zapondn(n)*pressure_head*rdt_ice / &
735                                      (viscosity*hicen(n))
736             dvolp = dvolp + min(drain, zvolp)
737             zvolp = max(zvolp - drain, z0)
738             IF (zvolp < epsi10) THEN
739                dvolp = dvolp + zvolp
740                zvolp = z0
741             END IF
742          END IF
743       END DO
744 
745       ! adjust melt pond DIMENSIONs
746       IF (permflag > 0) THEN
747          ! recompute pond depth   
748!         CALL calc_hpond(reduced_aicen, asnon, hsnon, rhos, alfan, &
749!                         zvolp, cum_max_vol, hpond, m_index)
750          DO n=1, m_index
751             zhpondn(n) = hpond - alfan(n) + alfan(1)
752             zapondn(n) = reduced_aicen(n) 
753          END DO
754       END IF
755       END IF ! pressure_head
756 
757       !-------------------------------
758       ! X) remove water from the snow
759       !-------------------------------
760       !------------------------------------------------------------------------
761       ! total melt pond volume in category DOes not include snow volume
762       ! snow in melt ponds is not melted
763       !------------------------------------------------------------------------
764 
765       ! Calculate pond volume for lower categories
766       DO n=1,m_index-1
767          zvolpn(n) = zapondn(n) * zhpondn(n) & ! what is not in the snow
768                   - (rhosn/rhofw) * asnon(n) * min(hsnon(n), zhpondn(n))
769       END DO
770 
771       ! Calculate pond volume for highest category = remaining pond volume
772
773       ! The following is completely unclear to Martin at least
774       ! Could we redefine properly and recode in a more readable way ?
775
776       ! m_index = last category with melt pond
777
778       IF (m_index == 1) zvolpn(m_index) = zvolp ! volume of mw in 1st category is the total volume of melt water
779
780       IF (m_index > 1) THEN
781         IF (zvolp > sum(zvolpn(1:m_index-1))) THEN
782           zvolpn(m_index) = zvolp - sum(zvolpn(1:m_index-1)) !
783         ELSE
784           zvolpn(m_index) = z0
785           zhpondn(m_index) = z0
786           zapondn(m_index) = z0
787           ! If remaining pond volume is negative reduce pond volume of
788           ! lower category
789           IF (zvolp+epsi10 < sum(zvolpn(1:m_index-1))) & 
790             zvolpn(m_index-1) = zvolpn(m_index-1)-sum(zvolpn(1:m_index-1))&
791                                + zvolp
792         END IF
793       END IF
794 
795       DO n=1,m_index
796          IF (zapondn(n) > epsi10) THEN
797              zhpondn(n) = zvolpn(n) / zapondn(n)
798          ELSE
799             dvolp = dvolp + zvolpn(n)
800             zhpondn(n) = z0
801             zvolpn(n) = z0
802             zapondn(n) = z0
803          end IF
804       END DO
805       DO n = m_index+1, jpl
806          zhpondn(n) = z0
807          zapondn(n) = z0
808          zvolpn (n) = z0
809       END DO
810 
811    END SUBROUTINE lim_mp_area
812
813!OLI_CODE   
814!OLI_CODE
815!OLI_CODE    SUBROUTINE calc_hpond(aicen, asnon, hsnon, rhos, alfan, &
816!OLI_CODE                          zvolp, cum_max_vol,                &
817!OLI_CODE                          hpond, m_index)
818!OLI_CODE       !!-------------------------------------------------------------------
819!OLI_CODE       !!                ***  ROUTINE calc_hpond  ***
820!OLI_CODE       !!
821!OLI_CODE       !! ** Purpose :   Compute melt pond depth
822!OLI_CODE       !!-------------------------------------------------------------------
823!OLI_CODE     
824!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(IN) :: &
825!OLI_CODE          aicen, &
826!OLI_CODE          asnon, &
827!OLI_CODE          hsnon, &
828!OLI_CODE          rhos,  &
829!OLI_CODE          alfan, &
830!OLI_CODE          cum_max_vol
831!OLI_CODE     
832!OLI_CODE       REAL (wp), INTENT(IN) :: &
833!OLI_CODE          zvolp
834!OLI_CODE     
835!OLI_CODE       REAL (wp), INTENT(OUT) :: &
836!OLI_CODE          hpond
837!OLI_CODE     
838!OLI_CODE       INTEGER, INTENT(OUT) :: &
839!OLI_CODE          m_index
840!OLI_CODE     
841!OLI_CODE       INTEGER :: n, ns
842!OLI_CODE     
843!OLI_CODE       REAL (wp), DIMENSION(0:jpl+1) :: &
844!OLI_CODE          hitl, &
845!OLI_CODE          aicetl
846!OLI_CODE     
847!OLI_CODE       REAL (wp) :: &
848!OLI_CODE          rem_vol, &
849!OLI_CODE          area, &
850!OLI_CODE          vol, &
851!OLI_CODE          tmp, &
852!OLI_CODE          z0   = 0.0_wp,    &   
853!OLI_CODE          epsi10 = 1.0e-11_wp
854!OLI_CODE     
855!OLI_CODE       !----------------------------------------------------------------
856!OLI_CODE       ! hpond is zero if zvolp is zero - have we fully drained?
857!OLI_CODE       !----------------------------------------------------------------
858!OLI_CODE     
859!OLI_CODE       IF (zvolp < epsi10) THEN
860!OLI_CODE        hpond = z0
861!OLI_CODE        m_index = 0
862!OLI_CODE       ELSE
863!OLI_CODE       
864!OLI_CODE        !----------------------------------------------------------------
865!OLI_CODE        ! Calculate the category where water fills up to
866!OLI_CODE        !----------------------------------------------------------------
867!OLI_CODE       
868!OLI_CODE        !----------|
869!OLI_CODE        !          |
870!OLI_CODE        !          |
871!OLI_CODE        !          |----------|                                     -- --
872!OLI_CODE        !__________|__________|_________________________________________ ^
873!OLI_CODE        !          |          |             rem_vol     ^                | Semi-filled
874!OLI_CODE        !          |          |----------|-- -- -- - ---|-- ---- -- -- --v layer
875!OLI_CODE        !          |          |          |              |
876!OLI_CODE        !          |          |          |              |hpond
877!OLI_CODE        !          |          |          |----------|   |     |-------
878!OLI_CODE        !          |          |          |          |   |     |
879!OLI_CODE        !          |          |          |          |---v-----|
880!OLI_CODE        !          |          | m_index  |          |         |
881!OLI_CODE        !-------------------------------------------------------------
882!OLI_CODE       
883!OLI_CODE        m_index = 0  ! 1:m_index categories have water in them
884!OLI_CODE        DO n = 1, jpl
885!OLI_CODE           IF (zvolp <= cum_max_vol(n)) THEN
886!OLI_CODE              m_index = n
887!OLI_CODE              IF (n == 1) THEN
888!OLI_CODE                 rem_vol = zvolp
889!OLI_CODE              ELSE
890!OLI_CODE                 rem_vol = zvolp - cum_max_vol(n-1)
891!OLI_CODE              END IF
892!OLI_CODE              exit ! to break out of the loop
893!OLI_CODE           END IF
894!OLI_CODE        END DO
895!OLI_CODE        m_index = min(jpl-1, m_index)
896!OLI_CODE       
897!OLI_CODE        !----------------------------------------------------------------
898!OLI_CODE        ! semi-filled layer may have m_index different snow in it
899!OLI_CODE        !----------------------------------------------------------------
900!OLI_CODE       
901!OLI_CODE        !-----------------------------------------------------------  ^
902!OLI_CODE        !                                                             |  alfan(m_index+1)
903!OLI_CODE        !                                                             |
904!OLI_CODE        !hitl(3)-->                             |----------|          |
905!OLI_CODE        !hitl(2)-->                |------------| * * * * *|          |
906!OLI_CODE        !hitl(1)-->     |----------|* * * * * * |* * * * * |          |
907!OLI_CODE        !hitl(0)-->-------------------------------------------------  |  ^
908!OLI_CODE        !                various snow from lower categories          |  |alfa(m_index)
909!OLI_CODE       
910!OLI_CODE        ! hitl - heights of the snow layers from thinner and current categories
911!OLI_CODE        ! aicetl - area of each snow depth in this layer
912!OLI_CODE       
913!OLI_CODE        hitl(:) = z0
914!OLI_CODE        aicetl(:) = z0
915!OLI_CODE        DO n = 1, m_index
916!OLI_CODE           hitl(n)   = max(min(hsnon(n) + alfan(n) - alfan(m_index), &
917!OLI_CODE                                  alfan(m_index+1) - alfan(m_index)), z0)
918!OLI_CODE           aicetl(n) = asnon(n)
919!OLI_CODE           
920!OLI_CODE           aicetl(0) = aicetl(0) + (aicen(n) - asnon(n))
921!OLI_CODE        END DO
922!OLI_CODE        hitl(m_index+1) = alfan(m_index+1) - alfan(m_index)
923!OLI_CODE        aicetl(m_index+1) = z0
924!OLI_CODE       
925!OLI_CODE        !----------------------------------------------------------------
926!OLI_CODE        ! reorder array according to hitl
927!OLI_CODE        ! snow heights not necessarily in height order
928!OLI_CODE        !----------------------------------------------------------------
929!OLI_CODE       
930!OLI_CODE        DO ns = 1, m_index+1
931!OLI_CODE           DO n = 0, m_index - ns + 1
932!OLI_CODE              IF (hitl(n) > hitl(n+1)) THEN ! swap order
933!OLI_CODE                 tmp = hitl(n)
934!OLI_CODE                 hitl(n) = hitl(n+1)
935!OLI_CODE                 hitl(n+1) = tmp
936!OLI_CODE                 tmp = aicetl(n)
937!OLI_CODE                 aicetl(n) = aicetl(n+1)
938!OLI_CODE                 aicetl(n+1) = tmp
939!OLI_CODE              END IF
940!OLI_CODE           END DO
941!OLI_CODE        END DO
942!OLI_CODE       
943!OLI_CODE        !----------------------------------------------------------------
944!OLI_CODE        ! divide semi-filled layer into set of sublayers each vertically homogenous
945!OLI_CODE        !----------------------------------------------------------------
946!OLI_CODE       
947!OLI_CODE        !hitl(3)----------------------------------------------------------------
948!OLI_CODE        !                                                       | * * * * * * * * 
949!OLI_CODE        !                                                       |* * * * * * * * *
950!OLI_CODE        !hitl(2)----------------------------------------------------------------
951!OLI_CODE        !                                    | * * * * * * * *  | * * * * * * * * 
952!OLI_CODE        !                                    |* * * * * * * * * |* * * * * * * * *
953!OLI_CODE        !hitl(1)----------------------------------------------------------------
954!OLI_CODE        !                 | * * * * * * * *  | * * * * * * * *  | * * * * * * * * 
955!OLI_CODE        !                 |* * * * * * * * * |* * * * * * * * * |* * * * * * * * *
956!OLI_CODE        !hitl(0)----------------------------------------------------------------
957!OLI_CODE        !    aicetl(0)         aicetl(1)           aicetl(2)          aicetl(3)           
958!OLI_CODE       
959!OLI_CODE        ! move up over layers incrementing volume
960!OLI_CODE        DO n = 1, m_index+1
961!OLI_CODE           
962!OLI_CODE           area = sum(aicetl(:)) - &                 ! total area of sub-layer
963!OLI_CODE                (rhos(n)/rau0) * sum(aicetl(n:jpl+1)) ! area of sub-layer occupied by snow
964!OLI_CODE           
965!OLI_CODE           vol = (hitl(n) - hitl(n-1)) * area      ! thickness of sub-layer times area
966!OLI_CODE           
967!OLI_CODE           IF (vol >= rem_vol) THEN  ! have reached the sub-layer with the depth within
968!OLI_CODE              hpond = rem_vol / area + hitl(n-1) + alfan(m_index) - &
969!OLI_CODE                           alfan(1)
970!OLI_CODE              exit
971!OLI_CODE           ELSE  ! still in sub-layer below the sub-layer with the depth
972!OLI_CODE              rem_vol = rem_vol - vol
973!OLI_CODE           END IF
974!OLI_CODE           
975!OLI_CODE        END DO
976!OLI_CODE       
977!OLI_CODE       END IF
978!OLI_CODE     
979!OLI_CODE    END SUBROUTINE calc_hpond
980!OLI_CODE   
981!OLI_CODE
982    SUBROUTINE lim_mp_perm(ticen, salin, vicen, perm)
983       !!-------------------------------------------------------------------
984       !!                ***  ROUTINE lim_mp_perm ***
985       !!
986       !! ** Purpose :   Determine the liquid fraction of brine in the ice
987       !!                and its permeability
988       !!-------------------------------------------------------------------
989       REAL (wp), DIMENSION(nlay_i), INTENT(IN) :: &
990          ticen,  & ! energy of melting for each ice layer (J/m2)
991          salin
992 
993       REAL (wp), INTENT(IN) :: &
994          vicen     ! ice volume
995     
996       REAL (wp), INTENT(OUT) :: &
997          perm      ! permeability
998 
999       REAL (wp) ::   &
1000          Sbr        ! brine salinity
1001 
1002       REAL (wp), DIMENSION(nlay_i) ::   &
1003          Tin, &    ! ice temperature
1004          phi       ! liquid fraction
1005 
1006       INTEGER :: k
1007     
1008       REAL (wp) :: &
1009          c2    = 2.0_wp
1010 
1011       !-----------------------------------------------------------------
1012       ! Compute ice temperatures from enthalpies using quadratic formula
1013       !-----------------------------------------------------------------
1014 
1015       DO k = 1,nlay_i
1016          Tin(k) = ticen(k) 
1017       END DO
1018 
1019       !-----------------------------------------------------------------
1020       ! brine salinity and liquid fraction
1021       !-----------------------------------------------------------------
1022 
1023       IF (maxval(Tin-rtt) <= -c2) THEN
1024 
1025          DO k = 1,nlay_i
1026             Sbr = - 1.2_wp                 &
1027                   -21.8_wp     * (Tin(k)-rtt)    &
1028                   - 0.919_wp   * (Tin(k)-rtt)**2 &
1029                   - 0.01878_wp * (Tin(k)-rtt)**3
1030             phi(k) = salin(k)/Sbr ! liquid fraction
1031          END DO ! k
1032       
1033       ELSE
1034 
1035          DO k = 1,nlay_i
1036             Sbr = -17.6_wp    * (Tin(k)-rtt)    &
1037                   - 0.389_wp  * (Tin(k)-rtt)**2 &
1038                   - 0.00362_wp* (Tin(k)-rtt)**3
1039             phi(k) = salin(k)/Sbr ! liquid fraction
1040          END DO
1041 
1042       END IF
1043     
1044       !-----------------------------------------------------------------
1045       ! permeability
1046       !-----------------------------------------------------------------
1047 
1048       perm = 3.0e-08_wp * (minval(phi))**3 ! REFERENCE PLEASE (this fucking
1049                                            ! bastard of Golden)
1050     
1051    END SUBROUTINE lim_mp_perm
1052!OLI_CODE   
1053!OLI_CODE #else
1054!OLI_CODE    !!----------------------------------------------------------------------
1055!OLI_CODE    !!   Default option         Dummy Module          No LIM-3 sea-ice model
1056!OLI_CODE    !!----------------------------------------------------------------------
1057!OLI_CODE CONTAINS
1058!OLI_CODE    SUBROUTINE lim_mp_init          ! Empty routine
1059!OLI_CODE    END SUBROUTINE lim_mp_init   
1060!OLI_CODE    SUBROUTINE lim_mp               ! Empty routine
1061!OLI_CODE    END SUBROUTINE lim_mp
1062!OLI_CODE    SUBROUTINE compute_mp_topo      ! Empty routine
1063!OLI_CODE    END SUBROUTINE compute_mp_topo       
1064!OLI_CODE    SUBROUTINE pond_area            ! Empty routine
1065!OLI_CODE    END SUBROUTINE pond_area   
1066!OLI_CODE    SUBROUTINE calc_hpond           ! Empty routine
1067!OLI_CODE    END SUBROUTINE calc_hpond   
1068!OLI_CODE    SUBROUTINE permeability_phy     ! Empty routine
1069!OLI_CODE    END SUBROUTINE permeability_phy   
1070!OLI_CODE #endif
1071!OLI_CODE    !!======================================================================
1072!OLI_CODE END MODULE limmp_topo
1073
1074
[7293]1075!OLI_CODE MODULE limmp_topo
1076!OLI_CODE    !!======================================================================
1077!OLI_CODE    !!                       ***  MODULE limmp_topo ***
1078!OLI_CODE    !! LIM-3 sea-ice :  computation of melt ponds' properties
1079!OLI_CODE    !!======================================================================
1080!OLI_CODE    !! History :  Original code by Daniela Flocco and Adrian Turner
1081!OLI_CODE    !!            ! 2012-09 (O. Lecomte) Adaptation for routine inclusion in
1082!OLI_CODE    !!                      NEMO-LIM3.1
1083!OLI_CODE    !!            ! 2016-11 (O. Lecomte, C. Rousset, M. Vancoppenolle)
1084!OLI_CODE    !!                      Adaptation for merge with NEMO-LIM3.6
1085!OLI_CODE    !!----------------------------------------------------------------------
1086!OLI_CODE #if defined key_lim3
1087!OLI_CODE    !!----------------------------------------------------------------------
1088!OLI_CODE    !!   'key_lim3'                                      LIM-3 sea-ice model
1089!OLI_CODE    !!----------------------------------------------------------------------
1090!OLI_CODE    !!   lim_mp_init     : melt pond properties initialization
1091!OLI_CODE    !!   lim_mp          : melt pond routine caller
1092!OLI_CODE    !!   compute_mp_topo : Actual melt pond routine
1093!OLI_CODE    !!----------------------------------------------------------------------
1094!OLI_CODE    USE ice_oce, ONLY: rdt_ice, tatm_ice
1095!OLI_CODE    USE phycst
1096!OLI_CODE    USE dom_ice
1097!OLI_CODE    USE dom_oce
1098!OLI_CODE    USE sbc_oce
1099!OLI_CODE    USE sbc_ice
1100!OLI_CODE    USE par_ice
1101!OLI_CODE    USE par_oce
1102!OLI_CODE    USE ice
1103!OLI_CODE    USE thd_ice
1104!OLI_CODE    USE in_out_manager
1105!OLI_CODE    USE lbclnk
1106!OLI_CODE    USE lib_mpp
1107!OLI_CODE
1108!OLI_CODE    IMPLICIT NONE
1109!OLI_CODE    PRIVATE
1110!OLI_CODE
1111!OLI_CODE    PUBLIC   lim_mp_init
1112!OLI_CODE    PUBLIC   lim_mp
1113!OLI_CODE
1114!OLI_CODE CONTAINS
1115!OLI_CODE
1116!OLI_CODE    SUBROUTINE lim_mp_init
1117!OLI_CODE       !!-------------------------------------------------------------------
1118!OLI_CODE       !!                ***  ROUTINE lim_mp_init  ***
1119!OLI_CODE       !!
1120!OLI_CODE       !! ** Purpose :   Initialize melt ponds
1121!OLI_CODE       !!-------------------------------------------------------------------
1122!OLI_CODE       a_ip_frac(:,:,:)    = 0._wp
1123!OLI_CODE       a_ip(:,:,:)         = 0._wp
1124!OLI_CODE       h_ip(:,:,:)         = 0._wp
1125!OLI_CODE       v_ip(:,:,:)         = 0._wp
1126!OLI_CODE       h_il(:,:,:)         = 0._wp
1127!OLI_CODE       v_il(:,:,:)         = 0._wp
1128!OLI_CODE         
1129!OLI_CODE    END SUBROUTINE lim_mp_init
1130!OLI_CODE
1131!OLI_CODE
1132!OLI_CODE    SUBROUTINE lim_mp
1133!OLI_CODE       !!-------------------------------------------------------------------
1134!OLI_CODE       !!                ***  ROUTINE lim_mp  ***
1135!OLI_CODE       !!
1136!OLI_CODE       !! ** Purpose :   Compute surface heat flux and call main melt pond
1137!OLI_CODE       !!                routine
1138!OLI_CODE       !!-------------------------------------------------------------------
1139!OLI_CODE
1140!OLI_CODE       INTEGER  ::   ji, jj, jl   ! dummy loop indices
1141!OLI_CODE
1142!OLI_CODE       fsurf(:,:) = 0.e0
1143!OLI_CODE       DO jl = 1, jpl
1144!OLI_CODE          DO jj = 1, jpj
1145!OLI_CODE             DO ji = 1, jpi
1146!OLI_CODE                fsurf(ji,jj) = fsurf(ji,jj) + a_i(ji,jj,jl) * &
1147!OLI_CODE                      (qns_ice(ji,jj,jl) + (1.0 - izero(ji,jj,jl)) &
1148!OLI_CODE                        * qsr_ice(ji,jj,jl))
1149!OLI_CODE             END DO
1150!OLI_CODE          END DO
1151!OLI_CODE       END DO
1152!OLI_CODE
1153!OLI_CODE       CALL compute_mp_topo(at_i, a_i,                               &
1154!OLI_CODE                          vt_i, v_i, v_s, rhosn_glo, t_i, s_i, a_ip_frac,  &
1155!OLI_CODE                       h_ip, h_il, t_su, tatm_ice, diag_sur_me*rdt_ice, &
1156!OLI_CODE                          fsurf, fwoc)
1157!OLI_CODE
1158!OLI_CODE       at_ip(:,:) = 0.0
1159!OLI_CODE       vt_ip(:,:) = 0.0
1160!OLI_CODE       vt_il(:,:) = 0.0
1161!OLI_CODE       DO jl = 1, jpl
1162!OLI_CODE         DO jj = 1, jpj
1163!OLI_CODE            DO ji = 1, jpi
1164!OLI_CODE               a_ip(ji,jj,jl) = MAX(0.0_wp, a_ip_frac(ji,jj,jl) * &
1165!OLI_CODE                                                   a_i(ji,jj,jl))
1166!OLI_CODE               v_ip(ji,jj,jl) = MAX(0.0_wp, a_ip_frac(ji,jj,jl) * &
1167!OLI_CODE                                   a_i(ji,jj,jl) * h_ip(ji,jj,jl))
1168!OLI_CODE               v_il(ji,jj,jl) = MAX(0.0_wp, a_ip_frac(ji,jj,jl) * &
1169!OLI_CODE                                   a_i(ji,jj,jl) * h_il(ji,jj,jl))
1170!OLI_CODE               at_ip(ji,jj)   = at_ip(ji,jj) + a_ip(ji,jj,jl)
1171!OLI_CODE               vt_ip(ji,jj)   = vt_ip(ji,jj) + v_ip(ji,jj,jl)
1172!OLI_CODE               vt_il(ji,jj)   = vt_il(ji,jj) + v_il(ji,jj,jl)
1173!OLI_CODE            END DO
1174!OLI_CODE         END DO
1175!OLI_CODE       END DO
1176!OLI_CODE
1177!OLI_CODE    END SUBROUTINE lim_mp
1178!OLI_CODE
1179!OLI_CODE
1180!OLI_CODE    SUBROUTINE compute_mp_topo(aice,      aicen,     &
1181!OLI_CODE                               vice,      vicen,     &
1182!OLI_CODE                               vsnon,     rhos,      &
1183!OLI_CODE                               ticen,     salin,     &
1184!OLI_CODE                               a_ip_frac, h_ip,      &
1185!OLI_CODE                               h_il,      Tsfc,      &
1186!OLI_CODE                               potT,      meltt,     &
1187!OLI_CODE                               fsurf,     fwoc)
1188!OLI_CODE       !!-------------------------------------------------------------------
1189!OLI_CODE       !!                ***  ROUTINE compute_mp_topo  ***
1190!OLI_CODE       !!
1191!OLI_CODE       !! ** Purpose :   Compute melt pond evolution based on the ice
1192!OLI_CODE       !!                topography as inferred from the ice thickness
1193!OLI_CODE       !!                distribution. 
1194!OLI_CODE       !!
1195!OLI_CODE       !! ** Method  :   This code is initially based on Flocco and Feltham
1196!OLI_CODE       !!                (2007) and Flocco et al. (2010). More to come...
1197!OLI_CODE       !!
1198!OLI_CODE       !! ** Tunable parameters :
1199!OLI_CODE       !!
1200!OLI_CODE       !! ** Note :
1201!OLI_CODE       !!
1202!OLI_CODE       !! ** References
1203!OLI_CODE       !!    Flocco, D. and D. L. Feltham, 2007.  A continuum model of melt pond
1204!OLI_CODE       !!    evolution on Arctic sea ice.  J. Geophys. Res. 112, C08016, doi:
1205!OLI_CODE       !!    10.1029/2006JC003836.
1206!OLI_CODE       !!    Flocco, D., D. L. Feltham and A. K. Turner, 2010.  Incorporation of
1207!OLI_CODE       !!    a physically based melt pond scheme into the sea ice component of a
1208!OLI_CODE       !!    climate model.  J. Geophys. Res. 115, C08012,
1209!OLI_CODE       !!    doi: 10.1029/2009JC005568.
1210!OLI_CODE       !!   
1211!OLI_CODE       !!-------------------------------------------------------------------
1212!OLI_CODE
1213!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj), &
1214!OLI_CODE          INTENT(IN) :: &
1215!OLI_CODE          aice, &    ! total ice area fraction
1216!OLI_CODE          vice       ! total ice volume (m)
1217!OLI_CODE
1218!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl), &
1219!OLI_CODE          INTENT(IN) :: &
1220!OLI_CODE          aicen, &   ! ice area fraction, per category
1221!OLI_CODE          vsnon, &   ! snow volume, per category (m)
1222!OLI_CODE          rhos,  &   ! equivalent snow density, per category (kg/m^3)
1223!OLI_CODE          vicen      ! ice volume, per category (m)
1224!OLI_CODE
1225!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,nlay_i,jpl), &
1226!OLI_CODE          INTENT(IN) :: &
1227!OLI_CODE          ticen, &   ! ice enthalpy, per category
1228!OLI_CODE          salin
1229!OLI_CODE
1230!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl), &
1231!OLI_CODE          INTENT(INOUT) :: &
1232!OLI_CODE          a_ip_frac , &   ! pond area fraction of ice, per ice category
1233!OLI_CODE          h_ip , &   ! pond depth, per ice category (m)
1234!OLI_CODE          h_il       ! Refrozen ice lid thickness, per ice category (m)
1235!OLI_CODE
1236!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj), &
1237!OLI_CODE          INTENT(IN) :: &
1238!OLI_CODE          potT,  &   ! air potential temperature
1239!OLI_CODE          meltt, &   ! total surface meltwater flux
1240!OLI_CODE          fsurf      ! thermodynamic heat flux at ice/snow surface (W/m^2)
1241!OLI_CODE
1242!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj), &
1243!OLI_CODE          INTENT(INOUT) :: &
1244!OLI_CODE          fwoc      ! fresh water flux to the ocean (from draining and other pond volume adjustments)
1245!OLI_CODE                    ! (m)
1246!OLI_CODE
1247!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl), &
1248!OLI_CODE          INTENT(IN) :: &
1249!OLI_CODE          Tsfc       ! snow/sea ice surface temperature
1250!OLI_CODE
1251!OLI_CODE       ! local variables
1252!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl) :: &
1253!OLI_CODE          zTsfcn, & ! ice/snow surface temperature (C)
1254!OLI_CODE          zvolpn, & ! pond volume per unit area, per category (m)
1255!OLI_CODE          zvuin     ! water-equivalent volume of ice lid on melt pond ('upper ice', m)
1256!OLI_CODE
1257!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl) :: &
1258!OLI_CODE          zapondn,& ! pond area fraction, per category
1259!OLI_CODE          zhpondn   ! pond depth, per category (m)
1260!OLI_CODE
1261!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj) :: &
1262!OLI_CODE          zvolp       ! total volume of pond, per unit area of pond (m)
1263!OLI_CODE
1264!OLI_CODE       REAL (wp) :: &
1265!OLI_CODE          zhi,    & ! ice thickness (m)
1266!OLI_CODE          zdHui,  & ! change in thickness of ice lid (m)
1267!OLI_CODE          zomega, & ! conduction
1268!OLI_CODE          zdTice, & ! temperature difference across ice lid (C)
1269!OLI_CODE          zdvice, & ! change in ice volume (m)
1270!OLI_CODE          zTavg,  & ! mean surface temperature across categories (C)
1271!OLI_CODE          zTp,    & ! pond freezing temperature (C)
1272!OLI_CODE          zdvn      ! change in melt pond volume for fresh water budget
1273!OLI_CODE       INTEGER, DIMENSION (jpi*jpj) :: &
1274!OLI_CODE          indxi, indxj    ! compressed indices for cells with ice melting
1275!OLI_CODE
1276!OLI_CODE       INTEGER :: n,k,i,j,ij,icells,indxij ! loop indices
1277!OLI_CODE
1278!OLI_CODE       INTEGER, DIMENSION (jpl) :: &
1279!OLI_CODE          kcells          ! cells where ice lid combines with vice
1280!OLI_CODE
1281!OLI_CODE       INTEGER, DIMENSION (jpi*jpj,jpl) :: &
1282!OLI_CODE          indxii, indxjj  ! i,j indices for kcells loop
1283!OLI_CODE
1284!OLI_CODE       REAL (wp), parameter :: &
1285!OLI_CODE          zhicemin  = 0.1_wp , & ! minimum ice thickness with ponds (m)
1286!OLI_CODE          zTd       = 0.15_wp, & ! temperature difference for freeze-up (C)
1287!OLI_CODE          zr1_rlfus = 1._wp / 0.334e+6 / 917._wp , & ! (J/m^3)
1288!OLI_CODE          zmin_volp = 1.e-4_wp, & ! minimum pond volume (m)
1289!OLI_CODE          z0       = 0._wp,    &
1290!OLI_CODE          zTimelt   = 0._wp,    &
1291!OLI_CODE          z01      = 0.01_wp,  &
1292!OLI_CODE          z25      = 0.25_wp,  &
1293!OLI_CODE          z5       = 0.5_wp,   &
[7325]1294!OLI_CODE          epsi10     = 1.0e-11_wp
[7293]1295!OLI_CODE       !---------------------------------------------------------------
1296!OLI_CODE       ! initialize
1297!OLI_CODE       !---------------------------------------------------------------
1298!OLI_CODE
1299!OLI_CODE       DO j = 1, jpj
1300!OLI_CODE          DO i = 1, jpi
1301!OLI_CODE             zvolp(i,j) = z0
1302!OLI_CODE          END DO
1303!OLI_CODE       END DO
1304!OLI_CODE       DO n = 1, jpl
1305!OLI_CODE          DO j = 1, jpj
1306!OLI_CODE             DO i = 1, jpi
1307!OLI_CODE                ! load tracers
1308!OLI_CODE                zvolp(i,j) = zvolp(i,j) + h_ip(i,j,n) &
1309!OLI_CODE                                      * a_ip_frac(i,j,n) * aicen(i,j,n)
1310!OLI_CODE                zTsfcn(i,j,n) = Tsfc(i,j,n) - rtt ! convert in Celsius - Oli
1311!OLI_CODE                zvuin (i,j,n) = h_il(i,j,n) &
1312!OLI_CODE                             * a_ip_frac(i,j,n) * aicen(i,j,n)
1313!OLI_CODE
1314!OLI_CODE                zhpondn(i,j,n) = z0     ! pond depth, per category
1315!OLI_CODE                zapondn(i,j,n) = z0     ! pond area,  per category
1316!OLI_CODE             END DO
1317!OLI_CODE          END DO
1318!OLI_CODE          indxii(:,n) = 0
1319!OLI_CODE          indxjj(:,n) = 0
1320!OLI_CODE          kcells  (n) = 0
1321!OLI_CODE       END DO
1322!OLI_CODE
1323!OLI_CODE       ! The freezing temperature for meltponds is assumed slightly below 0C,
1324!OLI_CODE       ! as if meltponds had a little salt in them.  The salt budget is not
1325!OLI_CODE       ! altered for meltponds, but if it were then an actual pond freezing
1326!OLI_CODE       ! temperature could be computed.
1327!OLI_CODE
1328!OLI_CODE       zTp = zTimelt - zTd
1329!OLI_CODE
1330!OLI_CODE       !-----------------------------------------------------------------
1331!OLI_CODE       ! Identify grid cells with ponds
1332!OLI_CODE       !-----------------------------------------------------------------
1333!OLI_CODE
1334!OLI_CODE       icells = 0
1335!OLI_CODE       DO j = 1, jpj
1336!OLI_CODE       DO i = 1, jpi
1337!OLI_CODE          zhi = z0
[7325]1338!OLI_CODE          IF (aice(i,j) > epsi10) zhi = vice(i,j)/aice(i,j)
[7293]1339!OLI_CODE          IF ( aice(i,j) > z01 .and. zhi > zhicemin .and. &
1340!OLI_CODE             zvolp(i,j) > zmin_volp*aice(i,j)) THEN
1341!OLI_CODE             icells = icells + 1
1342!OLI_CODE             indxi(icells) = i
1343!OLI_CODE             indxj(icells) = j
1344!OLI_CODE          ELSE  ! remove ponds on thin ice
1345!OLI_CODE             !fpond(i,j) = fpond(i,j) - zvolp(i,j)
1346!OLI_CODE             zvolpn(i,j,:) = z0
1347!OLI_CODE             zvuin (i,j,:) = z0
1348!OLI_CODE             zvolp (i,j) = z0
1349!OLI_CODE          END IF
1350!OLI_CODE       END DO                     ! i
1351!OLI_CODE       END DO                     ! j
1352!OLI_CODE
1353!OLI_CODE       DO ij = 1, icells
1354!OLI_CODE          i = indxi(ij)
1355!OLI_CODE          j = indxj(ij)
1356!OLI_CODE
1357!OLI_CODE          !--------------------------------------------------------------
1358!OLI_CODE          ! calculate pond area and depth
1359!OLI_CODE          !--------------------------------------------------------------
1360!OLI_CODE          CALL pond_area(aice(i,j),vice(i,j),rhos(i,j,:), &
1361!OLI_CODE                    aicen(i,j,:), vicen(i,j,:), vsnon(i,j,:), &
1362!OLI_CODE                    ticen(i,j,:,:), salin(i,j,:,:), &
1363!OLI_CODE                    zvolpn(i,j,:), zvolp(i,j), &
1364!OLI_CODE                    zapondn(i,j,:),zhpondn(i,j,:), zdvn)
1365!OLI_CODE
1366!OLI_CODE          fwoc(i,j) = fwoc(i,j) + zdvn ! -> Goes to fresh water budget
1367!OLI_CODE
1368!OLI_CODE          ! mean surface temperature
1369!OLI_CODE          zTavg = z0
1370!OLI_CODE          DO n = 1, jpl
1371!OLI_CODE             zTavg = zTavg + zTsfcn(i,j,n)*aicen(i,j,n)
1372!OLI_CODE          END DO
1373!OLI_CODE          zTavg = zTavg / aice(i,j)
1374!OLI_CODE
1375!OLI_CODE          DO n = 1, jpl-1
1376!OLI_CODE                       
[7325]1377!OLI_CODE             IF (zvuin(i,j,n) > epsi10) THEN
[7293]1378!OLI_CODE
1379!OLI_CODE          !----------------------------------------------------------------
1380!OLI_CODE          ! melting: floating upper ice layer melts in whole or part
1381!OLI_CODE          !----------------------------------------------------------------
1382!OLI_CODE !               IF (zTsfcn(i,j,n) > zTp) THEN
1383!OLI_CODE                IF (zTavg > zTp) THEN
1384!OLI_CODE
1385!OLI_CODE                   zdvice = min(meltt(i,j)*zapondn(i,j,n), zvuin(i,j,n))
[7325]1386!OLI_CODE                   IF (zdvice > epsi10) THEN
[7293]1387!OLI_CODE                      zvuin (i,j,n) = zvuin (i,j,n) - zdvice
1388!OLI_CODE                      zvolpn(i,j,n) = zvolpn(i,j,n) + zdvice
1389!OLI_CODE                      zvolp (i,j)   = zvolp (i,j)   + zdvice
1390!OLI_CODE                      !fwoc(i,j)   = fwoc(i,j)   + zdvice
1391!OLI_CODE                       
[7325]1392!OLI_CODE                      IF (zvuin(i,j,n) < epsi10 .and. zvolpn(i,j,n) > puny) THEN
[7293]1393!OLI_CODE                         ! ice lid melted and category is pond covered
1394!OLI_CODE                         zvolpn(i,j,n) = zvolpn(i,j,n) + zvuin(i,j,n)
1395!OLI_CODE                         !fwoc(i,j)   = fwoc(i,j)   + zvuin(i,j,n)
1396!OLI_CODE                         zvuin(i,j,n)  = z0
1397!OLI_CODE                      END IF
1398!OLI_CODE                      zhpondn(i,j,n) = zvolpn(i,j,n) / zapondn(i,j,n)
1399!OLI_CODE                   END IF
1400!OLI_CODE
1401!OLI_CODE          !----------------------------------------------------------------
1402!OLI_CODE          ! freezing: existing upper ice layer grows
1403!OLI_CODE          !----------------------------------------------------------------
[7325]1404!OLI_CODE                ELSE IF (zvolpn(i,j,n) > epsi10) THEN ! zTavg <= zTp
[7293]1405!OLI_CODE
1406!OLI_CODE                 ! dIFferential growth of base of surface floating ice layer
1407!OLI_CODE                   zdTice = max(-zTavg, z0) ! > 0
1408!OLI_CODE                   zomega = rcdic*zdTice * zr1_rlfus
1409!OLI_CODE                   zdHui = sqrt(zomega*rdt_ice + z25*(zvuin(i,j,n)/  &
1410!OLI_CODE                         aicen(i,j,n))**2)- z5 * zvuin(i,j,n)/aicen(i,j,n)
1411!OLI_CODE
1412!OLI_CODE                   zdvice = min(zdHui*zapondn(i,j,n), zvolpn(i,j,n))   
[7325]1413!OLI_CODE                   IF (zdvice > epsi10) THEN
[7293]1414!OLI_CODE                      zvuin (i,j,n) = zvuin (i,j,n) + zdvice
1415!OLI_CODE                      zvolpn(i,j,n) = zvolpn(i,j,n) - zdvice
1416!OLI_CODE                      zvolp (i,j)   = zvolp (i,j)   - zdvice
1417!OLI_CODE                      !fwoc(i,j)   = fwoc(i,j)   - zdvice
1418!OLI_CODE                      zhpondn(i,j,n) = zvolpn(i,j,n) / zapondn(i,j,n)
1419!OLI_CODE                   END IF
1420!OLI_CODE
1421!OLI_CODE                END IF ! zTavg
1422!OLI_CODE
1423!OLI_CODE          !----------------------------------------------------------------
1424!OLI_CODE          ! freezing: upper ice layer begins to form
1425!OLI_CODE          ! note: albedo does not change
1426!OLI_CODE          !----------------------------------------------------------------
[7325]1427!OLI_CODE             ELSE ! zvuin < epsi10
[7293]1428!OLI_CODE                     
1429!OLI_CODE                ! thickness of newly formed ice
1430!OLI_CODE                ! the surface temperature of a meltpond is the same as that
1431!OLI_CODE                ! of the ice underneath (0C), and the thermodynamic surface
1432!OLI_CODE                ! flux is the same
1433!OLI_CODE                zdHui = max(-fsurf(i,j)*rdt_ice*zr1_rlfus, z0)
1434!OLI_CODE                zdvice = min(zdHui*zapondn(i,j,n), zvolpn(i,j,n)) 
[7325]1435!OLI_CODE                IF (zdvice > epsi10) THEN
[7293]1436!OLI_CODE                   zvuin (i,j,n) = zdvice
1437!OLI_CODE                   zvolpn(i,j,n) = zvolpn(i,j,n) - zdvice
1438!OLI_CODE                   zvolp (i,j)   = zvolp (i,j)   - zdvice
1439!OLI_CODE                   !fwoc(i,j)   = fwoc(i,j)   - zdvice
1440!OLI_CODE                   zhpondn(i,j,n)= zvolpn(i,j,n) / zapondn(i,j,n)
1441!OLI_CODE                END IF
1442!OLI_CODE                     
1443!OLI_CODE             END IF  ! zvuin
1444!OLI_CODE
1445!OLI_CODE          END DO ! jpl
1446!OLI_CODE
1447!OLI_CODE       END DO ! ij
1448!OLI_CODE
1449!OLI_CODE       !---------------------------------------------------------------
1450!OLI_CODE       ! remove ice lid if there is no liquid pond
1451!OLI_CODE       ! zvuin may be nonzero on category jpl due to dynamics
1452!OLI_CODE       !---------------------------------------------------------------
1453!OLI_CODE
1454!OLI_CODE       DO j = 1, jpj
1455!OLI_CODE       DO i = 1, jpi
1456!OLI_CODE          DO n = 1, jpl
[7325]1457!OLI_CODE             IF (aicen(i,j,n) > epsi10 .and. zvolpn(i,j,n) < puny &
1458!OLI_CODE                                     .and. zvuin (i,j,n) > epsi10) THEN
[7293]1459!OLI_CODE                kcells(n) = kcells(n) + 1
1460!OLI_CODE                indxij    = kcells(n)
1461!OLI_CODE                indxii(indxij,n) = i
1462!OLI_CODE                indxjj(indxij,n) = j
1463!OLI_CODE             END IF
1464!OLI_CODE          END DO
1465!OLI_CODE       END DO                     ! i
1466!OLI_CODE       END DO                     ! j
1467!OLI_CODE
1468!OLI_CODE       DO n = 1, jpl
1469!OLI_CODE
1470!OLI_CODE          IF (kcells(n) > 0) THEN
1471!OLI_CODE          DO ij = 1, kcells(n)
1472!OLI_CODE             i = indxii(ij,n)
1473!OLI_CODE             j = indxjj(ij,n)
1474!OLI_CODE             fwoc(i,j) = fwoc(i,j) + rhoic/rauw * zvuin(i,j,n) ! Completely refrozen lid goes into ocean (to be changed)
1475!OLI_CODE             zvuin(i,j,n) = z0
1476!OLI_CODE          END DO    ! ij
1477!OLI_CODE          END IF
1478!OLI_CODE
1479!OLI_CODE          ! reload tracers
1480!OLI_CODE          DO j = 1, jpj
1481!OLI_CODE             DO i = 1, jpi
[7325]1482!OLI_CODE                IF (zapondn(i,j,n) > epsi10) THEN
[7293]1483!OLI_CODE                   h_il(i,j,n) = zvuin(i,j,n) / zapondn(i,j,n)
1484!OLI_CODE                ELSE
1485!OLI_CODE                   zvuin(i,j,n) = z0
1486!OLI_CODE                   h_il(i,j,n) = z0
1487!OLI_CODE                END IF
[7325]1488!OLI_CODE                IF (aicen(i,j,n) > epsi10) THEN
[7293]1489!OLI_CODE                   a_ip_frac(i,j,n) = zapondn(i,j,n) / aicen(i,j,n) * &
1490!OLI_CODE                         (1.0_wp - MAX(z0, SIGN(1.0_wp, -zvolpn(i,j,n))))
1491!OLI_CODE                   h_ip(i,j,n) = zhpondn(i,j,n)
1492!OLI_CODE                ELSE
1493!OLI_CODE                   a_ip_frac(i,j,n) = z0
1494!OLI_CODE                   h_ip(i,j,n) = z0
1495!OLI_CODE                   h_il(i,j,n) = z0
1496!OLI_CODE                END IF
1497!OLI_CODE             END DO ! i
1498!OLI_CODE          END DO    ! j
1499!OLI_CODE
1500!OLI_CODE       END DO       ! n
1501!OLI_CODE
1502!OLI_CODE    END SUBROUTINE compute_mp_topo
1503!OLI_CODE
1504!OLI_CODE
1505!OLI_CODE    SUBROUTINE pond_area(aice,vice,rhos,             &
1506!OLI_CODE                         aicen, vicen, vsnon, ticen, &
1507!OLI_CODE                         salin, zvolpn, zvolp,         &
1508!OLI_CODE                         zapondn,zhpondn,dvolp)
1509!OLI_CODE       !!-------------------------------------------------------------------
1510!OLI_CODE       !!                ***  ROUTINE pond_area  ***
1511!OLI_CODE       !!
1512!OLI_CODE       !! ** Purpose :   Compute melt pond area, depth and melting rates
1513!OLI_CODE       !!------------------------------------------------------------------
1514!OLI_CODE       REAL (wp), INTENT(IN) :: &
1515!OLI_CODE          aice,vice
1516!OLI_CODE
1517!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(IN) :: &
1518!OLI_CODE          aicen, vicen, vsnon, rhos
1519!OLI_CODE
1520!OLI_CODE       REAL (wp), DIMENSION(nlay_i,jpl), INTENT(IN) :: &
1521!OLI_CODE          ticen, salin
1522!OLI_CODE
1523!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(INOUT) :: &
1524!OLI_CODE          zvolpn
1525!OLI_CODE
1526!OLI_CODE       REAL (wp), INTENT(INOUT) :: &
1527!OLI_CODE          zvolp, dvolp
1528!OLI_CODE
1529!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(OUT) :: &
1530!OLI_CODE          zapondn, zhpondn
1531!OLI_CODE
1532!OLI_CODE       INTEGER :: &
1533!OLI_CODE          n, ns,   &
1534!OLI_CODE          m_index, &
1535!OLI_CODE          permflag
1536!OLI_CODE
1537!OLI_CODE       REAL (wp), DIMENSION(jpl) :: &
1538!OLI_CODE          hicen, &
1539!OLI_CODE          hsnon, &
1540!OLI_CODE          asnon, &
1541!OLI_CODE          alfan, &
1542!OLI_CODE          betan, &
1543!OLI_CODE          cum_max_vol, &
1544!OLI_CODE          reduced_aicen       
1545!OLI_CODE
1546!OLI_CODE       REAL (wp), DIMENSION(0:jpl) :: &
1547!OLI_CODE          cum_max_vol_tmp
1548!OLI_CODE
1549!OLI_CODE       REAL (wp) :: &
1550!OLI_CODE          hpond, &
1551!OLI_CODE          drain, &
1552!OLI_CODE          floe_weight, &
1553!OLI_CODE          pressure_head, &
1554!OLI_CODE          hsl_rel, &
1555!OLI_CODE          deltah, &
1556!OLI_CODE          perm, &
1557!OLI_CODE          apond, &
1558!OLI_CODE          msno
1559!OLI_CODE
1560!OLI_CODE       REAL (wp), parameter :: &
1561!OLI_CODE          viscosity = 1.79e-3_wp, &  ! kinematic water viscosity in kg/m/s
1562!OLI_CODE          z0        = 0.0_wp    , &
1563!OLI_CODE          c1        = 1.0_wp    , &
1564!OLI_CODE          p4        = 0.4_wp    , &
1565!OLI_CODE          p6        = 0.6_wp    , &
[7325]1566!OLI_CODE          epsi10      = 1.0e-11_wp
[7293]1567!OLI_CODE         
1568!OLI_CODE      !-----------|
1569!OLI_CODE      !           |
1570!OLI_CODE      !           |-----------|
1571!OLI_CODE      !___________|___________|______________________________________sea-level
1572!OLI_CODE      !           |           |
1573!OLI_CODE      !           |           |---^--------|
1574!OLI_CODE      !           |           |   |        |
1575!OLI_CODE      !           |           |   |        |-----------|              |-------
1576!OLI_CODE      !           |           |   |alfan(n)|           |              |
1577!OLI_CODE      !           |           |   |        |           |--------------|
1578!OLI_CODE      !           |           |   |        |           |              |
1579!OLI_CODE      !---------------------------v-------------------------------------------
1580!OLI_CODE      !           |           |   ^        |           |              |
1581!OLI_CODE      !           |           |   |        |           |--------------|
1582!OLI_CODE      !           |           |   |betan(n)|           |              |
1583!OLI_CODE      !           |           |   |        |-----------|              |-------
1584!OLI_CODE      !           |           |   |        |
1585!OLI_CODE      !           |           |---v------- |
1586!OLI_CODE      !           |           |
1587!OLI_CODE      !           |-----------|
1588!OLI_CODE      !           |
1589!OLI_CODE      !-----------|
1590!OLI_CODE     
1591!OLI_CODE       !-------------------------------------------------------------------
1592!OLI_CODE       ! initialize
1593!OLI_CODE       !-------------------------------------------------------------------
1594!OLI_CODE
1595!OLI_CODE       DO n = 1, jpl
1596!OLI_CODE
1597!OLI_CODE          zapondn(n) = z0
1598!OLI_CODE          zhpondn(n) = z0
1599!OLI_CODE
[7325]1600!OLI_CODE          IF (aicen(n) < epsi10)  THEN
[7293]1601!OLI_CODE             hicen(n) =  z0
1602!OLI_CODE             hsnon(n) = z0
1603!OLI_CODE             reduced_aicen(n) = z0
1604!OLI_CODE          ELSE
1605!OLI_CODE             hicen(n) = vicen(n) / aicen(n)
1606!OLI_CODE             hsnon(n) = vsnon(n) / aicen(n)
1607!OLI_CODE             reduced_aicen(n) = c1 ! n=jpl
1608!OLI_CODE             IF (n < jpl) reduced_aicen(n) = aicen(n) &
1609!OLI_CODE                                  * (-0.024_wp*hicen(n) + 0.832_wp)
1610!OLI_CODE             asnon(n) = reduced_aicen(n)
1611!OLI_CODE          END IF
1612!OLI_CODE
1613!OLI_CODE ! This choice for alfa and beta ignores hydrostatic equilibium of categories.
1614!OLI_CODE ! Hydrostatic equilibium of the entire ITD is accounted for below, assuming
1615!OLI_CODE ! a surface topography implied by alfa=0.6 and beta=0.4, and rigidity across all
1616!OLI_CODE ! categories.  alfa and beta partition the ITD - they are areas not thicknesses!
1617!OLI_CODE ! Multiplying by hicen, alfan and betan (below) are thus volumes per unit area.
1618!OLI_CODE ! Here, alfa = 60% of the ice area (and since hice is constant in a category,
1619!OLI_CODE ! alfan = 60% of the ice volume) in each category lies above the reference line,
1620!OLI_CODE ! and 40% below. Note: p6 is an arbitrary choice, but alfa+beta=1 is required.
1621!OLI_CODE
1622!OLI_CODE          alfan(n) = p6 * hicen(n)
1623!OLI_CODE          betan(n) = p4 * hicen(n)
1624!OLI_CODE       
1625!OLI_CODE          cum_max_vol(n)     = z0
1626!OLI_CODE          cum_max_vol_tmp(n) = z0
1627!OLI_CODE     
1628!OLI_CODE       END DO ! jpl
1629!OLI_CODE
1630!OLI_CODE       cum_max_vol_tmp(0) = z0
1631!OLI_CODE       drain = z0
1632!OLI_CODE       dvolp = z0
1633!OLI_CODE     
1634!OLI_CODE       !--------------------------------------------------------------------------
1635!OLI_CODE       ! the maximum amount of water that can be contained up to each ice category
1636!OLI_CODE       !--------------------------------------------------------------------------
1637!OLI_CODE     
1638!OLI_CODE       DO n = 1, jpl-1 ! last category can not hold any volume
1639!OLI_CODE
1640!OLI_CODE          IF (alfan(n+1) >= alfan(n) .and. alfan(n+1) > z0) THEN
1641!OLI_CODE
1642!OLI_CODE             ! total volume in level including snow
1643!OLI_CODE             cum_max_vol_tmp(n) = cum_max_vol_tmp(n-1) + &
1644!OLI_CODE                (alfan(n+1) - alfan(n)) * sum(reduced_aicen(1:n))
1645!OLI_CODE
1646!OLI_CODE
1647!OLI_CODE             ! subtract snow solid volumes from lower categories in current level
1648!OLI_CODE             DO ns = 1, n
1649!OLI_CODE                cum_max_vol_tmp(n) = cum_max_vol_tmp(n) &
1650!OLI_CODE                   - rhos(ns)/rauw  * &    ! fraction of snow that is occupied by solid ??rauw
1651!OLI_CODE                     asnon(ns)  * &    ! area of snow from that category
1652!OLI_CODE                     max(min(hsnon(ns)+alfan(ns)-alfan(n), alfan(n+1)- &
1653!OLI_CODE                                   alfan(n)), z0) 
1654!OLI_CODE                                       ! thickness of snow from ns layer in n layer
1655!OLI_CODE             END DO
1656!OLI_CODE
1657!OLI_CODE          ELSE ! assume higher categories unoccupied
1658!OLI_CODE             cum_max_vol_tmp(n) = cum_max_vol_tmp(n-1)
1659!OLI_CODE          END IF
1660!OLI_CODE          !IF (cum_max_vol_tmp(n) < z0) THEN
1661!OLI_CODE          !   call abort_ice('negative melt pond volume')
1662!OLI_CODE          !END IF
1663!OLI_CODE       END DO
1664!OLI_CODE       cum_max_vol_tmp(jpl) = cum_max_vol_tmp(jpl-1)  ! last category holds no volume
1665!OLI_CODE       cum_max_vol  (1:jpl) = cum_max_vol_tmp(1:jpl)
1666!OLI_CODE     
1667!OLI_CODE       !----------------------------------------------------------------
1668!OLI_CODE       ! is there more meltwater than can be held in the floe?
1669!OLI_CODE       !----------------------------------------------------------------
1670!OLI_CODE       IF (zvolp >= cum_max_vol(jpl)) THEN
[7325]1671!OLI_CODE          drain = zvolp - cum_max_vol(jpl) + epsi10
[7293]1672!OLI_CODE          zvolp = zvolp - drain
1673!OLI_CODE          dvolp = drain
[7325]1674!OLI_CODE          IF (zvolp < epsi10) THEN
[7293]1675!OLI_CODE             dvolp = dvolp + zvolp
1676!OLI_CODE             zvolp = z0
1677!OLI_CODE          END IF
1678!OLI_CODE       END IF
1679!OLI_CODE     
1680!OLI_CODE       ! height and area corresponding to the remaining volume
1681!OLI_CODE
1682!OLI_CODE       call calc_hpond(reduced_aicen, asnon, hsnon, rhos, alfan, &
1683!OLI_CODE            zvolp, cum_max_vol, hpond, m_index)
1684!OLI_CODE     
1685!OLI_CODE       DO n=1, m_index
1686!OLI_CODE          zhpondn(n) = hpond - alfan(n) + alfan(1)
1687!OLI_CODE          zapondn(n) = reduced_aicen(n)
1688!OLI_CODE       END DO
1689!OLI_CODE       apond = sum(zapondn(1:m_index))
1690!OLI_CODE     
1691!OLI_CODE       !------------------------------------------------------------------------
1692!OLI_CODE       ! drainage due to ice permeability - Darcy's law
1693!OLI_CODE       !------------------------------------------------------------------------
1694!OLI_CODE     
1695!OLI_CODE       ! sea water level
1696!OLI_CODE       msno = z0
1697!OLI_CODE       DO n=1,jpl
1698!OLI_CODE         msno = msno + vsnon(n) * rhos(n)
1699!OLI_CODE       END DO
1700!OLI_CODE       floe_weight = (msno + rhoic*vice + rau0*zvolp) / aice
1701!OLI_CODE       hsl_rel = floe_weight / rau0 &
1702!OLI_CODE               - ((sum(betan(:)*aicen(:))/aice) + alfan(1))
1703!OLI_CODE     
1704!OLI_CODE       deltah = hpond - hsl_rel
1705!OLI_CODE       pressure_head = grav * rau0 * max(deltah, z0)
1706!OLI_CODE
1707!OLI_CODE       ! drain IF ice is permeable   
1708!OLI_CODE       permflag = 0
1709!OLI_CODE       IF (pressure_head > z0) THEN
1710!OLI_CODE       DO n = 1, jpl-1
1711!OLI_CODE          IF (hicen(n) /= z0) THEN
1712!OLI_CODE             CALL permeability_phi(ticen(:,n), salin(:,n), vicen(n), perm)
1713!OLI_CODE             IF (perm > z0) permflag = 1
1714!OLI_CODE             drain = perm*zapondn(n)*pressure_head*rdt_ice / &
1715!OLI_CODE                                      (viscosity*hicen(n))
1716!OLI_CODE             dvolp = dvolp + min(drain, zvolp)
1717!OLI_CODE             zvolp = max(zvolp - drain, z0)
[7325]1718!OLI_CODE             IF (zvolp < epsi10) THEN
[7293]1719!OLI_CODE                dvolp = dvolp + zvolp
1720!OLI_CODE                zvolp = z0
1721!OLI_CODE             END IF
1722!OLI_CODE          END IF
1723!OLI_CODE       END DO
1724!OLI_CODE 
1725!OLI_CODE       ! adjust melt pond DIMENSIONs
1726!OLI_CODE       IF (permflag > 0) THEN
1727!OLI_CODE          ! recompute pond depth   
1728!OLI_CODE          CALL calc_hpond(reduced_aicen, asnon, hsnon, rhos, alfan, &
1729!OLI_CODE                          zvolp, cum_max_vol, hpond, m_index)
1730!OLI_CODE          DO n=1, m_index
1731!OLI_CODE             zhpondn(n) = hpond - alfan(n) + alfan(1)
1732!OLI_CODE             zapondn(n) = reduced_aicen(n)
1733!OLI_CODE          END DO
1734!OLI_CODE          apond = sum(zapondn(1:m_index))
1735!OLI_CODE       END IF
1736!OLI_CODE       END IF ! pressure_head
1737!OLI_CODE
1738!OLI_CODE       !------------------------------------------------------------------------
1739!OLI_CODE       ! total melt pond volume in category DOes not include snow volume
1740!OLI_CODE       ! snow in melt ponds is not melted
1741!OLI_CODE       !------------------------------------------------------------------------
1742!OLI_CODE
1743!OLI_CODE       ! Calculate pond volume for lower categories
1744!OLI_CODE       DO n=1,m_index-1
1745!OLI_CODE          zvolpn(n) = zapondn(n) * zhpondn(n) &
1746!OLI_CODE                   - (rhos(n)/rauw) * asnon(n) * min(hsnon(n), zhpondn(n))!
1747!OLI_CODE       END DO
1748!OLI_CODE
1749!OLI_CODE       ! Calculate pond volume for highest category = remaining pond volume
1750!OLI_CODE       IF (m_index == 1) zvolpn(m_index) = zvolp
1751!OLI_CODE       IF (m_index > 1) THEN
1752!OLI_CODE         IF (zvolp > sum(zvolpn(1:m_index-1))) THEN
1753!OLI_CODE           zvolpn(m_index) = zvolp - sum(zvolpn(1:m_index-1))
1754!OLI_CODE         ELSE
1755!OLI_CODE           zvolpn(m_index) = z0
1756!OLI_CODE           zhpondn(m_index) = z0
1757!OLI_CODE           zapondn(m_index) = z0
1758!OLI_CODE           ! If remaining pond volume is negative reduce pond volume of
1759!OLI_CODE           ! lower category
[7325]1760!OLI_CODE           IF (zvolp+epsi10 < sum(zvolpn(1:m_index-1))) &
[7293]1761!OLI_CODE             zvolpn(m_index-1) = zvolpn(m_index-1)-sum(zvolpn(1:m_index-1))&
1762!OLI_CODE                                + zvolp
1763!OLI_CODE         END IF
1764!OLI_CODE       END IF
1765!OLI_CODE
1766!OLI_CODE       DO n=1,m_index
[7325]1767!OLI_CODE          IF (zapondn(n) > epsi10) THEN
[7293]1768!OLI_CODE              zhpondn(n) = zvolpn(n) / zapondn(n)
1769!OLI_CODE          ELSE
1770!OLI_CODE             dvolp = dvolp + zvolpn(n)
1771!OLI_CODE             zhpondn(n) = z0
1772!OLI_CODE             zvolpn(n) = z0
1773!OLI_CODE             zapondn(n) = z0
1774!OLI_CODE          end IF
1775!OLI_CODE       END DO
1776!OLI_CODE       DO n = m_index+1, jpl
1777!OLI_CODE          zhpondn(n) = z0
1778!OLI_CODE          zapondn(n) = z0
1779!OLI_CODE          zvolpn (n) = z0
1780!OLI_CODE       END DO
1781!OLI_CODE
1782!OLI_CODE    END SUBROUTINE pond_area
1783!OLI_CODE   
1784!OLI_CODE
1785!OLI_CODE    SUBROUTINE calc_hpond(aicen, asnon, hsnon, rhos, alfan, &
1786!OLI_CODE                          zvolp, cum_max_vol,                &
1787!OLI_CODE                          hpond, m_index)
1788!OLI_CODE       !!-------------------------------------------------------------------
1789!OLI_CODE       !!                ***  ROUTINE calc_hpond  ***
1790!OLI_CODE       !!
1791!OLI_CODE       !! ** Purpose :   Compute melt pond depth
1792!OLI_CODE       !!-------------------------------------------------------------------
1793!OLI_CODE     
1794!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(IN) :: &
1795!OLI_CODE          aicen, &
1796!OLI_CODE          asnon, &
1797!OLI_CODE          hsnon, &
1798!OLI_CODE          rhos,  &
1799!OLI_CODE          alfan, &
1800!OLI_CODE          cum_max_vol
1801!OLI_CODE     
1802!OLI_CODE       REAL (wp), INTENT(IN) :: &
1803!OLI_CODE          zvolp
1804!OLI_CODE     
1805!OLI_CODE       REAL (wp), INTENT(OUT) :: &
1806!OLI_CODE          hpond
1807!OLI_CODE     
1808!OLI_CODE       INTEGER, INTENT(OUT) :: &
1809!OLI_CODE          m_index
1810!OLI_CODE     
1811!OLI_CODE       INTEGER :: n, ns
1812!OLI_CODE     
1813!OLI_CODE       REAL (wp), DIMENSION(0:jpl+1) :: &
1814!OLI_CODE          hitl, &
1815!OLI_CODE          aicetl
1816!OLI_CODE     
1817!OLI_CODE       REAL (wp) :: &
1818!OLI_CODE          rem_vol, &
1819!OLI_CODE          area, &
1820!OLI_CODE          vol, &
1821!OLI_CODE          tmp, &
1822!OLI_CODE          z0   = 0.0_wp,    &   
[7325]1823!OLI_CODE          epsi10 = 1.0e-11_wp
[7293]1824!OLI_CODE     
1825!OLI_CODE       !----------------------------------------------------------------
1826!OLI_CODE       ! hpond is zero if zvolp is zero - have we fully drained?
1827!OLI_CODE       !----------------------------------------------------------------
1828!OLI_CODE     
[7325]1829!OLI_CODE       IF (zvolp < epsi10) THEN
[7293]1830!OLI_CODE        hpond = z0
1831!OLI_CODE        m_index = 0
1832!OLI_CODE       ELSE
1833!OLI_CODE       
1834!OLI_CODE        !----------------------------------------------------------------
1835!OLI_CODE        ! Calculate the category where water fills up to
1836!OLI_CODE        !----------------------------------------------------------------
1837!OLI_CODE       
1838!OLI_CODE        !----------|
1839!OLI_CODE        !          |
1840!OLI_CODE        !          |
1841!OLI_CODE        !          |----------|                                     -- --
1842!OLI_CODE        !__________|__________|_________________________________________ ^
1843!OLI_CODE        !          |          |             rem_vol     ^                | Semi-filled
1844!OLI_CODE        !          |          |----------|-- -- -- - ---|-- ---- -- -- --v layer
1845!OLI_CODE        !          |          |          |              |
1846!OLI_CODE        !          |          |          |              |hpond
1847!OLI_CODE        !          |          |          |----------|   |     |-------
1848!OLI_CODE        !          |          |          |          |   |     |
1849!OLI_CODE        !          |          |          |          |---v-----|
1850!OLI_CODE        !          |          | m_index  |          |         |
1851!OLI_CODE        !-------------------------------------------------------------
1852!OLI_CODE       
1853!OLI_CODE        m_index = 0  ! 1:m_index categories have water in them
1854!OLI_CODE        DO n = 1, jpl
1855!OLI_CODE           IF (zvolp <= cum_max_vol(n)) THEN
1856!OLI_CODE              m_index = n
1857!OLI_CODE              IF (n == 1) THEN
1858!OLI_CODE                 rem_vol = zvolp
1859!OLI_CODE              ELSE
1860!OLI_CODE                 rem_vol = zvolp - cum_max_vol(n-1)
1861!OLI_CODE              END IF
1862!OLI_CODE              exit ! to break out of the loop
1863!OLI_CODE           END IF
1864!OLI_CODE        END DO
1865!OLI_CODE        m_index = min(jpl-1, m_index)
1866!OLI_CODE       
1867!OLI_CODE        !----------------------------------------------------------------
1868!OLI_CODE        ! semi-filled layer may have m_index different snow in it
1869!OLI_CODE        !----------------------------------------------------------------
1870!OLI_CODE       
1871!OLI_CODE        !-----------------------------------------------------------  ^
1872!OLI_CODE        !                                                             |  alfan(m_index+1)
1873!OLI_CODE        !                                                             |
1874!OLI_CODE        !hitl(3)-->                             |----------|          |
1875!OLI_CODE        !hitl(2)-->                |------------| * * * * *|          |
1876!OLI_CODE        !hitl(1)-->     |----------|* * * * * * |* * * * * |          |
1877!OLI_CODE        !hitl(0)-->-------------------------------------------------  |  ^
1878!OLI_CODE        !                various snow from lower categories          |  |alfa(m_index)
1879!OLI_CODE       
1880!OLI_CODE        ! hitl - heights of the snow layers from thinner and current categories
1881!OLI_CODE        ! aicetl - area of each snow depth in this layer
1882!OLI_CODE       
1883!OLI_CODE        hitl(:) = z0
1884!OLI_CODE        aicetl(:) = z0
1885!OLI_CODE        DO n = 1, m_index
1886!OLI_CODE           hitl(n)   = max(min(hsnon(n) + alfan(n) - alfan(m_index), &
1887!OLI_CODE                                  alfan(m_index+1) - alfan(m_index)), z0)
1888!OLI_CODE           aicetl(n) = asnon(n)
1889!OLI_CODE           
1890!OLI_CODE           aicetl(0) = aicetl(0) + (aicen(n) - asnon(n))
1891!OLI_CODE        END DO
1892!OLI_CODE        hitl(m_index+1) = alfan(m_index+1) - alfan(m_index)
1893!OLI_CODE        aicetl(m_index+1) = z0
1894!OLI_CODE       
1895!OLI_CODE        !----------------------------------------------------------------
1896!OLI_CODE        ! reorder array according to hitl
1897!OLI_CODE        ! snow heights not necessarily in height order
1898!OLI_CODE        !----------------------------------------------------------------
1899!OLI_CODE       
1900!OLI_CODE        DO ns = 1, m_index+1
1901!OLI_CODE           DO n = 0, m_index - ns + 1
1902!OLI_CODE              IF (hitl(n) > hitl(n+1)) THEN ! swap order
1903!OLI_CODE                 tmp = hitl(n)
1904!OLI_CODE                 hitl(n) = hitl(n+1)
1905!OLI_CODE                 hitl(n+1) = tmp
1906!OLI_CODE                 tmp = aicetl(n)
1907!OLI_CODE                 aicetl(n) = aicetl(n+1)
1908!OLI_CODE                 aicetl(n+1) = tmp
1909!OLI_CODE              END IF
1910!OLI_CODE           END DO
1911!OLI_CODE        END DO
1912!OLI_CODE       
1913!OLI_CODE        !----------------------------------------------------------------
1914!OLI_CODE        ! divide semi-filled layer into set of sublayers each vertically homogenous
1915!OLI_CODE        !----------------------------------------------------------------
1916!OLI_CODE       
1917!OLI_CODE        !hitl(3)----------------------------------------------------------------
1918!OLI_CODE        !                                                       | * * * * * * * * 
1919!OLI_CODE        !                                                       |* * * * * * * * *
1920!OLI_CODE        !hitl(2)----------------------------------------------------------------
1921!OLI_CODE        !                                    | * * * * * * * *  | * * * * * * * * 
1922!OLI_CODE        !                                    |* * * * * * * * * |* * * * * * * * *
1923!OLI_CODE        !hitl(1)----------------------------------------------------------------
1924!OLI_CODE        !                 | * * * * * * * *  | * * * * * * * *  | * * * * * * * * 
1925!OLI_CODE        !                 |* * * * * * * * * |* * * * * * * * * |* * * * * * * * *
1926!OLI_CODE        !hitl(0)----------------------------------------------------------------
1927!OLI_CODE        !    aicetl(0)         aicetl(1)           aicetl(2)          aicetl(3)           
1928!OLI_CODE       
1929!OLI_CODE        ! move up over layers incrementing volume
1930!OLI_CODE        DO n = 1, m_index+1
1931!OLI_CODE           
1932!OLI_CODE           area = sum(aicetl(:)) - &                 ! total area of sub-layer
1933!OLI_CODE                (rhos(n)/rau0) * sum(aicetl(n:jpl+1)) ! area of sub-layer occupied by snow
1934!OLI_CODE           
1935!OLI_CODE           vol = (hitl(n) - hitl(n-1)) * area      ! thickness of sub-layer times area
1936!OLI_CODE           
1937!OLI_CODE           IF (vol >= rem_vol) THEN  ! have reached the sub-layer with the depth within
1938!OLI_CODE              hpond = rem_vol / area + hitl(n-1) + alfan(m_index) - &
1939!OLI_CODE                           alfan(1)
1940!OLI_CODE              exit
1941!OLI_CODE           ELSE  ! still in sub-layer below the sub-layer with the depth
1942!OLI_CODE              rem_vol = rem_vol - vol
1943!OLI_CODE           END IF
1944!OLI_CODE           
1945!OLI_CODE        END DO
1946!OLI_CODE       
1947!OLI_CODE       END IF
1948!OLI_CODE     
1949!OLI_CODE    END SUBROUTINE calc_hpond
1950!OLI_CODE   
1951!OLI_CODE
1952!OLI_CODE    SUBROUTINE permeability_phi(ticen, salin, vicen, perm)
1953!OLI_CODE       !!-------------------------------------------------------------------
1954!OLI_CODE       !!                ***  ROUTINE permeability_phi  ***
1955!OLI_CODE       !!
1956!OLI_CODE       !! ** Purpose :   Determine the liquid fraction of brine in the ice
1957!OLI_CODE       !!                and its permeability
1958!OLI_CODE       !!-------------------------------------------------------------------
1959!OLI_CODE       REAL (wp), DIMENSION(nlay_i), INTENT(IN) :: &
1960!OLI_CODE          ticen,  & ! energy of melting for each ice layer (J/m2)
1961!OLI_CODE          salin
1962!OLI_CODE
1963!OLI_CODE       REAL (wp), INTENT(IN) :: &
1964!OLI_CODE          vicen     ! ice volume
1965!OLI_CODE     
1966!OLI_CODE       REAL (wp), INTENT(OUT) :: &
1967!OLI_CODE          perm      ! permeability
1968!OLI_CODE
1969!OLI_CODE       REAL (wp) ::   &
1970!OLI_CODE          Sbr        ! brine salinity
1971!OLI_CODE
1972!OLI_CODE       REAL (wp), DIMENSION(nlay_i) ::   &
1973!OLI_CODE          Tin, &    ! ice temperature
1974!OLI_CODE          phi       ! liquid fraction
1975!OLI_CODE
1976!OLI_CODE       INTEGER :: k
1977!OLI_CODE     
1978!OLI_CODE       REAL (wp) :: &
1979!OLI_CODE          c2    = 2.0_wp
1980!OLI_CODE 
1981!OLI_CODE       !-----------------------------------------------------------------
1982!OLI_CODE       ! Compute ice temperatures from enthalpies using quadratic formula
1983!OLI_CODE       !-----------------------------------------------------------------
1984!OLI_CODE
1985!OLI_CODE       DO k = 1,nlay_i
1986!OLI_CODE          Tin(k) = ticen(k)
1987!OLI_CODE       END DO
1988!OLI_CODE
1989!OLI_CODE       !-----------------------------------------------------------------
1990!OLI_CODE       ! brine salinity and liquid fraction
1991!OLI_CODE       !-----------------------------------------------------------------
1992!OLI_CODE
1993!OLI_CODE       IF (maxval(Tin-rtt) <= -c2) THEN
1994!OLI_CODE
1995!OLI_CODE          DO k = 1,nlay_i
1996!OLI_CODE             Sbr = - 1.2_wp                 &
1997!OLI_CODE                   -21.8_wp     * (Tin(k)-rtt)    &
1998!OLI_CODE                   - 0.919_wp   * (Tin(k)-rtt)**2 &
1999!OLI_CODE                   - 0.01878_wp * (Tin(k)-rtt)**3
2000!OLI_CODE             phi(k) = salin(k)/Sbr ! liquid fraction
2001!OLI_CODE          END DO ! k
2002!OLI_CODE       
2003!OLI_CODE       ELSE
2004!OLI_CODE
2005!OLI_CODE          DO k = 1,nlay_i
2006!OLI_CODE             Sbr = -17.6_wp    * (Tin(k)-rtt)    &
2007!OLI_CODE                   - 0.389_wp  * (Tin(k)-rtt)**2 &
2008!OLI_CODE                   - 0.00362_wp* (Tin(k)-rtt)**3
2009!OLI_CODE             phi(k) = salin(k)/Sbr ! liquid fraction
2010!OLI_CODE          END DO
2011!OLI_CODE
2012!OLI_CODE       END IF
2013!OLI_CODE     
2014!OLI_CODE       !-----------------------------------------------------------------
2015!OLI_CODE       ! permeability
2016!OLI_CODE       !-----------------------------------------------------------------
2017!OLI_CODE
2018!OLI_CODE       perm = 3.0e-08_wp * (minval(phi))**3
2019!OLI_CODE     
2020!OLI_CODE    END SUBROUTINE permeability_phi
2021!OLI_CODE   
2022!OLI_CODE #else
2023!OLI_CODE    !!----------------------------------------------------------------------
2024!OLI_CODE    !!   Default option         Dummy Module          No LIM-3 sea-ice model
2025!OLI_CODE    !!----------------------------------------------------------------------
2026!OLI_CODE CONTAINS
2027!OLI_CODE    SUBROUTINE lim_mp_init          ! Empty routine
2028!OLI_CODE    END SUBROUTINE lim_mp_init   
2029!OLI_CODE    SUBROUTINE lim_mp               ! Empty routine
2030!OLI_CODE    END SUBROUTINE lim_mp
2031!OLI_CODE    SUBROUTINE compute_mp_topo      ! Empty routine
2032!OLI_CODE    END SUBROUTINE compute_mp_topo       
2033!OLI_CODE    SUBROUTINE pond_area            ! Empty routine
2034!OLI_CODE    END SUBROUTINE pond_area   
2035!OLI_CODE    SUBROUTINE calc_hpond           ! Empty routine
2036!OLI_CODE    END SUBROUTINE calc_hpond   
2037!OLI_CODE    SUBROUTINE permeability_phy     ! Empty routine
2038!OLI_CODE    END SUBROUTINE permeability_phy   
2039!OLI_CODE #endif
2040!OLI_CODE    !!======================================================================
2041!OLI_CODE END MODULE limmp_topo
2042!OLI_CODE
[7325]2043#else
2044   !!----------------------------------------------------------------------
2045   !!   Default option          Empty module           NO LIM sea-ice model
2046   !!----------------------------------------------------------------------
2047CONTAINS
2048   SUBROUTINE lim_mp_init     ! Empty routine
2049   END SUBROUTINE lim_mp_init
2050   SUBROUTINE lim_mp          ! Empty routine
2051   END SUBROUTINE lim_mp     
2052   SUBROUTINE lim_mp_topo     ! Empty routine
2053   END SUBROUTINE lim_mp_topo
[8060]2054   SUBROUTINE lim_mp_cesm     ! Empty routine
2055   END SUBROUTINE lim_mp_cesm
[7325]2056   SUBROUTINE lim_mp_area     ! Empty routine
2057   END SUBROUTINE lim_mp_area
2058   SUBROUTINE lim_mp_perm     ! Empty routine
2059   END SUBROUTINE lim_mp_perm
2060#endif 
2061
2062   !!======================================================================
2063END MODULE limmp 
Note: See TracBrowser for help on using the repository browser.