Skip to content

Commit c119c81

Browse files
committed
Snow-DA: Introduce CLM:update_snow.eq.4
1 parent 84273e1 commit c119c81

4 files changed

Lines changed: 129 additions & 9 deletions

File tree

bldsva/intf_DA/pdaf/model/clm3_5/enkf_clm_mod.F90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,16 @@ subroutine define_clm_statevec(mype)
157157
error stop "Not implemented: clmupdate_snow.eq.1 or clmupdate_snow.eq.1"
158158
endif
159159
! Case 3: Assimilation of snow depth: Snow depth and snow water
160-
! equivalent in the state vector
160+
! equivalent in the state vector. Update of h2osoi_ice
161161
if(clmupdate_snow.eq.3) then
162162
error stop "Not implemented: clmupdate_snow.eq.3"
163163
endif
164+
! Case 4: Assimilation of snow depth: Snow depth and snow water
165+
! equivalent in the state vector. Update of h2osoi_ice, h2osoi_liq
166+
! and dz
167+
if(clmupdate_snow.eq.4) then
168+
error stop "Not implemented: clmupdate_snow.eq.4"
169+
endif
164170

165171
!hcp LST DA
166172
if(clmupdate_T.eq.1) then

bldsva/intf_DA/pdaf/model/clm5_0/enkf_clm_mod_5.F90

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ subroutine define_clm_statevec(mype)
287287
clm_varsize = (clm_endg-clm_begg+1)
288288
clm_statevecsize = 2*(clm_endg-clm_begg+1)
289289
endif
290+
! Case 4: Assimilation of snow depth: Snow depth and snow water
291+
! equivalent in the state vector. Update of h2osoi_ice, h2osoi_liq
292+
! and dz
293+
if(clmupdate_snow.eq.4) then
294+
clm_varsize = (clm_endg-clm_begg+1)
295+
clm_statevecsize = 2*(clm_endg-clm_begg+1)
296+
endif
290297

291298
!hcp LST DA
292299
if(clmupdate_T.eq.1) then
@@ -430,6 +437,9 @@ subroutine set_clm_statevec(tstartcycle, mype)
430437
else if(clmupdate_snow.eq.3) then
431438
clm_statevec(cc+offset) = snow_depth(jj)
432439
clm_statevec(cc+clm_varsize+offset) = h2osno(jj)
440+
else if(clmupdate_snow.eq.4) then
441+
clm_statevec(cc+offset) = snow_depth(jj)
442+
clm_statevec(cc+clm_varsize+offset) = h2osno(jj)
433443
else
434444
error stop "Wrong input for clmupdate_snow"
435445
end if
@@ -732,6 +742,9 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
732742
h2osno_in(j) = h2osno(j)
733743
else if (clmupdate_snow.eq.3) then
734744
h2osno_in(j) = h2osno(j)
745+
else if (clmupdate_snow.eq.4) then
746+
snow_depth_in(j) = snow_depth(j)
747+
h2osno_in(j) = h2osno(j)
735748
end if
736749

737750
if (clmupdate_snow.eq.1) then
@@ -740,9 +753,12 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
740753
h2osno_out(j) = clm_statevec(cc+offset)
741754
else if (clmupdate_snow.eq.3) then
742755
h2osno_out(j) = clm_statevec(cc+clm_varsize+offset)
756+
else if (clmupdate_snow.eq.4) then
757+
snow_depth_out(j) = clm_statevec(cc+offset)
758+
h2osno_out(j) = clm_statevec(cc+clm_varsize+offset)
743759
end if
744760

745-
if(clmupdate_snow.eq.1) then
761+
if(clmupdate_snow.eq.1 .or. clmupdate_snow.eq.4) then
746762
! Update state variable to CLM
747763
! Not needed for repartioning-case 3?
748764
if (snow_depth_out(j).gt.0.0) then
@@ -751,7 +767,7 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
751767
! Catch negative or 0 values from DA
752768
print *, "WARNING: Snow-depth is negative/zero at cc. cc, j, offset, snow_depth_out(j): ", cc, j, offset, snow_depth_out(j)
753769
end if
754-
else if(clmupdate_snow.eq.2 .or. clmupdate_snow.eq.3) then
770+
else if(clmupdate_snow.eq.2 .or. clmupdate_snow.eq.3 .or. clmupdate_snow.eq.4) then
755771
if (h2osno_out(j).gt.0.0) then
756772
h2osno(j) = h2osno_out(j)
757773
else
@@ -817,6 +833,43 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
817833
end do
818834
end if
819835

