With reset_state, the wave train is saved on entry and restored on exit, so a trial solution leaves no trace; only the final call of the time step, with reset_state false, commits the new waves through update_wav.
783
785
786 class(UzfCellGroupType) :: this
787 integer(I4B), intent(in) :: jbelow
788 integer(I4B), intent(in) :: icell
789 real(DP), intent(inout) :: totfluxtot
790 integer(I4B), intent(in) :: ietflag
791 integer(I4B), intent(in) :: issflag
792 integer(I4B), intent(in) :: iseepflag
793 real(DP), intent(in) :: hgwf
794 real(DP), intent(in) :: qfrommvr
795 integer(I4B), intent(inout) :: ierr
796 logical, intent(in) :: reset_state
797 real(DP), intent(inout), optional :: trhs
798 real(DP), intent(inout), optional :: thcof
799 real(DP), intent(inout), optional :: deriv
800 real(DP), intent(inout), optional :: watercontent
801
802 real(DP) :: test
803 real(DP) :: scale
804 real(DP) :: seep
805 real(DP) :: finfact
806 real(DP) :: derivfinf
807 real(DP) :: trhsfinf
808 real(DP) :: thcoffinf
809 real(DP) :: trhsseep
810 real(DP) :: thcofseep
811 real(DP) :: deriv1
812 real(DP) :: deriv2
813
814
815 totfluxtot = dzero
816 trhsfinf = dzero
817 thcoffinf = dzero
818 trhsseep = dzero
819 thcofseep = dzero
820 this%finf_rej(icell) = dzero
821 this%surf_infil(icell) = this%finf(icell) + qfrommvr / this%uzfarea(icell)
822 this%water_table(icell) = hgwf
823 this%surf_seep(icell) = dzero
824 seep = dzero
825 finfact = dzero
826 this%et_uz(icell) = dzero
827 this%surf_infil_below(icell) = dzero
828 if (this%cell_below(icell) > 0) then
829 this%finf(jbelow) = dzero
830 end if
831 if (this%water_table(icell) < this%celbot(icell)) &
832 this%water_table(icell) = this%celbot(icell)
833
834
835 deriv1 = dzero
836 deriv2 = dzero
837 derivfinf = dzero
838
839
840 if (reset_state) then
841 call this%store_waves(icell, this%wavsav)
842 end if
843
844 if (this%water_table(icell) > this%celtop(icell)) &
845 this%water_table(icell) = this%celtop(icell)
846
847
848 if (this%surf_infil(icell) > this%vks(icell)) then
849 this%surf_infil(icell) = this%vks(icell)
850 end if
851
852
853 if (this%landflag(icell) == 1) then
854 call this%rejfinf(icell, deriv1, hgwf, trhsfinf, thcoffinf, finfact)
855 this%surf_infil(icell) = finfact
856 end if
857
858
859 this%finf_rej(icell) = this%finf(icell) + &
860 (qfrommvr / this%uzfarea(icell)) &
861 - this%surf_infil(icell)
862
863
864 if (iseepflag > 0 .and. this%landflag(icell) == 1) then
865 call this%gwseep(icell, deriv2, scale, hgwf, trhsseep, thcofseep, seep)
866 this%surf_seep(icell) = seep
867 end if
868
869
870 test = this%water_table(icell)
871 if (this%water_table_old(icell) - test < -dem15) &
872 test = this%water_table_old(icell)
873 if (this%celtop(icell) - test > dem15) then
874 if (issflag == 0) then
875 call this%routewaves(totfluxtot,
delt, ietflag, icell, ierr)
876 if (ierr > 0) then
877 if (reset_state) &
878 call this%load_waves(icell, this%wavsav)
879 return
880 end if
881 call this%uz_rise(icell, totfluxtot)
882 this%flux_to_wt(icell) = totfluxtot
883 if (this%cell_below(icell) > 0) then
884 call this%addrech(icell, jbelow, hgwf, trhsfinf, thcoffinf, &
886 end if
887 else
888 this%flux_to_wt(icell) = this%surf_infil(icell) *
delt
889 totfluxtot = this%surf_infil(icell) *
delt
890 end if
891 thcoffinf = dzero
892 trhsfinf = this%flux_to_wt(icell) * this%uzfarea(icell) /
delt
893 if (.not. reset_state) then
894 call this%update_wav(icell,
delt, issflag, 0)
895 end if
896 else
897 this%flux_to_wt(icell) = this%surf_infil(icell) *
delt
898 totfluxtot = this%surf_infil(icell) *
delt
899 if (.not. reset_state) then
900 call this%update_wav(icell,
delt, issflag, 1)
901 end if
902 end if
903
904
905 if (present(deriv)) deriv = deriv1 + deriv2 + derivfinf
906 if (present(trhs)) trhs = trhsfinf + trhsseep
907 if (present(thcof)) thcof = thcoffinf + thcofseep
908
909
910 if (present(watercontent)) then
911 watercontent = this%get_wcnew(icell)
912 end if
913
914
915 if (reset_state) then
916 call this%load_waves(icell, this%wavsav)
917 end if
real(dp), pointer, public delt
length of the current time step