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_th.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_th.F90

    r869 r921  
    2828   USE prtctl           ! Print control 
    2929   USE lib_mpp  
    30   
     30 
    3131   IMPLICIT NONE 
    3232   PRIVATE 
     
    5151   !!---------------------------------------------------------------------- 
    5252 
    53 !!---------------------------------------------------------------------------------------------- 
    54 !!---------------------------------------------------------------------------------------------- 
     53   !!---------------------------------------------------------------------------------------------- 
     54   !!---------------------------------------------------------------------------------------------- 
    5555 
    5656CONTAINS 
    5757 
    58    SUBROUTINE lim_itd_th 
    59         !!------------------------------------------------------------------ 
    60         !!                ***  ROUTINE lim_itd_th *** 
    61         !! ** Purpose : 
    62         !!        This routine computes the thermodynamics of ice thickness 
    63         !!         distribution 
    64         !! ** Method  : 
    65         !! 
    66         !! ** Arguments : 
    67         !!           kideb , kiut : Starting and ending points on which the  
    68         !!                         the computation is applied 
    69         !! 
    70         !! ** Inputs / Ouputs : (global commons) 
    71         !! 
    72         !! ** External :  
    73         !! 
    74         !! ** References : 
    75         !! 
    76         !! ** History : 
    77         !!           (12-2005) Martin Vancoppenolle  
    78         !! 
    79         !!------------------------------------------------------------------ 
    80         !! * Arguments 
    81  
    82        !! * Local variables 
    83        INTEGER ::   jl, ja,   &   ! ice category, layers 
    84                     jm,       &   ! ice types    dummy loop index 
    85                     jbnd1,    & 
    86                     jbnd2 
    87  
    88        REAL(wp)  ::           &  ! constant values 
    89           zeps      =  1.0e-10, & 
    90           epsi10    =  1.0e-10 
    91  
    92 !!-- End of declarations 
    93 !!---------------------------------------------------------------------------------------------- 
    94  
    95        IF (lwp) THEN 
    96           WRITE(numout,*) 
    97           WRITE(numout,*) 'lim_itd_th  : Thermodynamics of the ice thickness distribution' 
    98           WRITE(numout,*) '~~~~~~~~~~~' 
    99        ENDIF 
    100  
    101 !------------------------------------------------------------------------------| 
    102 !  1) Transport of ice between thickness categories.                           | 
    103 !------------------------------------------------------------------------------| 
     58   SUBROUTINE lim_itd_th( kt ) 
     59      !!------------------------------------------------------------------ 
     60      !!                ***  ROUTINE lim_itd_th *** 
     61      !! ** Purpose : 
     62      !!        This routine computes the thermodynamics of ice thickness 
     63      !!         distribution 
     64      !! ** Method  : 
     65      !! 
     66      !! ** Arguments : 
     67      !!           kideb , kiut : Starting and ending points on which the  
     68      !!                         the computation is applied 
     69      !! 
     70      !! ** Inputs / Ouputs : (global commons) 
     71      !! 
     72      !! ** External :  
     73      !! 
     74      !! ** References : 
     75      !! 
     76      !! ** History : 
     77      !!           (12-2005) Martin Vancoppenolle  
     78      !! 
     79      !!------------------------------------------------------------------ 
     80      !! * Arguments 
     81      INTEGER, INTENT(in) :: kt 
     82      !! * Local variables 
     83      INTEGER ::   jl, ja,   &   ! ice category, layers 
     84         jm,       &   ! ice types    dummy loop index 
     85         jbnd1,    & 
     86         jbnd2 
     87 
     88      REAL(wp)  ::           &  ! constant values 
     89         zeps      =  1.0e-10, & 
     90         epsi10    =  1.0e-10 
     91 
     92      IF( kt == nit000 .AND. lwp ) THEN 
     93         WRITE(numout,*) 
     94         WRITE(numout,*) 'lim_itd_th  : Thermodynamics of the ice thickness distribution' 
     95         WRITE(numout,*) '~~~~~~~~~~~' 
     96      ENDIF 
     97 
     98      !------------------------------------------------------------------------------| 
     99      !  1) Transport of ice between thickness categories.                           | 
     100      !------------------------------------------------------------------------------| 
    104101      ! Given thermodynamic growth rates, transport ice between 
    105102      ! thickness categories. 
     
    107104         jbnd1 = ice_cat_bounds(jm,1) 
    108105         jbnd2 = ice_cat_bounds(jm,2) 
    109          IF (ice_ncat_types(jm) .GT. 1 ) CALL lim_itd_th_rem(jbnd1, jbnd2, jm) 
     106         IF (ice_ncat_types(jm) .GT. 1 ) CALL lim_itd_th_rem( jbnd1, jbnd2, jm, kt ) 
    110107      END DO 
    111108 
     
    113110      CALL lim_var_agg(1) 
    114111 
    115 !------------------------------------------------------------------------------| 
    116 !  3) Add frazil ice growing in leads. 
    117 !------------------------------------------------------------------------------| 
     112      !------------------------------------------------------------------------------| 
     113      !  3) Add frazil ice growing in leads. 
     114      !------------------------------------------------------------------------------| 
    118115 
    119116      CALL lim_thd_lac 
    120117      CALL lim_var_glo2eqv ! only for info 
    121118 
    122 !---------------------------------------------------------------------------------------- 
    123 !  4) Computation of trend terms and get back to old values       
    124 !---------------------------------------------------------------------------------------- 
     119      !---------------------------------------------------------------------------------------- 
     120      !  4) Computation of trend terms and get back to old values       
     121      !---------------------------------------------------------------------------------------- 
    125122 
    126123      !- Trend terms 
     
    133130      d_smv_i_thd(:,:,:) = 0.0 
    134131      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) & 
    135       d_smv_i_thd(:,:,:) = smv_i(:,:,:) - old_smv_i(:,:,:) 
     132         d_smv_i_thd(:,:,:) = smv_i(:,:,:) - old_smv_i(:,:,:) 
    136133 
    137134      IF(ln_ctl) THEN   ! Control print 
     
    166163         END DO 
    167164      ENDIF 
    168        
     165 
    169166      !- Recover Old values 
    170167      a_i(:,:,:)         = old_a_i (:,:,:) 
     
    175172 
    176173      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) & 
    177       smv_i(:,:,:)       = old_smv_i (:,:,:) 
    178  
    179  
    180       END SUBROUTINE lim_itd_th 
    181  
    182 !!---------------------------------------------------------------------------------------------- 
    183 !!---------------------------------------------------------------------------------------------- 
    184  
    185     SUBROUTINE lim_itd_th_rem(klbnd,kubnd,ntyp) 
    186         !!------------------------------------------------------------------ 
    187         !!                ***  ROUTINE lim_itd_th_rem *** 
    188         !! ** Purpose : 
    189         !!        This routine computes the redistribution of ice thickness 
    190         !!        after thermodynamic growth of ice thickness 
    191         !! 
    192         !! ** Method  : Linear remapping  
    193         !! 
    194         !! ** Arguments : 
    195         !!           klbnd, kubnd : Starting and ending category index on which the  
    196         !!                         the computation is applied 
    197         !! 
    198         !! ** Inputs / Ouputs : (global commons) 
    199         !! 
    200         !! ** External :  
    201         !! 
    202         !! ** References : W.H. Lipscomb, JGR 2001 
    203         !! 
    204         !! ** History : 
    205         !!           largely inspired from CICE (c) W. H. Lipscomb and E.C. Hunke 
    206         !!  
    207         !!           (01-2006) Martin Vancoppenolle, UCL-ASTR, translation from 
    208         !!                     CICE 
    209         !!           (06-2006) Adaptation to include salt, age and types 
    210         !!           (04-2007) Mass conservation checked 
    211         !!------------------------------------------------------------------ 
    212         !! * Arguments 
    213  
    214        INTEGER , INTENT (IN) ::  & 
    215           klbnd ,  &  ! Start thickness category index point 
    216           kubnd ,  &  ! End point on which the  the computation is applied 
    217           ntyp        ! Number of the type used 
    218  
    219        !! * Local variables 
    220        INTEGER ::   ji,       &   ! spatial dummy loop index 
    221                     jj,       &   ! spatial dummy loop index 
    222                     jl,       &   ! ice category dummy loop index 
    223                     zji, zjj, &   ! dummy indices used when changing coordinates 
    224                     nd            ! used for thickness categories 
    225  
    226        INTEGER , DIMENSION(jpi,jpj,jpl-1) :: &  
    227                     zdonor        ! donor category index 
    228    
    229        REAL(wp)  ::           &   ! constant values 
    230           zeps      =  1.0e-10 
    231  
    232        REAL(wp)  ::           &  ! constant values for ice enthalpy 
    233           zindb     ,         & 
    234           zareamin  ,         &  ! minimum tolerated area in a thickness category 
    235           zwk1, zwk2,         &  ! all the following are dummy arguments 
    236           zx1, zx2, zx3,      &  ! 
    237           zetamin   ,         &  ! minimum value of eta 
    238           zetamax   ,         &  ! maximum value of eta 
    239           zdh0      ,         &  !  
    240           zda0      ,         &  ! 
    241           zdamax    ,         &  ! 
    242           zhimin 
    243  
    244        REAL(wp), DIMENSION(jpi,jpj,jpl) :: & 
    245           zdhice           ,  &  ! ice thickness increment 
    246           g0               ,  &  ! coefficients for fitting the line of the ITD 
    247           g1               ,  &  ! coefficients for fitting the line of the ITD 
    248           hL               ,  &  ! left boundary for the ITD for each thickness 
    249           hR               ,  &  ! left boundary for the ITD for each thickness 
    250           zht_i_o          ,  &  ! old ice thickness 
    251           dummy_es 
    252  
    253        REAL(wp), DIMENSION(jpi,jpj,jpl-1) :: & 
    254           zdaice           ,  &  ! local increment of ice area  
    255           zdvice                 ! local increment of ice volume 
    256  
    257        REAL(wp), DIMENSION(jpi,jpj,0:jpl) :: & 
    258           zhbnew                 ! new boundaries of ice categories 
    259  
    260        REAL(wp), DIMENSION(jpi,jpj) :: & 
    261           zhb0, zhb1             ! category boundaries for thinnes categories 
    262  
    263        REAL, DIMENSION(1:(jpi+1)*(jpj+1)) :: & 
    264           zvetamin, zvetamax     ! maximum values for etas 
    265   
    266        INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: & 
    267           nind_i      ,  &  ! compressed indices for i/j directions 
    268           nind_j 
    269  
    270        INTEGER :: & 
    271           nbrem             ! number of cells with ice to transfer 
    272  
    273        LOGICAL, DIMENSION(jpi,jpj) ::   &  !: 
    274           zremap_flag             ! compute remapping or not ???? 
    275         
    276        REAL(wp)  ::           &  ! constant values for ice enthalpy 
    277           zslope                 ! used to compute local thermodynamic "speeds" 
    278  
    279        REAL (wp), DIMENSION(jpi,jpj) :: &  !  
    280                vt_i_init, vt_i_final,   &  !  ice volume summed over categories 
    281                vt_s_init, vt_s_final,   &  !  snow volume summed over categories 
    282                et_i_init, et_i_final,   &  !  ice energy summed over categories 
    283                et_s_init, et_s_final       !  snow energy summed over categories 
    284  
    285        CHARACTER (len = 15) :: fieldid 
    286         
    287 !!-- End of declarations 
    288 !!---------------------------------------------------------------------------------------------- 
     174         smv_i(:,:,:)       = old_smv_i (:,:,:) 
     175 
     176   END SUBROUTINE lim_itd_th 
     177   ! 
     178 
     179   SUBROUTINE lim_itd_th_rem( klbnd, kubnd, ntyp, kt ) 
     180      !!------------------------------------------------------------------ 
     181      !!                ***  ROUTINE lim_itd_th_rem *** 
     182      !! ** Purpose : 
     183      !!        This routine computes the redistribution of ice thickness 
     184      !!        after thermodynamic growth of ice thickness 
     185      !! 
     186      !! ** Method  : Linear remapping  
     187      !! 
     188      !! ** Arguments : 
     189      !!           klbnd, kubnd : Starting and ending category index on which the  
     190      !!                         the computation is applied 
     191      !! 
     192      !! ** Inputs / Ouputs : (global commons) 
     193      !! 
     194      !! ** External :  
     195      !! 
     196      !! ** References : W.H. Lipscomb, JGR 2001 
     197      !! 
     198      !! ** History : 
     199      !!           largely inspired from CICE (c) W. H. Lipscomb and E.C. Hunke 
     200      !!  
     201      !!           (01-2006) Martin Vancoppenolle, UCL-ASTR, translation from 
     202      !!                     CICE 
     203      !!           (06-2006) Adaptation to include salt, age and types 
     204      !!           (04-2007) Mass conservation checked 
     205      !!------------------------------------------------------------------ 
     206      !! * Arguments 
     207 
     208      INTEGER , INTENT (IN) ::  & 
     209         klbnd ,  &  ! Start thickness category index point 
     210         kubnd ,  &  ! End point on which the  the computation is applied 
     211         ntyp  ,  &  ! Number of the type used 
     212         kt          ! Ocean time step  
     213 
     214      !! * Local variables 
     215      INTEGER ::   ji,       &   ! spatial dummy loop index 
     216         jj,       &   ! spatial dummy loop index 
     217         jl,       &   ! ice category dummy loop index 
     218         zji, zjj, &   ! dummy indices used when changing coordinates 
     219         nd            ! used for thickness categories 
     220 
     221      INTEGER , DIMENSION(jpi,jpj,jpl-1) :: &  
     222         zdonor        ! donor category index 
     223 
     224      REAL(wp)  ::           &   ! constant values 
     225         zeps      =  1.0e-10 
     226 
     227      REAL(wp)  ::           &  ! constant values for ice enthalpy 
     228         zindb     ,         & 
     229         zareamin  ,         &  ! minimum tolerated area in a thickness category 
     230         zwk1, zwk2,         &  ! all the following are dummy arguments 
     231         zx1, zx2, zx3,      &  ! 
     232         zetamin   ,         &  ! minimum value of eta 
     233         zetamax   ,         &  ! maximum value of eta 
     234         zdh0      ,         &  !  
     235         zda0      ,         &  ! 
     236         zdamax    ,         &  ! 
     237         zhimin 
     238 
     239      REAL(wp), DIMENSION(jpi,jpj,jpl) :: & 
     240         zdhice           ,  &  ! ice thickness increment 
     241         g0               ,  &  ! coefficients for fitting the line of the ITD 
     242         g1               ,  &  ! coefficients for fitting the line of the ITD 
     243         hL               ,  &  ! left boundary for the ITD for each thickness 
     244         hR               ,  &  ! left boundary for the ITD for each thickness 
     245         zht_i_o          ,  &  ! old ice thickness 
     246         dummy_es 
     247 
     248      REAL(wp), DIMENSION(jpi,jpj,jpl-1) :: & 
     249         zdaice           ,  &  ! local increment of ice area  
     250         zdvice                 ! local increment of ice volume 
     251 
     252      REAL(wp), DIMENSION(jpi,jpj,0:jpl) :: & 
     253         zhbnew                 ! new boundaries of ice categories 
     254 
     255      REAL(wp), DIMENSION(jpi,jpj) :: & 
     256         zhb0, zhb1             ! category boundaries for thinnes categories 
     257 
     258      REAL, DIMENSION(1:(jpi+1)*(jpj+1)) :: & 
     259         zvetamin, zvetamax     ! maximum values for etas 
     260 
     261      INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: & 
     262         nind_i      ,  &  ! compressed indices for i/j directions 
     263         nind_j 
     264 
     265      INTEGER :: & 
     266         nbrem             ! number of cells with ice to transfer 
     267 
     268      LOGICAL, DIMENSION(jpi,jpj) ::   &  !: 
     269         zremap_flag             ! compute remapping or not ???? 
     270 
     271      REAL(wp)  ::           &  ! constant values for ice enthalpy 
     272         zslope                 ! used to compute local thermodynamic "speeds" 
     273 
     274      REAL (wp), DIMENSION(jpi,jpj) :: &  !  
     275         vt_i_init, vt_i_final,   &  !  ice volume summed over categories 
     276         vt_s_init, vt_s_final,   &  !  snow volume summed over categories 
     277         et_i_init, et_i_final,   &  !  ice energy summed over categories 
     278         et_s_init, et_s_final       !  snow energy summed over categories 
     279 
     280      CHARACTER (len = 15) :: fieldid 
     281 
     282      !!-- End of declarations 
     283      !!---------------------------------------------------------------------------------------------- 
    289284      zhimin = 0.1      !minimum ice thickness tolerated by the model 
    290285      zareamin = zeps   !minimum area in thickness categories tolerated by the conceptors of the model 
    291286 
    292 !!---------------------------------------------------------------------------------------------- 
    293 !! 0) Conservation checkand changes in each ice category 
    294 !!---------------------------------------------------------------------------------------------- 
     287      !!---------------------------------------------------------------------------------------------- 
     288      !! 0) Conservation checkand changes in each ice category 
     289      !!---------------------------------------------------------------------------------------------- 
    295290      IF ( con_i ) THEN 
    296291         CALL lim_column_sum (jpl,   v_i, vt_i_init) 
     
    300295         CALL lim_column_sum (jpl, dummy_es(:,:,:) , et_s_init) 
    301296      ENDIF 
    302   
    303 !!---------------------------------------------------------------------------------------------- 
    304 !! 1) Compute thickness and changes in each ice category 
    305 !!---------------------------------------------------------------------------------------------- 
    306        IF (lwp) THEN 
    307        WRITE(numout,*) 
    308        WRITE(numout,*) 'lim_itd_th_rem  : Remapping the ice thickness distribution' 
    309        WRITE(numout,*) '~~~~~~~~~~~~~~~' 
    310        WRITE(numout,*) ' klbnd :       ', klbnd 
    311        WRITE(numout,*) ' kubnd :       ', kubnd 
    312        WRITE(numout,*) ' ntyp  :       ', ntyp  
    313        ENDIF 
    314  
    315        zdhice(:,:,:) = 0.0 
    316        DO jl = klbnd, kubnd 
    317           DO jj = 1, jpj 
    318              DO ji = 1, jpi 
    319                 zindb             = 1.0-MAX(0.0,SIGN(1.0,-a_i(ji,jj,jl)))     !0 if no ice and 1 if yes 
    320                 ht_i(ji,jj,jl)    = v_i(ji,jj,jl) / MAX(a_i(ji,jj,jl),zeps) * zindb 
    321                 zindb             = 1.0-MAX(0.0,SIGN(1.0,-old_a_i(ji,jj,jl))) !0 if no ice and 1 if yes 
    322                 zht_i_o(ji,jj,jl) = old_v_i(ji,jj,jl) / MAX(old_a_i(ji,jj,jl),zeps) * zindb 
    323                 IF (a_i(ji,jj,jl).gt.1e-6) THEN 
    324                    zdhice(ji,jj,jl) = ht_i(ji,jj,jl) - zht_i_o(ji,jj,jl)  
    325                 ENDIF 
    326              END DO 
    327           END DO 
    328        END DO 
    329  
    330 !----------------------------------------------------------------------------------------------- 
    331 !  2) Compute fractional ice area in each grid cell 
    332 !----------------------------------------------------------------------------------------------- 
     297 
     298      !!---------------------------------------------------------------------------------------------- 
     299      !! 1) Compute thickness and changes in each ice category 
     300      !!---------------------------------------------------------------------------------------------- 
     301      IF (kt == nit000 .AND. lwp) THEN 
     302         WRITE(numout,*) 
     303         WRITE(numout,*) 'lim_itd_th_rem  : Remapping the ice thickness distribution' 
     304         WRITE(numout,*) '~~~~~~~~~~~~~~~' 
     305         WRITE(numout,*) ' klbnd :       ', klbnd 
     306         WRITE(numout,*) ' kubnd :       ', kubnd 
     307         WRITE(numout,*) ' ntyp  :       ', ntyp  
     308      ENDIF 
     309 
     310      zdhice(:,:,:) = 0.0 
     311      DO jl = klbnd, kubnd 
     312         DO jj = 1, jpj 
     313            DO ji = 1, jpi 
     314               zindb             = 1.0-MAX(0.0,SIGN(1.0,-a_i(ji,jj,jl)))     !0 if no ice and 1 if yes 
     315               ht_i(ji,jj,jl)    = v_i(ji,jj,jl) / MAX(a_i(ji,jj,jl),zeps) * zindb 
     316               zindb             = 1.0-MAX(0.0,SIGN(1.0,-old_a_i(ji,jj,jl))) !0 if no ice and 1 if yes 
     317               zht_i_o(ji,jj,jl) = old_v_i(ji,jj,jl) / MAX(old_a_i(ji,jj,jl),zeps) * zindb 
     318               IF (a_i(ji,jj,jl).gt.1e-6) THEN 
     319                  zdhice(ji,jj,jl) = ht_i(ji,jj,jl) - zht_i_o(ji,jj,jl)  
     320               ENDIF 
     321            END DO 
     322         END DO 
     323      END DO 
     324 
     325      !----------------------------------------------------------------------------------------------- 
     326      !  2) Compute fractional ice area in each grid cell 
     327      !----------------------------------------------------------------------------------------------- 
    333328      at_i(:,:) = 0.0 
    334329      DO jl = klbnd, kubnd 
     
    340335      END DO 
    341336 
    342 !----------------------------------------------------------------------------------------------- 
    343 !  3) Identify grid cells with ice 
    344 !----------------------------------------------------------------------------------------------- 
     337      !----------------------------------------------------------------------------------------------- 
     338      !  3) Identify grid cells with ice 
     339      !----------------------------------------------------------------------------------------------- 
    345340      nbrem = 0 
    346341      DO jj = 1, jpj 
     
    357352      END DO !jj 
    358353 
    359 !----------------------------------------------------------------------------------------------- 
    360 !  4) Compute new category boundaries 
    361 !----------------------------------------------------------------------------------------------- 
     354      !----------------------------------------------------------------------------------------------- 
     355      !  4) Compute new category boundaries 
     356      !----------------------------------------------------------------------------------------------- 
    362357      !- 4.1 Compute category boundaries 
    363358      ! Tricky trick see limitd_me.F90 
     
    374369            ! 
    375370            IF ( ( zht_i_o(zji,zjj,jl)  .GT.zeps ) .AND. &  
    376                  ( zht_i_o(zji,zjj,jl+1).GT.zeps ) ) THEN 
     371               ( zht_i_o(zji,zjj,jl+1).GT.zeps ) ) THEN 
    377372               !interpolate between adjacent category growth rates 
    378373               zslope = ( zdhice(zji,zjj,jl+1)     - zdhice(zji,zjj,jl) ) / & 
    379                         ( zht_i_o   (zji,zjj,jl+1) - zht_i_o   (zji,zjj,jl) ) 
     374                  ( zht_i_o   (zji,zjj,jl+1) - zht_i_o   (zji,zjj,jl) ) 
    380375               zhbnew(zji,zjj,jl) = hi_max(jl) + zdhice(zji,zjj,jl) + & 
    381                                     zslope * ( hi_max(jl) - zht_i_o(zji,zjj,jl) ) 
     376                  zslope * ( hi_max(jl) - zht_i_o(zji,zjj,jl) ) 
    382377            ELSEIF (zht_i_o(zji,zjj,jl).gt.zeps) THEN 
    383378               zhbnew(zji,zjj,jl) = hi_max(jl) + zdhice(zji,zjj,jl) 
     
    391386         ! jl 
    392387 
    393       !- 4.2 Check that each zhbnew lies between adjacent values of ice thickness 
     388         !- 4.2 Check that each zhbnew lies between adjacent values of ice thickness 
    394389         DO ji = 1, nbrem 
    395390            ! jl, ji 
     
    398393            ! jl, ji 
    399394            IF ( ( a_i(zji,zjj,jl) .GT.zeps) .AND. &  
    400                  ( ht_i(zji,zjj,jl).GE. zhbnew(zji,zjj,jl) ) & 
     395               ( ht_i(zji,zjj,jl).GE. zhbnew(zji,zjj,jl) ) & 
    401396               ) THEN 
    402397               zremap_flag(zji,zjj) = .false. 
    403398            ELSEIF ( ( a_i(zji,zjj,jl+1) .GT. zeps ) .AND. & 
    404                      ( ht_i(zji,zjj,jl+1).LE. zhbnew(zji,zjj,jl) ) & 
    405                    ) THEN 
     399               ( ht_i(zji,zjj,jl+1).LE. zhbnew(zji,zjj,jl) ) & 
     400               ) THEN 
    406401               zremap_flag(zji,zjj) = .false. 
    407402            ENDIF 
    408403 
    409       !- 4.3 Check that each zhbnew does not exceed maximal values hi_max   
     404            !- 4.3 Check that each zhbnew does not exceed maximal values hi_max   
    410405            ! jl, ji 
    411406            IF (zhbnew(zji,zjj,jl).gt.hi_max(jl+1)) THEN 
     
    420415         ! ji 
    421416      END DO !jl 
    422              
    423 !----------------------------------------------------------------------------------------------- 
    424 !  5) Identify cells where ITD is to be remapped 
    425 !----------------------------------------------------------------------------------------------- 
    426      nbrem = 0 
    427      DO jj = 1, jpj 
    428         DO ji = 1, jpi 
    429            IF ( zremap_flag(ji,jj) ) THEN 
    430               nbrem         = nbrem + 1 
    431               nind_i(nbrem) = ji 
    432               nind_j(nbrem) = jj 
    433            ENDIF 
    434         END DO !ji 
    435      END DO !jj 
    436  
    437 !----------------------------------------------------------------------------------------------- 
    438 !  6) Fill arrays with lowermost / uppermost boundaries of 'new' categories 
    439 !----------------------------------------------------------------------------------------------- 
    440      DO jj = 1, jpj 
    441         DO ji = 1, jpi 
    442            zhb0(ji,jj) = hi_max_typ(0,ntyp) ! 0eme 
    443            zhb1(ji,jj) = hi_max_typ(1,ntyp) ! 1er 
    444  
    445            zhbnew(ji,jj,klbnd-1) = 0.0 
    446             
    447            IF ( a_i(ji,jj,kubnd) .GT. zeps ) THEN 
    448               zhbnew(ji,jj,kubnd) = 3.0*ht_i(ji,jj,kubnd) - 2.0*zhbnew(ji,jj,kubnd-1) 
    449            ELSE 
    450               zhbnew(ji,jj,kubnd) = hi_max(kubnd) 
    451            ENDIF 
    452  
    453            IF ( zhbnew(ji,jj,kubnd) .LT. hi_max(kubnd-1) ) & 
    454               zhbnew(ji,jj,kubnd) = hi_max(kubnd-1) 
    455  
    456         END DO !jj 
    457      END DO !jj 
    458  
    459 !----------------------------------------------------------------------------------------------- 
    460 !  7) Compute g(h)  
    461 !----------------------------------------------------------------------------------------------- 
    462      !- 7.1 g(h) for category 1 at start of time step 
    463      CALL lim_itd_fitline(klbnd, zhb0, zhb1, zht_i_o(:,:,klbnd), & 
    464                           g0(:,:,klbnd), g1(:,:,klbnd), hL(:,:,klbnd), & 
    465                           hR(:,:,klbnd), zremap_flag) 
    466  
    467      !- 7.2 Area lost due to melting of thin ice (first category,  klbnd) 
    468      DO ji = 1, nbrem 
    469         zji = nind_i(ji)  
    470         zjj = nind_j(ji)  
    471        
    472         !ji 
    473         IF (a_i(zji,zjj,klbnd) .gt. zeps) THEN 
    474            zdh0 = zdhice(zji,zjj,klbnd) !decrease of ice thickness in the lower category 
    475            ! ji, a_i > zeps 
    476            IF (zdh0 .lt. 0.0) THEN !remove area from category 1 
    477               ! ji, a_i > zeps; zdh0 < 0 
    478               zdh0 = MIN(-zdh0,hi_max(klbnd)) 
    479          
    480               !Integrate g(1) from 0 to dh0 to estimate area melted 
    481               zetamax = MIN(zdh0,hR(zji,zjj,klbnd)) - hL(zji,zjj,klbnd) 
    482               IF (zetamax.gt.0.0) THEN 
    483                  zx1  = zetamax 
    484                  zx2  = 0.5 * zetamax*zetamax  
    485                  zda0 = g1(zji,zjj,klbnd) * zx2 + g0(zji,zjj,klbnd) * zx1 !ice area removed 
    486               ! Constrain new thickness <= ht_i 
    487                  zdamax = a_i(zji,zjj,klbnd) * &  
    488                           (1.0 - ht_i(zji,zjj,klbnd)/zht_i_o(zji,zjj,klbnd)) ! zdamax > 0 
    489               !ice area lost due to melting of thin ice 
    490                  zda0   = MIN(zda0, zdamax) 
    491  
    492               ! Remove area, conserving volume 
    493                  ht_i(zji,zjj,klbnd) = ht_i(zji,zjj,klbnd) &  
    494                                * a_i(zji,zjj,klbnd) / ( a_i(zji,zjj,klbnd) - zda0 ) 
    495                  a_i(zji,zjj,klbnd)  = a_i(zji,zjj,klbnd) - zda0 
    496                  v_i(zji,zjj,klbnd)  = a_i(zji,zjj,klbnd)*ht_i(zji,zjj,klbnd) 
    497               ENDIF     ! zetamax > 0 
    498            ! ji, a_i > zeps 
    499  
    500            ELSE ! if ice accretion 
    501               ! ji, a_i > zeps; zdh0 > 0 
    502               IF ( ntyp .EQ. 1 ) zhbnew(zji,zjj,klbnd-1) = MIN(zdh0,hi_max(klbnd))  
    503               ! zhbnew was 0, and is shifted to the right to account for thin ice 
    504               ! growth in openwater (F0 = f1) 
    505               IF ( ntyp .NE. 1 ) zhbnew(zji,zjj,0) = 0  
    506               ! in other types there is 
    507               ! no open water growth (F0 = 0) 
    508            ENDIF ! zdh0  
    509  
    510            ! a_i > zeps 
    511         ENDIF ! a_i > zeps 
    512  
    513      END DO ! ji 
    514  
    515      !- 7.3 g(h) for each thickness category   
    516      DO jl = klbnd, kubnd 
    517         CALL lim_itd_fitline(jl, zhbnew(:,:,jl-1), zhbnew(:,:,jl), ht_i(:,:,jl), & 
    518                              g0(:,:,jl), g1(:,:,jl), hL(:,:,jl), hR(:,:,jl),     & 
    519                              zremap_flag) 
    520      END DO 
    521  
    522 !----------------------------------------------------------------------------------------------- 
    523 !  8) Compute area and volume to be shifted across each boundary 
    524 !----------------------------------------------------------------------------------------------- 
    525  
    526      DO jl = klbnd, kubnd - 1 
    527         DO jj = 1, jpj 
    528            DO ji = 1, jpi 
    529               zdonor(ji,jj,jl) = 0 
    530               zdaice(ji,jj,jl) = 0.0 
    531               zdvice(ji,jj,jl) = 0.0 
    532            END DO 
    533         END DO 
    534  
    535         DO ji = 1, nbrem 
    536            zji = nind_i(ji) 
    537            zjj = nind_j(ji) 
    538             
    539            IF (zhbnew(zji,zjj,jl) .gt. hi_max(jl)) THEN ! transfer from jl to jl+1 
    540  
    541               ! left and right integration limits in eta space 
    542               zvetamin(ji) = MAX(hi_max(jl), hL(zji,zjj,jl)) - hL(zji,zjj,jl) 
    543               zvetamax(ji) = MIN(zhbnew(zji,zjj,jl), hR(zji,zjj,jl)) - hL(zji,zjj,jl) 
    544               zdonor(zji,zjj,jl) = jl 
    545  
    546            ELSE  ! zhbnew(jl) <= hi_max(jl) ; transfer from jl+1 to jl 
    547  
    548               ! left and right integration limits in eta space 
    549               zvetamin(ji) = 0.0 
    550               zvetamax(ji) = MIN(hi_max(jl), hR(zji,zjj,jl+1)) - hL(zji,zjj,jl+1) 
    551               zdonor(zji,zjj,jl) = jl + 1 
    552  
    553            ENDIF  ! zhbnew(jl) > hi_max(jl) 
    554  
    555            zetamax = MAX(zvetamax(ji), zvetamin(ji)) ! no transfer if etamax < etamin 
    556            zetamin = zvetamin(ji) 
    557  
    558            zx1  = zetamax - zetamin 
    559            zwk1 = zetamin*zetamin 
    560            zwk2 = zetamax*zetamax 
    561            zx2  = 0.5 * (zwk2 - zwk1) 
    562            zwk1 = zwk1 * zetamin 
    563            zwk2 = zwk2 * zetamax 
    564            zx3  = 1.0/3.0 * (zwk2 - zwk1) 
    565            nd   = zdonor(zji,zjj,jl) 
    566            zdaice(zji,zjj,jl) = g1(zji,zjj,nd)*zx2 + g0(zji,zjj,nd)*zx1 
    567            zdvice(zji,zjj,jl) = g1(zji,zjj,nd)*zx3 + g0(zji,zjj,nd)*zx2 + & 
    568                               zdaice(zji,zjj,jl)*hL(zji,zjj,nd) 
    569  
    570         END DO ! ji 
    571      END DO ! jl klbnd -> kubnd - 1 
    572  
    573 !!---------------------------------------------------------------------------------------------- 
    574 !! 9) Shift ice between categories 
    575 !!---------------------------------------------------------------------------------------------- 
    576      CALL lim_itd_shiftice ( klbnd, kubnd, zdonor, zdaice, zdvice ) 
    577  
    578 !!---------------------------------------------------------------------------------------------- 
    579 !! 10) Make sure ht_i >= minimum ice thickness hi_min 
    580 !!---------------------------------------------------------------------------------------------- 
    581  
    582     DO ji = 1, nbrem 
    583         zji = nind_i(ji) 
    584         zjj = nind_j(ji) 
    585         IF ( ( zhimin .GT. 0.0 ) .AND. &  
    586              ( ( a_i(zji,zjj,1) .GT. zeps ) .AND. ( ht_i(zji,zjj,1) .LT. zhimin ) ) & 
    587            ) THEN 
    588            a_i(zji,zjj,1)  = a_i(zji,zjj,1) * ht_i(zji,zjj,1) / zhimin  
    589            ht_i(zji,zjj,1) = zhimin 
    590            v_i(zji,zjj,1)  = a_i(zji,zjj,1)*ht_i(zji,zjj,1) 
    591         ENDIF 
    592     END DO !ji 
    593  
    594 !!---------------------------------------------------------------------------------------------- 
    595 !! 11) Conservation check 
    596 !!---------------------------------------------------------------------------------------------- 
     417 
     418      !----------------------------------------------------------------------------------------------- 
     419      !  5) Identify cells where ITD is to be remapped 
     420      !----------------------------------------------------------------------------------------------- 
     421      nbrem = 0 
     422      DO jj = 1, jpj 
     423         DO ji = 1, jpi 
     424            IF ( zremap_flag(ji,jj) ) THEN 
     425               nbrem         = nbrem + 1 
     426               nind_i(nbrem) = ji 
     427               nind_j(nbrem) = jj 
     428            ENDIF 
     429         END DO !ji 
     430      END DO !jj 
     431 
     432      !----------------------------------------------------------------------------------------------- 
     433      !  6) Fill arrays with lowermost / uppermost boundaries of 'new' categories 
     434      !----------------------------------------------------------------------------------------------- 
     435      DO jj = 1, jpj 
     436         DO ji = 1, jpi 
     437            zhb0(ji,jj) = hi_max_typ(0,ntyp) ! 0eme 
     438            zhb1(ji,jj) = hi_max_typ(1,ntyp) ! 1er 
     439 
     440            zhbnew(ji,jj,klbnd-1) = 0.0 
     441 
     442            IF ( a_i(ji,jj,kubnd) .GT. zeps ) THEN 
     443               zhbnew(ji,jj,kubnd) = 3.0*ht_i(ji,jj,kubnd) - 2.0*zhbnew(ji,jj,kubnd-1) 
     444            ELSE 
     445               zhbnew(ji,jj,kubnd) = hi_max(kubnd) 
     446            ENDIF 
     447 
     448            IF ( zhbnew(ji,jj,kubnd) .LT. hi_max(kubnd-1) ) & 
     449               zhbnew(ji,jj,kubnd) = hi_max(kubnd-1) 
     450 
     451         END DO !jj 
     452      END DO !jj 
     453 
     454      !----------------------------------------------------------------------------------------------- 
     455      !  7) Compute g(h)  
     456      !----------------------------------------------------------------------------------------------- 
     457      !- 7.1 g(h) for category 1 at start of time step 
     458      CALL lim_itd_fitline(klbnd, zhb0, zhb1, zht_i_o(:,:,klbnd), & 
     459         g0(:,:,klbnd), g1(:,:,klbnd), hL(:,:,klbnd), & 
     460         hR(:,:,klbnd), zremap_flag) 
     461 
     462      !- 7.2 Area lost due to melting of thin ice (first category,  klbnd) 
     463      DO ji = 1, nbrem 
     464         zji = nind_i(ji)  
     465         zjj = nind_j(ji)  
     466 
     467         !ji 
     468         IF (a_i(zji,zjj,klbnd) .gt. zeps) THEN 
     469            zdh0 = zdhice(zji,zjj,klbnd) !decrease of ice thickness in the lower category 
     470            ! ji, a_i > zeps 
     471            IF (zdh0 .lt. 0.0) THEN !remove area from category 1 
     472               ! ji, a_i > zeps; zdh0 < 0 
     473               zdh0 = MIN(-zdh0,hi_max(klbnd)) 
     474 
     475               !Integrate g(1) from 0 to dh0 to estimate area melted 
     476               zetamax = MIN(zdh0,hR(zji,zjj,klbnd)) - hL(zji,zjj,klbnd) 
     477               IF (zetamax.gt.0.0) THEN 
     478                  zx1  = zetamax 
     479                  zx2  = 0.5 * zetamax*zetamax  
     480                  zda0 = g1(zji,zjj,klbnd) * zx2 + g0(zji,zjj,klbnd) * zx1 !ice area removed 
     481                  ! Constrain new thickness <= ht_i 
     482                  zdamax = a_i(zji,zjj,klbnd) * &  
     483                     (1.0 - ht_i(zji,zjj,klbnd)/zht_i_o(zji,zjj,klbnd)) ! zdamax > 0 
     484                  !ice area lost due to melting of thin ice 
     485                  zda0   = MIN(zda0, zdamax) 
     486 
     487                  ! Remove area, conserving volume 
     488                  ht_i(zji,zjj,klbnd) = ht_i(zji,zjj,klbnd) &  
     489                     * a_i(zji,zjj,klbnd) / ( a_i(zji,zjj,klbnd) - zda0 ) 
     490                  a_i(zji,zjj,klbnd)  = a_i(zji,zjj,klbnd) - zda0 
     491                  v_i(zji,zjj,klbnd)  = a_i(zji,zjj,klbnd)*ht_i(zji,zjj,klbnd) 
     492               ENDIF     ! zetamax > 0 
     493               ! ji, a_i > zeps 
     494 
     495            ELSE ! if ice accretion 
     496               ! ji, a_i > zeps; zdh0 > 0 
     497               IF ( ntyp .EQ. 1 ) zhbnew(zji,zjj,klbnd-1) = MIN(zdh0,hi_max(klbnd))  
     498               ! zhbnew was 0, and is shifted to the right to account for thin ice 
     499               ! growth in openwater (F0 = f1) 
     500               IF ( ntyp .NE. 1 ) zhbnew(zji,zjj,0) = 0  
     501               ! in other types there is 
     502               ! no open water growth (F0 = 0) 
     503            ENDIF ! zdh0  
     504 
     505            ! a_i > zeps 
     506         ENDIF ! a_i > zeps 
     507 
     508      END DO ! ji 
     509 
     510      !- 7.3 g(h) for each thickness category   
     511      DO jl = klbnd, kubnd 
     512         CALL lim_itd_fitline(jl, zhbnew(:,:,jl-1), zhbnew(:,:,jl), ht_i(:,:,jl), & 
     513            g0(:,:,jl), g1(:,:,jl), hL(:,:,jl), hR(:,:,jl),     & 
     514            zremap_flag) 
     515      END DO 
     516 
     517      !----------------------------------------------------------------------------------------------- 
     518      !  8) Compute area and volume to be shifted across each boundary 
     519      !----------------------------------------------------------------------------------------------- 
     520 
     521      DO jl = klbnd, kubnd - 1 
     522         DO jj = 1, jpj 
     523            DO ji = 1, jpi 
     524               zdonor(ji,jj,jl) = 0 
     525               zdaice(ji,jj,jl) = 0.0 
     526               zdvice(ji,jj,jl) = 0.0 
     527            END DO 
     528         END DO 
     529 
     530         DO ji = 1, nbrem 
     531            zji = nind_i(ji) 
     532            zjj = nind_j(ji) 
     533 
     534            IF (zhbnew(zji,zjj,jl) .gt. hi_max(jl)) THEN ! transfer from jl to jl+1 
     535 
     536               ! left and right integration limits in eta space 
     537               zvetamin(ji) = MAX(hi_max(jl), hL(zji,zjj,jl)) - hL(zji,zjj,jl) 
     538               zvetamax(ji) = MIN(zhbnew(zji,zjj,jl), hR(zji,zjj,jl)) - hL(zji,zjj,jl) 
     539               zdonor(zji,zjj,jl) = jl 
     540 
     541            ELSE  ! zhbnew(jl) <= hi_max(jl) ; transfer from jl+1 to jl 
     542 
     543               ! left and right integration limits in eta space 
     544               zvetamin(ji) = 0.0 
     545               zvetamax(ji) = MIN(hi_max(jl), hR(zji,zjj,jl+1)) - hL(zji,zjj,jl+1) 
     546               zdonor(zji,zjj,jl) = jl + 1 
     547 
     548            ENDIF  ! zhbnew(jl) > hi_max(jl) 
     549 
     550            zetamax = MAX(zvetamax(ji), zvetamin(ji)) ! no transfer if etamax < etamin 
     551            zetamin = zvetamin(ji) 
     552 
     553            zx1  = zetamax - zetamin 
     554            zwk1 = zetamin*zetamin 
     555            zwk2 = zetamax*zetamax 
     556            zx2  = 0.5 * (zwk2 - zwk1) 
     557            zwk1 = zwk1 * zetamin 
     558            zwk2 = zwk2 * zetamax 
     559            zx3  = 1.0/3.0 * (zwk2 - zwk1) 
     560            nd   = zdonor(zji,zjj,jl) 
     561            zdaice(zji,zjj,jl) = g1(zji,zjj,nd)*zx2 + g0(zji,zjj,nd)*zx1 
     562            zdvice(zji,zjj,jl) = g1(zji,zjj,nd)*zx3 + g0(zji,zjj,nd)*zx2 + & 
     563               zdaice(zji,zjj,jl)*hL(zji,zjj,nd) 
     564 
     565         END DO ! ji 
     566      END DO ! jl klbnd -> kubnd - 1 
     567 
     568      !!---------------------------------------------------------------------------------------------- 
     569      !! 9) Shift ice between categories 
     570      !!---------------------------------------------------------------------------------------------- 
     571      CALL lim_itd_shiftice ( klbnd, kubnd, zdonor, zdaice, zdvice ) 
     572 
     573      !!---------------------------------------------------------------------------------------------- 
     574      !! 10) Make sure ht_i >= minimum ice thickness hi_min 
     575      !!---------------------------------------------------------------------------------------------- 
     576 
     577      DO ji = 1, nbrem 
     578         zji = nind_i(ji) 
     579         zjj = nind_j(ji) 
     580         IF ( ( zhimin .GT. 0.0 ) .AND. &  
     581            ( ( a_i(zji,zjj,1) .GT. zeps ) .AND. ( ht_i(zji,zjj,1) .LT. zhimin ) ) & 
     582            ) THEN 
     583            a_i(zji,zjj,1)  = a_i(zji,zjj,1) * ht_i(zji,zjj,1) / zhimin  
     584            ht_i(zji,zjj,1) = zhimin 
     585            v_i(zji,zjj,1)  = a_i(zji,zjj,1)*ht_i(zji,zjj,1) 
     586         ENDIF 
     587      END DO !ji 
     588 
     589      !!---------------------------------------------------------------------------------------------- 
     590      !! 11) Conservation check 
     591      !!---------------------------------------------------------------------------------------------- 
    597592      IF ( con_i ) THEN 
    598593         CALL lim_column_sum (jpl,   v_i, vt_i_final) 
     
    614609      ENDIF 
    615610 
    616     END SUBROUTINE lim_itd_th_rem 
    617  
    618 !!---------------------------------------------------------------------------------------------- 
    619 !!---------------------------------------------------------------------------------------------- 
    620  
    621     SUBROUTINE lim_itd_fitline(num_cat, HbL, Hbr, hice, g0, g1, hL, hR, zremap_flag ) 
    622  
    623         !!------------------------------------------------------------------ 
    624         !!                ***  ROUTINE lim_itd_fitline *** 
    625         !! ** Purpose : 
    626         !! fit g(h) with a line using area, volume constraints 
    627         !! 
    628         !! ** Method  : 
    629         !! Fit g(h) with a line, satisfying area and volume constraints. 
    630         !! To reduce roundoff errors caused by large values of g0 and g1, 
    631         !! we actually compute g(eta), where eta = h - hL, and hL is the 
    632         !! left boundary. 
    633         !! 
    634         !! ** Arguments : 
    635         !! 
    636         !! ** Inputs / Ouputs : (global commons) 
    637         !! 
    638         !! ** External :  
    639         !! 
    640         !! ** References : 
    641         !! 
    642         !! ** History : 
    643         !! authors: William H. Lipscomb, LANL, Elizabeth C. Hunke, LANL 
    644         !!          (01-2006) Martin Vancoppenolle  
    645         !! 
    646         !!------------------------------------------------------------------ 
    647         !! * Arguments 
     611   END SUBROUTINE lim_itd_th_rem 
     612   ! 
     613 
     614   SUBROUTINE lim_itd_fitline(num_cat, HbL, Hbr, hice, g0, g1, hL, hR, zremap_flag ) 
     615 
     616      !!------------------------------------------------------------------ 
     617      !!                ***  ROUTINE lim_itd_fitline *** 
     618      !! ** Purpose : 
     619      !! fit g(h) with a line using area, volume constraints 
     620      !! 
     621      !! ** Method  : 
     622      !! Fit g(h) with a line, satisfying area and volume constraints. 
     623      !! To reduce roundoff errors caused by large values of g0 and g1, 
     624      !! we actually compute g(eta), where eta = h - hL, and hL is the 
     625      !! left boundary. 
     626      !! 
     627      !! ** Arguments : 
     628      !! 
     629      !! ** Inputs / Ouputs : (global commons) 
     630      !! 
     631      !! ** External :  
     632      !! 
     633      !! ** References : 
     634      !! 
     635      !! ** History : 
     636      !! authors: William H. Lipscomb, LANL, Elizabeth C. Hunke, LANL 
     637      !!          (01-2006) Martin Vancoppenolle  
     638      !! 
     639      !!------------------------------------------------------------------ 
     640      !! * Arguments 
    648641 
    649642      INTEGER, INTENT(in) :: num_cat      ! category index 
     
    674667 
    675668      REAL(wp)  ::           &  ! constant values 
    676           zeps      =  1.0e-10 
     669         zeps      =  1.0e-10 
    677670 
    678671      zacrith       = 1.0e-6 
    679 !!-- End of declarations 
    680 !!---------------------------------------------------------------------------------------------- 
     672      !!-- End of declarations 
     673      !!---------------------------------------------------------------------------------------------- 
    681674 
    682675      DO jj = 1, jpj 
     
    684677 
    685678            IF ( zremap_flag(ji,jj) .AND. a_i(ji,jj,num_cat) .gt. zacrith & 
    686                  .AND. hice(ji,jj) .GT. 0.0 ) THEN 
    687    
    688             ! Initialize hL and hR 
     679               .AND. hice(ji,jj) .GT. 0.0 ) THEN 
     680 
     681               ! Initialize hL and hR 
    689682 
    690683               hL(ji,jj) = HbL(ji,jj) 
    691684               hR(ji,jj) = HbR(ji,jj) 
    692685 
    693             ! Change hL or hR if hice falls outside central third of range 
     686               ! Change hL or hR if hice falls outside central third of range 
    694687 
    695688               zh13 = 1.0/3.0 * (2.0*hL(ji,jj) + hR(ji,jj)) 
     
    702695               ENDIF 
    703696 
    704             ! Compute coefficients of g(eta) = g0 + g1*eta 
    705                    
     697               ! Compute coefficients of g(eta) = g0 + g1*eta 
     698 
    706699               zdhr = 1.0 / (hR(ji,jj) - hL(ji,jj)) 
    707700               zwk1 = 6.0 * a_i(ji,jj,num_cat) * zdhr 
     
    722715      END DO ! jj 
    723716 
    724     END SUBROUTINE lim_itd_fitline 
    725  
    726 !---------------------------------------------------------------------------------------------- 
    727 !---------------------------------------------------------------------------------------------- 
    728  
    729     SUBROUTINE lim_itd_shiftice (klbnd, kubnd, zdonor, zdaice, zdvice) 
    730         !!------------------------------------------------------------------ 
    731         !!                ***  ROUTINE lim_itd_shiftice *** 
    732         !! ** Purpose : shift ice across category boundaries, conserving everything 
    733         !!              ( area, volume, energy, age*vol, and mass of salt ) 
    734         !! 
    735         !! ** Method  : 
    736         !! 
    737         !! ** Arguments : 
    738         !! 
    739         !! ** Inputs / Ouputs : (global commons) 
    740         !! 
    741         !! ** External :  
    742         !! 
    743         !! ** References : 
    744         !! 
    745         !! ** History : 
    746         !! authors: William H. Lipscomb, LANL, Elizabeth C. Hunke, LANL 
    747         !!          (01-2006) Martin Vancoppenolle  
    748         !! 
    749         !!------------------------------------------------------------------ 
    750         !! * Arguments 
     717   END SUBROUTINE lim_itd_fitline 
     718   ! 
     719 
     720   SUBROUTINE lim_itd_shiftice (klbnd, kubnd, zdonor, zdaice, zdvice) 
     721      !!------------------------------------------------------------------ 
     722      !!                ***  ROUTINE lim_itd_shiftice *** 
     723      !! ** Purpose : shift ice across category boundaries, conserving everything 
     724      !!              ( area, volume, energy, age*vol, and mass of salt ) 
     725      !! 
     726      !! ** Method  : 
     727      !! 
     728      !! ** Arguments : 
     729      !! 
     730      !! ** Inputs / Ouputs : (global commons) 
     731      !! 
     732      !! ** External :  
     733      !! 
     734      !! ** References : 
     735      !! 
     736      !! ** History : 
     737      !! authors: William H. Lipscomb, LANL, Elizabeth C. Hunke, LANL 
     738      !!          (01-2006) Martin Vancoppenolle  
     739      !! 
     740      !!------------------------------------------------------------------ 
     741      !! * Arguments 
    751742 
    752743      INTEGER , INTENT (IN) ::  & 
    753           klbnd ,  &  ! Start thickness category index point 
    754           kubnd       ! End point on which the  the computation is applied 
     744         klbnd ,  &  ! Start thickness category index point 
     745         kubnd       ! End point on which the  the computation is applied 
    755746 
    756747      INTEGER , DIMENSION(jpi,jpj,jpl-1), INTENT(IN) :: &  
     
    792783 
    793784      LOGICAL :: & 
    794         zdaice_negative       , & ! true if daice < -puny 
    795         zdvice_negative       , & ! true if dvice < -puny 
    796         zdaice_greater_aicen  , & ! true if daice > aicen 
    797         zdvice_greater_vicen      ! true if dvice > vicen 
    798  
    799        REAL(wp)  ::           &  ! constant values 
    800           zeps      =  1.0e-10 
    801  
    802 !!-- End of declarations 
    803  
    804 !---------------------------------------------------------------------------------------------- 
    805 ! 1) Define a variable equal to a_i*T_su 
    806 !---------------------------------------------------------------------------------------------- 
     785         zdaice_negative       , & ! true if daice < -puny 
     786         zdvice_negative       , & ! true if dvice < -puny 
     787         zdaice_greater_aicen  , & ! true if daice > aicen 
     788         zdvice_greater_vicen      ! true if dvice > vicen 
     789 
     790      REAL(wp)  ::           &  ! constant values 
     791         zeps      =  1.0e-10 
     792 
     793      !!-- End of declarations 
     794 
     795      !---------------------------------------------------------------------------------------------- 
     796      ! 1) Define a variable equal to a_i*T_su 
     797      !---------------------------------------------------------------------------------------------- 
    807798 
    808799      DO jl = klbnd, kubnd 
     
    814805      END DO ! jl 
    815806 
    816 !---------------------------------------------------------------------------------------------- 
    817 ! 2) Check for daice or dvice out of range, allowing for roundoff error 
    818 !---------------------------------------------------------------------------------------------- 
     807      !---------------------------------------------------------------------------------------------- 
     808      ! 2) Check for daice or dvice out of range, allowing for roundoff error 
     809      !---------------------------------------------------------------------------------------------- 
    819810      ! Note: zdaice < 0 or zdvice < 0 usually happens when category jl 
    820811      ! has a small area, with h(n) very close to a boundary.  Then 
     
    834825            DO ji = 1, jpi 
    835826 
    836             IF (zdonor(ji,jj,jl) .GT. 0) THEN 
    837                jl1 = zdonor(ji,jj,jl) 
    838  
    839                IF (zdaice(ji,jj,jl) .LT. 0.0) THEN 
    840                   IF (zdaice(ji,jj,jl) .GT. -zeps) THEN 
    841                      IF ( ( jl1.EQ.jl   .AND. ht_i(ji,jj,jl1) .GT. hi_max(jl) )           & 
    842                                                 .OR.                                      & 
    843                           ( jl1.EQ.jl+1 .AND. ht_i(ji,jj,jl1) .LE. hi_max(jl) )           &   
    844                         ) THEN                                                              
    845                         zdaice(ji,jj,jl) = a_i(ji,jj,jl1)  ! shift entire category 
    846                         zdvice(ji,jj,jl) = v_i(ji,jj,jl1) 
     827               IF (zdonor(ji,jj,jl) .GT. 0) THEN 
     828                  jl1 = zdonor(ji,jj,jl) 
     829 
     830                  IF (zdaice(ji,jj,jl) .LT. 0.0) THEN 
     831                     IF (zdaice(ji,jj,jl) .GT. -zeps) THEN 
     832                        IF ( ( jl1.EQ.jl   .AND. ht_i(ji,jj,jl1) .GT. hi_max(jl) )           & 
     833                           .OR.                                      & 
     834                           ( jl1.EQ.jl+1 .AND. ht_i(ji,jj,jl1) .LE. hi_max(jl) )           &   
     835                           ) THEN                                                              
     836                           zdaice(ji,jj,jl) = a_i(ji,jj,jl1)  ! shift entire category 
     837                           zdvice(ji,jj,jl) = v_i(ji,jj,jl1) 
     838                        ELSE 
     839                           zdaice(ji,jj,jl) = 0.0 ! shift no ice 
     840                           zdvice(ji,jj,jl) = 0.0 
     841                        ENDIF 
    847842                     ELSE 
    848                         zdaice(ji,jj,jl) = 0.0 ! shift no ice 
    849                         zdvice(ji,jj,jl) = 0.0 
     843                        zdaice_negative = .true. 
    850844                     ENDIF 
    851                   ELSE 
    852                      zdaice_negative = .true. 
    853845                  ENDIF 
    854                ENDIF 
    855  
    856                IF (zdvice(ji,jj,jl) .LT. 0.0) THEN 
    857                   IF (zdvice(ji,jj,jl) .GT. -zeps ) THEN 
    858                      IF ( ( jl1.EQ.jl .AND. ht_i(ji,jj,jl1).GT.hi_max(jl) )     & 
    859                                        .OR.                                     & 
    860                           ( jl1.EQ.jl+1 .AND. ht_i(ji,jj,jl1) .LE. hi_max(jl) ) & 
    861                         ) THEN 
    862                         zdaice(ji,jj,jl) = a_i(ji,jj,jl1) ! shift entire category 
     846 
     847                  IF (zdvice(ji,jj,jl) .LT. 0.0) THEN 
     848                     IF (zdvice(ji,jj,jl) .GT. -zeps ) THEN 
     849                        IF ( ( jl1.EQ.jl .AND. ht_i(ji,jj,jl1).GT.hi_max(jl) )     & 
     850                           .OR.                                     & 
     851                           ( jl1.EQ.jl+1 .AND. ht_i(ji,jj,jl1) .LE. hi_max(jl) ) & 
     852                           ) THEN 
     853                           zdaice(ji,jj,jl) = a_i(ji,jj,jl1) ! shift entire category 
     854                           zdvice(ji,jj,jl) = v_i(ji,jj,jl1)  
     855                        ELSE 
     856                           zdaice(ji,jj,jl) = 0.0    ! shift no ice 
     857                           zdvice(ji,jj,jl) = 0.0 
     858                        ENDIF 
     859                     ELSE 
     860                        zdvice_negative = .true. 
     861                     ENDIF 
     862                  ENDIF 
     863 
     864                  ! If daice is close to aicen, set daice = aicen. 
     865                  IF (zdaice(ji,jj,jl) .GT. a_i(ji,jj,jl1) - zeps ) THEN 
     866                     IF (zdaice(ji,jj,jl) .LT. a_i(ji,jj,jl1)+zeps) THEN 
     867                        zdaice(ji,jj,jl) = a_i(ji,jj,jl1) 
    863868                        zdvice(ji,jj,jl) = v_i(ji,jj,jl1)  
    864869                     ELSE 
    865                         zdaice(ji,jj,jl) = 0.0    ! shift no ice 
    866                         zdvice(ji,jj,jl) = 0.0 
     870                        zdaice_greater_aicen = .true. 
    867871                     ENDIF 
    868                   ELSE 
    869                      zdvice_negative = .true. 
    870872                  ENDIF 
    871                ENDIF 
    872  
    873             ! If daice is close to aicen, set daice = aicen. 
    874                IF (zdaice(ji,jj,jl) .GT. a_i(ji,jj,jl1) - zeps ) THEN 
    875                   IF (zdaice(ji,jj,jl) .LT. a_i(ji,jj,jl1)+zeps) THEN 
    876                      zdaice(ji,jj,jl) = a_i(ji,jj,jl1) 
    877                      zdvice(ji,jj,jl) = v_i(ji,jj,jl1)  
    878                   ELSE 
    879                      zdaice_greater_aicen = .true. 
     873 
     874                  IF (zdvice(ji,jj,jl) .GT. v_i(ji,jj,jl1)-zeps) THEN 
     875                     IF (zdvice(ji,jj,jl) .LT. v_i(ji,jj,jl1)+zeps) THEN 
     876                        zdaice(ji,jj,jl) = a_i(ji,jj,jl1) 
     877                        zdvice(ji,jj,jl) = v_i(ji,jj,jl1)  
     878                     ELSE 
     879                        zdvice_greater_vicen = .true. 
     880                     ENDIF 
    880881                  ENDIF 
    881                ENDIF 
    882  
    883                IF (zdvice(ji,jj,jl) .GT. v_i(ji,jj,jl1)-zeps) THEN 
    884                   IF (zdvice(ji,jj,jl) .LT. v_i(ji,jj,jl1)+zeps) THEN 
    885                      zdaice(ji,jj,jl) = a_i(ji,jj,jl1) 
    886                      zdvice(ji,jj,jl) = v_i(ji,jj,jl1)  
    887                   ELSE 
    888                      zdvice_greater_vicen = .true. 
    889                   ENDIF 
    890                ENDIF 
    891  
    892             ENDIF               ! donor > 0 
    893          END DO                   ! i 
     882 
     883               ENDIF               ! donor > 0 
     884            END DO                   ! i 
    894885         END DO                 ! j 
    895886 
    896887      END DO !jl 
    897888 
    898 !------------------------------------------------------------------------------- 
    899 ! 3) Transfer volume and energy between categories 
    900 !------------------------------------------------------------------------------- 
     889      !------------------------------------------------------------------------------- 
     890      ! 3) Transfer volume and energy between categories 
     891      !------------------------------------------------------------------------------- 
    901892 
    902893      DO jl = klbnd, kubnd - 1 
     
    10121003      DO jl = klbnd, kubnd 
    10131004         DO jj = 1, jpj 
    1014          DO ji = 1, jpi  
    1015             IF ( a_i(ji,jj,jl) .GT. zeps ) THEN  
    1016                ht_i(ji,jj,jl)  =  v_i(ji,jj,jl) / a_i(ji,jj,jl)  
    1017                t_su(ji,jj,jl)  =  zaTsfn(ji,jj,jl) / a_i(ji,jj,jl)  
    1018                zindsn          =  1.0 - MAX(0.0,SIGN(1.0,-v_s(ji,jj,jl))) !0 if no ice and 1 if yes 
    1019             ELSE 
    1020                ht_i(ji,jj,jl)  = 0.0 
    1021                t_su(ji,jj,jl)  = rtt 
    1022             ENDIF 
    1023          END DO                 ! ji 
     1005            DO ji = 1, jpi  
     1006               IF ( a_i(ji,jj,jl) .GT. zeps ) THEN  
     1007                  ht_i(ji,jj,jl)  =  v_i(ji,jj,jl) / a_i(ji,jj,jl)  
     1008                  t_su(ji,jj,jl)  =  zaTsfn(ji,jj,jl) / a_i(ji,jj,jl)  
     1009                  zindsn          =  1.0 - MAX(0.0,SIGN(1.0,-v_s(ji,jj,jl))) !0 if no ice and 1 if yes 
     1010               ELSE 
     1011                  ht_i(ji,jj,jl)  = 0.0 
     1012                  t_su(ji,jj,jl)  = rtt 
     1013               ENDIF 
     1014            END DO                 ! ji 
    10241015         END DO                 ! jj 
    10251016      END DO                    ! jl 
    10261017 
    1027     END SUBROUTINE lim_itd_shiftice 
    1028  
    1029 !---------------------------------------------------------------------------------------- 
    1030 !---------------------------------------------------------------------------------------- 
    1031  
    1032     SUBROUTINE lim_itd_th_reb(klbnd, kubnd, ntyp) 
    1033         !!------------------------------------------------------------------ 
    1034         !!                ***  ROUTINE lim_itd_th_reb *** 
    1035         !! ** Purpose : rebin - rebins thicknesses into defined categories 
    1036         !! 
    1037         !! ** Method  : 
    1038         !! 
    1039         !! ** Arguments : 
    1040         !! 
    1041         !! ** Inputs / Ouputs : (global commons) 
    1042         !! 
    1043         !! ** External :  
    1044         !! 
    1045         !! ** References : 
    1046         !! 
    1047         !! ** History : (2005) Translation from CICE 
    1048         !!              (2006) Adaptation to include salt, age and types 
    1049         !!              (2007) Mass conservation checked 
    1050         !! 
    1051         !! authors: William H. Lipscomb, LANL, Elizabeth C. Hunke, LANL 
    1052         !!          (01-2006) Martin Vancoppenolle (adaptation) 
    1053         !! 
    1054         !!------------------------------------------------------------------ 
    1055         !! * Arguments 
     1018   END SUBROUTINE lim_itd_shiftice 
     1019   ! 
     1020 
     1021   SUBROUTINE lim_itd_th_reb(klbnd, kubnd, ntyp) 
     1022      !!------------------------------------------------------------------ 
     1023      !!                ***  ROUTINE lim_itd_th_reb *** 
     1024      !! ** Purpose : rebin - rebins thicknesses into defined categories 
     1025      !! 
     1026      !! ** Method  : 
     1027      !! 
     1028      !! ** Arguments : 
     1029      !! 
     1030      !! ** Inputs / Ouputs : (global commons) 
     1031      !! 
     1032      !! ** External :  
     1033      !! 
     1034      !! ** References : 
     1035      !! 
     1036      !! ** History : (2005) Translation from CICE 
     1037      !!              (2006) Adaptation to include salt, age and types 
     1038      !!              (2007) Mass conservation checked 
     1039      !! 
     1040      !! authors: William H. Lipscomb, LANL, Elizabeth C. Hunke, LANL 
     1041      !!          (01-2006) Martin Vancoppenolle (adaptation) 
     1042      !! 
     1043      !!------------------------------------------------------------------ 
     1044      !! * Arguments 
    10561045      INTEGER , INTENT (in) ::  & 
    1057           klbnd ,  &  ! Start thickness category index point 
    1058           kubnd ,  &  ! End point on which the  the computation is applied 
    1059           ntyp        ! number of the ice type involved in the rebinning process 
     1046         klbnd ,  &  ! Start thickness category index point 
     1047         kubnd ,  &  ! End point on which the  the computation is applied 
     1048         ntyp        ! number of the ice type involved in the rebinning process 
    10601049 
    10611050      INTEGER :: & 
     
    10811070         vt_s_init, vt_s_final       !  snow volume summed over categories 
    10821071 
    1083        CHARACTER (len = 15) :: fieldid 
    1084  
    1085 !!-- End of declarations 
    1086 !------------------------------------------------------------------------------ 
    1087  
    1088 !     ! conservation check 
     1072      CHARACTER (len = 15) :: fieldid 
     1073 
     1074      !!-- End of declarations 
     1075      !------------------------------------------------------------------------------ 
     1076 
     1077      !     ! conservation check 
    10891078      IF ( con_i ) THEN 
    10901079         CALL lim_column_sum (jpl,   v_i, vt_i_init) 
     
    10921081      ENDIF 
    10931082 
    1094 ! 
    1095 !------------------------------------------------------------------------------ 
    1096 ! 1) Compute ice thickness. 
    1097 !------------------------------------------------------------------------------ 
     1083      ! 
     1084      !------------------------------------------------------------------------------ 
     1085      ! 1) Compute ice thickness. 
     1086      !------------------------------------------------------------------------------ 
    10981087      DO jl = klbnd, kubnd 
    10991088         DO jj = 1, jpj 
    1100          DO ji = 1, jpi  
    1101             IF (a_i(ji,jj,jl) .GT. zeps) THEN  
    1102                ht_i(ji,jj,jl) = v_i(ji,jj,jl) / a_i(ji,jj,jl) 
    1103             ELSE 
    1104                ht_i(ji,jj,jl) = 0.0 
    1105             ENDIF 
    1106          END DO                 ! i 
     1089            DO ji = 1, jpi  
     1090               IF (a_i(ji,jj,jl) .GT. zeps) THEN  
     1091                  ht_i(ji,jj,jl) = v_i(ji,jj,jl) / a_i(ji,jj,jl) 
     1092               ELSE 
     1093                  ht_i(ji,jj,jl) = 0.0 
     1094               ENDIF 
     1095            END DO                 ! i 
    11071096         END DO                 ! j 
    11081097      END DO                    ! n 
    11091098 
    1110 !------------------------------------------------------------------------------ 
    1111 ! 2) Make sure thickness of cat klbnd is at least hi_max_typ(klbnd) 
    1112 !------------------------------------------------------------------------------ 
     1099      !------------------------------------------------------------------------------ 
     1100      ! 2) Make sure thickness of cat klbnd is at least hi_max_typ(klbnd) 
     1101      !------------------------------------------------------------------------------ 
    11131102      DO jj = 1, jpj  
    1114       DO ji = 1, jpi  
    1115  
    1116          IF (a_i(ji,jj,klbnd) > zeps) THEN 
    1117             IF (ht_i(ji,jj,klbnd) .LE. hi_max_typ(0,ntyp) .AND. hi_max_typ(0,ntyp) .GT. 0.0 ) THEN 
    1118                a_i(ji,jj,klbnd)  = v_i(ji,jj,klbnd) / hi_max_typ(0,ntyp)  
    1119                ht_i(ji,jj,klbnd) = hi_max_typ(0,ntyp) 
     1103         DO ji = 1, jpi  
     1104 
     1105            IF (a_i(ji,jj,klbnd) > zeps) THEN 
     1106               IF (ht_i(ji,jj,klbnd) .LE. hi_max_typ(0,ntyp) .AND. hi_max_typ(0,ntyp) .GT. 0.0 ) THEN 
     1107                  a_i(ji,jj,klbnd)  = v_i(ji,jj,klbnd) / hi_max_typ(0,ntyp)  
     1108                  ht_i(ji,jj,klbnd) = hi_max_typ(0,ntyp) 
     1109               ENDIF 
    11201110            ENDIF 
    1121          ENDIF 
    1122       END DO                    ! i 
     1111         END DO                    ! i 
    11231112      END DO                    ! j 
    11241113 
    1125 !------------------------------------------------------------------------------ 
    1126 ! 3) If a category thickness is not in bounds, shift the 
    1127 ! entire area, volume, and energy to the neighboring category 
    1128 !------------------------------------------------------------------------------ 
     1114      !------------------------------------------------------------------------------ 
     1115      ! 3) If a category thickness is not in bounds, shift the 
     1116      ! entire area, volume, and energy to the neighboring category 
     1117      !------------------------------------------------------------------------------ 
    11291118      !------------------------- 
    11301119      ! Initialize shift arrays 
     
    11331122      DO jl = klbnd, kubnd 
    11341123         DO jj = 1, jpj  
    1135          DO ji = 1, jpi 
    1136             zdonor(ji,jj,jl) = 0 
    1137             zdaice(ji,jj,jl) = 0.0 
    1138             zdvice(ji,jj,jl) = 0.0 
    1139          END DO 
     1124            DO ji = 1, jpi 
     1125               zdonor(ji,jj,jl) = 0 
     1126               zdaice(ji,jj,jl) = 0.0 
     1127               zdvice(ji,jj,jl) = 0.0 
     1128            END DO 
    11401129         END DO 
    11411130      END DO 
     
    11471136      DO jl = klbnd, kubnd - 1  ! loop over category boundaries 
    11481137 
    1149       !--------------------------------------- 
    1150       ! identify thicknesses that are too big 
    1151       !--------------------------------------- 
     1138         !--------------------------------------- 
     1139         ! identify thicknesses that are too big 
     1140         !--------------------------------------- 
    11521141         zshiftflag = 0 
    11531142 
     
    11661155         IF ( zshiftflag == 1 ) THEN 
    11671156 
    1168       !------------------------------ 
    1169       ! Shift ice between categories 
    1170       !------------------------------ 
     1157            !------------------------------ 
     1158            ! Shift ice between categories 
     1159            !------------------------------ 
    11711160            CALL lim_itd_shiftice (klbnd, kubnd, zdonor, zdaice, zdvice) 
    1172                   
    1173       !------------------------ 
    1174       ! Reset shift parameters 
    1175       !------------------------ 
     1161 
     1162            !------------------------ 
     1163            ! Reset shift parameters 
     1164            !------------------------ 
    11761165            DO jj = 1, jpj 
    1177             DO ji = 1, jpi 
    1178                zdonor(ji,jj,jl) = 0 
    1179                zdaice(ji,jj,jl) = 0.0 
    1180                zdvice(ji,jj,jl) = 0.0 
    1181             END DO 
     1166               DO ji = 1, jpi 
     1167                  zdonor(ji,jj,jl) = 0 
     1168                  zdaice(ji,jj,jl) = 0.0 
     1169                  zdvice(ji,jj,jl) = 0.0 
     1170               END DO 
    11821171            END DO 
    11831172 
     
    11921181      DO jl = kubnd - 1, 1, -1       ! loop over category boundaries 
    11931182 
    1194       !----------------------------------------- 
    1195       ! Identify thicknesses that are too small 
    1196       !----------------------------------------- 
     1183         !----------------------------------------- 
     1184         ! Identify thicknesses that are too small 
     1185         !----------------------------------------- 
    11971186         zshiftflag = 0 
    11981187 
     
    12131202         IF (zshiftflag==1) THEN 
    12141203 
    1215       !------------------------------ 
    1216       ! Shift ice between categories 
    1217       !------------------------------ 
     1204            !------------------------------ 
     1205            ! Shift ice between categories 
     1206            !------------------------------ 
    12181207            CALL lim_itd_shiftice (klbnd, kubnd, zdonor, zdaice, zdvice) 
    12191208 
    1220       !------------------------ 
    1221       ! Reset shift parameters 
    1222       !------------------------ 
     1209            !------------------------ 
     1210            ! Reset shift parameters 
     1211            !------------------------ 
    12231212            DO jj = 1, jpj  
    1224             DO ji = 1, jpi  
    1225                zdonor(ji,jj,jl)  = 0 
    1226                zdaice(ji,jj,jl)  = 0.0 
    1227                zdvice(ji,jj,jl)  = 0.0 
     1213               DO ji = 1, jpi  
     1214                  zdonor(ji,jj,jl)  = 0 
     1215                  zdaice(ji,jj,jl)  = 0.0 
     1216                  zdvice(ji,jj,jl)  = 0.0 
     1217               END DO 
    12281218            END DO 
    1229             END DO 
    12301219 
    12311220         ENDIF                  ! zshiftflag 
     
    12331222      END DO                    ! jl 
    12341223 
    1235 !------------------------------------------------------------------------------ 
    1236 ! 4) Conservation check 
    1237 !------------------------------------------------------------------------------ 
    1238  
    1239     IF ( con_i ) THEN 
    1240        CALL lim_column_sum (jpl,   v_i, vt_i_final) 
    1241        fieldid = ' v_i : limitd_reb ' 
    1242        CALL lim_cons_check (vt_i_init, vt_i_final, 1.0e-6, fieldid)  
    1243  
    1244        CALL lim_column_sum (jpl,   v_s, vt_s_final) 
    1245        fieldid = ' v_s : limitd_reb ' 
    1246        CALL lim_cons_check (vt_s_init, vt_s_final, 1.0e-6, fieldid)  
    1247     ENDIF 
    1248  
    1249     END SUBROUTINE lim_itd_th_reb 
     1224      !------------------------------------------------------------------------------ 
     1225      ! 4) Conservation check 
     1226      !------------------------------------------------------------------------------ 
     1227 
     1228      IF ( con_i ) THEN 
     1229         CALL lim_column_sum (jpl,   v_i, vt_i_final) 
     1230         fieldid = ' v_i : limitd_reb ' 
     1231         CALL lim_cons_check (vt_i_init, vt_i_final, 1.0e-6, fieldid)  
     1232 
     1233         CALL lim_column_sum (jpl,   v_s, vt_s_final) 
     1234         fieldid = ' v_s : limitd_reb ' 
     1235         CALL lim_cons_check (vt_s_init, vt_s_final, 1.0e-6, fieldid)  
     1236      ENDIF 
     1237 
     1238   END SUBROUTINE lim_itd_th_reb 
    12501239 
    12511240#else 
     
    12681257   END SUBROUTINE lim_itd_th_reb 
    12691258#endif 
    1270  END MODULE limitd_th 
     1259END MODULE limitd_th 
Note: See TracChangeset for help on using the changeset viewer.