Skip to content

Commit c199995

Browse files
committed
Merge branch 'cwhicker/elm/use_extrasnowlayers_bugfix_snowdiags' (PR #6859)
Minor mods to fix segmentation fault errors in use_extrasnowlayers errors that occur when the snow depth is very shallow. [B4B] Conflicts: components/elm/src/biogeophys/BalanceCheckMod.F90 components/elm/src/biogeophys/HydrologyDrainageMod.F90 components/elm/src/biogeophys/SoilTemperatureMod.F90 components/elm/src/data_types/ColumnDataType.F90
2 parents caf0f37 + 16383cb commit c199995

File tree

8 files changed

+72
-25
lines changed

8 files changed

+72
-25
lines changed

components/elm/src/biogeophys/BalanceCheckMod.F90

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ subroutine ColWaterBalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
164164
! error = abs(precipitation - change of water storage - evaporation - runoff)
165165
!
166166
! !USES:
167-
use elm_varcon , only : spval
167+
use elm_varcon , only : spval, h2osno_max
168168
use column_varcon , only : icol_roof, icol_sunwall, icol_shadewall
169169
use column_varcon , only : icol_road_perv, icol_road_imperv
170-
use landunit_varcon , only : istice_mec, istdlak, istsoil,istcrop,istwet
170+
use landunit_varcon , only : istice_mec, istice, istdlak, istsoil,istcrop,istwet
171171
use elm_varctl , only : create_glacier_mec_landunit, use_IM2_hillslope_hydrology
172172
use elm_initializeMod , only : surfalb_vars
173173
use CanopyStateType , only : canopystate_type
@@ -221,6 +221,7 @@ subroutine ColWaterBalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
221221
qflx_surf_irrig_col => col_wf%qflx_surf_irrig , & ! Input: [real(r8) (:) ] real surface irrigation flux (mm H2O /s)
222222
qflx_over_supply_col => col_wf%qflx_over_supply , & ! Input: [real(r8) (:) ] over supply irrigation flux (mm H2O /s)
223223
qflx_snwcp_ice => col_wf%qflx_snwcp_ice , & ! Input: [real(r8) (:) ] excess snowfall due to snow capping (mm H2O /s) [+]`
224+
qflx_ice_runoff_xs => col_wf%qflx_ice_runoff_xs , & ! Input: [real(r8) (:) ]
224225
qflx_evap_tot => col_wf%qflx_evap_tot , & ! Input: [real(r8) (:) ] qflx_evap_soi + qflx_evap_can + qflx_tran_veg
225226
qflx_dew_snow => col_wf%qflx_dew_snow , & ! Input: [real(r8) (:) ] surface dew added to snow pack (mm H2O /s) [+]
226227
qflx_sub_snow => col_wf%qflx_sub_snow , & ! Input: [real(r8) (:) ] sublimation rate from snow pack (mm H2O /s) [+]
@@ -334,7 +335,7 @@ subroutine ColWaterBalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
334335
- (forc_rain_col(c) + forc_snow_col(c) + qflx_floodc(c) + qflx_from_uphill(c) &
335336
+ qflx_surf_irrig_col(c) + qflx_over_supply_col(c) &
336337
- qflx_evap_tot(c) - qflx_surf(c) - qflx_h2osfc_surf(c) - qflx_to_downhill(c) &
337-
- qflx_qrgwl(c) - qflx_drain(c) - qflx_drain_perched(c) - qflx_snwcp_ice(c) &
338+
- qflx_qrgwl(c) - qflx_drain(c) - qflx_drain_perched(c) - qflx_snwcp_ice(c) - qflx_ice_runoff_xs(c) &
338339
- qflx_lateral(c) + qflx_h2orof_drain(c)) * dtime
339340
dwb(c) = (endwb(c)-begwb(c))/dtime
340341

@@ -406,6 +407,7 @@ subroutine ColWaterBalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
406407
write(iulog,*)'qflx_lateral = ',qflx_lateral(indexc)
407408
write(iulog,*)'total_plant_stored_h2o_col = ',total_plant_stored_h2o_col(indexc)
408409
write(iulog,*)'qflx_h2orof_drain = ',qflx_h2orof_drain(indexc)
410+
write(iulog,*)'qflx_ice_runoff_xs = ',qflx_ice_runoff_xs(indexc)
409411
write(iulog,*)'elm model is stopping'
410412
call endrun(decomp_index=indexc, elmlevel=namec, msg=errmsg(__FILE__, __LINE__))
411413

@@ -436,6 +438,7 @@ subroutine ColWaterBalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
436438
write(iulog,*)'qflx_lateral = ',qflx_lateral(indexc)
437439
write(iulog,*)'total_plant_stored_h2o_col = ',total_plant_stored_h2o_col(indexc)
438440
write(iulog,*)'qflx_h2orof_drain = ',qflx_h2orof_drain(indexc)
441+
write(iulog,*)'qflx_ice_runoff_xs = ',qflx_ice_runoff_xs(indexc)
439442
write(iulog,*)'elm model is stopping'
440443
call endrun(decomp_index=indexc, elmlevel=namec, msg=errmsg(__FILE__, __LINE__))
441444
end if
@@ -559,15 +562,23 @@ subroutine ColWaterBalanceCheck( bounds, num_do_smb_c, filter_do_smb_c, &
559562
write(iulog,*)'h2osno_old = ',h2osno_old(indexc)
560563
write(iulog,*)'snow_sources = ',snow_sources(indexc)
561564
write(iulog,*)'snow_sinks = ',snow_sinks(indexc)
562-
write(iulog,*)'qflx_prec_grnd = ',qflx_prec_grnd(indexc)*dtime
563-
write(iulog,*)'qflx_sub_snow = ',qflx_sub_snow(indexc)*dtime
564-
write(iulog,*)'qflx_evap_grnd = ',qflx_evap_grnd(indexc)*dtime
565-
write(iulog,*)'qflx_top_soil = ',qflx_top_soil(indexc)*dtime
566-
write(iulog,*)'qflx_dew_snow = ',qflx_dew_snow(indexc)*dtime
567-
write(iulog,*)'qflx_dew_grnd = ',qflx_dew_grnd(indexc)*dtime
568-
write(iulog,*)'qflx_snwcp_ice = ',qflx_snwcp_ice(indexc)*dtime
569-
write(iulog,*)'qflx_snwcp_liq = ',qflx_snwcp_liq(indexc)*dtime
570-
write(iulog,*)'qflx_sl_top_soil = ',qflx_sl_top_soil(indexc)*dtime
565+
write(iulog,*)'qflx_prec_grnd = ',qflx_prec_grnd(indexc)
566+
write(iulog,*)'qflx_sub_snow = ',qflx_sub_snow(indexc)
567+
write(iulog,*)'qflx_evap_grnd = ',qflx_evap_grnd(indexc)
568+
write(iulog,*)'qflx_top_soil = ',qflx_top_soil(indexc)
569+
write(iulog,*)'qflx_dew_snow = ',qflx_dew_snow(indexc)
570+
write(iulog,*)'qflx_dew_grnd = ',qflx_dew_grnd(indexc)
571+
write(iulog,*)'qflx_snwcp_ice = ',qflx_snwcp_ice(indexc)
572+
write(iulog,*)'qflx_snwcp_liq = ',qflx_snwcp_liq(indexc)
573+
write(iulog,*)'qflx_sl_top_soil = ',qflx_sl_top_soil(indexc)
574+
write(iulog,*)'qflx_snow_melt = ',qflx_snow_melt(indexc)
575+
write(iulog,*)'frac_sno_eff = ',frac_sno_eff(indexc)
576+
write(iulog,*)'qflx_rain_grnd_col= ',qflx_rain_grnd_col(indexc)
577+
write(iulog,*)'qflx_snow_grnd_col= ',qflx_snow_grnd_col(indexc)
578+
write(iulog,*)'qflx_h2osfc_to_ice= ',qflx_h2osfc_to_ice(indexc)
579+
write(iulog,*)'qflx_snow_h2osfc= ',qflx_snow_h2osfc(indexc)*dtime
580+
write(iulog,*)'(glc_dyn_runoff_routing(g))',(glc_dyn_runoff_routing(g))
581+
571582
if (create_glacier_mec_landunit) then
572583
write(iulog,*)'qflx_glcice_frz = ',qflx_glcice_frz(indexc)*dtime
573584
end if

components/elm/src/biogeophys/HydrologyDrainageMod.F90

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module HydrologyDrainageMod
77
use shr_kind_mod , only : r8 => shr_kind_r8
88
use shr_log_mod , only : errMsg => shr_log_errMsg
99
use decompMod , only : bounds_type
10-
use elm_varctl , only : iulog, use_vichydro
10+
use elm_varctl , only : iulog, use_vichydro, use_firn_percolation_and_compaction
1111
use elm_varcon , only : e_ice, denh2o, denice, rpi, spval
1212
use atm2lndType , only : atm2lnd_type
1313
use glc2lndMod , only : glc2lnd_type
@@ -238,6 +238,12 @@ subroutine HydrologyDrainage(bounds, &
238238
qflx_glcice(c) = qflx_glcice(c) + qflx_glcice_frz(c)
239239
if (glc_dyn_runoff_routing(g)) qflx_snwcp_ice(c) = 0._r8
240240
end if
241+
242+
!if (lun_pp%itype(l)==istice) then
243+
! qflx_glcice_frz_diag(c) = qflx_snwcp_ice(c)
244+
! qflx_glcice_diag(c) = qflx_glcice_diag(c) + qflx_glcice_frz_diag(c)
245+
!endif
246+
241247
end do
242248

243249
! Determine wetland and land ice hydrology (must be placed here
@@ -270,8 +276,9 @@ subroutine HydrologyDrainage(bounds, &
270276
! glc_dyn_runoff_routing = true: in this case, melting ice runs off, and excess
271277
! snow is sent to CISM, where it is converted to ice. These corrections are
272278
! done here:
273-
274279
if (glc_dyn_runoff_routing(g) .and. lun_pp%itype(l)==istice_mec) then
280+
! this allows GLC melt to runoff to qflx_qrgwl!
281+
275282
! If glc_dyn_runoff_routing=T, add meltwater from istice_mec ice columns to the runoff.
276283
! Note: The meltwater contribution is computed in PhaseChanges (part of Biogeophysics2)
277284
qflx_qrgwl(c) = qflx_qrgwl(c) + qflx_glcice_melt(c)

components/elm/src/biogeophys/LakeTemperatureMod.F90

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ subroutine PhaseChange_Lake (bounds, num_lakec, filter_lakec, cv, cv_lake, lhabs
12911291
qflx_snofrz_lyr => col_wf%qflx_snofrz_lyr , & ! Input: [real(r8) (:,:) ] snow freezing rate (positive definite) (col,lyr) [kg m-2 s-1]
12921292
qflx_snow_melt => col_wf%qflx_snow_melt , & ! Output: [real(r8) (:) ] net snow melt
12931293
qflx_snomelt => col_wf%qflx_snomelt , & ! Output: [real(r8) (:) ] snow melt (mm H2O /s)
1294+
qflx_snomelt_lyr=> col_wf%qflx_snomelt_lyr, & ! Output: [real(r8) (:) ] snow melt per layer (mm H2O /s)
12941295
qflx_snofrz_col => col_wf%qflx_snofrz , & ! Output: [real(r8) (:) ] column-integrated snow freezing rate (kg m-2 s-1) [+]
12951296

12961297
t_soisno => col_es%t_soisno , & ! Input: [real(r8) (:,:) ] soil temperature (Kelvin)
@@ -1306,10 +1307,11 @@ subroutine PhaseChange_Lake (bounds, num_lakec, filter_lakec, cv, cv_lake, lhabs
13061307
do fc = 1,num_lakec
13071308
c = filter_lakec(fc)
13081309

1309-
qflx_snomelt(c) = 0._r8
1310-
eflx_snomelt(c) = 0._r8
1311-
lhabs(c) = 0._r8
1312-
qflx_snow_melt(c) = 0._r8
1310+
qflx_snomelt(c) = 0._r8
1311+
qflx_snomelt_lyr(c,:)= 0._r8
1312+
eflx_snomelt(c) = 0._r8
1313+
lhabs(c) = 0._r8
1314+
qflx_snow_melt(c) = 0._r8
13131315
end do
13141316

13151317
do j = -nlevsno+1,0
@@ -1399,6 +1401,7 @@ subroutine PhaseChange_Lake (bounds, num_lakec, filter_lakec, cv, cv_lake, lhabs
13991401
if (j <= 0) then !snow
14001402
imelt(c,j) = 1
14011403
qflx_snomelt(c) = qflx_snomelt(c) + melt/dtime
1404+
qflx_snomelt_lyr(c,j) = melt/dtime
14021405
end if
14031406
else if (t_soisno(c,j) < tfrz .and. h2osoi_liq(c,j) > 0._r8) then !freezing
14041407
dophasechangeflag = .true.

components/elm/src/biogeophys/SnowHydrologyMod.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,7 @@ subroutine SnowCapping(bounds, num_nolakec, filter_initc, num_snowc, filter_snow
22732273
associate( &
22742274
qflx_snwcp_ice => col_wf%qflx_snwcp_ice , & ! Output: [real(r8) (:) ] excess solid h2o due to snow capping (outgoing) (mm H2O /s) [+]
22752275
qflx_snwcp_liq => col_wf%qflx_snwcp_liq , & ! Output: [real(r8) (:) ] excess liquid h2o due to snow capping (outgoing) (mm H2O /s) [+]
2276+
qflx_ice_runoff_xs => col_wf%qflx_ice_runoff_xs , & ! Input: [real(r8) (:) ]
22762277
h2osoi_ice => col_ws%h2osoi_ice , & ! In/Out: [real(r8) (:,:) ] ice lens (kg/m2)
22772278
h2osoi_liq => col_ws%h2osoi_liq , & ! In/Out: [real(r8) (:,:) ] liquid water (kg/m2)
22782279
h2osno => col_ws%h2osno , & ! Input: [real(r8) (:) ] snow water (mm H2O)
@@ -2294,6 +2295,7 @@ subroutine SnowCapping(bounds, num_nolakec, filter_initc, num_snowc, filter_snow
22942295
c = filter_initc(fc)
22952296
qflx_snwcp_ice(c) = 0.0_r8
22962297
qflx_snwcp_liq(c) = 0.0_r8
2298+
qflx_ice_runoff_xs(c) = 0.0_r8
22972299
end do
22982300

22992301
loop_columns: do fc = 1, num_snowc

components/elm/src/biogeophys/SoilHydrologyMod.F90

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,9 +1016,11 @@ subroutine Drainage(bounds, num_hydrologyc, filter_hydrologyc, num_urbanc, filte
10161016
use elm_varpar , only : nlevsoi, nlevgrnd, nlayer, nlayert
10171017
use elm_varcon , only : pondmx, tfrz, watmin,rpi, secspday, nlvic
10181018
use column_varcon , only : icol_roof, icol_road_imperv, icol_road_perv
1019-
use elm_varctl , only : use_vsfm, use_var_soil_thick
1019+
use elm_varctl , only : use_vsfm, use_var_soil_thick, use_firn_percolation_and_compaction
10201020
use SoilWaterMovementMod, only : zengdecker_2009_with_var_soil_thick
10211021
use pftvarcon , only : rsub_top_globalmax
1022+
use LandunitType , only : lun_pp
1023+
use landunit_varcon , only : istice_mec, istice
10221024
!
10231025
! !ARGUMENTS:
10241026
type(bounds_type) , intent(in) :: bounds
@@ -1121,6 +1123,7 @@ subroutine Drainage(bounds, num_hydrologyc, filter_hydrologyc, num_urbanc, filte
11211123

11221124
qflx_snwcp_liq => col_wf%qflx_snwcp_liq , & ! Output: [real(r8) (:) ] excess rainfall due to snow capping (mm H2O /s) [+]
11231125
qflx_snwcp_ice => col_wf%qflx_snwcp_ice , & ! Output: [real(r8) (:) ] excess snowfall due to snow capping (mm H2O /s) [+]
1126+
qflx_ice_runoff_xs => col_wf%qflx_ice_runoff_xs , & ! Output: solid runoff from excess ice in soil (mm H2O /s) [+]
11241127
!qflx_dew_grnd => col_wf%qflx_dew_grnd , & ! Output: [real(r8) (:) ] ground surface dew formation (mm H2O /s) [+]
11251128
!qflx_dew_snow => col_wf%qflx_dew_snow , & ! Output: [real(r8) (:) ] surface dew added to snow pack (mm H2O /s) [+]
11261129
!qflx_sub_snow => col_wf%qflx_sub_snow , & ! Output: [real(r8) (:) ] sublimation rate from snow pack (mm H2O /s) [+]
@@ -1559,7 +1562,11 @@ subroutine Drainage(bounds, num_hydrologyc, filter_hydrologyc, num_urbanc, filte
15591562
! add in ice check
15601563
xs1(c) = max(max(h2osoi_ice(c,1),0._r8)-max(0._r8,(pondmx+watsat(c,1)*dzmm(c,1)-h2osoi_liq(c,1))),0._r8)
15611564
h2osoi_ice(c,1) = min(max(0._r8,pondmx+watsat(c,1)*dzmm(c,1)-h2osoi_liq(c,1)), h2osoi_ice(c,1))
1562-
qflx_snwcp_ice(c) = qflx_snwcp_ice(c) + xs1(c) / dtime
1565+
if ( (lun_pp%itype(col_pp%landunit(c)) == istice .or. lun_pp%itype(col_pp%landunit(c)) == istice_mec) .or. (.not. use_firn_percolation_and_compaction)) then
1566+
qflx_snwcp_ice(c) = qflx_snwcp_ice(c) + xs1(c) / dtime
1567+
else
1568+
qflx_ice_runoff_xs(c) = qflx_ice_runoff_xs(c) + xs1(c) / dtime
1569+
endif
15631570
end do
15641571

15651572
! Limit h2osoi_liq to be greater than or equal to watmin.

components/elm/src/biogeophys/SoilTemperatureMod.F90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ subroutine Phasechange_beta (bounds, num_nolakec, filter_nolakec, dhsdT, &
13721372
qflx_glcice_diag => col_wf%qflx_glcice_diag , & ! Output: [real(r8) (:) ] flux of new glacier ice (mm H2O/s) [+ = ice grows]
13731373
qflx_glcice_melt_diag => col_wf%qflx_glcice_melt_diag , & ! Output: [real(r8) (:) ] ice melt (positive definite) (mm H2O/s)
13741374
qflx_snomelt => col_wf%qflx_snomelt , & ! Output: [real(r8) (:) ] snow melt (mm H2O /s)
1375+
qflx_snomelt_lyr => col_wf%qflx_snomelt_lyr , & ! Output: [real(r8) (:) ] snow melt (mm H2O /s)
13751376

13761377
eflx_snomelt => col_ef%eflx_snomelt , & ! Output: [real(r8) (:) ] snow melt heat flux (W/m**2)
13771378
eflx_snomelt_r => col_ef%eflx_snomelt_r , & ! Output: [real(r8) (:) ] rural snow melt heat flux (W/m**2)
@@ -1391,6 +1392,7 @@ subroutine Phasechange_beta (bounds, num_nolakec, filter_nolakec, dhsdT, &
13911392
l = col_pp%landunit(c)
13921393

13931394
qflx_snomelt(c) = 0._r8
1395+
qflx_snomelt_lyr(c,-nlevsno+1:0) = 0._r8
13941396
xmf(c) = 0._r8
13951397
qflx_snofrz_lyr(c,-nlevsno+1:0) = 0._r8
13961398
qflx_snofrz_col(c) = 0._r8
@@ -1626,7 +1628,7 @@ subroutine Phasechange_beta (bounds, num_nolakec, filter_nolakec, dhsdT, &
16261628

16271629
if (imelt(c,j) == 1 .AND. j < 1) then
16281630
qflx_snomelt(c) = qflx_snomelt(c) + max(0._r8,(wice0(c,j)-h2osoi_ice(c,j)))/dtime
1629-
1631+
qflx_snomelt_lyr(c,j) = max(0._r8,(wice0(c,j)-h2osoi_ice(c,j)))/dtime
16301632

16311633
endif
16321634

@@ -1646,7 +1648,6 @@ subroutine Phasechange_beta (bounds, num_nolakec, filter_nolakec, dhsdT, &
16461648
! as computed in HydrologyDrainageMod.F90.
16471649

16481650
l = col_pp%landunit(c)
1649-
16501651
if ( lun_pp%itype(l)==istice_mec) then
16511652
if (j>=1 .and. h2osoi_liq(c,j) > 0._r8) then ! ice layer with meltwater
16521653
! melting corresponds to a negative ice flux

0 commit comments

Comments
 (0)