Ignore:
Timestamp:
Apr 10, 2026, 7:17:55 PM (4 hours ago)
Author:
jbclement
Message:

PEM:

  • Rework layering-related logic, especially clarify interactions between surface and subsurface water tendencies and disable CO2 lag resistance (inconsistent without updating pressure and mass balance + PCM).
  • Prevent simultaneous activation of layering and ice flows.
  • Add warning when flux_geo /= 0 while soil is disabled.
  • Add new utility function "is_lvl_enabled" for displaying.
  • Replace deprecated 'minieps' with 'eps'/'tol'.

JBC

Location:
trunk/LMDZ.COMMON/libf/evolution
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/changelog.txt

    r4174 r4180  
    963963    - adds new stopping criterion when H2O flux balance fails8 (sanity check);
    964964    - introduces configurable weighting strategies for H2O flux balancing.
     965
     966== 10/04/2026 == JBC
     967- Rework layering-related logic, especially clarify interactions between surface and subsurface water tendencies and disable CO2 lag resistance (inconsistent without updating pressure and mass balance + PCM).
     968- Prevent simultaneous activation of layering and ice flows.
     969- Add warning when flux_geo /= 0 while soil is disabled.
     970- Add new utility function "is_lvl_enabled" for displaying.
     971- Replace deprecated 'minieps' with 'eps'/'tol'.
  • trunk/LMDZ.COMMON/libf/evolution/config.F90

    r4170 r4180  
    1717! DEPENDENCIES
    1818! ------------
    19 use numerics, only: dp, di, k4, minieps
     19use numerics, only: dp, di, k4, eps
    2020
    2121! DECLARATION
     
    240240! DEPENDENCIES
    241241! ------------
    242 use stoppage,  only: stop_clean
    243 use soil,      only: do_soil, reg_thprop_dependp, flux_geo
    244 use sorption,  only: do_sorption
    245 use orbit,     only: evo_orbit
    246 use evolution, only: pem_ini_date
    247 use ice_table, only: icetable_equilibrium, icetable_dynamic
    248 use display,   only: print_msg, LVL_WRN
     242use stoppage,         only: stop_clean
     243use soil,             only: do_soil, reg_thprop_dependp, flux_geo
     244use sorption,         only: do_sorption
     245use orbit,            only: evo_orbit
     246use evolution,        only: pem_ini_date
     247use ice_table,        only: icetable_equilibrium, icetable_dynamic
     248use glaciers,         only: h2oice_flow, co2ice_flow
     249use layered_deposits, only: do_layering
     250use display,          only: print_msg, LVL_WRN
    249251
    250252! DECLARATION
     
    255257! ----
    256258! Warnings (possible incompatibilities)
    257 if (evo_orbit .and. abs(pem_ini_date) < minieps) call print_msg('''evo_orbit = .true.'' but the initial date of the PEM is set to 0!',LVL_WRN)
     259if (evo_orbit .and. abs(pem_ini_date) < eps) call print_msg('''evo_orbit = .true.'' but the initial date of the PEM is set to 0!',LVL_WRN)
     260if (abs(flux_geo) > eps .and. .not. do_soil) call print_msg('soil is not activated but flux_geo /= 0!',LVL_WRN)
    258261
    259262! Errors (true incompatibilities)
    260263if (.not. do_soil) then
    261264    if (icetable_equilibrium .or. icetable_dynamic) call stop_clean(__FILE__,__LINE__,'ice table must be used when do_soil = true!',1)
    262     if (abs(flux_geo) > minieps) call stop_clean(__FILE__,__LINE__,'soil is not activated but flux_geo /= 0!',1)
    263265    if (reg_thprop_dependp) call stop_clean(__FILE__,__LINE__,'regolith properties vary according to Ps only when soil = true!',1)
    264266    if (do_sorption) call stop_clean(__FILE__,__LINE__,'do_soil must be true when do_sorption = true!',1)
    265267end if
     268if (do_layering .and. h2oice_flow) call stop_clean(__FILE__,__LINE__,'layering and H2O ice flow cannot be activated at the same time!',1)
     269if (do_layering .and. co2ice_flow) call stop_clean(__FILE__,__LINE__,'layering and CO2 ice flow cannot be activated at the same time!',1)
    266270
    267271END SUBROUTINE check_config_incompatibility
     
    458462call print_msg('> Initializing soil parameters',LVL_NFO)
    459463volcapa = controle(35)
    460 if (abs(volcapa) < minieps) call stop_clean(__FILE__,__LINE__,'volcapa is 0 in "'//startfi_name//'"!',1)
     464if (abs(volcapa) < eps) call stop_clean(__FILE__,__LINE__,'volcapa is 0 in "'//startfi_name//'"!',1)
    461465
    462466! Initialize orbital data
  • trunk/LMDZ.COMMON/libf/evolution/display.F90

    r4170 r4180  
    1919use, intrinsic :: iso_fortran_env, only: stderr => error_unit
    2020use, intrinsic :: iso_fortran_env, only: stdin => input_unit
    21 use numerics,                      only: dp, di, li, k4, minieps
     21use numerics,                      only: dp, di, li, k4, eps
    2222
    2323! DECLARATION
     
    277277
    278278END SUBROUTINE print_msg
     279!=======================================================================
     280
     281!=======================================================================
     282FUNCTION is_lvl_enabled(lvl) RESULT(enabled)
     283!-----------------------------------------------------------------------
     284! NAME
     285!     is_lvl_enabled
     286!
     287! DESCRIPTION
     288!     Return true if a message at level 'lvl' should be displayed.
     289!
     290! AUTHORS & DATE
     291!     JB Clement, 04/2026
     292!
     293! NOTES
     294!
     295!-----------------------------------------------------------------------
     296
     297! DECLARATION
     298! -----------
     299implicit none
     300
     301! ARGUMENTS
     302! ---------
     303integer(di), intent(in) :: lvl
     304
     305! LOCAL VARIABLES
     306! ---------------
     307logical(k4) :: enabled
     308
     309! CODE
     310! ----
     311enabled = .false.
     312if (lvl <= verbosity_lvl) enabled = .true.
     313
     314END FUNCTION is_lvl_enabled
    279315!=======================================================================
    280316
     
    465501if (gottacatch_emall_()) then
    466502    call print_msg('',LVL_NFO)
    467     if (abs(n_yr_run - first_gen) < minieps) then
     503    if (abs(n_yr_run - first_gen) < eps) then
    468504        do i = 1,size(surprise)
    469505            call print_msg(trim(surprise(i)),LVL_NFO)
  • trunk/LMDZ.COMMON/libf/evolution/glaciers.F90

    r4170 r4180  
    1818! DEPENDENCIES
    1919! ------------
    20 use numerics, only: dp, di, k4, minieps
     20use numerics, only: dp, di, k4, eps
    2121
    2222! DECLARATION
     
    301301                    iaval = islope + 1
    302302                end if
    303                 do while (iaval /= iflat .and. abs(subslope_dist(ig,iaval)) < minieps)
     303                do while (iaval /= iflat .and. abs(subslope_dist(ig,iaval)) < eps)
    304304                    if (iaval > iflat) then
    305305                        iaval = iaval - 1
  • trunk/LMDZ.COMMON/libf/evolution/io_netcdf.F90

    r4152 r4180  
    1616! DEPEDENCIES
    1717! -----------
    18 use numerics, only: dp, di, k4, minieps
     18use numerics, only: dp, di, k4, eps
    1919use netcdf,   only: nf90_double, nf90_noerr, nf90_strerror, nf90_write, nf90_nowrite,                &
    2020                    nf90_open, nf90_close, nf90_redef, nf90_enddef, nf90_inquire, nf90_max_var_dims, &
     
    989989if (.not. has_fill) call check_nc(nf90_get_att(ncid,varid,"missing_value",fill_value),'getting missing value',has_fill)
    990990if (has_fill) then
    991     if (abs(var - fill_value) < minieps) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     991    if (abs(var - fill_value) < eps) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
    992992end if
    993993
     
    10741074if (.not. has_fill) call check_nc(nf90_get_att(ncid,varid,"missing_value",fill_value),'getting missing value',has_fill)
    10751075if (has_fill) then
    1076     if (any(abs(var - fill_value) < minieps)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1076    if (any(abs(var - fill_value) < eps)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
    10771077end if
    10781078
     
    11591159if (.not. has_fill) call check_nc(nf90_get_att(ncid,varid,"missing_value",fill_value),'getting missing value',has_fill)
    11601160if (has_fill) then
    1161     if (any(abs(var - fill_value) < minieps)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1161    if (any(abs(var - fill_value) < eps)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
    11621162end if
    11631163
     
    12441244if (.not. has_fill) call check_nc(nf90_get_att(ncid,varid,"missing_value",fill_value),'getting missing value',has_fill)
    12451245if (has_fill) then
    1246     if (any(abs(var - fill_value) < minieps)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1246    if (any(abs(var - fill_value) < eps)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
    12471247end if
    12481248
     
    13291329if (.not. has_fill) call check_nc(nf90_get_att(ncid,varid,"missing_value",fill_value),'getting missing value',has_fill)
    13301330if (has_fill) then
    1331     if (any(abs(var - fill_value) < minieps)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1331    if (any(abs(var - fill_value) < eps)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
    13321332end if
    13331333
  • trunk/LMDZ.COMMON/libf/evolution/layered_deposits.F90

    r4174 r4180  
    1717! DEPENDENCIES
    1818! ------------
    19 use numerics, only: dp, di, k4, tol
     19use numerics, only: dp, di, k4, tol, eps
    2020use geometry, only: ngrid, nslope
    2121use surf_ice, only: rho_co2ice, rho_h2oice
     
    505505end do
    506506this%nb_str = 0
     507nullify(this%top)
     508nullify(this%bottom)
    507509
    508510END SUBROUTINE del_layering
     
    699701    do ig = 1,ngrid
    700702        do k = 1,size(layerings_array,3)
    701             call add_stratum(layerings_map(ig,islope),layerings_array(ig,islope,k,1),layerings_array(ig,islope,k,2),layerings_array(ig,islope,k,3),layerings_array(ig,islope,k,4),layerings_array(ig,islope,k,5),layerings_array(ig,islope,k,6))
     703            call add_stratum(layerings_map(ig,islope),layerings_array(ig,islope,k,1),       &
     704                             layerings_array(ig,islope,k,2),layerings_array(ig,islope,k,3), &
     705                             layerings_array(ig,islope,k,4),layerings_array(ig,islope,k,5), &
     706                             layerings_array(ig,islope,k,6))
    702707        end do
    703708    end do
     
    742747! CODE
    743748! ----
     749h2o_ice(:,:) = 0._dp
     750co2_ice(:,:) = 0._dp
     751h2oice_depth(:,:) = 0._dp
    744752do ig = 1,ngrid
    745753    do islope = 1,nslope
     
    10701078! Is the considered stratum a dust lag?
    10711079if (.not. is_dust_lag(current)) return
    1072 do while (is_dust_lag(current))
     1080do
    10731081    h_toplag = h_toplag + thickness(current)
    1074     if (associated(current%down)) then
    1075         current => current%down
    1076     else
    1077         exit
     1082    if (.not. associated(current%down)) then ! Bottom of the layering and only dust lag strata
     1083        h_toplag = 0._dp
     1084        return
    10781085    end if
     1086    current => current%down
     1087    if (.not. is_dust_lag(current)) exit
    10791088end do
    1080 
    1081 if (.not. associated(current%down)) then ! Bottom of the layering -> no ice below
    1082     h_toplag = 0._dp
    1083     return
    1084 end if
    10851089
    10861090! Is the stratum below the dust lag made of ice?
     
    10911095    end if
    10921096else if (current%h_co2ice > 0._dp .and. current%h_co2ice > current%h_h2oice) then ! No, there is more CO2 ice than H2O ice
     1097    if (h_toplag < h_patchy_ice) co2_ice = current%h_co2ice*rho_co2ice ! The dust lag is too thin to considered ice as subsurface ice
    10931098    h_toplag = 0._dp ! Because it matters only for H2O ice
    1094     if (h_toplag < h_patchy_ice) co2_ice = current%h_co2ice*rho_co2ice ! But the dust lag is too thin to considered ice as subsurface ice
    10951099end if
    10961100
     
    11281132! Update of properties in the eroding dust lag
    11291133str%top_elevation = str%top_elevation - h2lift*(1._dp + str%h_pore/str%h_dust)
    1130 str%h_pore        = str%h_pore        - h2lift*str%h_pore/str%h_dust
    1131 str%h_dust        = str%h_dust        - h2lift
     1134str%h_pore        = max(0._dp,str%h_pore - h2lift*str%h_pore/str%h_dust)
     1135str%h_dust        = max(0._dp,str%h_dust - h2lift)
    11321136
    11331137! Remove the eroding dust lag if there is no dust anymore
     
    11881192str%h_dust        = str%h_dust        - hlag_dust
    11891193str%h_pore        = str%h_pore        - h2subl*h_pore/h_ice
     1194str%h_co2ice      = max(0._dp,str%h_co2ice)
     1195str%h_h2oice      = max(0._dp,str%h_h2oice)
     1196str%h_dust        = max(0._dp,str%h_dust)
     1197str%h_pore        = max(0._dp,str%h_pore)
    11901198
    11911199! Correct the value of top_elevation for the upper strata
     
    12241232
    12251233!=======================================================================
    1226 SUBROUTINE evolve_layering(this,d_co2ice,d_h2oice,new_str,zshift_surf,new_lag,zlag,current)
     1234SUBROUTINE get_co2_subl_resistance(current,R_subl)
     1235!-----------------------------------------------------------------------
     1236! NAME
     1237!     get_co2_subl_resistance
     1238!
     1239! DESCRIPTION
     1240!     Compute CO2 sublimation inhibition factor due to upper lag strata.
     1241!
     1242! AUTHORS & DATE
     1243!     JB Clement, 04/2026
     1244!
     1245! NOTES
     1246!
     1247!-----------------------------------------------------------------------
     1248
     1249! DECLARATION
     1250! -----------
     1251implicit none
     1252
     1253! ARGUMENTS
     1254! ---------
     1255type(stratum), pointer, intent(in)  :: current
     1256real(dp),               intent(out) :: R_subl
     1257
     1258! LOCAL VARIABLES
     1259! ---------------
     1260real(dp)               :: h_toplag
     1261type(stratum), pointer :: currentloc
     1262
     1263! CODE
     1264! ----
     1265R_subl = 1._dp
     1266if (.not. associated(current%up)) return ! If there is no upper stratum
     1267
     1268h_toplag = 0._dp
     1269currentloc => current%up
     1270do while (is_dust_lag(currentloc) .and. associated(currentloc%up))
     1271    h_toplag = h_toplag + thickness(currentloc)
     1272    currentloc => currentloc%up
     1273end do
     1274
     1275if (currentloc%h_h2oice >= h_patchy_ice) then
     1276    ! There is a thick H2O ice layer above the dust lag, so CO2 sublimation is fully inhibited
     1277    R_subl = 0._dp
     1278else
     1279    h_toplag = h_toplag + thickness(currentloc)
     1280    R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
     1281end if
     1282
     1283END SUBROUTINE get_co2_subl_resistance
     1284!=======================================================================
     1285
     1286!=======================================================================
     1287SUBROUTINE settle_h2o_surf_subsurf_tend(h2oice_depth,flux_ssice,d_h2oice,icell,jcell)
     1288!-----------------------------------------------------------------------
     1289! NAME
     1290!     settle_h2o_surf_subsurf_tend
     1291!
     1292! DESCRIPTION
     1293!     Reconcile H2O surface and subsurface tendencies for one grid cell.
     1294!
     1295! AUTHORS & DATE
     1296!     JB Clement, 04/2026
     1297!
     1298! NOTES
     1299!
     1300!-----------------------------------------------------------------------
     1301
     1302! DEPENDENCIES
     1303! ------------
     1304use display, only: print_msg, LVL_ERR, LVL_WRN, LVL_DBG, is_lvl_enabled
     1305
     1306! DECLARATION
     1307! -----------
     1308implicit none
     1309
     1310! ARGUMENTS
     1311! ---------
     1312real(dp),               intent(in)           :: h2oice_depth
     1313real(dp),               intent(inout)        :: flux_ssice, d_h2oice
     1314integer(di),            intent(in), optional :: icell, jcell
     1315
     1316! LOCAL VARIABLES
     1317! ---------------
     1318logical(k4)   :: has_ssice, ss_sublim, ss_cond, surf_sublim, surf_cond
     1319character(64) :: cell_tag
     1320
     1321! CODE
     1322! ----
     1323cell_tag = ''
     1324if (present(icell) .and. present(jcell)) then
     1325    if (is_lvl_enabled(LVL_DBG)) write(cell_tag,'(a,i0,a,i0,a)') ' [i=',icell,',islope=',jcell,']'
     1326end if
     1327
     1328has_ssice = h2oice_depth > 0._dp
     1329ss_sublim = flux_ssice < -eps
     1330ss_cond = flux_ssice > eps
     1331surf_sublim = d_h2oice < -eps
     1332surf_cond = d_h2oice > eps
     1333
     1334if (has_ssice) then
     1335    if (ss_sublim) then
     1336        if (surf_sublim) then
     1337            call print_msg('Sublimating subsurface ice but sublimating surface ice is also present!'//trim(cell_tag),LVL_ERR)
     1338        else if (surf_cond) then
     1339            call print_msg('Sublimating subsurface ice but condensing surface ice is also present!'//trim(cell_tag),LVL_WRN)
     1340            call print_msg('This may happen because yearly minimum of frost is growing!',LVL_WRN)
     1341            call print_msg('Choice: condensing surface ice overrules sublimating subsurface ice!',LVL_WRN)
     1342            flux_ssice = 0._dp
     1343        else
     1344            ! Needed so the layering algorithm receives a retreat tendency
     1345            d_h2oice = flux_ssice
     1346        end if
     1347    else if (ss_cond) then
     1348        if (surf_cond) then
     1349            call print_msg('Condensing subsurface ice but condensing surface ice is also present!'//trim(cell_tag),LVL_WRN)
     1350            call print_msg('This may happen because yearly minimum of frost is growing!',LVL_WRN)
     1351            call print_msg('Choice: condensing surface ice overrules condensing subsurface ice!',LVL_WRN)
     1352            flux_ssice = 0._dp
     1353        else if (surf_sublim) then
     1354            call print_msg('Condensing subsurface ice but sublimating surface ice is also present!'//trim(cell_tag),LVL_ERR)
     1355        else
     1356            call print_msg('Condensing subsurface ice cannot be handled by the current layering algorithm!'//trim(cell_tag),LVL_ERR)
     1357        end if
     1358    else
     1359        flux_ssice = 0._dp ! Very small subsurface flux is set to zero to avoid numerical issues
     1360    end if
     1361else
     1362    if (abs(flux_ssice) > eps) call print_msg('Subsurface ice flux is non-zero while there is no subsurface ice!'//trim(cell_tag),LVL_ERR)
     1363end if
     1364
     1365END SUBROUTINE settle_h2o_surf_subsurf_tend
     1366!=======================================================================
     1367
     1368!=======================================================================
     1369SUBROUTINE evolve_layering(this,d_co2ice,d_h2oice,h2oice_depth,flux_ssice,new_str,zshift_surf,new_lag,zlag,current,icell,jcell)
    12271370!-----------------------------------------------------------------------
    12281371! NAME
     
    12391382!
    12401383! NOTES
    1241 !     Creates dust lag layers when ice sublimation occurs.
     1384!
    12421385!-----------------------------------------------------------------------
    12431386
     
    12551398! ARGUMENTS
    12561399! ---------
    1257 real(dp),               intent(in)    :: d_co2ice, d_h2oice
    1258 type(layering),         intent(inout) :: this
    1259 type(stratum), pointer, intent(inout) :: current
    1260 logical(k4),            intent(inout) :: new_str, new_lag
    1261 real(dp),               intent(out)   :: zshift_surf, zlag
    1262 
    1263 ! LOCAL VARIABLES
    1264 ! ---------------
    1265 real(dp)               :: dh_co2ice, dh_h2oice, dh_dust, dh_dust_co2, dh_dust_h2o
    1266 real(dp)               :: h_co2ice_old, h_h2oice_old
    1267 real(dp)               :: h2subl_co2ice, h2subl_h2oice, h2subl_co2ice_tot, h2subl_h2oice_tot
    1268 real(dp)               :: h2lift, h2lift_tot, h_pore, h_tot, h_toplag, R_subl
    1269 logical(k4)            :: unexpected
    1270 type(stratum), pointer :: currentloc
    1271 
    1272 ! CODE
    1273 ! ----
     1400real(dp),               intent(inout)        :: d_co2ice, d_h2oice, flux_ssice
     1401real(dp),               intent(in)           :: h2oice_depth
     1402type(layering),         intent(inout)        :: this
     1403type(stratum), pointer, intent(inout)        :: current
     1404logical(k4),            intent(inout)        :: new_str, new_lag
     1405real(dp),               intent(out)          :: zshift_surf, zlag
     1406integer(di),            intent(in), optional :: icell, jcell
     1407
     1408! LOCAL VARIABLES
     1409! ---------------
     1410real(dp)    :: dh_co2ice, dh_h2oice, dh_dust, dh_dust_co2, dh_dust_h2o
     1411real(dp)    :: h_co2ice_old, h_h2oice_old
     1412real(dp)    :: h2subl_co2ice, h2subl_h2oice, h2subl_co2ice_tot, h2subl_h2oice_tot
     1413real(dp)    :: h2lift, h2lift_tot, h_pore, h_tot!, R_subl
     1414logical(k4) :: unexpected
     1415
     1416! CODE
     1417! ----
     1418call settle_h2o_surf_subsurf_tend(h2oice_depth,flux_ssice,d_h2oice,icell,jcell)
     1419
    12741420dh_co2ice = d_co2ice/rho_co2ice
    12751421dh_h2oice = d_h2oice/rho_h2oice
     
    12981444else if (dh_co2ice >= 0._dp .and. dh_h2oice >= 0._dp .and. dh_dust >= 0._dp) then
    12991445    ! Which porosity is considered?
    1300     if (dh_co2ice > dh_h2oice .and. dh_co2ice > dh_dust) then ! CO2 ice is dominant
     1446    if (dh_co2ice >= dh_h2oice .and. dh_co2ice >= dh_dust) then ! CO2 ice is dominant
    13011447        h_pore = dh_co2ice*co2ice_porosity/(1._dp - co2ice_porosity)
    1302     else if (dh_h2oice > dh_co2ice .and. dh_h2oice > dh_dust) then ! H2O ice is dominant
     1448    else if (dh_h2oice >= dh_co2ice .and. dh_h2oice >= dh_dust) then ! H2O ice is dominant
    13031449        h_pore = dh_h2oice*h2oice_porosity/(1._dp - h2oice_porosity)
    1304     else if (dh_dust > dh_co2ice .and. dh_dust > dh_h2oice) then ! Dust is dominant
     1450    else if (dh_dust >= dh_co2ice .and. dh_dust >= dh_h2oice) then ! Dust is dominant
    13051451        h_pore = dh_dust*regolith_porosity/(1._dp - regolith_porosity)
    13061452    else
     
    13301476
    13311477            ! How much is CO2 ice sublimation inhibited by the top dust lag?
    1332             R_subl = 1.
    1333             if (associated(current%up)) then ! If there is an upper stratum
    1334                 h_toplag = 0._dp
    1335                 currentloc => current%up
    1336                 do while (is_dust_lag(currentloc) .and. associated(currentloc%up))
    1337                     h_toplag = h_toplag + thickness(currentloc)
    1338                     currentloc => currentloc%up
    1339                 end do
    1340                 if (currentloc%h_h2oice >= h_patchy_ice) then
    1341                     R_subl = 0._dp
    1342                 else if (0._dp < currentloc%h_h2oice .and. currentloc%h_h2oice < h_patchy_ice) then
    1343                     h_toplag = h_toplag + thickness(currentloc)
    1344                     R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
    1345                 else
    1346                     R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
    1347                 end if
    1348             end if
    1349            h2subl_co2ice_tot = h2subl_co2ice_tot*R_subl
     1478            !call get_co2_subl_resistance(current,R_subl)
     1479            !h2subl_co2ice_tot = h2subl_co2ice_tot*R_subl
    13501480
    13511481            ! Is there CO2 ice to sublimate?
     
    13881518            end if
    13891519        end do
     1520        ! In case the retreat loop exhausted all strata while residual demand remains then the tendency is set to 0
    13901521        if (h2subl_co2ice_tot > 0._dp) dh_co2ice = 0._dp ! No CO2 ice available anymore so the tendency is set to 0
    13911522        if (h2subl_h2oice_tot > 0._dp) dh_h2oice = 0._dp ! No H2O ice available anymore so the tendency is set to 0
     
    14091540
    14101541            ! How much is CO2 ice sublimation inhibited by the top dust lag?
    1411             R_subl = 1.
    1412             if (associated(current%up)) then ! If there is an upper stratum
    1413                 h_toplag = 0._dp
    1414                 currentloc => current%up
    1415                 do while (is_dust_lag(currentloc) .and. associated(currentloc%up))
    1416                     h_toplag = h_toplag + thickness(currentloc)
    1417                     currentloc => currentloc%up
    1418                 end do
    1419                 if (currentloc%h_h2oice >= h_patchy_ice) then
    1420                     R_subl = 0._dp
    1421                 else if (0._dp < currentloc%h_h2oice .and. currentloc%h_h2oice < h_patchy_ice) then
    1422                     h_toplag = h_toplag + thickness(currentloc)
    1423                     R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
    1424                 else
    1425                     R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
    1426                 end if
    1427             end if
    1428            h2subl_co2ice_tot = h2subl_co2ice_tot*R_subl
     1542            !call get_co2_subl_resistance(current,R_subl)
     1543            !h2subl_co2ice_tot = h2subl_co2ice_tot*R_subl
    14291544
    14301545            ! Is there CO2 ice to sublimate?
     
    14611576            end if
    14621577        end do
     1578        ! In case the retreat loop exhausted all strata while residual demand remains then the tendency is set to 0
    14631579        if (h2subl_co2ice_tot > 0._dp) dh_co2ice = 0._dp ! No CO2 ice available anymore so the tendency is set to 0
    14641580        if (h2lift_tot > 0._dp) dh_dust = 0._dp ! No dust available anymore so the tendency is set to 0
     
    14991615
    15001616            ! How much is CO2 ice sublimation inhibited by the top dust lag?
    1501             R_subl = 1._dp
    1502             if (associated(current%up)) then ! If there is an upper stratum
    1503                 h_toplag = 0._dp
    1504                 currentloc => current%up
    1505                 do while (is_dust_lag(currentloc) .and. associated(currentloc%up))
    1506                     h_toplag = h_toplag + thickness(currentloc)
    1507                     currentloc => currentloc%up
    1508                 end do
    1509                 if (currentloc%h_h2oice >= h_patchy_ice) then
    1510                     R_subl = 0._dp
    1511                 else if (0._dp < currentloc%h_h2oice .and. currentloc%h_h2oice < h_patchy_ice) then
    1512                     h_toplag = h_toplag + thickness(currentloc)
    1513                     R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
    1514                 else
    1515                     R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
    1516                 end if
    1517             end if
    1518            h2subl_co2ice_tot = h2subl_co2ice_tot*R_subl
     1617            !call get_co2_subl_resistance(current,R_subl)
     1618            !h2subl_co2ice_tot = h2subl_co2ice_tot*R_subl
    15191619
    15201620            ! Is there CO2 ice to sublimate?
     
    15511651            end if
    15521652        end do
     1653        ! In case the retreat loop exhausted all strata while residual demand remains then the tendency is set to 0
    15531654        if (h2subl_co2ice_tot > 0._dp) dh_co2ice = 0._dp ! No CO2 ice available anymore so the tendency is set to 0
    15541655        if (h2lift_tot > 0._dp) dh_dust = 0._dp ! No dust available anymore so the tendency is set to 0
     
    15671668end if
    15681669
     1670! New tendencies for ice
     1671d_co2ice = dh_co2ice*rho_co2ice
     1672d_h2oice = dh_h2oice*rho_h2oice
     1673
    15691674zshift_surf = this%top%top_elevation - zshift_surf
    15701675
  • trunk/LMDZ.COMMON/libf/evolution/maths.F90

    r4138 r4180  
    1717! DEPENDENCIES
    1818! ------------
    19 use numerics, only: dp, di, k4, minieps
     19use numerics, only: dp, di, k4
    2020
    2121! DECLARATION
  • trunk/LMDZ.COMMON/libf/evolution/numerics.F90

    r4076 r4180  
    7474real(qp), parameter :: minieps_qp = epsilon(1._qp)
    7575real(wp), parameter :: minieps = epsilon(1._wp)
    76 real(wp), parameter :: tol = 100._wp*minieps
     76real(wp), parameter :: eps    = 100._wp*minieps    ! ~ 10^(-14)
     77real(wp), parameter :: eps_qp = 100._wp*minieps_qp ! ~ 10^(-14)
     78real(wp), parameter :: tol    = 100._wp*eps        ! ~ 10^(-12)
    7779
    7880! Minimum number of significant decimal digits
  • trunk/LMDZ.COMMON/libf/evolution/orbit.F90

    r4170 r4180  
    1515! DEPENDENCIES
    1616! ------------
    17 use numerics, only: dp, di, k4, largest_nb, minieps
     17use numerics, only: dp, di, k4, largest_nb, eps
    1818
    1919! DECLARATION
     
    477477call print_msg('Obl. (current|accepted min|accepted max): '//real2str(obliquity)//' | '//real2str(min_obl)//real2str(max_obl),LVL_NFO)
    478478
    479 max_ecc = min(eccentricity + max_change_ecc,1. - minieps) ! ecc < 1.
     479max_ecc = min(eccentricity + max_change_ecc,1. - eps) ! ecc < 1.
    480480min_ecc = max(eccentricity - max_change_ecc,0._dp) ! ecc >= 0.
    481481call print_msg('Ecc. (current|accepted min|accepted max): '//real2str(eccentricity)//' | '//real2str(min_ecc)//' | '//real2str(max_ecc),LVL_NFO)
  • trunk/LMDZ.COMMON/libf/evolution/output.F90

    r4170 r4180  
    1616! DEPENDENCIES
    1717! ------------
    18 use numerics, only: dp, di, k4, minieps
     18use numerics, only: dp, di, k4, eps
    1919
    2020! DECLARATION
     
    469469
    470470! If output timing not met, return
    471 if (abs(mod(idt,output_rate)) > minieps) return
     471if (abs(mod(idt,output_rate)) > eps) return
    472472
    473473! If it is the first writing of the current timestep
  • trunk/LMDZ.COMMON/libf/evolution/pem.F90

    r4174 r4180  
    3131use clim_state_init,    only: read_start, read_startfi, read_startevo
    3232use config,             only: read_rundef, read_display_config
    33 use display,            only: print_ini, print_end, print_msg, LVL_NFO, LVL_WRN
     33use display,            only: print_ini, print_end, print_msg, is_lvl_enabled, LVL_NFO, LVL_WRN, LVL_DBG
    3434use evolution,          only: n_yr_run, n_yr_sim, ntot_yr_sim, nmax_yr_run, dt, idt, r_plnt2earth_yr, pem_ini_date
    3535use geometry,           only: ngrid, nslope, nsoil_PCM, nsoil, cell_area, total_surface
     
    3838use layered_deposits,   only: do_layering, del_layering, evolve_layering, ptrarray, layering2surfice, surfice2layering, print_layering
    3939use maths,              only: pi
    40 use numerics,           only: dp, qp, di, li, k4, minieps, minieps_qp
     40use numerics,           only: dp, qp, di, li, k4, eps, eps_qp
    4141use orbit,              only: evo_orbit, read_orbitpm, compute_maxyr_orbit, update_orbit
    4242use output,             only: write_diagevo, dim_ngrid, dim_nsoil
     
    233233    if (do_layering) then
    234234        h2oice_depth_old(:,:) = h2oice_depth(:,:)
    235         ! The sublimating tendency coming from subsurface ice is given through the surface ice tendency
    236         where (h2oice_depth(:,:) > 0. .and. flux_ssice_avg(:,:) < 0._dp) d_h2oice(:,:) = flux_ssice_avg(:,:)
    237235        do islope = 1,nslope
    238236            do i = 1,ngrid
    239                 call evolve_layering(layerings_map(i,islope),d_co2ice(i,islope),d_h2oice(i,islope),new_str(i,islope),zshift_surf(i,islope),new_lag(i,islope),zlag(i,islope),current(i,islope)%p)
    240                 call print_layering(layerings_map(i,islope))
     237                call evolve_layering(layerings_map(i,islope),d_co2ice(i,islope),d_h2oice(i,islope),h2oice_depth(i,islope),flux_ssice_avg(i,islope), &
     238                                     new_str(i,islope),zshift_surf(i,islope),new_lag(i,islope),zlag(i,islope),current(i,islope)%p,i,islope)
     239                if (is_lvl_enabled(LVL_DBG)) call print_layering(layerings_map(i,islope))
    241240            end do
    242241        end do
     
    255254        call evolve_h2oice(delta_h2o_ads,delta_icetable,h2o_ice,d_h2oice,zshift_surf,stopcrit)
    256255        call evolve_co2ice(co2_ice,d_co2ice,zshift_surf)
    257     end if
    258 
    259     ! Flow glaciers according to surface ice
    260     if (co2ice_flow) then
    261         allocate(is_co2ice_flow(ngrid,nslope))
    262         call flow_co2glaciers(q_co2_ts,ps_ts,ps_avg_glob_old,ps_avg_glob,co2_ice,is_co2ice_flow)
    263     end if
    264     if (h2oice_flow) then
    265         allocate(is_h2oice_flow(ngrid,nslope))
    266         call flow_h2oglaciers(tsurf_avg,h2o_ice,is_h2oice_flow)
    267     end if
    268     if (do_layering) call surfice2layering(h2o_ice,co2_ice,layerings_map)
     256
     257        ! Flow glaciers according to surface ice
     258        if (co2ice_flow) then
     259            allocate(is_co2ice_flow(ngrid,nslope))
     260            call flow_co2glaciers(q_co2_ts,ps_ts,ps_avg_glob_old,ps_avg_glob,co2_ice,is_co2ice_flow)
     261        end if
     262        if (h2oice_flow) then
     263            allocate(is_h2oice_flow(ngrid,nslope))
     264            call flow_h2oglaciers(tsurf_avg,h2o_ice,is_h2oice_flow)
     265        end if
     266    end if ! do_layering
    269267
    270268    ! Adapt surface temperature if surface ice disappeared
     
    337335
    338336    ! Checking mass balance for CO2
    339     if (abs(CO2cond_ps_PCM - 1._dp) < minieps) then
     337    if (abs(CO2cond_ps_PCM - 1._dp) < eps) then
    340338        totmass_co2ice = 0._dp
    341339        totmass_atmco2 = 0._dp
     
    346344            end do
    347345        end do
    348         totmass_ini = max(totmass_atmco2_ini + totmass_co2ice_ini + totmass_adsco2_ini,minieps_qp) ! To avoid division by 0
     346        totmass_ini = max(totmass_atmco2_ini + totmass_co2ice_ini + totmass_adsco2_ini,eps_qp) ! To avoid division by 0
    349347        call print_msg('> Relative total CO2 mass balance = '//real2str(100._qp*(totmass_atmco2 + totmass_co2ice + totmass_adsco2 - totmass_atmco2_ini - totmass_co2ice_ini - totmass_adsco2_ini)/totmass_ini)//' %',LVL_NFO)
    350348        if (abs((totmass_atmco2 + totmass_co2ice + totmass_adsco2 - totmass_atmco2_ini - totmass_co2ice_ini - totmass_adsco2_ini)/totmass_ini) > 0.01_qp) then
    351349            call print_msg('Mass balance is not conserved!',LVL_WRN)
    352             totmass_ini = max(totmass_atmco2_ini,minieps_qp) ! To avoid division by 0
     350            totmass_ini = max(totmass_atmco2_ini,eps_qp) ! To avoid division by 0
    353351            call print_msg('    Atmospheric CO2 mass balance = '//real2str(100._qp*(totmass_atmco2 - totmass_atmco2_ini)/totmass_ini)//' %',LVL_WRN)
    354             totmass_ini = max(totmass_co2ice_ini,minieps_qp) ! To avoid division by 0
     352            totmass_ini = max(totmass_co2ice_ini,eps_qp) ! To avoid division by 0
    355353            call print_msg('    CO2 ice mass balance         = '//real2str(100._qp*(totmass_co2ice - totmass_co2ice_ini)/totmass_ini)//' %',LVL_WRN)
    356             totmass_ini = max(totmass_adsco2_ini,minieps_qp) ! To avoid division by 0
     354            totmass_ini = max(totmass_adsco2_ini,eps_qp) ! To avoid division by 0
    357355            call print_msg('    Adsorbed CO2 mass balance    = '//real2str(100._qp*(totmass_adsco2 - totmass_adsco2_ini)/totmass_ini)//' %',LVL_WRN)
    358356        end if
     
    412410call update_workflow_status(n_yr_run,stopcrit%stop_code(),n_yr_sim,ntot_yr_sim)
    413411
    414 ! Deallocation
    415 if (do_layering) then
    416     deallocate(h2oice_depth,h2oice_depth_old,new_str,new_lag,current)
    417     do islope = 1,nslope
    418         do i = 1,ngrid
    419             call del_layering(layerings_map(i,islope))
    420         end do
    421     end do
    422 end if
     412! Clean-up
     413if (do_layering) deallocate(h2oice_depth,h2oice_depth_old,new_str,new_lag,current)
    423414call end_allocation()
    424415
  • trunk/LMDZ.COMMON/libf/evolution/planet.F90

    r4170 r4180  
    2121! ------------
    2222use numerics,         only: dp, qp, k4
    23 use layered_deposits, only: layering
     23use layered_deposits, only: layering, del_layering
    2424
    2525! DECLARATION
     
    231231implicit none
    232232
     233! LOCAL VARIABLES
     234! ---------------
     235integer :: i, islope
     236
    233237! CODE
    234238! ----
     
    253257delta_h2o_ads(:) = 0._dp
    254258delta_co2_ads(:) = 0._dp
     259do islope = 1,nslope
     260    do i = 1,ngrid
     261        layerings_map(i,islope)%nb_str = 0
     262        nullify(layerings_map(i,islope)%bottom,layerings_map(i,islope)%top)
     263    end do
     264end do
    255265
    256266END SUBROUTINE allocate_startevo_state
     
    386396!-----------------------------------------------------------------------
    387397
    388 ! DECLARATION
    389 ! -----------
    390 implicit none
     398! DEPENDENCIES
     399! ------------
     400use geometry, only: ngrid, nslope
     401
     402! DECLARATION
     403! -----------
     404implicit none
     405
     406! LOCAL VARIABLES
     407! ---------------
     408integer :: i, islope
    391409
    392410! CODE
     
    407425if (allocated(tsoil_ts)) deallocate(tsoil_ts)
    408426if (allocated(tsoil_ts_old)) deallocate(tsoil_ts_old)
    409 if (allocated(layerings_map)) deallocate(layerings_map)
     427if (allocated(layerings_map)) then
     428    do islope = 1,nslope
     429        do i = 1,ngrid
     430            call del_layering(layerings_map(i,islope))
     431        end do
     432    end do
     433    deallocate(layerings_map)
     434end if
    410435if (allocated(h2o_soildensity_avg)) deallocate(h2o_soildensity_avg)
    411436if (allocated(delta_co2_ads)) deallocate(delta_co2_ads)
     
    424449if (allocated(d_co2ice_ini)) deallocate(d_co2ice_ini)
    425450if (allocated(d_h2oice)) deallocate(d_h2oice)
    426 if (allocated(layerings_map)) deallocate(layerings_map)
    427451if (allocated(flux_ssice_avg)) deallocate(flux_ssice_avg)
    428452
  • trunk/LMDZ.COMMON/libf/evolution/soil_therm_inertia.F90

    r4135 r4180  
    1818! DEPENDENCIES
    1919! ------------
    20 use numerics, only: dp, di, k4, minieps
     20use numerics, only: dp, di, k4, eps
    2121
    2222! DECLARATION
     
    143143    regolith_inertia(:,islope) = inertiedat(:,1)
    144144    do ig = 1,ngrid
    145         if (abs(h2o_ice(ig,islope)) < minieps) regolith_inertia(ig,islope) = TI_regolith_avg
     145        if (abs(h2o_ice(ig,islope)) < eps) regolith_inertia(ig,islope) = TI_regolith_avg
    146146        if (reg_thprop_dependp) then
    147147            if (TI(ig,1,islope) < reg_inertie_thresold) then
     
    191191        if (icetable_depth(ig,islope) > -1.e-6_dp) then
    192192        ! 3.0 Case where it is perennial ice
    193             if (icetable_depth(ig,islope) < minieps) then
     193            if (icetable_depth(ig,islope) < eps) then
    194194                call get_ice_TI(.true.,1._dp,0._dp,ice_inertia)
    195195                do isoil = 1,nsoil
  • trunk/LMDZ.COMMON/libf/evolution/sorption.F90

    r4174 r4180  
    1818! DEPENDENCIES
    1919! ------------
    20 use numerics, only: dp, qp, di, k4, minieps
     20use numerics, only: dp, qp, di, k4, eps
    2121
    2222! DECLARATION
     
    230230        deltam_reg_slope(ig,islope) = 0._dp
    231231        do iloop = 1,index_breccia
    232             if (TI(ig,iloop,islope) < inertie_thresold .and. abs(h2o_ice(ig,islope)) < minieps .and. abs(co2_ice(ig,islope)) < minieps) then
     232            if (TI(ig,iloop,islope) < inertie_thresold .and. abs(h2o_ice(ig,islope)) < eps .and. abs(co2_ice(ig,islope)) < eps) then
    233233                if (iloop == 1) then
    234234                    deltam_reg_complete(ig,iloop,islope) = (dm_h2o_regolith_slope(ig,iloop,islope) - h2o_ads_reg(ig,iloop,islope))*(layer(iloop))
     
    347347    do islope = 1,nslope
    348348        do iloop = 1,index_breccia
    349             if (TI(ig,iloop,islope) < inertie_thresold .and. abs(h2o_ice(ig,islope)) < minieps .and. abs(co2_ice(ig,islope)) < minieps) then
     349            if (TI(ig,iloop,islope) < inertie_thresold .and. abs(h2o_ice(ig,islope)) < eps .and. abs(co2_ice(ig,islope)) < eps) then
    350350                dm_co2_regolith_slope(ig,iloop,islope) = as*rho_regolith*m_theta*(1._dp - theta_h2o_ads(ig,iloop,islope))*alpha*pco2_avg(ig)/ &
    351351                                                         (alpha*pco2_avg(ig) + sqrt(tsoil(ig,iloop,islope))*exp(beta/tsoil(ig,iloop,islope)))
    352352            else
    353                 if (abs(co2_ads_reg(ig,iloop,islope)) < minieps) then !!! we are at first call
     353                if (abs(co2_ads_reg(ig,iloop,islope)) < eps) then !!! we are at first call
    354354                    dm_co2_regolith_slope(ig,iloop,islope) = as*rho_regolith*m_theta*(1._dp - theta_h2o_ads(ig,iloop,islope))*alpha*pco2_avg(ig) &
    355355                                                             /(alpha*pco2_avg(ig)+sqrt(tsoil(ig,iloop,islope))*exp(beta/tsoil(ig,iloop,islope)))
     
    368368        deltam_reg_slope(ig,islope) = 0._dp
    369369        do iloop = 1,index_breccia
    370             if (TI(ig,iloop,islope) < inertie_thresold .and. abs(h2o_ice(ig,islope)) < minieps .and. abs(co2_ice(ig,islope)) < minieps) then
     370            if (TI(ig,iloop,islope) < inertie_thresold .and. abs(h2o_ice(ig,islope)) < eps .and. abs(co2_ice(ig,islope)) < eps) then
    371371                if (iloop == 1) then
    372372                    deltam_reg_complete(ig,iloop,islope) = (dm_co2_regolith_slope(ig,iloop,islope) - co2_ads_reg(ig,iloop,islope))*(layer(iloop))
  • trunk/LMDZ.COMMON/libf/evolution/stopping_crit.F90

    r4174 r4180  
    1616! DEPENDENCIES
    1717! ------------
    18 use numerics, only: dp, qp, di, k4, minieps_qp
     18use numerics, only: dp, di, k4
    1919
    2020! DECLARATION
  • trunk/LMDZ.COMMON/libf/evolution/surf_ice.F90

    r4174 r4180  
    1616! DEPENDENCIES
    1717! ------------
    18 use numerics, only: dp, qp, di, k4, minieps
     18use numerics, only: dp, qp, di, k4, eps, tol
    1919
    2020! DECLARATION
     
    3030integer(di),                              parameter :: WEIGHT_RESERVOIR = 5_di ! Weight by locally available H2O ice mass
    3131integer(di),                              parameter :: WEIGHT_DIRECTION = 6_di ! Weight by directional capacity (up/down)
    32 integer(di),                              private   :: weight_method = WEIGHT_DIRECTION ! Default method for balancing
     32integer(di),                              private   :: weight_method = WEIGHT_COMBINED ! Default method for balancing
    3333real(dp),                                 parameter :: rho_co2ice = 1650._dp ! Density of CO2 ice [kg.m-3]
    3434real(dp),                                 parameter :: rho_h2oice = 920._dp  ! Density of H2O ice [kg.m-3]
     
    420420! ---------------
    421421integer(di), parameter :: max_iter = 50_di ! Maximum number of iterations for the balancing procedure
    422 real(dp),    parameter :: eps = 1.e-12_dp ! Small number to prevent division by zero in weights normalization
    423 real(dp),    parameter :: tiny_corr = minieps ! Minimum correction to consider that progress is made in the balancing procedure
    424422integer(di)                              :: i, islope, iter
    425423integer(di)                              :: method_used
     
    556554    Delta = Delta - Delta_used
    557555
    558     if (abs(Delta_used) < tiny_corr) exit
     556    ! Test if the balancing procedure progresses
     557    if (abs(Delta_used) < tol) exit
    559558end do
    560559
  • trunk/LMDZ.COMMON/libf/evolution/surf_temp.F90

    r4147 r4180  
    1616! DEPENDENCIES
    1717! ------------
    18 use numerics, only: dp, di, k4, minieps
     18use numerics, only: dp, di, k4, eps
    1919
    2020! DECLARATION
     
    182182    do i = 1,nlon
    183183        do islope = 1,nslope
    184             if (mask_co2ice_ini(i,j,islope) > 0.5_dp .and. co2ice_ll(i,j,islope) < minieps .and. mask_co2ice_disappeared(i,j,islope) < 0.5_dp) then
     184            if (mask_co2ice_ini(i,j,islope) > 0.5_dp .and. co2ice_ll(i,j,islope) < eps .and. mask_co2ice_disappeared(i,j,islope) < 0.5_dp) then
    185185                found = .false.
    186186                mask_co2ice_disappeared(i,j,islope) = 1._dp
  • trunk/LMDZ.COMMON/libf/evolution/tendencies.F90

    r4170 r4180  
    1818! DEPENDENCIES
    1919! ------------
    20 use numerics, only: dp, di, k4, minieps, tol
     20use numerics, only: dp, di, k4, eps
    2121
    2222! DECLARATION
     
    6262
    6363! If the difference is too small, then there is no evolution
    64 where (abs(d_ice) < minieps) d_ice = 0._dp
     64where (abs(d_ice) < eps) d_ice = 0._dp
    6565
    6666! If the tendency is negative but there is no ice reservoir for the PEM
    67 where (d_ice(:,:) < 0._dp .and. abs(perice(:,:)) < minieps) d_ice(:,:) = 0._dp
     67where (d_ice(:,:) < 0._dp .and. abs(perice(:,:)) < eps) d_ice(:,:) = 0._dp
    6868
    6969END SUBROUTINE compute_tendice
     
    170170! ARGUMENTS
    171171! ---------
    172 real(dp), dimension(:,:),     intent(in) :: h2oice_depth_old ! Old H2O ice depth
    173 real(dp), dimension(:,:),     intent(in) :: h2oice_depth_new ! New H2O ice depth
    174 real(dp), dimension(:,:),     intent(in) :: tsurf            ! Surface temperature
    175 real(dp), dimension(:,:,:,:), intent(in) :: tsoil_ts_old     ! Old soil temperature time series
    176 real(dp), dimension(:,:,:,:), intent(in) :: tsoil_ts_new     ! New soil temperature time series
    177 real(dp), dimension(:,:),     intent(inout) :: flux_ssice_avg       ! Tendency of sub-surface ice
     172real(dp), dimension(:,:),     intent(in)    :: h2oice_depth_old ! Old H2O ice depth
     173real(dp), dimension(:,:),     intent(in)    :: h2oice_depth_new ! New H2O ice depth
     174real(dp), dimension(:,:),     intent(in)    :: tsurf            ! Surface temperature
     175real(dp), dimension(:,:,:,:), intent(in)    :: tsoil_ts_old     ! Old soil temperature time series
     176real(dp), dimension(:,:,:,:), intent(in)    :: tsoil_ts_new     ! New soil temperature time series
     177real(dp), dimension(:,:),     intent(inout) :: flux_ssice_avg   ! Tendency of sub-surface ice
    178178
    179179! LOCAL VARIABLES
     
    190190    do islope = 1,nslope
    191191        ! Higher resistance due to growing lag layer (higher depth)
    192         Rz_old = h2oice_depth_old(i,islope)*zcdv/coef_ssdif_PCM(i,islope) ! Old resistance from PCM
    193         Rz_new = h2oice_depth_new(i,islope)*zcdv/coef_ssdif_PCM(i,islope) ! New resistance based on new depth
    194         R_dec = Rz_old/Rz_new ! Decrease because of resistance
     192        Rz_old = h2oice_depth_old(i,islope)*zcdv/max(abs(coef_ssdif_PCM(i,islope)),eps) ! Old resistance from PCM
     193        Rz_new = h2oice_depth_new(i,islope)*zcdv/max(abs(coef_ssdif_PCM(i,islope)),eps) ! New resistance based on new depth
     194        R_dec = Rz_old/max(Rz_new,eps) ! Decrease because of resistance
    195195
    196196        ! The maxmimum of the daily averages over one year for the saturation vapor pressure at the ice table location
     
    203203
    204204        ! Lower humidity due to growing lag layer (higher depth)
    205         if (abs(psv_max_old) < tol) then
     205        if (abs(psv_max_old) < eps) then
    206206            hum_dec = 1._dp
    207207        else
  • trunk/LMDZ.COMMON/libf/evolution/utility.F90

    r4117 r4180  
    1616! DEPENDENCIES
    1717! ------------
    18 use numerics, only: dp, qp, di, li, k4, minieps
     18use numerics, only: dp, qp, di, li, k4, eps
    1919
    2020! DECLARATION
     
    302302idigits = 1
    303303! If x /= 0 then:
    304 if (abs(x) >= minieps) idigits = int(log10(abs(x))) + 1
     304if (abs(x) >= eps) idigits = int(log10(abs(x))) + 1
    305305
    306306END FUNCTION nb_digits
Note: See TracChangeset for help on using the changeset viewer.