Skip to content

Commit

Permalink
revert to main: version
Browse files Browse the repository at this point in the history
  • Loading branch information
JhanSrbinovsky committed Oct 10, 2024
1 parent bc0ed32 commit 467902a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
50 changes: 23 additions & 27 deletions src/science/soilsnow/cbl_soilsnow_main.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ SUBROUTINE soil_snow(dels, soil, ssnow, canopy, met, bal, veg)
USE snow_accum_mod, ONLY: snow_accum
USE snowdensity_mod, ONLY: snowDensity

USE cable_phys_constants_mod, ONLY: density_liq, density_ice

REAL, INTENT(IN) :: dels ! integration time step (s)
TYPE(soil_parameter_type), INTENT(INOUT) :: soil
TYPE(soil_snow_type), INTENT(INOUT) :: ssnow
Expand All @@ -53,20 +51,21 @@ SUBROUTINE soil_snow(dels, soil, ssnow, canopy, met, bal, veg)
REAL, DIMENSION(mp) :: snowmlt
REAL, DIMENSION(mp) :: totwet
REAL, DIMENSION(mp) :: weting
REAL(r_2), DIMENSION(mp) :: xx
REAL, DIMENSION(mp) :: xx
REAL(r_2), DIMENSION(mp) :: xxx
REAL(r_2), DIMENSION(mp) :: deltat,sinfil1,sinfil2,sinfil3
REAL :: zsetot
INTEGER, SAVE :: ktau =0
REAL :: wbliq(mp,ms)

ktau = ktau +1
!this is the value it is initialized with in cable_common anyway
max_glacier_snowd = 1100.0 ! for ACCESS1.3 onwards. = 50000.0 for ACCESS1.0

zsetot = SUM(soil%zse)
ssnow%tggav(:) = 0.
ssnow%tggav = 0.
DO k = 1, ms
ssnow%tggav(:) = ssnow%tggav(:) + ( (soil%zse(k)/zsetot) * ssnow%tgg(:,k) )
ssnow%tggav = ssnow%tggav + soil%zse(k)*ssnow%tgg(:,k)/zsetot
soil%heat_cap_lower_limit(:,k) = MAX( 0.01, soil%css(:) * soil%rhosoil(:) )
END DO

Expand All @@ -84,7 +83,8 @@ SUBROUTINE soil_snow(dels, soil, ssnow, canopy, met, bal, veg)
ssnow%dtmlt = 0.0
ssnow%osnowd = ssnow%snowd

ssnow%wbliq = ssnow%wb - ssnow%wbice

wbliq = ssnow%wb - ssnow%wbice

!%cable_runtime_coupled special initalizations in um_init NA for ESM1.5

Expand Down Expand Up @@ -122,7 +122,7 @@ SUBROUTINE soil_snow(dels, soil, ssnow, canopy, met, bal, veg)
! snow aging etc...
CALL snowl_adjust(dels, ssnow, canopy )

CALL stempv(dels, canopy, ssnow, soil, REAL(soil%heat_cap_lower_limit) )
CALL stempv(dels, canopy, ssnow, soil, soil%heat_cap_lower_limit )

ssnow%tss = (1-ssnow%isflag)*ssnow%tgg(:,1) + ssnow%isflag*ssnow%tggsn(:,1)

Expand All @@ -133,7 +133,7 @@ SUBROUTINE soil_snow(dels, soil, ssnow, canopy, met, bal, veg)

CALL remove_trans(dels, soil, ssnow, canopy, veg)

CALL soilfreeze(dels, soil, ssnow, REAL(soil%heat_cap_lower_limit) )
CALL soilfreeze(dels, soil, ssnow, soil%heat_cap_lower_limit)


totwet = canopy%precis + ssnow%smelt
Expand Down Expand Up @@ -162,9 +162,8 @@ SUBROUTINE soil_snow(dels, soil, ssnow, canopy, met, bal, veg)

! correction required for energy balance in online simulations
IF( cable_runtime%um ) THEN
! These corrections cause energy imbalances so disable
canopy%fhs_cor = 0. ! ssnow%dtmlt(:,1)*ssnow%dfh_dtg
canopy%fes_cor = 0. ! ssnow%dtmlt(:,1)*ssnow%dfe_dtg
canopy%fhs_cor = ssnow%dtmlt(:,1)*ssnow%dfh_dtg
canopy%fes_cor = ssnow%dtmlt(:,1)*ssnow%dfe_dtg

