Ignore:
Timestamp:
Mar 25, 2026, 11:19:02 AM (3 weeks ago)
Author:
jbclement
Message:

PEM:

  • Fix outputs "diagevo.nc" for 3D data.
  • Fix sign in computing exchanges due to adsorption/ice table and in balancing H2O flux from/into atmosphere.
  • Few cleanings.

JBC

File:
1 edited

Legend:

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

    r4147 r4152  
    378378end if
    379379
    380 h2o_ice = h2o_ice + d_h2oice_new*dt
    381 zshift_surf = d_h2oice_new*dt/rho_h2oice
     380h2o_ice(:,:) = h2o_ice(:,:) + d_h2oice_new(:,:)*dt
     381zshift_surf(:,:) = d_h2oice_new(:,:)*dt/rho_h2oice
    382382
    383383END SUBROUTINE evolve_h2oice
     
    385385
    386386!=======================================================================
    387 SUBROUTINE balance_h2oice_reservoirs(S_atm_2_h2o,S_h2o_2_atm,S_atm_2_h2oice,S_h2oice_2_atm,h2o_ice,d_h2oice,d_h2oice_new)
     387SUBROUTINE balance_h2oice_reservoirs(S_atm_2_h2o,S_h2o_2_atm,S_atm_2_h2oice,S_h2oice_2_atm,h2o_ice,d_h2oice,d_balanced)
    388388!-----------------------------------------------------------------------
    389389! NAME
     
    414414real(dp), dimension(:,:), intent(in)    :: h2o_ice
    415415real(dp), dimension(:,:), intent(inout) :: d_h2oice
    416 real(dp), dimension(:,:), intent(out)   :: d_h2oice_new
     416real(dp), dimension(:,:), intent(out)   :: d_balanced
    417417
    418418! LOCAL VARIABLES
    419419! ---------------
    420420integer(di) :: i, islope
    421 real(qp)    :: S_target, S_target_subl_h2oice, S_target_cond_h2oice, S_ghostice ! Balance variables
     421real(qp)    :: S_corr_subl, S_corr_cond, S_target_subl, S_target_cond, S_ghostice ! Balance variables
    422422real(dp)    :: d_target
    423423
    424424! CODE
    425425! ----
    426 S_target = (S_atm_2_h2o + S_h2o_2_atm)/2._dp
    427 S_target_cond_h2oice = S_atm_2_h2oice + S_target - S_atm_2_h2o
    428 S_target_subl_h2oice = S_h2oice_2_atm + S_target - S_h2o_2_atm
    429 
    430 d_h2oice_new = 0._dp
     426! Compute global targets
     427S_corr_cond = (S_h2o_2_atm - S_atm_2_h2o)/2._qp ! Correction = deviation to the mean
     428S_corr_subl = (S_atm_2_h2o - S_h2o_2_atm)/2._qp ! Correction = deviation to the mean
     429S_target_cond = abs(S_atm_2_h2oice + S_corr_cond)
     430S_target_subl = abs(S_h2oice_2_atm + S_corr_subl)
     431
     432! Compute balanced tendencies with positivity limiter
     433d_balanced(:,:) = 0._dp
    431434S_ghostice = 0._qp
    432435do i = 1,ngrid
    433436    do islope = 1,nslope
    434         if (d_h2oice(i,islope) > 0._dp) then ! Condensing
    435             d_h2oice_new(i,islope) = d_h2oice(i,islope)*real(S_target_cond_h2oice/S_atm_2_h2oice,dp)
    436         else if (d_h2oice(i,islope) < 0._dp) then ! Sublimating
    437             d_target = d_h2oice(i,islope)*real(S_target_subl_h2oice/S_h2oice_2_atm,dp)
    438             if (abs(d_target*dt) <= h2o_ice(i,islope)) then ! Enough ice to sublimate everything
    439                 d_h2oice_new(i,islope) = d_target
    440             else ! Not enough ice to sublimate everything
    441                 ! We sublimate what we can
    442                 d_h2oice_new(i,islope) = h2o_ice(i,islope)/dt
    443                 ! It means the tendency is zero next time
     437        if (d_h2oice(i,islope) > 0._dp) then ! Condensation
     438            d_balanced(i,islope) = d_h2oice(i,islope)*real(S_target_cond/S_atm_2_h2oice,dp)
     439        else if (d_h2oice(i,islope) < 0._dp) then ! Sublimation
     440            d_target = d_h2oice(i,islope)*real(S_target_subl/S_h2oice_2_atm,dp)
     441            if (abs(d_target*dt) <= h2o_ice(i,islope)) then ! Enough ice to sublimate
     442                d_balanced(i,islope) = d_target
     443            else ! Not enough ice to sublimate
     444                ! Sublimate all the available ice
     445                d_balanced(i,islope) = -h2o_ice(i,islope)/dt
     446                ! If fully depleted, zero tendency for next time
    444447                d_h2oice(i,islope) = 0._dp
    445                 ! We compute the amount of H2O ice that we could not make sublimate
    446                 S_ghostice = S_ghostice + abs(d_target*dt) - h2o_ice(i,islope)
     448                ! Compute the amount of H2O ice unable to sublimate
     449                S_ghostice = S_ghostice + real(abs(d_target*dt),qp) - real(h2o_ice(i,islope),qp)
    447450            end if
    448451        end if
     
    450453end do
    451454
    452 ! We need to remove this ice unable to sublimate from places where ice condensed in order to keep balance
    453 where (d_h2oice_new > 0._dp) d_h2oice_new = d_h2oice_new*real((S_target_cond_h2oice - S_ghostice)/S_target_cond_h2oice,dp)
     455! Enforce conservation removing the ghost ice from places where ice condensed
     456where (d_balanced(:,:) > 0._dp) d_balanced(:,:) = d_balanced(:,:)*real((S_target_cond - S_ghostice)/S_target_cond,dp)
    454457
    455458END SUBROUTINE balance_h2oice_reservoirs
Note: See TracChangeset for help on using the changeset viewer.