Ignore:
Timestamp:
Apr 10, 2026, 7:17:55 PM (6 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.