canopy%fhs = canopy%fhs+canopy%fhs_cor
canopy%fes = canopy%fes+canopy%fes_cor
Expand All @@ -173,9 +172,8 @@ SUBROUTINE soil_snow(dels, soil, ssnow, canopy, met, bal, veg)
!NB canopy%fns changed not rad%flws as the correction term needs to
!pass through the canopy in entirety, not be partially absorbed
IF (cable_user%L_REV_CORR) THEN
! These corrections cause energy imbalances so disable
canopy%fns_cor = 0. ! ssnow%dtmlt(:,1)*ssnow%dfn_dtg
canopy%ga_cor = 0. ! ssnow%dtmlt(:,1)*canopy%dgdtg
canopy%fns_cor = ssnow%dtmlt(:,1)*ssnow%dfn_dtg
canopy%ga_cor = ssnow%dtmlt(:,1)*canopy%dgdtg

canopy%fns = canopy%fns + canopy%fns_cor
canopy%ga = canopy%ga + canopy%ga_cor
Expand All @@ -184,23 +182,21 @@ SUBROUTINE soil_snow(dels, soil, ssnow, canopy, met, bal, veg)
ENDIF
ENDIF

! redistrb (set in cable.nml) by default==.FALSE.
IF( redistrb ) &
CALL hydraulic_redistribution( dels, soil, ssnow, canopy, veg, met )

ssnow%smelt = ssnow%smelt/dels
! redistrb (set in cable.nml) by default==.FALSE.
IF( redistrb ) &
CALL hydraulic_redistribution( dels, soil, ssnow, canopy, veg, met )

! Set weighted soil/snow surface temperature
ssnow%tss=(1-ssnow%isflag)*ssnow%tgg(:,1) + ssnow%isflag*ssnow%tggsn(:,1)
ssnow%smelt = ssnow%smelt/dels

ssnow%wbliq = ssnow%wb - ssnow%wbice
! Set weighted soil/snow surface temperature
ssnow%tss=(1-ssnow%isflag)*ssnow%tgg(:,1) + ssnow%isflag*ssnow%tggsn(:,1)

ssnow%wbtot = 0.0
DO k = 1, ms
ssnow%wbtot(:) = ssnow%wbtot(:) + &
(ssnow%wbliq(:,k)*density_liq + ssnow%wbice(:,k)*density_ice) * soil%zse(k)
wbliq = ssnow%wb - ssnow%wbice

END DO
ssnow%wbtot = 0.0
DO k = 1, ms
ssnow%wbtot = ssnow%wbtot + REAL(ssnow%wb(:,k)*1000.0*soil%zse(k),r_2)
END DO


RETURN
Expand Down
4 changes: 4 additions & 0 deletions src/science/soilsnow/cbl_thermal.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ MODULE snow_processes_soil_thermal_mod

CONTAINS

!SUBROUTINE snow_processes_soil_thermal(dels,ssnow,soil,veg,canopy,met,bal,snowmlt) ! replaced by rk4417 - phase2
! snowmlt is not used in cable_gw_hydro_module and as far as I can tell serves no purpose in the code - rk4417

SUBROUTINE snow_processes_soil_thermal(dels,ssnow,soil,veg,canopy,met,bal)
!* calculate snow processes and thermal soil

Expand All @@ -26,6 +29,7 @@ SUBROUTINE snow_processes_soil_thermal(dels,ssnow,soil,veg,canopy,met,bal)
TYPE(met_type), INTENT(INOUT) :: met ! all met forcing
TYPE (balances_type), INTENT(INOUT) :: bal
REAL, DIMENSION(mp) :: snowmlt !track snow melt
! REAL, DIMENSION(:), INTENT(INOUT) :: snowmlt ! replaced by rk4417 - phase2
INTEGER :: k,i

snowmlt = 0.0 ! inserted by rk4417 - phase2
Expand Down

0 comments on commit 467902a

Please sign in to comment.