Ignore:
Timestamp:
Jul 9, 2025, 11:52:15 AM (6 days ago)
Author:
jbclement
Message:

PEM:

  • Handling the situation in the layering algorithm when CO2 ice sublimation and H2O ice condensation happen simultaneously.
  • Correction of the incorporation of the sub-surface sublimation tendency into the overall tendency to be more robust.
  • Revision of the layering initialization in the case where there is no "startpem.nc" file.

JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/layering_mod.F90

    r3840 r3842  
    598598else if (current%h_co2ice > 0. .and. current%h_co2ice > current%h_h2oice) then ! No, there is more CO2 ice than H2O ice
    599599    h_toplag = 0. ! Because it matters only for H2O ice
    600     if (h_toplag < h_patchy_ice) then ! But the dust lag is too thin to considered ice as subsurface ice
    601         co2_ice = current%h_co2ice
    602     endif
     600    if (h_toplag < h_patchy_ice) co2_ice = current%h_co2ice ! But the dust lag is too thin to considered ice as subsurface ice
    603601endif
    604602
     
    713711
    714712!---- Local variables
    715 real                   :: dh_co2ice, dh_h2oice, dh_dust
     713real                   :: dh_co2ice, dh_h2oice, dh_dust, dh_dust_co2, dh_dust_h2o
    716714real                   :: h_co2ice_old, h_h2oice_old, h_dust_old
    717715real                   :: h2subl_co2ice, h2subl_h2oice, h2subl_co2ice_tot, h2subl_h2oice_tot
     
    724722dh_h2oice = d_h2oice/rho_h2oice
    725723dh_dust = 0.
    726 if (dh_h2oice >= 0. .and. dh_co2ice >= 0.) then ! To put a dust sedimentation tendency only when ice is condensing
     724if (dh_h2oice >= 0.) then ! To put a dust sedimentation tendency only when ice is condensing
    727725    if (impose_dust_ratio) then
    728         dh_dust = dust2ice_ratio*(dh_h2oice + dh_co2ice)
    729     else
     726        if (dh_co2ice >= 0.) then
     727            dh_dust = dust2ice_ratio*(dh_h2oice + dh_co2ice)
     728        else
     729            dh_dust = dust2ice_ratio*dh_h2oice
     730        endif
     731    else
    730732        dh_dust = d_dust/rho_dust
    731733    endif
     
    838840!-----------------------------------------------------------------------
    839841! CO2 ICE SUBLIMATION + H2O ICE CONDENSATION
    840 else if (dh_co2ice < 0. .and. dh_h2oice > 0.) then
    841 !~     if (abs(dh_co2ice) > dh_h2oice .and. dh_co2ice < dh_dust .and. dh_dust <= 0.) then ! CO2 sublimation is dominant
    842 
    843 !~     else if (dh_h2oice > abs(dh_co2ice) .and. 0 <= dh_dust .and. dh_dust < dh_h2oice) then ! H2O condensation is dominant
    844 
    845 !~     else
    846         unexpected = .true.
    847 !~     endif
     842else if (dh_co2ice <= 0. .and. dh_h2oice >= 0.) then
     843    if (dh_dust >= 0.) then
     844        dh_dust_co2 = 0.
     845        dh_dust_h2o = dh_dust
     846    else
     847        dh_dust_co2 = dh_dust
     848        dh_dust_h2o = 0.
     849    endif
     850    if (abs(dh_co2ice) > dh_h2oice) then ! CO2 ice sublimation is dominant
     851        ! CO2 ICE SUBLIMATION: retreating a stratum
     852        h2subl_co2ice_tot = abs(dh_co2ice)
     853        h2lift_tot = abs(dh_dust_co2)
     854        do while ((h2subl_co2ice_tot > 0. .or. h2lift_tot > 0.) .and. associated(current))
     855            h_co2ice_old = current%h_co2ice
     856
     857            ! How much is CO2 ice sublimation inhibited by the top dust lag?
     858            R_subl = 1.
     859            if (associated(current%up)) then ! If there is an upper stratum
     860                h_toplag = 0.
     861                currentloc => current%up
     862                do while (is_dust_lag(currentloc) .and. associated(currentloc%up))
     863                    h_toplag = h_toplag + thickness(currentloc)
     864                    currentloc => currentloc%up
     865                enddo
     866                if (currentloc%h_h2oice >= h_patchy_ice) then
     867                    R_subl = 0.
     868                else if (0. < currentloc%h_h2oice .and. currentloc%h_h2oice < h_patchy_ice) then
     869                    h_toplag = h_toplag + thickness(currentloc)
     870                    R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
     871                else
     872                    R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
     873                endif
     874            endif
     875           h2subl_co2ice_tot = h2subl_co2ice_tot*R_subl
     876
     877            ! Is there CO2 ice to sublimate?
     878            h2subl_co2ice = 0.
     879            if (h_co2ice_old > 0. .and. h2subl_co2ice_tot > 0.) then
     880                h2subl_co2ice = min(h2subl_co2ice_tot,h_co2ice_old)
     881                h2subl_co2ice_tot = h2subl_co2ice_tot - h2subl_co2ice
     882            endif
     883            ! Ice sublimation
     884            if (h2subl_co2ice > 0.) call sublimate_ice(this,current,h2subl_co2ice,0.,new_lag,zlag)
     885
     886            ! Is there dust to lift?
     887            h2lift = 0.
     888            if (is_dust_lag(current) .and. h2lift_tot > 0.) then
     889                h2lift = min(h2lift_tot,current%h_dust)
     890                h2lift_tot = h2lift_tot - h2lift
     891                ! Dust lifting
     892                if (h2lift > 0.) call lift_dust(this,current,h2lift)
     893            else if (associated(current%up)) then
     894                if (is_dust_lag(current%up) .and. h2lift_tot > 0.) then
     895                    h2lift = min(h2lift_tot,current%up%h_dust)
     896                    h2lift_tot = h2lift_tot - h2lift
     897                    ! Dust lifting
     898                    if (h2lift > 0.) call lift_dust(this,current%up,h2lift)
     899                endif
     900            endif
     901
     902            ! Still ice to be sublimated or dust to be lifted and no more ice in the current stratum so we move to the underlying stratum
     903            if ((h2subl_co2ice_tot > 0. .or. h2lift_tot > 0.) .and. current%h_co2ice < tol) then
     904                current => current%down
     905                new_lag = .true.
     906            else
     907                exit
     908            endif
     909        enddo
     910        if (h2subl_co2ice_tot > 0.) dh_co2ice = 0. ! No CO2 ice available anymore so the tendency is set to 0
     911        if (h2lift_tot > 0.) dh_dust = 0. ! No dust available anymore so the tendency is set to 0
     912
     913        ! H2O ICE CONDENSATION: building a stratum
     914        h_pore = dh_h2oice*h2oice_porosity/(1. - h2oice_porosity)
     915        h_tot = dh_h2oice + dh_dust_h2o + h_pore
     916        ! New stratum at the top of the layering
     917        if (new_str) then
     918            call add_stratum(this,this%top%top_elevation + h_tot,0.,dh_h2oice,dh_dust_h2o,h_pore,0.)
     919            new_str = .false.
     920        else
     921            this%top%top_elevation = this%top%top_elevation + h_tot
     922            this%top%h_h2oice      = this%top%h_h2oice      + dh_h2oice
     923            this%top%h_dust        = this%top%h_dust        + dh_dust_h2o
     924            this%top%h_pore        = this%top%h_pore        + h_pore
     925        endif
     926    else ! H2O ice condensation is dominant
     927        ! H2O ICE CONDENSATION: building a stratum
     928        h_pore = dh_h2oice*h2oice_porosity/(1. - h2oice_porosity)
     929        h_tot = dh_h2oice + dh_dust_h2o + h_pore
     930        ! New stratum at the top of the layering
     931        if (new_str) then
     932            call add_stratum(this,this%top%top_elevation + h_tot,0.,dh_h2oice,dh_dust_h2o,h_pore,0.)
     933            new_str = .false.
     934        else
     935            this%top%top_elevation = this%top%top_elevation + h_tot
     936            this%top%h_h2oice      = this%top%h_h2oice      + dh_h2oice
     937            this%top%h_dust        = this%top%h_dust        + dh_dust_h2o
     938            this%top%h_pore        = this%top%h_pore        + h_pore
     939        endif
     940
     941        ! CO2 ICE SUBLIMATION: retreating a stratum
     942        h2subl_co2ice_tot = abs(dh_co2ice)
     943        h2lift_tot = abs(dh_dust_co2)
     944        do while ((h2subl_co2ice_tot > 0. .or. h2lift_tot > 0.) .and. associated(current))
     945            h_co2ice_old = current%h_co2ice
     946
     947            ! How much is CO2 ice sublimation inhibited by the top dust lag?
     948            R_subl = 1.
     949            if (associated(current%up)) then ! If there is an upper stratum
     950                h_toplag = 0.
     951                currentloc => current%up
     952                do while (is_dust_lag(currentloc) .and. associated(currentloc%up))
     953                    h_toplag = h_toplag + thickness(currentloc)
     954                    currentloc => currentloc%up
     955                enddo
     956                if (currentloc%h_h2oice >= h_patchy_ice) then
     957                    R_subl = 0.
     958                else if (0. < currentloc%h_h2oice .and. currentloc%h_h2oice < h_patchy_ice) then
     959                    h_toplag = h_toplag + thickness(currentloc)
     960                    R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
     961                else
     962                    R_subl = fred_sublco2**(h_toplag/hmin_lag_co2)
     963                endif
     964            endif
     965           h2subl_co2ice_tot = h2subl_co2ice_tot*R_subl
     966
     967            ! Is there CO2 ice to sublimate?
     968            h2subl_co2ice = 0.
     969            if (h_co2ice_old > 0. .and. h2subl_co2ice_tot > 0.) then
     970                h2subl_co2ice = min(h2subl_co2ice_tot,h_co2ice_old)
     971                h2subl_co2ice_tot = h2subl_co2ice_tot - h2subl_co2ice
     972            endif
     973            ! Ice sublimation
     974            if (h2subl_co2ice > 0.) call sublimate_ice(this,current,h2subl_co2ice,0.,new_lag,zlag)
     975
     976            ! Is there dust to lift?
     977            h2lift = 0.
     978            if (is_dust_lag(current) .and. h2lift_tot > 0.) then
     979                h2lift = min(h2lift_tot,current%h_dust)
     980                h2lift_tot = h2lift_tot - h2lift
     981                ! Dust lifting
     982                if (h2lift > 0.) call lift_dust(this,current,h2lift)
     983            else if (associated(current%up)) then
     984                if (is_dust_lag(current%up) .and. h2lift_tot > 0.) then
     985                    h2lift = min(h2lift_tot,current%up%h_dust)
     986                    h2lift_tot = h2lift_tot - h2lift
     987                    ! Dust lifting
     988                    if (h2lift > 0.) call lift_dust(this,current%up,h2lift)
     989                endif
     990            endif
     991
     992            ! Still ice to be sublimated or dust to be lifted and no more ice in the current stratum so we move to the underlying stratum
     993            if ((h2subl_co2ice_tot > 0. .or. h2lift_tot > 0.) .and. current%h_co2ice < tol) then
     994                current => current%down
     995                new_lag = .true.
     996            else
     997                exit
     998            endif
     999        enddo
     1000        if (h2subl_co2ice_tot > 0.) dh_co2ice = 0. ! No CO2 ice available anymore so the tendency is set to 0
     1001        if (h2lift_tot > 0.) dh_dust = 0. ! No dust available anymore so the tendency is set to 0
     1002    endif
    8481003!-----------------------------------------------------------------------
    8491004! NOT EXPECTED SITUATION
Note: See TracChangeset for help on using the changeset viewer.