836+
if (clmupdate_snow.eq.4) then
837+
do j=clm_begc,clm_endc
838+
if (h2osno_out(j).gt.0.0) then
839+
if ( ABS(h2osno_in(j) - h2osno_out(j)).gt.0.000001) then
840+
if (h2osno_in(j).gt.0.0) then
841+
! Update h2osoi_ice/h2osoi_liq with increment
842+
incr_swe = h2osno_out(j) / h2osno_in(j)
843+
do i=snlsno(j)+1,0
844+
h2osoi_ice(j,i) = h2osoi_ice(j,i) * incr_swe
845+
h2osoi_liq(j,i) = h2osoi_liq(j,i) * incr_swe
846+
if (isnan(h2osoi_ice(j,i))) then
847+
print *, "WARNING: h2osoi_ice at j,i is nan: ", j, i
848+
endif
849+
if (isnan(h2osoi_liq(j,i))) then
850+
print *, "WARNING: h2osoi_ice at j,i is nan: ", j, i
851+
endif
852+
end do
853+
end if
854+
end if
855+
end if
856+
if (snow_depth_out(j).gt.0.0) then
857+
if ( ABS(snow_depth_in(j) - snow_depth_out(j)).gt.0.000001) then
858+
if (snow_depth_in(j).gt.0.0) then
859+
! Update snow_depth with increment
860+
incr_sd = snow_depth_out(j) / snow_depth_in(j)
861+
do i=snlsno(j)+1,0
862+
dz(j,i) = dz(j,i) * incr_sd
863+
if (isnan(dz(j,i))) then
864+
print *, "WARNING: dz at j,i is nan: ", j, i
865+
endif
866+
end do
867+
end if
868+
end if
869+
end if
870+
end do
871+
end if
872+
820873
end if
821874

822875
#ifdef PDAF_DEBUG

bldsva/intf_DA/pdaf/model/eclm/enkf_clm_mod_5.F90

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ subroutine define_clm_statevec(mype)
287287
clm_varsize = (clm_endg-clm_begg+1)
288288
clm_statevecsize = 2*(clm_endg-clm_begg+1)
289289
endif
290+
! Case 4: Assimilation of snow depth: Snow depth and snow water
291+
! equivalent in the state vector. Update of h2osoi_ice, h2osoi_liq
292+
! and dz
293+
if(clmupdate_snow.eq.4) then
294+
clm_varsize = (clm_endg-clm_begg+1)
295+
clm_statevecsize = 2*(clm_endg-clm_begg+1)
296+
endif
290297

291298
!hcp LST DA
292299
if(clmupdate_T.eq.1) then
@@ -430,6 +437,9 @@ subroutine set_clm_statevec(tstartcycle, mype)
430437
else if(clmupdate_snow.eq.3) then
431438
clm_statevec(cc+offset) = snow_depth(jj)
432439
clm_statevec(cc+clm_varsize+offset) = h2osno(jj)
440+
else if(clmupdate_snow.eq.4) then
441+
clm_statevec(cc+offset) = snow_depth(jj)
442+
clm_statevec(cc+clm_varsize+offset) = h2osno(jj)
433443
else
434444
error stop "Wrong input for clmupdate_snow"
435445
end if
@@ -732,6 +742,9 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
732742
h2osno_in(j) = h2osno(j)
733743
else if (clmupdate_snow.eq.3) then
734744
h2osno_in(j) = h2osno(j)
745+
else if (clmupdate_snow.eq.4) then
746+
snow_depth_in(j) = snow_depth(j)
747+
h2osno_in(j) = h2osno(j)
735748
end if
736749

737750
if (clmupdate_snow.eq.1) then
@@ -740,9 +753,12 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
740753
h2osno_out(j) = clm_statevec(cc+offset)
741754
else if (clmupdate_snow.eq.3) then
742755
h2osno_out(j) = clm_statevec(cc+clm_varsize+offset)
756+
else if (clmupdate_snow.eq.4) then
757+
snow_depth_out(j) = clm_statevec(cc+offset)
758+
h2osno_out(j) = clm_statevec(cc+clm_varsize+offset)
743759
end if
744760

