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.
Changeset 921 for trunk/NEMO/LIM_SRC_3/limitd_me.F90 – NEMO

Ignore:
Timestamp:
2008-05-13T10:28:52+02:00 (16 years ago)
Author:
rblod
Message:

Correct indentation and print for debug in LIM3, see ticket #134, step I

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMO/LIM_SRC_3/limitd_me.F90

    r903 r921  
    3232   USE prtctl           ! Print control 
    3333   USE lib_mpp 
    34   
     34 
    3535   IMPLICIT NONE 
    3636   PRIVATE 
     
    5353      zone   = 1.e0 
    5454 
    55 !----------------------------------------------------------------------- 
    56 ! Variables shared among ridging subroutines 
    57 !----------------------------------------------------------------------- 
    58       REAL(wp), DIMENSION (jpi,jpj) ::    & 
    59          asum         , & ! sum of total ice and open water area 
    60          aksum            ! ratio of area removed to area ridged 
    61  
    62       REAL(wp), DIMENSION(jpi,jpj,0:jpl) :: &      
    63          athorn           ! participation function; fraction of ridging/ 
    64                           !  closing associated w/ category n 
    65  
    66       REAL(wp), DIMENSION(jpi,jpj,jpl) ::  & 
    67          hrmin      , &   ! minimum ridge thickness 
    68          hrmax      , &   ! maximum ridge thickness 
    69          hraft      , &   ! thickness of rafted ice 
    70          krdg       , &   ! mean ridge thickness/thickness of ridging ice  
    71          aridge     , &   ! participating ice ridging 
    72          araft            ! participating ice rafting 
    73  
    74       REAL(wp), PARAMETER :: & 
    75          krdgmin = 1.1, &    ! min ridge thickness multiplier 
    76          kraft   = 2.0       ! rafting multipliyer 
    77  
    78       REAL(wp) :: &                                
    79          Cp  
    80 ! 
    81 !----------------------------------------------------------------------- 
    82 ! Ridging diagnostic arrays for history files 
    83 !----------------------------------------------------------------------- 
    84 ! 
    85       REAL (wp), DIMENSION(jpi,jpj) :: & 
    86          dardg1dt     , & ! rate of fractional area loss by ridging ice (1/s) 
    87          dardg2dt     , & ! rate of fractional area gain by new ridges (1/s) 
    88          dvirdgdt     , & ! rate of ice volume ridged (m/s) 
    89          opening          ! rate of opening due to divergence/shear (1/s) 
    90                                         
     55   !----------------------------------------------------------------------- 
     56   ! Variables shared among ridging subroutines 
     57   !----------------------------------------------------------------------- 
     58   REAL(wp), DIMENSION (jpi,jpj) ::    & 
     59      asum         , & ! sum of total ice and open water area 
     60      aksum            ! ratio of area removed to area ridged 
     61 
     62   REAL(wp), DIMENSION(jpi,jpj,0:jpl) :: &      
     63      athorn           ! participation function; fraction of ridging/ 
     64   !  closing associated w/ category n 
     65 
     66   REAL(wp), DIMENSION(jpi,jpj,jpl) ::  & 
     67      hrmin      , &   ! minimum ridge thickness 
     68      hrmax      , &   ! maximum ridge thickness 
     69      hraft      , &   ! thickness of rafted ice 
     70      krdg       , &   ! mean ridge thickness/thickness of ridging ice  
     71      aridge     , &   ! participating ice ridging 
     72      araft            ! participating ice rafting 
     73 
     74   REAL(wp), PARAMETER :: & 
     75      krdgmin = 1.1, &    ! min ridge thickness multiplier 
     76      kraft   = 2.0       ! rafting multipliyer 
     77 
     78   REAL(wp) :: &                                
     79      Cp  
     80   ! 
     81   !----------------------------------------------------------------------- 
     82   ! Ridging diagnostic arrays for history files 
     83   !----------------------------------------------------------------------- 
     84   ! 
     85   REAL (wp), DIMENSION(jpi,jpj) :: & 
     86      dardg1dt     , & ! rate of fractional area loss by ridging ice (1/s) 
     87      dardg2dt     , & ! rate of fractional area gain by new ridges (1/s) 
     88      dvirdgdt     , & ! rate of ice volume ridged (m/s) 
     89      opening          ! rate of opening due to divergence/shear (1/s) 
     90 
    9191 
    9292   !!---------------------------------------------------------------------- 
     
    9797CONTAINS 
    9898 
    99 !!-----------------------------------------------------------------------------! 
    100 !!-----------------------------------------------------------------------------! 
     99   !!-----------------------------------------------------------------------------! 
     100   !!-----------------------------------------------------------------------------! 
    101101 
    102102   SUBROUTINE lim_itd_me ! (subroutine 1/6) 
    103         !!---------------------------------------------------------------------! 
    104         !!                ***  ROUTINE lim_itd_me *** 
    105         !! ** Purpose : 
    106         !!        This routine computes the mechanical redistribution 
    107         !!                      of ice thickness 
    108         !! 
    109         !! ** Method  : a very simple method :-) 
    110         !! 
    111         !! ** Arguments : 
    112         !!           kideb , kiut : Starting and ending points on which the  
    113         !!                         the computation is applied 
    114         !! 
    115         !! ** Inputs / Ouputs : (global commons) 
    116         !! 
    117         !! ** External :  
    118         !! 
    119         !! ** Steps : 
    120         !!  1) Thickness categories boundaries, ice / o.w. concentrations 
    121         !!     Ridge preparation 
    122         !!  2) Dynamical inputs (closing rate, divu_adv, opning) 
    123         !!  3) Ridging iteration 
    124         !!  4) Ridging diagnostics 
    125         !!  5) Heat, salt and freshwater fluxes 
    126         !!  6) Compute increments of tate variables and come back to old values 
    127         !! 
    128         !! ** References : There are a lot of references and can be difficult /  
    129         !!                 boring to read 
    130         !! 
    131         !! Flato, G. M., and W. D. Hibler III, 1995: Ridging and strength 
    132         !!  in modeling the thickness distribution of Arctic sea ice, 
    133         !!  J. Geophys. Res., 100, 18,611-18,626. 
    134         !! 
    135         !! Hibler, W. D. III, 1980: Modeling a variable thickness sea ice 
    136         !!  cover, Mon. Wea. Rev., 108, 1943-1973, 1980. 
    137         !! 
    138         !! Rothrock, D. A., 1975: The energetics of the plastic deformation of 
    139         !!  pack ice by ridging, J. Geophys. Res., 80, 4514-4519. 
    140         !! 
    141         !! Thorndike, A. S., D. A. Rothrock, G. A. Maykut, and R. Colony,  
    142         !!  1975: The thickness distribution of sea ice, J. Geophys. Res.,  
    143         !!  80, 4501-4513.  
    144         !! 
    145         !! Bitz et al., JGR 2001 
    146         !! 
    147         !! Amundrud and Melling, JGR 2005 
    148         !! 
    149         !! Babko et al., JGR 2002  
    150         !! 
    151         !! ** History : 
    152         !!           This routine is based on CICE code 
    153         !!           and authors William H. Lipscomb, 
    154         !!           and Elizabeth C. Hunke, LANL 
    155         !!           are gratefully acknowledged 
    156         !! 
    157         !!           (02-2006) Martin Vancoppenolle, UCL-ASTR  
    158         !! 
    159         !!--------------------------------------------------------------------! 
    160         !! * Arguments 
    161  
    162         !! * Local variables 
    163         INTEGER ::   ji,       &   ! spatial dummy loop index 
    164                      jj,       &   ! spatial dummy loop index 
    165                      jk,       &   ! vertical layering dummy loop index 
    166                      jl,       &   ! ice category dummy loop index 
    167                      niter,    &   ! iteration counter 
    168                      nitermax = 20 ! max number of ridging iterations  
    169  
    170         REAL(wp)  ::             &  ! constant values 
    171            zeps      =  1.0e-10, & 
    172            epsi10    =  1.0e-10, & 
    173            epsi06    =  1.0e-6 
    174  
    175         REAL(wp), DIMENSION(jpi,jpj) :: & 
    176            closing_net,        &  ! net rate at which area is removed    (1/s) 
    177                                   ! (ridging ice area - area of new ridges) / dt 
    178            divu_adv   ,        &  ! divu as implied by transport scheme  (1/s) 
    179            opning     ,        &  ! rate of opening due to divergence/shear 
    180            closing_gross,      &  ! rate at which area removed, not counting 
    181                                   ! area of new ridges 
    182            msnow_mlt  ,        &  ! mass of snow added to ocean (kg m-2) 
    183            esnow_mlt              ! energy needed to melt snow in ocean (J m-2) 
    184  
    185         REAL(wp) ::            & 
    186            w1,                 &  ! temporary variable 
    187            tmpfac,             &  ! factor by which opening/closing rates are cut 
    188            dti                    ! 1 / dt 
    189  
    190         LOGICAL   ::           & 
    191            asum_error              ! flag for asum .ne. 1 
    192  
    193         INTEGER :: iterate_ridging ! if true, repeat the ridging 
    194  
    195         REAL(wp) ::  &          
    196            big = 1.0e8 
    197  
    198         REAL (wp), DIMENSION(jpi,jpj) :: &  !  
    199            vt_i_init, vt_i_final       !  ice volume summed over categories 
    200  
    201         CHARACTER (len = 15) :: fieldid 
    202  
    203 !!-- End of declarations 
    204 !-----------------------------------------------------------------------------! 
     103      !!---------------------------------------------------------------------! 
     104      !!                ***  ROUTINE lim_itd_me *** 
     105      !! ** Purpose : 
     106      !!        This routine computes the mechanical redistribution 
     107      !!                      of ice thickness 
     108      !! 
     109      !! ** Method  : a very simple method :-) 
     110      !! 
     111      !! ** Arguments : 
     112      !!           kideb , kiut : Starting and ending points on which the  
     113      !!                         the computation is applied 
     114      !! 
     115      !! ** Inputs / Ouputs : (global commons) 
     116      !! 
     117      !! ** External :  
     118      !! 
     119      !! ** Steps : 
     120      !!  1) Thickness categories boundaries, ice / o.w. concentrations 
     121      !!     Ridge preparation 
     122      !!  2) Dynamical inputs (closing rate, divu_adv, opning) 
     123      !!  3) Ridging iteration 
     124      !!  4) Ridging diagnostics 
     125      !!  5) Heat, salt and freshwater fluxes 
     126      !!  6) Compute increments of tate variables and come back to old values 
     127      !! 
     128      !! ** References : There are a lot of references and can be difficult /  
     129      !!                 boring to read 
     130      !! 
     131      !! Flato, G. M., and W. D. Hibler III, 1995: Ridging and strength 
     132      !!  in modeling the thickness distribution of Arctic sea ice, 
     133      !!  J. Geophys. Res., 100, 18,611-18,626. 
     134      !! 
     135      !! Hibler, W. D. III, 1980: Modeling a variable thickness sea ice 
     136      !!  cover, Mon. Wea. Rev., 108, 1943-1973, 1980. 
     137      !! 
     138      !! Rothrock, D. A., 1975: The energetics of the plastic deformation of 
     139      !!  pack ice by ridging, J. Geophys. Res., 80, 4514-4519. 
     140      !! 
     141      !! Thorndike, A. S., D. A. Rothrock, G. A. Maykut, and R. Colony,  
     142      !!  1975: The thickness distribution of sea ice, J. Geophys. Res.,  
     143      !!  80, 4501-4513.  
     144      !! 
     145      !! Bitz et al., JGR 2001 
     146      !! 
     147      !! Amundrud and Melling, JGR 2005 
     148      !! 
     149      !! Babko et al., JGR 2002  
     150      !! 
     151      !! ** History : 
     152      !!           This routine is based on CICE code 
     153      !!           and authors William H. Lipscomb, 
     154      !!           and Elizabeth C. Hunke, LANL 
     155      !!           are gratefully acknowledged 
     156      !! 
     157      !!           (02-2006) Martin Vancoppenolle, UCL-ASTR  
     158      !! 
     159      !!--------------------------------------------------------------------! 
     160      !! * Arguments 
     161 
     162      !! * Local variables 
     163      INTEGER ::   ji,       &   ! spatial dummy loop index 
     164         jj,       &   ! spatial dummy loop index 
     165         jk,       &   ! vertical layering dummy loop index 
     166         jl,       &   ! ice category dummy loop index 
     167         niter,    &   ! iteration counter 
     168         nitermax = 20 ! max number of ridging iterations  
     169 
     170      REAL(wp)  ::             &  ! constant values 
     171         zeps      =  1.0e-10, & 
     172         epsi10    =  1.0e-10, & 
     173         epsi06    =  1.0e-6 
     174 
     175      REAL(wp), DIMENSION(jpi,jpj) :: & 
     176         closing_net,        &  ! net rate at which area is removed    (1/s) 
     177                                ! (ridging ice area - area of new ridges) / dt 
     178         divu_adv   ,        &  ! divu as implied by transport scheme  (1/s) 
     179         opning     ,        &  ! rate of opening due to divergence/shear 
     180         closing_gross,      &  ! rate at which area removed, not counting 
     181                                ! area of new ridges 
     182         msnow_mlt  ,        &  ! mass of snow added to ocean (kg m-2) 
     183         esnow_mlt              ! energy needed to melt snow in ocean (J m-2) 
     184 
     185      REAL(wp) ::            & 
     186         w1,                 &  ! temporary variable 
     187         tmpfac,             &  ! factor by which opening/closing rates are cut 
     188         dti                    ! 1 / dt 
     189 
     190      LOGICAL   ::           & 
     191         asum_error              ! flag for asum .ne. 1 
     192 
     193      INTEGER :: iterate_ridging ! if true, repeat the ridging 
     194 
     195      REAL(wp) ::  &          
     196         big = 1.0e8 
     197 
     198      REAL (wp), DIMENSION(jpi,jpj) :: &  !  
     199         vt_i_init, vt_i_final       !  ice volume summed over categories 
     200 
     201      CHARACTER (len = 15) :: fieldid 
     202 
     203      !!-- End of declarations 
     204      !-----------------------------------------------------------------------------! 
    205205 
    206206      IF( numit == nstart  ) CALL lim_itd_me_init ! Initialization (first time-step only) 
     
    211211      ENDIF 
    212212 
    213 !-----------------------------------------------------------------------------! 
    214 ! 1) Thickness categories boundaries, ice / o.w. concentrations, init_ons 
    215 !-----------------------------------------------------------------------------! 
    216 ! Set hi_max(ncat) to a big value to ensure that all ridged ice  
    217 ! is thinner than hi_max(ncat). 
     213      !-----------------------------------------------------------------------------! 
     214      ! 1) Thickness categories boundaries, ice / o.w. concentrations, init_ons 
     215      !-----------------------------------------------------------------------------! 
     216      ! Set hi_max(ncat) to a big value to ensure that all ridged ice  
     217      ! is thinner than hi_max(ncat). 
    218218 
    219219      hi_max(jpl) = 999.99 
     
    225225      IF ( con_i) CALL lim_column_sum (jpl,   v_i, vt_i_init) 
    226226 
    227 ! Initialize arrays. 
     227      ! Initialize arrays. 
    228228      DO jj = 1, jpj 
    229229         DO ji = 1, jpi 
    230230 
    231          msnow_mlt(ji,jj) = 0.0 
    232          esnow_mlt(ji,jj) = 0.0 
    233          dardg1dt(ji,jj)  = 0.0 
    234          dardg2dt(ji,jj)  = 0.0 
    235          dvirdgdt(ji,jj)  = 0.0 
    236          opening (ji,jj)  = 0.0 
    237  
    238 !-----------------------------------------------------------------------------! 
    239 ! 2) Dynamical inputs (closing rate, divu_adv, opning) 
    240 !-----------------------------------------------------------------------------! 
    241 ! 
    242 ! 2.1 closing_net 
    243 !----------------- 
    244 ! Compute the net rate of closing due to convergence  
    245 ! and shear, based on Flato and Hibler (1995). 
    246 !  
    247 ! The energy dissipation rate is equal to the net closing rate 
    248 ! times the ice strength. 
    249 ! 
    250 ! NOTE: The NET closing rate is equal to the rate that open water  
    251 !  area is removed, plus the rate at which ice area is removed by  
    252 !  ridging, minus the rate at which area is added in new ridges. 
    253 !  The GROSS closing rate is equal to the first two terms (open 
    254 !  water closing and thin ice ridging) without the third term 
    255 !  (thick, newly ridged ice). 
    256  
    257          closing_net(ji,jj) = & 
    258               Cs*0.5*(Delta_i(ji,jj)-ABS(divu_i(ji,jj))) - MIN(divu_i(ji,jj),0.0) 
    259  
    260 ! 2.2 divu_adv 
    261 !-------------- 
    262 ! Compute divu_adv, the divergence rate given by the transport/ 
    263 ! advection scheme, which may not be equal to divu as computed  
    264 ! from the velocity field. 
    265 ! 
    266 ! If divu_adv < 0, make sure the closing rate is large enough 
    267 ! to give asum = 1.0 after ridging. 
    268  
    269          divu_adv(ji,jj) = (1.0-asum(ji,jj)) / rdt_ice  ! asum found in ridgeprep 
    270  
    271          IF (divu_adv(ji,jj) .LT. 0.0) & 
    272               closing_net(ji,jj) = max(closing_net(ji,jj), -divu_adv(ji,jj)) 
    273  
    274 ! 2.3 opning 
    275 !------------ 
    276 ! Compute the (non-negative) opening rate that will give  
    277 ! asum = 1.0 after ridging. 
    278          opning(ji,jj) = closing_net(ji,jj) + divu_adv(ji,jj) 
     231            msnow_mlt(ji,jj) = 0.0 
     232            esnow_mlt(ji,jj) = 0.0 
     233            dardg1dt(ji,jj)  = 0.0 
     234            dardg2dt(ji,jj)  = 0.0 
     235            dvirdgdt(ji,jj)  = 0.0 
     236            opening (ji,jj)  = 0.0 
     237 
     238            !-----------------------------------------------------------------------------! 
     239            ! 2) Dynamical inputs (closing rate, divu_adv, opning) 
     240            !-----------------------------------------------------------------------------! 
     241            ! 
     242            ! 2.1 closing_net 
     243            !----------------- 
     244            ! Compute the net rate of closing due to convergence  
     245            ! and shear, based on Flato and Hibler (1995). 
     246            !  
     247            ! The energy dissipation rate is equal to the net closing rate 
     248            ! times the ice strength. 
     249            ! 
     250            ! NOTE: The NET closing rate is equal to the rate that open water  
     251            !  area is removed, plus the rate at which ice area is removed by  
     252            !  ridging, minus the rate at which area is added in new ridges. 
     253            !  The GROSS closing rate is equal to the first two terms (open 
     254            !  water closing and thin ice ridging) without the third term 
     255            !  (thick, newly ridged ice). 
     256 
     257            closing_net(ji,jj) = & 
     258               Cs*0.5*(Delta_i(ji,jj)-ABS(divu_i(ji,jj))) - MIN(divu_i(ji,jj),0.0) 
     259 
     260            ! 2.2 divu_adv 
     261            !-------------- 
     262            ! Compute divu_adv, the divergence rate given by the transport/ 
     263            ! advection scheme, which may not be equal to divu as computed  
     264            ! from the velocity field. 
     265            ! 
     266            ! If divu_adv < 0, make sure the closing rate is large enough 
     267            ! to give asum = 1.0 after ridging. 
     268 
     269            divu_adv(ji,jj) = (1.0-asum(ji,jj)) / rdt_ice  ! asum found in ridgeprep 
     270 
     271            IF (divu_adv(ji,jj) .LT. 0.0) & 
     272               closing_net(ji,jj) = max(closing_net(ji,jj), -divu_adv(ji,jj)) 
     273 
     274            ! 2.3 opning 
     275            !------------ 
     276            ! Compute the (non-negative) opening rate that will give  
     277            ! asum = 1.0 after ridging. 
     278            opning(ji,jj) = closing_net(ji,jj) + divu_adv(ji,jj) 
    279279 
    280280         END DO 
    281281      END DO 
    282282 
    283 !-----------------------------------------------------------------------------! 
    284 ! 3) Ridging iteration 
    285 !-----------------------------------------------------------------------------! 
     283      !-----------------------------------------------------------------------------! 
     284      ! 3) Ridging iteration 
     285      !-----------------------------------------------------------------------------! 
    286286      niter = 1                 ! iteration counter 
    287287      iterate_ridging = 1 
     
    290290      DO WHILE ( iterate_ridging > 0 .AND. niter < nitermax ) 
    291291 
     292         DO jj = 1, jpj 
     293            DO ji = 1, jpi 
     294 
     295               ! 3.2 closing_gross 
     296               !-----------------------------------------------------------------------------! 
     297               ! Based on the ITD of ridging and ridged ice, convert the net 
     298               !  closing rate to a gross closing rate.   
     299               ! NOTE: 0 < aksum <= 1 
     300               closing_gross(ji,jj) = closing_net(ji,jj) / aksum(ji,jj) 
     301 
     302               ! correction to closing rate and opening if closing rate is excessive 
     303               !--------------------------------------------------------------------- 
     304               ! Reduce the closing rate if more than 100% of the open water  
     305               ! would be removed.  Reduce the opening rate proportionately. 
     306               IF ( ato_i(ji,jj) .GT. epsi11 .AND. athorn(ji,jj,0) .GT. 0.0 ) THEN 
     307                  w1 = athorn(ji,jj,0) * closing_gross(ji,jj) * rdt_ice 
     308                  IF ( w1 .GT. ato_i(ji,jj)) THEN 
     309                     tmpfac = ato_i(ji,jj) / w1 
     310                     closing_gross(ji,jj) = closing_gross(ji,jj) * tmpfac 
     311                     opning(ji,jj) = opning(ji,jj) * tmpfac 
     312                  ENDIF !w1 
     313               ENDIF !at0i and athorn 
     314 
     315            END DO ! ji 
     316         END DO ! jj 
     317 
     318         ! correction to closing rate / opening if excessive ice removal 
     319         !--------------------------------------------------------------- 
     320         ! Reduce the closing rate if more than 100% of any ice category  
     321         ! would be removed.  Reduce the opening rate proportionately. 
     322 
     323         DO jl = 1, jpl 
     324            DO jj = 1, jpj 
     325               DO ji = 1, jpi 
     326                  IF ( a_i(ji,jj,jl) .GT. epsi11 .AND. athorn(ji,jj,jl) .GT. 0.0 ) THEN 
     327                     w1 = athorn(ji,jj,jl) * closing_gross(ji,jj) * rdt_ice 
     328                     IF ( w1 .GT. a_i(ji,jj,jl) ) THEN 
     329                        tmpfac = a_i(ji,jj,jl) / w1 
     330                        closing_gross(ji,jj) = closing_gross(ji,jj) * tmpfac 
     331                        opning(ji,jj) = opning(ji,jj) * tmpfac 
     332                     ENDIF 
     333                  ENDIF 
     334               END DO !ji 
     335            END DO ! jj 
     336         END DO !jl 
     337 
     338         ! 3.3 Redistribute area, volume, and energy. 
     339         !-----------------------------------------------------------------------------! 
     340 
     341         CALL lim_itd_me_ridgeshift (opning,    closing_gross, & 
     342            msnow_mlt, esnow_mlt) 
     343 
     344         ! 3.4 Compute total area of ice plus open water after ridging. 
     345         !-----------------------------------------------------------------------------! 
     346 
     347         CALL lim_itd_me_asumr 
     348 
     349         ! 3.5 Do we keep on iterating ??? 
     350         !-----------------------------------------------------------------------------! 
     351         ! Check whether asum = 1.  If not (because the closing and opening 
     352         ! rates were reduced above), ridge again with new rates. 
     353 
     354         iterate_ridging = 0 
     355 
     356         DO jj = 1, jpj 
     357            DO ji = 1, jpi 
     358               IF (ABS(asum(ji,jj) - 1.0) .LT. epsi11) THEN 
     359                  closing_net(ji,jj) = 0.0  
     360                  opning(ji,jj)      = 0.0 
     361               ELSE 
     362                  iterate_ridging    = 1 
     363                  divu_adv(ji,jj)    = (1.0 - asum(ji,jj)) / rdt_ice 
     364                  closing_net(ji,jj) = MAX(0.0, -divu_adv(ji,jj)) 
     365                  opning(ji,jj)      = MAX(0.0, divu_adv(ji,jj)) 
     366               ENDIF 
     367            END DO 
     368         END DO 
     369 
     370         IF( lk_mpp ) CALL mpp_max(iterate_ridging) 
     371 
     372         ! Repeat if necessary. 
     373         ! NOTE: If strength smoothing is turned on, the ridging must be 
     374         ! iterated globally because of the boundary update in the  
     375         ! smoothing. 
     376 
     377         niter = niter + 1 
     378 
     379         IF (iterate_ridging == 1) THEN 
     380            IF (niter .GT. nitermax) THEN 
     381               WRITE(numout,*) ' ALERTE : non-converging ridging scheme ' 
     382               WRITE(numout,*) ' niter, iterate_ridging ', niter, iterate_ridging 
     383            ENDIF 
     384            CALL lim_itd_me_ridgeprep 
     385         ENDIF 
     386 
     387      END DO !! on the do while over iter 
     388 
     389      !-----------------------------------------------------------------------------! 
     390      ! 4) Ridging diagnostics 
     391      !-----------------------------------------------------------------------------! 
     392      ! Convert ridging rate diagnostics to correct units. 
     393      ! Update fresh water and heat fluxes due to snow melt. 
     394 
     395      dti = 1.0/rdt_ice 
     396 
     397      asum_error = .false.  
     398 
    292399      DO jj = 1, jpj 
    293400         DO ji = 1, jpi 
    294401 
    295 ! 3.2 closing_gross 
    296 !-----------------------------------------------------------------------------! 
    297 ! Based on the ITD of ridging and ridged ice, convert the net 
    298 !  closing rate to a gross closing rate.   
    299 ! NOTE: 0 < aksum <= 1 
    300             closing_gross(ji,jj) = closing_net(ji,jj) / aksum(ji,jj) 
    301  
    302 ! correction to closing rate and opening if closing rate is excessive 
    303 !--------------------------------------------------------------------- 
    304 ! Reduce the closing rate if more than 100% of the open water  
    305 ! would be removed.  Reduce the opening rate proportionately. 
    306             IF ( ato_i(ji,jj) .GT. epsi11 .AND. athorn(ji,jj,0) .GT. 0.0 ) THEN 
    307                w1 = athorn(ji,jj,0) * closing_gross(ji,jj) * rdt_ice 
    308                IF ( w1 .GT. ato_i(ji,jj)) THEN 
    309                   tmpfac = ato_i(ji,jj) / w1 
    310                   closing_gross(ji,jj) = closing_gross(ji,jj) * tmpfac 
    311                   opning(ji,jj) = opning(ji,jj) * tmpfac 
    312                ENDIF !w1 
    313             ENDIF !at0i and athorn 
    314  
    315          END DO ! ji 
    316       END DO ! jj 
    317  
    318 ! correction to closing rate / opening if excessive ice removal 
    319 !--------------------------------------------------------------- 
    320 ! Reduce the closing rate if more than 100% of any ice category  
    321 ! would be removed.  Reduce the opening rate proportionately. 
    322  
    323       DO jl = 1, jpl 
    324          DO jj = 1, jpj 
    325             DO ji = 1, jpi 
    326                IF ( a_i(ji,jj,jl) .GT. epsi11 .AND. athorn(ji,jj,jl) .GT. 0.0 ) THEN 
    327                   w1 = athorn(ji,jj,jl) * closing_gross(ji,jj) * rdt_ice 
    328                   IF ( w1 .GT. a_i(ji,jj,jl) ) THEN 
    329                      tmpfac = a_i(ji,jj,jl) / w1 
    330                      closing_gross(ji,jj) = closing_gross(ji,jj) * tmpfac 
    331                      opning(ji,jj) = opning(ji,jj) * tmpfac 
    332                   ENDIF 
    333                ENDIF 
    334             END DO !ji 
    335          END DO ! jj 
    336       END DO !jl 
    337  
    338 ! 3.3 Redistribute area, volume, and energy. 
    339 !-----------------------------------------------------------------------------! 
    340  
    341       CALL lim_itd_me_ridgeshift (opning,    closing_gross, & 
    342                         msnow_mlt, esnow_mlt) 
    343  
    344 ! 3.4 Compute total area of ice plus open water after ridging. 
    345 !-----------------------------------------------------------------------------! 
    346  
    347       CALL lim_itd_me_asumr 
    348  
    349 ! 3.5 Do we keep on iterating ??? 
    350 !-----------------------------------------------------------------------------! 
    351 ! Check whether asum = 1.  If not (because the closing and opening 
    352 ! rates were reduced above), ridge again with new rates. 
    353  
    354       iterate_ridging = 0 
    355  
    356       DO jj = 1, jpj 
    357          DO ji = 1, jpi 
    358             IF (ABS(asum(ji,jj) - 1.0) .LT. epsi11) THEN 
    359                closing_net(ji,jj) = 0.0  
    360                opning(ji,jj)      = 0.0 
    361             ELSE 
    362                iterate_ridging    = 1 
    363                divu_adv(ji,jj)    = (1.0 - asum(ji,jj)) / rdt_ice 
    364                closing_net(ji,jj) = MAX(0.0, -divu_adv(ji,jj)) 
    365                opning(ji,jj)      = MAX(0.0, divu_adv(ji,jj)) 
    366             ENDIF 
    367          END DO 
    368       END DO 
    369  
    370       IF( lk_mpp ) CALL mpp_max(iterate_ridging) 
    371  
    372 ! Repeat if necessary. 
    373 ! NOTE: If strength smoothing is turned on, the ridging must be 
    374 ! iterated globally because of the boundary update in the  
    375 ! smoothing. 
    376  
    377       niter = niter + 1 
    378  
    379       IF (iterate_ridging == 1) THEN 
    380          IF (niter .GT. nitermax) THEN 
    381             WRITE(numout,*) ' ALERTE : non-converging ridging scheme ' 
    382             WRITE(numout,*) ' niter, iterate_ridging ', niter, iterate_ridging 
    383          ENDIF 
    384          CALL lim_itd_me_ridgeprep 
    385       ENDIF 
    386  
    387       END DO !! on the do while over iter 
    388  
    389 !-----------------------------------------------------------------------------! 
    390 ! 4) Ridging diagnostics 
    391 !-----------------------------------------------------------------------------! 
    392 ! Convert ridging rate diagnostics to correct units. 
    393 ! Update fresh water and heat fluxes due to snow melt. 
    394  
    395       dti = 1.0/rdt_ice 
    396  
    397       asum_error = .false.  
    398  
    399       DO jj = 1, jpj 
    400          DO ji = 1, jpi 
    401  
    402          IF (ABS(asum(ji,jj) - 1.0) .GT. epsi11) asum_error = .true. 
    403  
    404          dardg1dt(ji,jj) = dardg1dt(ji,jj) * dti 
    405          dardg2dt(ji,jj) = dardg2dt(ji,jj) * dti 
    406          dvirdgdt(ji,jj) = dvirdgdt(ji,jj) * dti 
    407          opening (ji,jj) = opening (ji,jj) * dti 
    408  
    409 !-----------------------------------------------------------------------------! 
    410 ! 5) Heat, salt and freshwater fluxes 
    411 !-----------------------------------------------------------------------------! 
    412          ! fresh water source for ocean 
    413          fmmec(ji,jj)      = fmmec(ji,jj)      + msnow_mlt(ji,jj)*dti   
    414        
    415          ! heat sink for ocean 
    416          fhmec(ji,jj)      = fhmec(ji,jj)      + esnow_mlt(ji,jj)*dti 
     402            IF (ABS(asum(ji,jj) - 1.0) .GT. epsi11) asum_error = .true. 
     403 
     404            dardg1dt(ji,jj) = dardg1dt(ji,jj) * dti 
     405            dardg2dt(ji,jj) = dardg2dt(ji,jj) * dti 
     406            dvirdgdt(ji,jj) = dvirdgdt(ji,jj) * dti 
     407            opening (ji,jj) = opening (ji,jj) * dti 
     408 
     409            !-----------------------------------------------------------------------------! 
     410            ! 5) Heat, salt and freshwater fluxes 
     411            !-----------------------------------------------------------------------------! 
     412            ! fresh water source for ocean 
     413            fmmec(ji,jj)      = fmmec(ji,jj)      + msnow_mlt(ji,jj)*dti   
     414 
     415            ! heat sink for ocean 
     416            fhmec(ji,jj)      = fhmec(ji,jj)      + esnow_mlt(ji,jj)*dti 
    417417 
    418418         END DO 
     
    444444      ENDIF 
    445445 
    446 !-----------------------------------------------------------------------------! 
    447 ! 6) Updating state variables and trend terms 
    448 !-----------------------------------------------------------------------------! 
     446      !-----------------------------------------------------------------------------! 
     447      ! 6) Updating state variables and trend terms 
     448      !-----------------------------------------------------------------------------! 
    449449 
    450450      CALL lim_var_glo2eqv 
     
    465465      d_smv_i_trp(:,:,:)   = 0.0 
    466466      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) & 
    467       d_smv_i_trp(:,:,:)  = smv_i(:,:,:) - old_smv_i(:,:,:) 
     467         d_smv_i_trp(:,:,:)  = smv_i(:,:,:) - old_smv_i(:,:,:) 
    468468 
    469469      IF(ln_ctl) THEN     ! Control print 
     
    513513      oa_i(:,:,:)   = old_oa_i(:,:,:) 
    514514      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) &  
    515       smv_i(:,:,:)  = old_smv_i(:,:,:) 
     515         smv_i(:,:,:)  = old_smv_i(:,:,:) 
    516516 
    517517      !----------------------------------------------------! 
     
    528528               DO ji = 1, jpi 
    529529                  IF ( ( old_v_i(ji,jj,jl) .LT. epsi06 ) .AND. & 
    530                        ( d_v_i_trp(ji,jj,jl) .GT. epsi06 ) ) THEN 
    531                       old_e_i(ji,jj,jk,jl)   = d_e_i_trp(ji,jj,jk,jl) 
    532                       d_e_i_trp(ji,jj,jk,jl) = 0.0 
     530                     ( d_v_i_trp(ji,jj,jl) .GT. epsi06 ) ) THEN 
     531                     old_e_i(ji,jj,jk,jl)   = d_e_i_trp(ji,jj,jk,jl) 
     532                     d_e_i_trp(ji,jj,jk,jl) = 0.0 
    533533                  ENDIF 
    534534               END DO 
     
    541541            DO ji = 1, jpi 
    542542               IF ( ( old_v_i(ji,jj,jl) .LT. epsi06 ) .AND. & 
    543                     ( d_v_i_trp(ji,jj,jl) .GT. epsi06 ) ) THEN 
    544                    old_v_i(ji,jj,jl)     = d_v_i_trp(ji,jj,jl) 
    545                    d_v_i_trp(ji,jj,jl)   = 0.0 
    546                    old_a_i(ji,jj,jl)     = d_a_i_trp(ji,jj,jl) 
    547                    d_a_i_trp(ji,jj,jl)   = 0.0 
    548                    old_v_s(ji,jj,jl)     = d_v_s_trp(ji,jj,jl) 
    549                    d_v_s_trp(ji,jj,jl)   = 0.0 
    550                    old_e_s(ji,jj,1,jl)   = d_e_s_trp(ji,jj,1,jl) 
    551                    d_e_s_trp(ji,jj,1,jl) = 0.0 
    552                    old_oa_i(ji,jj,jl)    = d_oa_i_trp(ji,jj,jl) 
    553                    d_oa_i_trp(ji,jj,jl)  = 0.0 
    554                    IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) &  
    555                    old_smv_i(ji,jj,jl)   = d_smv_i_trp(ji,jj,jl) 
    556                    d_smv_i_trp(ji,jj,jl) = 0.0 
     543                  ( d_v_i_trp(ji,jj,jl) .GT. epsi06 ) ) THEN 
     544                  old_v_i(ji,jj,jl)     = d_v_i_trp(ji,jj,jl) 
     545                  d_v_i_trp(ji,jj,jl)   = 0.0 
     546                  old_a_i(ji,jj,jl)     = d_a_i_trp(ji,jj,jl) 
     547                  d_a_i_trp(ji,jj,jl)   = 0.0 
     548                  old_v_s(ji,jj,jl)     = d_v_s_trp(ji,jj,jl) 
     549                  d_v_s_trp(ji,jj,jl)   = 0.0 
     550                  old_e_s(ji,jj,1,jl)   = d_e_s_trp(ji,jj,1,jl) 
     551                  d_e_s_trp(ji,jj,1,jl) = 0.0 
     552                  old_oa_i(ji,jj,jl)    = d_oa_i_trp(ji,jj,jl) 
     553                  d_oa_i_trp(ji,jj,jl)  = 0.0 
     554                  IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) &  
     555                     old_smv_i(ji,jj,jl)   = d_smv_i_trp(ji,jj,jl) 
     556                  d_smv_i_trp(ji,jj,jl) = 0.0 
    557557               ENDIF 
    558558            END DO 
    559559         END DO 
    560560      END DO 
    561           
     561 
    562562   END SUBROUTINE lim_itd_me 
    563563 
    564 !=============================================================================== 
     564   !=============================================================================== 
    565565 
    566566   SUBROUTINE lim_itd_me_icestrength (kstrngth) ! (subroutine 2/6) 
    567567 
    568         !!---------------------------------------------------------------------- 
    569         !!                ***  ROUTINE lim_itd_me_icestrength *** 
    570         !! ** Purpose : 
    571         !!        This routine computes ice strength used in dynamics routines 
    572         !!                      of ice thickness 
    573         !! 
    574         !! ** Method  : 
    575         !!       Compute the strength of the ice pack, defined as the energy (J m-2)  
    576         !! dissipated per unit area removed from the ice pack under compression, 
    577         !! and assumed proportional to the change in potential energy caused 
    578         !! by ridging. Note that only Hibler's formulation is stable and that 
    579         !! ice strength has to be smoothed 
    580         !! 
    581         !! ** Inputs / Ouputs : kstrngth (what kind of ice strength we are using) 
    582         !! 
    583         !! ** External :  
    584         !! 
    585         !! ** References : 
    586         !!                 
    587         !!---------------------------------------------------------------------- 
    588         !! * Arguments 
    589   
     568      !!---------------------------------------------------------------------- 
     569      !!                ***  ROUTINE lim_itd_me_icestrength *** 
     570      !! ** Purpose : 
     571      !!        This routine computes ice strength used in dynamics routines 
     572      !!                      of ice thickness 
     573      !! 
     574      !! ** Method  : 
     575      !!       Compute the strength of the ice pack, defined as the energy (J m-2)  
     576      !! dissipated per unit area removed from the ice pack under compression, 
     577      !! and assumed proportional to the change in potential energy caused 
     578      !! by ridging. Note that only Hibler's formulation is stable and that 
     579      !! ice strength has to be smoothed 
     580      !! 
     581      !! ** Inputs / Ouputs : kstrngth (what kind of ice strength we are using) 
     582      !! 
     583      !! ** External :  
     584      !! 
     585      !! ** References : 
     586      !!                 
     587      !!---------------------------------------------------------------------- 
     588      !! * Arguments 
     589 
    590590      INTEGER, INTENT(in) :: & 
    591591         kstrngth    ! = 1 for Rothrock formulation, 0 for Hibler (1979) 
     
    606606         zworka              !: temporary array used here 
    607607 
    608 !------------------------------------------------------------------------------! 
    609 ! 1) Initialize 
    610 !------------------------------------------------------------------------------! 
     608      !------------------------------------------------------------------------------! 
     609      ! 1) Initialize 
     610      !------------------------------------------------------------------------------! 
    611611      strength(:,:) = 0.0 
    612612 
    613 !------------------------------------------------------------------------------! 
    614 ! 2) Compute thickness distribution of ridging and ridged ice 
    615 !------------------------------------------------------------------------------! 
     613      !------------------------------------------------------------------------------! 
     614      ! 2) Compute thickness distribution of ridging and ridged ice 
     615      !------------------------------------------------------------------------------! 
    616616      CALL lim_itd_me_ridgeprep 
    617617 
    618 !------------------------------------------------------------------------------! 
    619 ! 3) Rothrock(1975)'s method 
    620 !------------------------------------------------------------------------------! 
     618      !------------------------------------------------------------------------------! 
     619      ! 3) Rothrock(1975)'s method 
     620      !------------------------------------------------------------------------------! 
    621621      IF (kstrngth == 1) then 
    622622 
     
    626626 
    627627                  IF(     ( a_i(ji,jj,jl)    .GT. epsi11 )                     & 
    628                     .AND. ( athorn(ji,jj,jl) .GT. 0.0    ) ) THEN 
     628                     .AND. ( athorn(ji,jj,jl) .GT. 0.0    ) ) THEN 
    629629                     hi = v_i(ji,jj,jl) / a_i(ji,jj,jl) 
    630630                     !---------------------------- 
     
    632632                     !---------------------------- 
    633633                     strength(ji,jj) = strength(ji,jj) - athorn(ji,jj,jl) *    & 
    634                      hi * hi 
     634                        hi * hi 
    635635 
    636636                     !-------------------------- 
     
    638638                     !-------------------------- 
    639639                     strength(ji,jj) = strength(ji,jj) + 2.0 * araft(ji,jj,jl) & 
    640                      * hi * hi 
     640                        * hi * hi 
    641641 
    642642                     !---------------------------- 
     
    644644                     !---------------------------- 
    645645                     strength(ji,jj) = strength(ji,jj)                         & 
    646                      + aridge(ji,jj,jl)/krdg(ji,jj,jl)                         & 
    647                      * 1.0/3.0 * (hrmax(ji,jj,jl)**3 - hrmin(ji,jj,jl)**3)     & 
    648                      / (hrmax(ji,jj,jl)-hrmin(ji,jj,jl))                       
     646                        + aridge(ji,jj,jl)/krdg(ji,jj,jl)                         & 
     647                        * 1.0/3.0 * (hrmax(ji,jj,jl)**3 - hrmin(ji,jj,jl)**3)     & 
     648                        / (hrmax(ji,jj,jl)-hrmin(ji,jj,jl))                       
    649649                  ENDIF            ! aicen > epsi11 
    650650 
     
    656656            DO ji = 1, jpi 
    657657               strength(ji,jj) = Cf * Cp * strength(ji,jj) / aksum(ji,jj)  
    658                           ! Cp = (g/2)*(rhow-rhoi)*(rhoi/rhow) 
    659                           ! Cf accounts for frictional dissipation 
    660                 
     658               ! Cp = (g/2)*(rhow-rhoi)*(rhoi/rhow) 
     659               ! Cf accounts for frictional dissipation 
     660 
    661661            END DO              ! j 
    662662         END DO                 ! i 
     
    664664         ksmooth = 1 
    665665 
    666 !------------------------------------------------------------------------------! 
    667 ! 4) Hibler (1979)' method 
    668 !------------------------------------------------------------------------------! 
     666         !------------------------------------------------------------------------------! 
     667         ! 4) Hibler (1979)' method 
     668         !------------------------------------------------------------------------------! 
    669669      ELSE                      ! kstrngth ne 1:  Hibler (1979) form 
    670670 
     
    679679      ENDIF                     ! kstrngth 
    680680 
    681 ! 
    682 !------------------------------------------------------------------------------! 
    683 ! 5) Impact of brine volume 
    684 !------------------------------------------------------------------------------! 
    685 ! CAN BE REMOVED 
    686 ! 
     681      ! 
     682      !------------------------------------------------------------------------------! 
     683      ! 5) Impact of brine volume 
     684      !------------------------------------------------------------------------------! 
     685      ! CAN BE REMOVED 
     686      ! 
    687687      IF ( brinstren_swi .EQ. 1 ) THEN 
    688688 
     
    700700      ENDIF 
    701701 
    702 ! 
    703 !------------------------------------------------------------------------------! 
    704 ! 6) Smoothing ice strength 
    705 !------------------------------------------------------------------------------! 
    706 ! 
     702      ! 
     703      !------------------------------------------------------------------------------! 
     704      ! 6) Smoothing ice strength 
     705      !------------------------------------------------------------------------------! 
     706      ! 
    707707      !------------------- 
    708708      ! Spatial smoothing 
     
    715715            DO ji = 2, jpi - 1 
    716716               IF ( ( asum(ji,jj) - ato_i(ji,jj) ) .GT. epsi11) THEN ! ice is 
    717                                                                      ! present 
     717                  ! present 
    718718                  zworka(ji,jj) = 4.0 * strength(ji,jj)              & 
    719                                   + strength(ji-1,jj) * tms(ji-1,jj) &   
    720                                   + strength(ji+1,jj) * tms(ji+1,jj) &   
    721                                   + strength(ji,jj-1) * tms(ji,jj-1) &   
    722                                   + strength(ji,jj+1) * tms(ji,jj+1)     
     719                     + strength(ji-1,jj) * tms(ji-1,jj) &   
     720                     + strength(ji+1,jj) * tms(ji+1,jj) &   
     721                     + strength(ji,jj-1) * tms(ji,jj-1) &   
     722                     + strength(ji,jj+1) * tms(ji,jj+1)     
    723723 
    724724                  zw1 = 4.0 + tms(ji-1,jj) + tms(ji+1,jj)            & 
    725                             + tms(ji,jj-1) + tms(ji,jj+1) 
     725                     + tms(ji,jj-1) + tms(ji,jj+1) 
    726726                  zworka(ji,jj) = zworka(ji,jj) / zw1 
    727727               ELSE 
     
    749749 
    750750      IF ( ksmooth .EQ. 2 ) THEN 
    751                   
    752           
     751 
     752 
    753753         CALL lbc_lnk( strength, 'T', 1. ) 
    754              
     754 
    755755         DO jj = 1, jpj - 1 
    756756            DO ji = 1, jpi - 1 
    757757               IF ( ( asum(ji,jj) - ato_i(ji,jj) ) .GT. epsi11) THEN ! ice is 
    758                                                                      ! present 
     758                  ! present 
    759759                  numts_rm = 1 ! number of time steps for the running mean 
    760760                  IF ( strp1(ji,jj) .GT. 0.0 ) numts_rm = numts_rm + 1 
    761761                  IF ( strp2(ji,jj) .GT. 0.0 ) numts_rm = numts_rm + 1 
    762762                  zp = ( strength(ji,jj) + strp1(ji,jj) + strp2(ji,jj) ) /   & 
    763                        numts_rm 
     763                     numts_rm 
    764764                  strp2(ji,jj) = strp1(ji,jj) 
    765765                  strp1(ji,jj) = strength(ji,jj) 
     
    771771 
    772772      ENDIF ! ksmooth 
    773        
     773 
    774774      ! Boundary conditions 
    775775      CALL lbc_lnk( strength, 'T', 1. ) 
    776776 
    777       END SUBROUTINE lim_itd_me_icestrength 
    778  
    779 !=============================================================================== 
    780  
    781       SUBROUTINE lim_itd_me_ridgeprep !(subroutine 3/6) 
    782  
    783         !!---------------------------------------------------------------------! 
    784         !!                ***  ROUTINE lim_itd_me_ridgeprep *** 
    785         !! ** Purpose : 
    786         !!         preparation for ridging and strength calculations 
    787         !! 
    788         !! ** Method  : 
    789         !! Compute the thickness distribution of the ice and open water  
    790         !! participating in ridging and of the resulting ridges. 
    791         !! 
    792         !! ** Arguments : 
    793         !! 
    794         !! ** External :  
    795         !! 
    796         !!---------------------------------------------------------------------! 
    797         !! * Arguments 
    798   
     777   END SUBROUTINE lim_itd_me_icestrength 
     778 
     779   !=============================================================================== 
     780 
     781   SUBROUTINE lim_itd_me_ridgeprep !(subroutine 3/6) 
     782 
     783      !!---------------------------------------------------------------------! 
     784      !!                ***  ROUTINE lim_itd_me_ridgeprep *** 
     785      !! ** Purpose : 
     786      !!         preparation for ridging and strength calculations 
     787      !! 
     788      !! ** Method  : 
     789      !! Compute the thickness distribution of the ice and open water  
     790      !! participating in ridging and of the resulting ridges. 
     791      !! 
     792      !! ** Arguments : 
     793      !! 
     794      !! ** External :  
     795      !! 
     796      !!---------------------------------------------------------------------! 
     797      !! * Arguments 
     798 
    799799      INTEGER :: & 
    800800         ji,jj,  &          ! horizontal indices 
     
    820820         epsi06 = 1.0e-6 
    821821 
    822 !------------------------------------------------------------------------------! 
     822      !------------------------------------------------------------------------------! 
    823823 
    824824      Gstari     = 1.0/Gstar     
     
    833833      krdg (:,:,:)  = 1.0 
    834834 
    835 !     ! Zero out categories with very small areas 
     835      !     ! Zero out categories with very small areas 
    836836      CALL lim_itd_me_zapsmall 
    837837 
    838 !------------------------------------------------------------------------------! 
    839 ! 1) Participation function  
    840 !------------------------------------------------------------------------------! 
     838      !------------------------------------------------------------------------------! 
     839      ! 1) Participation function  
     840      !------------------------------------------------------------------------------! 
    841841 
    842842      ! Compute total area of ice plus open water. 
     
    886886            DO ji = 1, jpi 
    887887               Gsum(ji,jj,jl) = Gsum(ji,jj,jl) * zworka(ji,jj) 
    888             END DO  
     888            END DO 
    889889         END DO 
    890890      END DO 
    891891 
    892 ! 1.3 Compute participation function a(h) = b(h).g(h) (athorn) 
    893 !-------------------------------------------------------------------------------------------------- 
    894 ! Compute the participation function athorn; this is analogous to 
    895 ! a(h) = b(h)g(h) as defined in Thorndike et al. (1975). 
    896 ! area lost from category n due to ridging/closing 
    897 ! athorn(n)   = total area lost due to ridging/closing 
    898 ! assume b(h) = (2/Gstar) * (1 - G(h)/Gstar).  
    899 ! 
    900 ! The expressions for athorn are found by integrating b(h)g(h) between 
    901 ! the category boundaries. 
    902 !----------------------------------------------------------------- 
     892      ! 1.3 Compute participation function a(h) = b(h).g(h) (athorn) 
     893      !-------------------------------------------------------------------------------------------------- 
     894      ! Compute the participation function athorn; this is analogous to 
     895      ! a(h) = b(h)g(h) as defined in Thorndike et al. (1975). 
     896      ! area lost from category n due to ridging/closing 
     897      ! athorn(n)   = total area lost due to ridging/closing 
     898      ! assume b(h) = (2/Gstar) * (1 - G(h)/Gstar).  
     899      ! 
     900      ! The expressions for athorn are found by integrating b(h)g(h) between 
     901      ! the category boundaries. 
     902      !----------------------------------------------------------------- 
    903903 
    904904      krdg_index = 1 
     
    906906      IF ( krdg_index .EQ. 0 ) THEN 
    907907 
    908       !--- Linear formulation (Thorndike et al., 1975) 
    909       DO jl = 0, ice_cat_bounds(1,2) ! only undeformed ice participates 
    910          DO jj = 1, jpj  
    911             DO ji = 1, jpi 
    912                IF (Gsum(ji,jj,jl) < Gstar) THEN 
    913                   athorn(ji,jj,jl) = Gstari * (Gsum(ji,jj,jl)-Gsum(ji,jj,jl-1)) * & 
    914                        (2.0 - (Gsum(ji,jj,jl-1)+Gsum(ji,jj,jl))*Gstari) 
    915                ELSEIF (Gsum(ji,jj,jl-1) < Gstar) THEN 
    916                   athorn(ji,jj,jl) = Gstari * (Gstar-Gsum(ji,jj,jl-1)) *  & 
    917                        (2.0 - (Gsum(ji,jj,jl-1)+Gstar)*Gstari) 
    918                ELSE 
    919                   athorn(ji,jj,jl) = 0.0 
    920                ENDIF 
    921             END DO ! ji 
    922          END DO ! jj 
    923       END DO ! jl  
     908         !--- Linear formulation (Thorndike et al., 1975) 
     909         DO jl = 0, ice_cat_bounds(1,2) ! only undeformed ice participates 
     910            DO jj = 1, jpj  
     911               DO ji = 1, jpi 
     912                  IF (Gsum(ji,jj,jl) < Gstar) THEN 
     913                     athorn(ji,jj,jl) = Gstari * (Gsum(ji,jj,jl)-Gsum(ji,jj,jl-1)) * & 
     914                        (2.0 - (Gsum(ji,jj,jl-1)+Gsum(ji,jj,jl))*Gstari) 
     915                  ELSEIF (Gsum(ji,jj,jl-1) < Gstar) THEN 
     916                     athorn(ji,jj,jl) = Gstari * (Gstar-Gsum(ji,jj,jl-1)) *  & 
     917                        (2.0 - (Gsum(ji,jj,jl-1)+Gstar)*Gstari) 
     918                  ELSE 
     919                     athorn(ji,jj,jl) = 0.0 
     920                  ENDIF 
     921               END DO ! ji 
     922            END DO ! jj 
     923         END DO ! jl  
    924924 
    925925      ELSE ! krdg_index = 1 
    926        
    927       !--- Exponential, more stable formulation (Lipscomb et al, 2007) 
    928       ! precompute exponential terms using Gsum as a work array 
    929       zdummy = 1.0 / (1.0-EXP(-astari)) 
    930  
    931       DO jl = -1, jpl 
    932          DO jj = 1, jpj 
    933             DO ji = 1, jpi 
    934                Gsum(ji,jj,jl) = EXP(-Gsum(ji,jj,jl)*astari)*zdummy 
    935             END DO !ji 
    936          END DO !jj 
    937       END DO !jl 
    938  
    939       ! compute athorn 
    940       DO jl = 0, ice_cat_bounds(1,2) 
    941          DO jj = 1, jpj 
    942             DO ji = 1, jpi 
    943                athorn(ji,jj,jl) = Gsum(ji,jj,jl-1) - Gsum(ji,jj,jl) 
    944             END DO !ji 
    945          END DO ! jj 
    946       END DO !jl 
     926 
     927         !--- Exponential, more stable formulation (Lipscomb et al, 2007) 
     928         ! precompute exponential terms using Gsum as a work array 
     929         zdummy = 1.0 / (1.0-EXP(-astari)) 
     930 
     931         DO jl = -1, jpl 
     932            DO jj = 1, jpj 
     933               DO ji = 1, jpi 
     934                  Gsum(ji,jj,jl) = EXP(-Gsum(ji,jj,jl)*astari)*zdummy 
     935               END DO !ji 
     936            END DO !jj 
     937         END DO !jl 
     938 
     939         ! compute athorn 
     940         DO jl = 0, ice_cat_bounds(1,2) 
     941            DO jj = 1, jpj 
     942               DO ji = 1, jpi 
     943                  athorn(ji,jj,jl) = Gsum(ji,jj,jl-1) - Gsum(ji,jj,jl) 
     944               END DO !ji 
     945            END DO ! jj 
     946         END DO !jl 
    947947 
    948948      ENDIF ! krdg_index 
     
    956956                  IF ( athorn(ji,jj,jl) .GT. 0.0 ) THEN 
    957957                     aridge(ji,jj,jl) = ( TANH ( Craft * ( ht_i(ji,jj,jl) - & 
    958                                           hparmeter ) ) + 1.0 ) / 2.0 * &  
    959                                           athorn(ji,jj,jl) 
     958                        hparmeter ) ) + 1.0 ) / 2.0 * &  
     959                        athorn(ji,jj,jl) 
    960960                     araft (ji,jj,jl) = ( TANH ( - Craft * ( ht_i(ji,jj,jl) - & 
    961                                           hparmeter ) ) + 1.0 ) / 2.0 * & 
    962                                           athorn(ji,jj,jl) 
     961                        hparmeter ) ) + 1.0 ) / 2.0 * & 
     962                        athorn(ji,jj,jl) 
    963963                     IF ( araft(ji,jj,jl) .LT. epsi06 ) araft(ji,jj,jl)  = 0.0 
    964964                     aridge(ji,jj,jl) = MAX( athorn(ji,jj,jl) - araft(ji,jj,jl), 0.0) 
     
    982982      IF ( raftswi .EQ. 1 ) THEN 
    983983 
    984       IF( MAXVAL(aridge + araft - athorn(:,:,1:jpl)) .GT. epsi11 ) THEN 
    985          DO jl = 1, jpl 
    986             DO jj = 1, jpj 
    987                DO ji = 1, jpi 
    988                   IF ( aridge(ji,jj,jl) + araft(ji,jj,jl) - athorn(ji,jj,jl) .GT. & 
    989                   epsi11 ) THEN 
    990                      WRITE(numout,*) ' ALERTE 96 : wrong participation function ... ' 
    991                      WRITE(numout,*) ' ji, jj, jl : ', ji, jj, jl 
    992                      WRITE(numout,*) ' lat, lon   : ', gphit(ji,jj), glamt(ji,jj) 
    993                      WRITE(numout,*) ' aridge     : ', aridge(ji,jj,1:jpl) 
    994                      WRITE(numout,*) ' araft      : ', araft(ji,jj,1:jpl) 
    995                      WRITE(numout,*) ' athorn     : ', athorn(ji,jj,1:jpl) 
    996                   ENDIF 
     984         IF( MAXVAL(aridge + araft - athorn(:,:,1:jpl)) .GT. epsi11 ) THEN 
     985            DO jl = 1, jpl 
     986               DO jj = 1, jpj 
     987                  DO ji = 1, jpi 
     988                     IF ( aridge(ji,jj,jl) + araft(ji,jj,jl) - athorn(ji,jj,jl) .GT. & 
     989                        epsi11 ) THEN 
     990                        WRITE(numout,*) ' ALERTE 96 : wrong participation function ... ' 
     991                        WRITE(numout,*) ' ji, jj, jl : ', ji, jj, jl 
     992                        WRITE(numout,*) ' lat, lon   : ', gphit(ji,jj), glamt(ji,jj) 
     993                        WRITE(numout,*) ' aridge     : ', aridge(ji,jj,1:jpl) 
     994                        WRITE(numout,*) ' araft      : ', araft(ji,jj,1:jpl) 
     995                        WRITE(numout,*) ' athorn     : ', athorn(ji,jj,1:jpl) 
     996                     ENDIF 
     997                  END DO 
    997998               END DO 
    998999            END DO 
    999          END DO 
     1000         ENDIF 
     1001 
    10001002      ENDIF 
    10011003 
    1002       ENDIF 
    1003  
    1004 !----------------------------------------------------------------- 
    1005 ! 2) Transfer function 
    1006 !----------------------------------------------------------------- 
    1007 ! Compute max and min ridged ice thickness for each ridging category. 
    1008 ! Assume ridged ice is uniformly distributed between hrmin and hrmax. 
    1009 !  
    1010 ! This parameterization is a modified version of Hibler (1980). 
    1011 ! The mean ridging thickness, hrmean, is proportional to hi^(0.5) 
    1012 !  and for very thick ridging ice must be >= krdgmin*hi 
    1013 ! 
    1014 ! The minimum ridging thickness, hrmin, is equal to 2*hi  
    1015 !  (i.e., rafting) and for very thick ridging ice is 
    1016 !  constrained by hrmin <= (hrmean + hi)/2. 
    1017 !  
    1018 ! The maximum ridging thickness, hrmax, is determined by 
    1019 !  hrmean and hrmin. 
    1020 ! 
    1021 ! These modifications have the effect of reducing the ice strength 
    1022 ! (relative to the Hibler formulation) when very thick ice is 
    1023 ! ridging. 
    1024 ! 
    1025 ! aksum = net area removed/ total area removed 
    1026 ! where total area removed = area of ice that ridges 
    1027 !         net area removed = total area removed - area of new ridges 
    1028 !----------------------------------------------------------------- 
     1004      !----------------------------------------------------------------- 
     1005      ! 2) Transfer function 
     1006      !----------------------------------------------------------------- 
     1007      ! Compute max and min ridged ice thickness for each ridging category. 
     1008      ! Assume ridged ice is uniformly distributed between hrmin and hrmax. 
     1009      !  
     1010      ! This parameterization is a modified version of Hibler (1980). 
     1011      ! The mean ridging thickness, hrmean, is proportional to hi^(0.5) 
     1012      !  and for very thick ridging ice must be >= krdgmin*hi 
     1013      ! 
     1014      ! The minimum ridging thickness, hrmin, is equal to 2*hi  
     1015      !  (i.e., rafting) and for very thick ridging ice is 
     1016      !  constrained by hrmin <= (hrmean + hi)/2. 
     1017      !  
     1018      ! The maximum ridging thickness, hrmax, is determined by 
     1019      !  hrmean and hrmin. 
     1020      ! 
     1021      ! These modifications have the effect of reducing the ice strength 
     1022      ! (relative to the Hibler formulation) when very thick ice is 
     1023      ! ridging. 
     1024      ! 
     1025      ! aksum = net area removed/ total area removed 
     1026      ! where total area removed = area of ice that ridges 
     1027      !         net area removed = total area removed - area of new ridges 
     1028      !----------------------------------------------------------------- 
    10291029 
    10301030      ! Transfer function 
     
    10621062            DO ji = 1, jpi 
    10631063               aksum(ji,jj)    = aksum(ji,jj)                          & 
    1064                        + aridge(ji,jj,jl) * (1.0 - 1.0/krdg(ji,jj,jl))    & 
    1065                        + araft (ji,jj,jl) * (1.0 - 1.0/kraft) 
     1064                  + aridge(ji,jj,jl) * (1.0 - 1.0/krdg(ji,jj,jl))    & 
     1065                  + araft (ji,jj,jl) * (1.0 - 1.0/kraft) 
    10661066            END DO 
    10671067         END DO 
    10681068      END DO 
    10691069 
    1070       END SUBROUTINE lim_itd_me_ridgeprep 
    1071  
    1072 !=============================================================================== 
    1073  
    1074       SUBROUTINE lim_itd_me_ridgeshift(opning,    closing_gross,       & 
    1075                               msnow_mlt, esnow_mlt) ! (subroutine 4/6) 
    1076  
    1077         !!----------------------------------------------------------------------------- 
    1078         !!                ***  ROUTINE lim_itd_me_icestrength *** 
    1079         !! ** Purpose : 
    1080         !!        This routine shift ridging ice among thickness categories 
    1081         !!                      of ice thickness 
    1082         !! 
    1083         !! ** Method  : 
    1084         !! Remove area, volume, and energy from each ridging category 
    1085         !! and add to thicker ice categories. 
    1086         !! 
    1087         !! ** Arguments : 
    1088         !! 
    1089         !! ** Inputs / Ouputs :  
    1090         !! 
    1091         !! ** External :  
    1092         !! 
     1070   END SUBROUTINE lim_itd_me_ridgeprep 
     1071 
     1072   !=============================================================================== 
     1073 
     1074   SUBROUTINE lim_itd_me_ridgeshift(opning,    closing_gross,       & 
     1075      msnow_mlt, esnow_mlt) ! (subroutine 4/6) 
     1076 
     1077      !!----------------------------------------------------------------------------- 
     1078      !!                ***  ROUTINE lim_itd_me_icestrength *** 
     1079      !! ** Purpose : 
     1080      !!        This routine shift ridging ice among thickness categories 
     1081      !!                      of ice thickness 
     1082      !! 
     1083      !! ** Method  : 
     1084      !! Remove area, volume, and energy from each ridging category 
     1085      !! and add to thicker ice categories. 
     1086      !! 
     1087      !! ** Arguments : 
     1088      !! 
     1089      !! ** Inputs / Ouputs :  
     1090      !! 
     1091      !! ** External :  
     1092      !! 
    10931093 
    10941094      REAL (wp), DIMENSION(jpi,jpj), INTENT(IN)   :: & 
    10951095         opning,         & ! rate of opening due to divergence/shear 
    10961096         closing_gross     ! rate at which area removed, not counting 
    1097                            ! area of new ridges 
     1097      ! area of new ridges 
    10981098 
    10991099      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: & 
     
    11761176      LOGICAL, PARAMETER :: & 
    11771177         l_conservation_check = .true.  ! if true, check conservation  
    1178                                         ! (useful for debugging) 
     1178      ! (useful for debugging) 
    11791179      LOGICAL ::         & 
    11801180         neg_ato_i     , &  ! flag for ato_i(i,j) < -puny 
     
    11871187         zindb              ! switch for the presence of ridge poros or not 
    11881188 
    1189    !---------------------------------------------------------------------------- 
     1189      !---------------------------------------------------------------------------- 
    11901190 
    11911191      ! Conservation check 
     
    12021202      epsi10 = 1.0d-10 
    12031203 
    1204 !------------------------------------------------------------------------------- 
    1205 ! 1) Compute change in open water area due to closing and opening. 
    1206 !------------------------------------------------------------------------------- 
     1204      !------------------------------------------------------------------------------- 
     1205      ! 1) Compute change in open water area due to closing and opening. 
     1206      !------------------------------------------------------------------------------- 
    12071207 
    12081208      neg_ato_i = .false. 
     
    12111211         DO ji = 1, jpi 
    12121212            ato_i(ji,jj) = ato_i(ji,jj)                                   & 
    1213                     - athorn(ji,jj,0)*closing_gross(ji,jj)*rdt_ice        & 
    1214                     + opning(ji,jj)*rdt_ice 
     1213               - athorn(ji,jj,0)*closing_gross(ji,jj)*rdt_ice        & 
     1214               + opning(ji,jj)*rdt_ice 
    12151215            IF (ato_i(ji,jj) .LT. -epsi11) THEN 
    12161216               neg_ato_i = .true. 
     
    12341234      ENDIF                     ! neg_ato_i 
    12351235 
    1236 !----------------------------------------------------------------- 
    1237 ! 2) Save initial state variables 
    1238 !----------------------------------------------------------------- 
     1236      !----------------------------------------------------------------- 
     1237      ! 2) Save initial state variables 
     1238      !----------------------------------------------------------------- 
    12391239 
    12401240      DO jl = 1, jpl 
     
    12521252 
    12531253      esnon_init(:,:,:) = e_s(:,:,1,:) 
    1254              
     1254 
    12551255      DO jl = 1, jpl   
    12561256         DO jk = 1, nlay_i 
     
    12631263      END DO !jl 
    12641264 
    1265 ! 
    1266 !----------------------------------------------------------------- 
    1267 ! 3) Pump everything from ice which is being ridged / rafted 
    1268 !----------------------------------------------------------------- 
    1269 ! Compute the area, volume, and energy of ice ridging in each 
    1270 ! category, along with the area of the resulting ridge. 
     1265      ! 
     1266      !----------------------------------------------------------------- 
     1267      ! 3) Pump everything from ice which is being ridged / rafted 
     1268      !----------------------------------------------------------------- 
     1269      ! Compute the area, volume, and energy of ice ridging in each 
     1270      ! category, along with the area of the resulting ridge. 
    12711271 
    12721272      DO jl1 = 1, jpl !jl1 describes the ridging category 
    12731273 
    1274       !------------------------------------------------ 
    1275       ! 3.1) Identify grid cells with nonzero ridging 
    1276       !------------------------------------------------ 
     1274         !------------------------------------------------ 
     1275         ! 3.1) Identify grid cells with nonzero ridging 
     1276         !------------------------------------------------ 
    12771277 
    12781278         icells = 0 
     
    12801280            DO ji = 1, jpi 
    12811281               IF (aicen_init(ji,jj,jl1) .GT. epsi11 .AND. athorn(ji,jj,jl1) .GT. 0.0       & 
    1282                     .AND. closing_gross(ji,jj) > 0.0) THEN 
     1282                  .AND. closing_gross(ji,jj) > 0.0) THEN 
    12831283                  icells = icells + 1 
    12841284                  indxi(icells) = ji 
     
    12961296            jj = indxj(ij) 
    12971297 
    1298       !-------------------------------------------------------------------- 
    1299       ! 3.2) Compute area of ridging ice (ardg1) and of new ridge (ardg2) 
    1300       !-------------------------------------------------------------------- 
     1298            !-------------------------------------------------------------------- 
     1299            ! 3.2) Compute area of ridging ice (ardg1) and of new ridge (ardg2) 
     1300            !-------------------------------------------------------------------- 
    13011301 
    13021302            ardg1(ji,jj) = aridge(ji,jj,jl1)*closing_gross(ji,jj)*rdt_ice 
     
    13101310            oirft2(ji,jj)= oirft1(ji,jj) / kraft 
    13111311 
    1312       !--------------------------------------------------------------- 
    1313       ! 3.3) Compute ridging /rafting fractions, make sure afrac <=1  
    1314       !--------------------------------------------------------------- 
     1312            !--------------------------------------------------------------- 
     1313            ! 3.3) Compute ridging /rafting fractions, make sure afrac <=1  
     1314            !--------------------------------------------------------------- 
    13151315 
    13161316            afrac(ji,jj) = ardg1(ji,jj) / aicen_init(ji,jj,jl1) !ridging 
     
    13281328            ENDIF 
    13291329 
    1330       !-------------------------------------------------------------------------- 
    1331       ! 3.4) Subtract area, volume, and energy from ridging  
    1332       !     / rafting category n1. 
    1333       !-------------------------------------------------------------------------- 
     1330            !-------------------------------------------------------------------------- 
     1331            ! 3.4) Subtract area, volume, and energy from ridging  
     1332            !     / rafting category n1. 
     1333            !-------------------------------------------------------------------------- 
    13341334            vrdg1(ji,jj) = vicen_init(ji,jj,jl1) * afrac(ji,jj) /             & 
    1335                            ( 1.0 + ridge_por ) 
     1335               ( 1.0 + ridge_por ) 
    13361336            vrdg2(ji,jj) = vrdg1(ji,jj) * ( 1. + ridge_por ) 
    13371337            vsw  (ji,jj) = vrdg1(ji,jj) * ridge_por 
     
    13401340            esrdg(ji,jj) = esnon_init(ji,jj,jl1) * afrac(ji,jj) 
    13411341            srdg1(ji,jj) = smv_i_init(ji,jj,jl1) * afrac(ji,jj) /            & 
    1342                             ( 1. + ridge_por ) 
     1342               ( 1. + ridge_por ) 
    13431343            srdg2(ji,jj) = smv_i_init(ji,jj,jl1) * afrac(ji,jj) 
    13441344 
     
    13571357            smv_i(ji,jj,jl1) = smv_i(ji,jj,jl1) - srdg1(ji,jj)  - smrft(ji,jj) 
    13581358 
    1359       !----------------------------------------------------------------- 
    1360       ! 3.5) Compute properties of new ridges 
    1361       !----------------------------------------------------------------- 
     1359            !----------------------------------------------------------------- 
     1360            ! 3.5) Compute properties of new ridges 
     1361            !----------------------------------------------------------------- 
    13621362            !------------- 
    13631363            ! Salinity 
     
    13731373            ! salt flux due to ridge creation 
    13741374            fsalt_rpo(ji,jj)  = fsalt_rpo(ji,jj) + &  
    1375             MAX ( zdummy - srdg2(ji,jj) , 0.0 )    & 
    1376             * rhoic / rdt_ice 
     1375               MAX ( zdummy - srdg2(ji,jj) , 0.0 )    & 
     1376               * rhoic / rdt_ice 
    13771377 
    13781378            ! sal times volume for new ridges 
    13791379            srdg2(ji,jj)      = sm_newridge * vrdg2(ji,jj)  
    13801380 
    1381       !------------------------------------             
    1382       ! 3.6 Increment ridging diagnostics 
    1383       !------------------------------------             
    1384  
    1385 !        jl1 looping 1-jpl 
    1386 !           ij looping 1-icells 
     1381            !------------------------------------             
     1382            ! 3.6 Increment ridging diagnostics 
     1383            !------------------------------------             
     1384 
     1385            !        jl1 looping 1-jpl 
     1386            !           ij looping 1-icells 
    13871387 
    13881388            dardg1dt(ji,jj) = dardg1dt(ji,jj) + ardg1(ji,jj) + arft1(ji,jj) 
     
    13931393            IF (con_i) vice_init(ji,jj) = vice_init(ji,jj) + vrdg2(ji,jj) - vrdg1(ji,jj) 
    13941394 
    1395       !------------------------------------------             
    1396       ! 3.7 Put the snow somewhere in the ocean 
    1397       !------------------------------------------             
    1398  
    1399 !  Place part of the snow lost by ridging into the ocean.  
    1400 !  Note that esnow_mlt < 0; the ocean must cool to melt snow. 
    1401 !  If the ocean temp = Tf already, new ice must grow. 
    1402 !  During the next time step, thermo_rates will determine whether 
    1403 !  the ocean cools or new ice grows. 
    1404 !        jl1 looping 1-jpl 
    1405 !           ij looping 1-icells 
    1406                 
     1395            !------------------------------------------             
     1396            ! 3.7 Put the snow somewhere in the ocean 
     1397            !------------------------------------------             
     1398 
     1399            !  Place part of the snow lost by ridging into the ocean.  
     1400            !  Note that esnow_mlt < 0; the ocean must cool to melt snow. 
     1401            !  If the ocean temp = Tf already, new ice must grow. 
     1402            !  During the next time step, thermo_rates will determine whether 
     1403            !  the ocean cools or new ice grows. 
     1404            !        jl1 looping 1-jpl 
     1405            !           ij looping 1-icells 
     1406 
    14071407            msnow_mlt(ji,jj) = msnow_mlt(ji,jj)                  & 
    1408                            + rhosn*vsrdg(ji,jj)*(1.0-fsnowrdg)   & 
    1409                            !rafting included 
    1410                            + rhosn*vsrft(ji,jj)*(1.0-fsnowrft) 
     1408               + rhosn*vsrdg(ji,jj)*(1.0-fsnowrdg)   & 
     1409                                !rafting included 
     1410               + rhosn*vsrft(ji,jj)*(1.0-fsnowrft) 
    14111411 
    14121412            esnow_mlt(ji,jj) = esnow_mlt(ji,jj)                  & 
    1413                            + esrdg(ji,jj)*(1.0-fsnowrdg)         & 
    1414                            !rafting included 
    1415                            + esrft(ji,jj)*(1.0-fsnowrft)           
    1416  
    1417       !----------------------------------------------------------------- 
    1418       ! 3.8 Compute quantities used to apportion ice among categories 
    1419       ! in the n2 loop below 
    1420       !----------------------------------------------------------------- 
    1421  
    1422 !        jl1 looping 1-jpl 
    1423 !           ij looping 1-icells 
     1413               + esrdg(ji,jj)*(1.0-fsnowrdg)         & 
     1414                                !rafting included 
     1415               + esrft(ji,jj)*(1.0-fsnowrft)           
     1416 
     1417            !----------------------------------------------------------------- 
     1418            ! 3.8 Compute quantities used to apportion ice among categories 
     1419            ! in the n2 loop below 
     1420            !----------------------------------------------------------------- 
     1421 
     1422            !        jl1 looping 1-jpl 
     1423            !           ij looping 1-icells 
    14241424 
    14251425            dhr(ji,jj)  = hrmax(ji,jj,jl1) - hrmin(ji,jj,jl1) 
    14261426            dhr2(ji,jj) = hrmax(ji,jj,jl1) * hrmax(ji,jj,jl1)    & 
    1427                       - hrmin(ji,jj,jl1)   * hrmin(ji,jj,jl1) 
     1427               - hrmin(ji,jj,jl1)   * hrmin(ji,jj,jl1) 
    14281428 
    14291429 
    14301430         END DO                 ! ij 
    14311431 
    1432       !-------------------------------------------------------------------- 
    1433       ! 3.9 Compute ridging ice enthalpy, remove it from ridging ice and 
    1434       !      compute ridged ice enthalpy  
    1435       !-------------------------------------------------------------------- 
     1432         !-------------------------------------------------------------------- 
     1433         ! 3.9 Compute ridging ice enthalpy, remove it from ridging ice and 
     1434         !      compute ridged ice enthalpy  
     1435         !-------------------------------------------------------------------- 
    14361436         DO jk = 1, nlay_i 
    14371437!CDIR NODEP 
    14381438            DO ij = 1, icells 
    1439             ji = indxi(ij) 
    1440             jj = indxj(ij) 
    1441             ! heat content of ridged ice 
    1442             erdg1(ji,jj,jk)      = eicen_init(ji,jj,jk,jl1) * afrac(ji,jj) / &  
    1443                                    ( 1.0 + ridge_por )  
    1444             eirft(ji,jj,jk)      = eicen_init(ji,jj,jk,jl1) * afrft(ji,jj) 
    1445             e_i(ji,jj,jk,jl1)    = e_i(ji,jj,jk,jl1)             & 
    1446                                         - erdg1(ji,jj,jk)        & 
    1447                                         - eirft(ji,jj,jk) 
    1448             ! sea water heat content 
    1449             ztmelts          = - tmut * sss_m(ji,jj) + rtt 
    1450             ! heat content per unit volume 
    1451             zdummy0          = - rcp * ( sst_m(ji,jj) + rt0 - rtt ) * vsw(ji,jj) 
    1452  
    1453             ! corrected sea water salinity 
    1454             zindb  = MAX( 0.0, SIGN( 1.0, vsw(ji,jj) - zeps ) ) 
    1455             zdummy = zindb * ( srdg1(ji,jj) - srdg2(ji,jj) ) / & 
    1456                      MAX( ridge_por * vsw(ji,jj), zeps ) 
    1457  
    1458             ztmelts          = - tmut * zdummy + rtt 
    1459             ersw(ji,jj,jk)   = - rcp * ( ztmelts - rtt ) * vsw(ji,jj) 
    1460  
    1461             ! heat flux 
    1462             fheat_rpo(ji,jj) = fheat_rpo(ji,jj) + ( ersw(ji,jj,jk) - zdummy0 ) / & 
    1463                                      rdt_ice 
    1464  
    1465             ! Correct dimensions to avoid big values 
    1466             ersw(ji,jj,jk)   = ersw(ji,jj,jk) / 1.0d+09 
    1467  
    1468             ! Mutliply by ice volume, and divide by number of layers to get heat content in 10^9 J 
    1469             ersw(ji,jj,jk)   = ersw(ji,jj,jk) * & 
    1470                                area(ji,jj) * vsw(ji,jj) / & 
    1471                                nlay_i 
    1472  
    1473             erdg2(ji,jj,jk)  = erdg1(ji,jj,jk) + ersw(ji,jj,jk) 
     1439               ji = indxi(ij) 
     1440               jj = indxj(ij) 
     1441               ! heat content of ridged ice 
     1442               erdg1(ji,jj,jk)      = eicen_init(ji,jj,jk,jl1) * afrac(ji,jj) / &  
     1443                  ( 1.0 + ridge_por )  
     1444               eirft(ji,jj,jk)      = eicen_init(ji,jj,jk,jl1) * afrft(ji,jj) 
     1445               e_i(ji,jj,jk,jl1)    = e_i(ji,jj,jk,jl1)             & 
     1446                  - erdg1(ji,jj,jk)        & 
     1447                  - eirft(ji,jj,jk) 
     1448               ! sea water heat content 
     1449               ztmelts          = - tmut * sss_m(ji,jj) + rtt 
     1450               ! heat content per unit volume 
     1451               zdummy0          = - rcp * ( sst_m(ji,jj) + rt0 - rtt ) * vsw(ji,jj) 
     1452 
     1453               ! corrected sea water salinity 
     1454               zindb  = MAX( 0.0, SIGN( 1.0, vsw(ji,jj) - zeps ) ) 
     1455               zdummy = zindb * ( srdg1(ji,jj) - srdg2(ji,jj) ) / & 
     1456                  MAX( ridge_por * vsw(ji,jj), zeps ) 
     1457 
     1458               ztmelts          = - tmut * zdummy + rtt 
     1459               ersw(ji,jj,jk)   = - rcp * ( ztmelts - rtt ) * vsw(ji,jj) 
     1460 
     1461               ! heat flux 
     1462               fheat_rpo(ji,jj) = fheat_rpo(ji,jj) + ( ersw(ji,jj,jk) - zdummy0 ) / & 
     1463                  rdt_ice 
     1464 
     1465               ! Correct dimensions to avoid big values 
     1466               ersw(ji,jj,jk)   = ersw(ji,jj,jk) / 1.0d+09 
     1467 
     1468               ! Mutliply by ice volume, and divide by number of layers to get heat content in 10^9 J 
     1469               ersw(ji,jj,jk)   = ersw(ji,jj,jk) * & 
     1470                  area(ji,jj) * vsw(ji,jj) / & 
     1471                  nlay_i 
     1472 
     1473               erdg2(ji,jj,jk)  = erdg1(ji,jj,jk) + ersw(ji,jj,jk) 
    14741474            END DO ! ij 
    14751475         END DO !jk 
     
    14831483                  jj = indxj(ij) 
    14841484                  eice_init(ji,jj) = eice_init(ji,jj) + erdg2(ji,jj,jk) - & 
    1485                   erdg1(ji,jj,jk) 
     1485                     erdg1(ji,jj,jk) 
    14861486               END DO ! ij 
    14871487            END DO !jk 
     
    14971497                  WRITE(numout,*) ' ardg > a_i' 
    14981498                  WRITE(numout,*) ' ardg, aicen_init : ', & 
    1499                        ardg1(ji,jj), aicen_init(ji,jj,jl1) 
     1499                     ardg1(ji,jj), aicen_init(ji,jj,jl1) 
    15001500               ENDIF            ! afrac > 1 + puny 
    15011501            ENDDO               ! if 
     
    15101510                  WRITE(numout,*) ' arft > a_i' 
    15111511                  WRITE(numout,*) ' arft, aicen_init : ', & 
    1512                        arft1(ji,jj), aicen_init(ji,jj,jl1) 
     1512                     arft1(ji,jj), aicen_init(ji,jj,jl1) 
    15131513               ENDIF            ! afrft > 1 + puny 
    15141514            ENDDO               ! if 
    15151515         ENDIF                  ! large_afrft 
    15161516 
    1517 !------------------------------------------------------------------------------- 
    1518 ! 4) Add area, volume, and energy of new ridge to each category jl2 
    1519 !------------------------------------------------------------------------------- 
    1520 !        jl1 looping 1-jpl 
     1517         !------------------------------------------------------------------------------- 
     1518         ! 4) Add area, volume, and energy of new ridge to each category jl2 
     1519         !------------------------------------------------------------------------------- 
     1520         !        jl1 looping 1-jpl 
    15211521         DO jl2  = ice_cat_bounds(1,1), ice_cat_bounds(1,2)  
    1522          ! over categories to which ridged ice is transferred 
     1522            ! over categories to which ridged ice is transferred 
    15231523!CDIR NODEP 
    15241524            DO ij = 1, icells 
     
    15311531 
    15321532               IF (hrmin(ji,jj,jl1) .GE. hi_max(jl2) .OR.        & 
    1533                    hrmax(ji,jj,jl1) .LE. hi_max(jl2-1)) THEN 
     1533                  hrmax(ji,jj,jl1) .LE. hi_max(jl2-1)) THEN 
    15341534                  hL = 0.0 
    15351535                  hR = 0.0 
     
    15461546               v_i(ji,jj,jl2)    = v_i(ji,jj,jl2) + fvol(ji,jj) * vrdg2(ji,jj) 
    15471547               v_s(ji,jj,jl2)    = v_s(ji,jj,jl2)                             & 
    1548                                  + fvol(ji,jj) * vsrdg(ji,jj) * fsnowrdg 
     1548                  + fvol(ji,jj) * vsrdg(ji,jj) * fsnowrdg 
    15491549               e_s(ji,jj,1,jl2)  = e_s(ji,jj,1,jl2)                           & 
    1550                                  + fvol(ji,jj) * esrdg(ji,jj) * fsnowrdg 
     1550                  + fvol(ji,jj) * esrdg(ji,jj) * fsnowrdg 
    15511551               smv_i(ji,jj,jl2)  = smv_i(ji,jj,jl2) + fvol(ji,jj) * srdg2(ji,jj) 
    15521552               oa_i(ji,jj,jl2)   = oa_i(ji,jj,jl2)  + farea * oirdg2(ji,jj) 
     
    15611561                  jj = indxj(ij) 
    15621562                  e_i(ji,jj,jk,jl2) = e_i(ji,jj,jk,jl2)          & 
    1563                                     + fvol(ji,jj)*erdg2(ji,jj,jk) 
     1563                     + fvol(ji,jj)*erdg2(ji,jj,jk) 
    15641564               END DO           ! ij 
    15651565            END DO !jk 
     
    15761576               ! Compute the fraction of rafted ice area and volume going to  
    15771577               ! thickness category jl2, transfer area, volume, and energy accordingly. 
    1578              
     1578 
    15791579               IF (hraft(ji,jj,jl1) .LE. hi_max(jl2) .AND.        & 
    1580                    hraft(ji,jj,jl1) .GT. hi_max(jl2-1)) THEN 
     1580                  hraft(ji,jj,jl1) .GT. hi_max(jl2-1)) THEN 
    15811581                  a_i(ji,jj,jl2) = a_i(ji,jj,jl2) + arft2(ji,jj) 
    15821582                  v_i(ji,jj,jl2) = v_i(ji,jj,jl2) + virft(ji,jj) 
    15831583                  v_s(ji,jj,jl2) = v_s(ji,jj,jl2)                   & 
    1584                                  + vsrft(ji,jj)*fsnowrft 
     1584                     + vsrft(ji,jj)*fsnowrft 
    15851585                  e_s(ji,jj,1,jl2) = e_s(ji,jj,1,jl2)                   & 
    1586                                  + esrft(ji,jj)*fsnowrft 
     1586                     + esrft(ji,jj)*fsnowrft 
    15871587                  smv_i(ji,jj,jl2) = smv_i(ji,jj,jl2)                 & 
    1588                                  + smrft(ji,jj)     
     1588                     + smrft(ji,jj)     
    15891589                  oa_i(ji,jj,jl2)  = oa_i(ji,jj,jl2)                  & 
    1590                                    + oirft2(ji,jj)     
     1590                     + oirft2(ji,jj)     
    15911591               ENDIF ! hraft 
    15921592 
     
    16001600                  jj = indxj(ij) 
    16011601                  IF (hraft(ji,jj,jl1) .LE. hi_max(jl2) .AND.        & 
    1602                       hraft(ji,jj,jl1) .GT. hi_max(jl2-1)) THEN 
     1602                     hraft(ji,jj,jl1) .GT. hi_max(jl2-1)) THEN 
    16031603                     e_i(ji,jj,jk,jl2) = e_i(ji,jj,jk,jl2)             & 
    1604                                        + eirft(ji,jj,jk) 
     1604                        + eirft(ji,jj,jk) 
    16051605                  ENDIF 
    16061606               END DO           ! ij 
     
    16281628   END SUBROUTINE lim_itd_me_ridgeshift 
    16291629 
    1630 !============================================================================== 
     1630   !============================================================================== 
    16311631 
    16321632   SUBROUTINE lim_itd_me_asumr !(subroutine 5/6) 
    16331633 
    1634         !!----------------------------------------------------------------------------- 
    1635         !!                ***  ROUTINE lim_itd_me_asumr *** 
    1636         !! ** Purpose : 
    1637         !!        This routine finds total fractional area 
    1638         !! 
    1639         !! ** Method  : 
    1640         !! Find the total area of ice plus open water in each grid cell. 
    1641         !! 
    1642         !! This is similar to the aggregate_area subroutine except that the 
    1643         !! total area can be greater than 1, so the open water area is  
    1644         !! included in the sum instead of being computed as a residual.  
    1645         !! 
    1646         !! ** Arguments : 
     1634      !!----------------------------------------------------------------------------- 
     1635      !!                ***  ROUTINE lim_itd_me_asumr *** 
     1636      !! ** Purpose : 
     1637      !!        This routine finds total fractional area 
     1638      !! 
     1639      !! ** Method  : 
     1640      !! Find the total area of ice plus open water in each grid cell. 
     1641      !! 
     1642      !! This is similar to the aggregate_area subroutine except that the 
     1643      !! total area can be greater than 1, so the open water area is  
     1644      !! included in the sum instead of being computed as a residual.  
     1645      !! 
     1646      !! ** Arguments : 
    16471647 
    16481648      INTEGER :: ji, jj, jl 
     
    16721672   END SUBROUTINE lim_itd_me_asumr 
    16731673 
    1674 !============================================================================== 
     1674   !============================================================================== 
    16751675 
    16761676   SUBROUTINE lim_itd_me_init ! (subroutine 6/6) 
     
    16911691      !!------------------------------------------------------------------- 
    16921692      NAMELIST/namiceitdme/ ridge_scheme_swi, Cs, Cf, fsnowrdg, fsnowrft,&  
    1693                             Gstar, astar,                                & 
    1694                             Hstar, raftswi, hparmeter, Craft, ridge_por, & 
    1695                             sal_max_ridge,  partfun_swi, transfun_swi,   & 
    1696                             brinstren_swi 
     1693         Gstar, astar,                                & 
     1694         Hstar, raftswi, hparmeter, Craft, ridge_por, & 
     1695         sal_max_ridge,  partfun_swi, transfun_swi,   & 
     1696         brinstren_swi 
    16971697      !!------------------------------------------------------------------- 
    16981698 
     
    17251725   END SUBROUTINE lim_itd_me_init 
    17261726 
    1727 !============================================================================== 
     1727   !============================================================================== 
    17281728 
    17291729   SUBROUTINE lim_itd_me_zapsmall 
     
    17431743 
    17441744      INTEGER ::   & 
    1745            ji,jj,  & ! horizontal indices 
    1746            jl,     & ! ice category index 
    1747            jk,     & ! ice layer index 
    1748 !           ij,     &   ! combined i/j horizontal index 
    1749            icells      ! number of cells with ice to zap 
    1750  
    1751 !      INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: & 
    1752 !           indxi,  & ! compressed indices for i/j directions 
    1753 !           indxj 
     1745         ji,jj,  & ! horizontal indices 
     1746         jl,     & ! ice category index 
     1747         jk,     & ! ice layer index 
     1748         !           ij,     &   ! combined i/j horizontal index 
     1749         icells      ! number of cells with ice to zap 
     1750 
     1751      !      INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: & 
     1752      !           indxi,  & ! compressed indices for i/j directions 
     1753      !           indxj 
    17541754 
    17551755      INTEGER, DIMENSION(jpi,jpj) :: zmask 
     
    17571757 
    17581758      REAL(wp) :: & 
    1759            xtmp      ! temporary variable 
     1759         xtmp      ! temporary variable 
    17601760 
    17611761      DO jl = 1, jpl 
    17621762 
    1763       !----------------------------------------------------------------- 
    1764       ! Count categories to be zapped. 
    1765       ! Abort model in case of negative area. 
    1766       !----------------------------------------------------------------- 
    1767          IF( MINVAL(a_i(:,:,jl)) .LT. -epsi11 ) THEN 
     1763         !----------------------------------------------------------------- 
     1764         ! Count categories to be zapped. 
     1765         ! Abort model in case of negative area. 
     1766         !----------------------------------------------------------------- 
     1767         IF( MINVAL(a_i(:,:,jl)) .LT. -epsi11 .AND. ln_nicep ) THEN 
    17681768            DO jj = 1, jpj 
    17691769               DO ji = 1, jpi 
     
    17741774                  ENDIF 
    17751775               END DO 
    1776             END DO  
     1776            END DO 
    17771777         ENDIF 
    1778   
    1779        icells = 0 
    1780        zmask = 0.e0 
    1781        DO jj = 1, jpj 
    1782          DO ji = 1, jpi 
    1783             IF ( ( a_i(ji,jj,jl) .GE. -epsi11 .AND. a_i(ji,jj,jl) .LT. 0.0)       & 
    1784                                          .OR.                                         & 
    1785                      ( a_i(ji,jj,jl) .GT. 0.0     .AND. a_i(ji,jj,jl) .LE. 1.0e-11 )  & 
    1786                                          .OR.                                         & 
    1787                                          !new line 
    1788                      ( v_i(ji,jj,jl) .EQ. 0.0     .AND. a_i(ji,jj,jl) .GT. 0.0    )   & 
    1789                                          .OR.                                         & 
    1790                      ( v_i(ji,jj,jl) .GT. 0.0     .AND. v_i(ji,jj,jl) .LT. 1.e-12 ) ) THEN 
    1791                 zmask(ji,jj) = 1 
    1792             ENDIF 
     1778 
     1779         icells = 0 
     1780         zmask = 0.e0 
     1781         DO jj = 1, jpj 
     1782            DO ji = 1, jpi 
     1783               IF ( ( a_i(ji,jj,jl) .GE. -epsi11 .AND. a_i(ji,jj,jl) .LT. 0.0)       & 
     1784                  .OR.                                         & 
     1785                  ( a_i(ji,jj,jl) .GT. 0.0     .AND. a_i(ji,jj,jl) .LE. 1.0e-11 )  & 
     1786                  .OR.                                         & 
     1787                                !new line 
     1788                  ( v_i(ji,jj,jl) .EQ. 0.0     .AND. a_i(ji,jj,jl) .GT. 0.0    )   & 
     1789                  .OR.                                         & 
     1790                  ( v_i(ji,jj,jl) .GT. 0.0     .AND. v_i(ji,jj,jl) .LT. 1.e-12 ) ) THEN 
     1791                  zmask(ji,jj) = 1 
     1792               ENDIF 
     1793            END DO 
    17931794         END DO 
    1794          END DO 
    1795          WRITE(numout,*) SUM(zmask), ' cells of ice zapped in the ocean ' 
    1796  
    1797       !----------------------------------------------------------------- 
    1798       ! Zap ice energy and use ocean heat to melt ice 
    1799       !----------------------------------------------------------------- 
     1795         IF( ln_nicep ) WRITE(numout,*) SUM(zmask), ' cells of ice zapped in the ocean ' 
     1796 
     1797         !----------------------------------------------------------------- 
     1798         ! Zap ice energy and use ocean heat to melt ice 
     1799         !----------------------------------------------------------------- 
    18001800 
    18011801         DO jk = 1, nlay_i 
     
    18031803               DO ji = 1 , jpi 
    18041804 
    1805                xtmp = e_i(ji,jj,jk,jl) / area(ji,jj) / rdt_ice 
    1806                xtmp = xtmp * unit_fac 
    1807 !              fheat_res(ji,jj) = fheat_res(ji,jj) - xtmp 
    1808                e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * ( 1 - zmask(ji,jj) ) 
     1805                  xtmp = e_i(ji,jj,jk,jl) / area(ji,jj) / rdt_ice 
     1806                  xtmp = xtmp * unit_fac 
     1807                  !              fheat_res(ji,jj) = fheat_res(ji,jj) - xtmp 
     1808                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * ( 1 - zmask(ji,jj) ) 
    18091809               END DO           ! ji 
    18101810            END DO           ! jj 
     
    18141814            DO ji = 1 , jpi 
    18151815 
    1816       !----------------------------------------------------------------- 
    1817       ! Zap snow energy and use ocean heat to melt snow 
    1818       !----------------------------------------------------------------- 
    1819  
    1820 !           xtmp = esnon(i,j,n) / dt ! < 0 
    1821 !           fhnet(i,j)      = fhnet(i,j)      + xtmp 
    1822 !           fhnet_hist(i,j) = fhnet_hist(i,j) + xtmp 
    1823             ! xtmp is greater than 0 
    1824             ! fluxes are positive to the ocean 
    1825             ! here the flux has to be negative for the ocean 
    1826             xtmp = ( rhosn*cpic*( rtt-t_s(ji,jj,1,jl) ) + rhosn*lfus ) / rdt_ice 
    1827 !           fheat_res(ji,jj) = fheat_res(ji,jj) - xtmp 
    1828  
    1829             xtmp = ( rhosn*cpic*( rtt-t_s(ji,jj,1,jl) ) + rhosn*lfus ) / rdt_ice !RB   ??????? 
    1830  
    1831             t_s(ji,jj,1,jl) = rtt * zmask(ji,jj) + t_s(ji,jj,1,jl) * ( 1 - zmask(ji,jj) ) 
    1832  
    1833       !----------------------------------------------------------------- 
    1834       ! zap ice and snow volume, add water and salt to ocean 
    1835       !----------------------------------------------------------------- 
    1836  
    1837 !           xtmp = (rhoi*vicen(i,j,n) + rhos*vsnon(i,j,n)) / dt 
    1838 !           fresh(i,j)      = fresh(i,j)      + xtmp 
    1839 !           fresh_hist(i,j) = fresh_hist(i,j) + xtmp 
    1840  
    1841 !           fsalt_res(ji,jj)  = fsalt_res(ji,jj) + ( sss_m(ji,jj)                  ) * &  
    1842 !                               rhosn * v_s(ji,jj,jl) / rdt_ice 
    1843  
    1844 !           fsalt_res(ji,jj)  = fsalt_res(ji,jj) + ( sss_m(ji,jj) - sm_i(ji,jj,jl) ) * &  
    1845 !                               rhoic * v_i(ji,jj,jl) / rdt_ice 
    1846  
    1847 !           emps(i,j)      = emps(i,j)      + xtmp 
    1848 !           fsalt_hist(i,j) = fsalt_hist(i,j) + xtmp 
    1849  
    1850             ato_i(ji,jj)   = a_i(ji,jj,jl)  * zmask(ji,jj) + ato_i(ji,jj) 
    1851             a_i(ji,jj,jl)  = a_i(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
    1852             v_i(ji,jj,jl)  = v_i(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
    1853             v_s(ji,jj,jl)  = v_s(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
    1854             t_su(ji,jj,jl) = t_su(ji,jj,jl) * (1 -zmask(ji,jj) ) + t_bo(ji,jj) * zmask(ji,jj) 
    1855             oa_i(ji,jj,jl) = oa_i(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
    1856             smv_i(ji,jj,jl) = smv_i(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
     1816               !----------------------------------------------------------------- 
     1817               ! Zap snow energy and use ocean heat to melt snow 
     1818               !----------------------------------------------------------------- 
     1819 
     1820               !           xtmp = esnon(i,j,n) / dt ! < 0 
     1821               !           fhnet(i,j)      = fhnet(i,j)      + xtmp 
     1822               !           fhnet_hist(i,j) = fhnet_hist(i,j) + xtmp 
     1823               ! xtmp is greater than 0 
     1824               ! fluxes are positive to the ocean 
     1825               ! here the flux has to be negative for the ocean 
     1826               xtmp = ( rhosn*cpic*( rtt-t_s(ji,jj,1,jl) ) + rhosn*lfus ) / rdt_ice 
     1827               !           fheat_res(ji,jj) = fheat_res(ji,jj) - xtmp 
     1828 
     1829               xtmp = ( rhosn*cpic*( rtt-t_s(ji,jj,1,jl) ) + rhosn*lfus ) / rdt_ice !RB   ??????? 
     1830 
     1831               t_s(ji,jj,1,jl) = rtt * zmask(ji,jj) + t_s(ji,jj,1,jl) * ( 1 - zmask(ji,jj) ) 
     1832 
     1833               !----------------------------------------------------------------- 
     1834               ! zap ice and snow volume, add water and salt to ocean 
     1835               !----------------------------------------------------------------- 
     1836 
     1837               !           xtmp = (rhoi*vicen(i,j,n) + rhos*vsnon(i,j,n)) / dt 
     1838               !           fresh(i,j)      = fresh(i,j)      + xtmp 
     1839               !           fresh_hist(i,j) = fresh_hist(i,j) + xtmp 
     1840 
     1841               !           fsalt_res(ji,jj)  = fsalt_res(ji,jj) + ( sss_m(ji,jj)                  ) * &  
     1842               !                               rhosn * v_s(ji,jj,jl) / rdt_ice 
     1843 
     1844               !           fsalt_res(ji,jj)  = fsalt_res(ji,jj) + ( sss_m(ji,jj) - sm_i(ji,jj,jl) ) * &  
     1845               !                               rhoic * v_i(ji,jj,jl) / rdt_ice 
     1846 
     1847               !           emps(i,j)      = emps(i,j)      + xtmp 
     1848               !           fsalt_hist(i,j) = fsalt_hist(i,j) + xtmp 
     1849 
     1850               ato_i(ji,jj)   = a_i(ji,jj,jl)  * zmask(ji,jj) + ato_i(ji,jj) 
     1851               a_i(ji,jj,jl)  = a_i(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
     1852               v_i(ji,jj,jl)  = v_i(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
     1853               v_s(ji,jj,jl)  = v_s(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
     1854               t_su(ji,jj,jl) = t_su(ji,jj,jl) * (1 -zmask(ji,jj) ) + t_bo(ji,jj) * zmask(ji,jj) 
     1855               oa_i(ji,jj,jl) = oa_i(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
     1856               smv_i(ji,jj,jl) = smv_i(ji,jj,jl) * ( 1 - zmask(ji,jj) ) 
    18571857 
    18581858            END DO                 ! ji 
Note: See TracChangeset for help on using the changeset viewer.