@@ -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
0 commit comments