745-
if(clmupdate_snow.eq.1) then
761+
if(clmupdate_snow.eq.1 .or. clmupdate_snow.eq.4) then
746762
! Update state variable to CLM
747763
! Not needed for repartioning-case 3?
748764
if (snow_depth_out(j).gt.0.0) then
@@ -751,7 +767,7 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
751767
! Catch negative or 0 values from DA
752768
print *, "WARNING: Snow-depth is negative/zero at cc. cc, j, offset, snow_depth_out(j): ", cc, j, offset, snow_depth_out(j)
753769
end if
754-
else if(clmupdate_snow.eq.2 .or. clmupdate_snow.eq.3) then
770+
else if(clmupdate_snow.eq.2 .or. clmupdate_snow.eq.3 .or. clmupdate_snow.eq.4) then
755771
if (h2osno_out(j).gt.0.0) then
756772
h2osno(j) = h2osno_out(j)
757773
else
@@ -817,6 +833,43 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
817833
end do
818834
end if
819835

836+
if (clmupdate_snow.eq.4) then
837+
do j=clm_begc,clm_endc
838+
if (h2osno_out(j).gt.0.0) then
839+
if ( ABS(h2osno_in(j) - h2osno_out(j)).gt.0.000001) then
840+
if (h2osno_in(j).gt.0.0) then
841+
! Update h2osoi_ice/h2osoi_liq with increment
842+
incr_swe = h2osno_out(j) / h2osno_in(j)
843+
do i=snlsno(j)+1,0
844+
h2osoi_ice(j,i) = h2osoi_ice(j,i) * incr_swe
845+
h2osoi_liq(j,i) = h2osoi_liq(j,i) * incr_swe
846+
if (isnan(h2osoi_ice(j,i))) then
847+
print *, "WARNING: h2osoi_ice at j,i is nan: ", j, i
848+
endif
849+
if (isnan(h2osoi_liq(j,i))) then
850+
print *, "WARNING: h2osoi_ice at j,i is nan: ", j, i
851+
endif
852+
end do
853+
end if
854+
end if
855+
end if
856+
if (snow_depth_out(j).gt.0.0) then
857+
if ( ABS(snow_depth_in(j) - snow_depth_out(j)).gt.0.000001) then
858+
if (snow_depth_in(j).gt.0.0) then
859+
! Update snow_depth with increment
860+
incr_sd = snow_depth_out(j) / snow_depth_in(j)
861+
do i=snlsno(j)+1,0
862+
dz(j,i) = dz(j,i) * incr_sd
863+
if (isnan(dz(j,i))) then
864+
print *, "WARNING: dz at j,i is nan: ", j, i
865+
endif
866+
end do
867+
end if
868+
end if
869+
end if
870+
end do
871+
end if
872+
820873
end if
821874

822875
#ifdef PDAF_DEBUG

doc/content/setup_tsmp/input_enkfpf.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,15 @@ Only CLM5.0/eCLM.
494494
equivalent.
495495

496496
- 3: Assimilation of snow depth. State vector: Snow depth and snow
497-
water equivalent. Snow water equivalent from state vector is used
498-
in the update as in Case 2.
497+
water equivalent. Requires
498+
`CLM:update_snow_repartitioning=3`. `h2osoi_ice` updated based on
499+
`h2osno`-increment.
500+
501+
- 4: Assimilation of snow depth. State vector: Snow depth and snow
502+
water equivalent. Requires
503+
`CLM:update_snow_repartitioning=3`. `h2osoi_ice` and `h2osoi_liq`
504+
updated based on `h2osno`-increment. `dz` updated based on
505+
`snow_depth`-increment.
499506

500507
See CLM Technical Note for more information on snow variable:
501508
<https://escomp.github.io/ctsm-docs/versions/release-clm5.0/html/tech_note/Snow_Hydrology/CLM50_Tech_Note_Snow_Hydrology.html>
@@ -521,8 +528,9 @@ CLM5.0/eCLM.
521528
routine in DA-interface: `clm_repartition_snow`. Option 2:
522529
Adjusting all active layers.
523530

524-
- 3 (Default, Currently recommended): `h2osoi_ice` updated by increment based
525-
on updated state vector variable. Further repartitioning left to
531+
- 3 (Default, Currently recommended): `h2osoi_ice` (and possibly
532+
`h2osoi_liq` and `dz`) updated by increment based on updated
533+
`h2osno` or `snow_depth`. Further repartitioning left to
526534
CLM-code. Based on
527535
<https://github.com/NASA-LIS/LISF/blob/master/lis/surfacemodels/land/clm2/da_snow/clm2_setsnowvars.F90>
528536

0 commit comments

Comments
 (0)