Soil Water Balance (SWB2)
Loading...
Searching...
No Matches
mass_balance__soil.F90
Go to the documentation of this file.
2
3 use iso_c_binding, only : c_float, c_double
5 implicit none
6
7 private
8
10
11contains
12
13 elemental subroutine calculate_soil_mass_balance( net_infiltration, &
14 soil_storage, &
15 actual_et_soil, &
16 runoff, &
17 delta_soil_storage, &
18 reference_et0, &
19 soil_storage_max, &
20 infiltration )
21
22 real (c_float), intent(inout) :: net_infiltration
23 real (c_double), intent(inout) :: soil_storage
24 real (c_double), intent(inout) :: actual_et_soil
25 real (c_float), intent(inout) :: runoff
26 real (c_float), intent(inout) :: delta_soil_storage
27 real (c_double), intent(in) :: reference_et0
28 real (c_float), intent(in) :: soil_storage_max
29 real (c_float), intent(in) :: infiltration
30
31 ! [ LOCALS ]
32 real (c_double) :: new_soil_storage
33
34 ! all of these entities have been previously corrected for pervious fraction
35 new_soil_storage = soil_storage + infiltration - actual_et_soil
36
37 ! open water cell
38 if ( soil_storage_max < near_zero ) then
39
40 actual_et_soil = min( reference_et0, real(infiltration, c_double) )
41 net_infiltration = 0.0_c_float
42 ! **** infiltration term includes the previously calculated runoff; add this back in
43 ! before adjusting the runoff value
44 runoff = real(max( 0.0_c_double, real(infiltration, c_double) + runoff - actual_et_soil ), c_float)
45 soil_storage = 0.0_c_float
46 delta_soil_storage = 0.0_c_float
47
48 ! new soil storage value exceeds soil_storage_max; net infiltration event
49 elseif ( new_soil_storage > soil_storage_max ) then
50
51 net_infiltration = real(new_soil_storage - soil_storage_max, c_float)
52
53 ! should represent a positive change in storage
54 delta_soil_storage = real(soil_storage_max - soil_storage, c_float)
55! actual_et_soil = max( 0.0_c_float, soil_storage + infiltration - net_infiltration )
56 soil_storage = soil_storage_max
57
58 else
59
60 ! could be positive or negative
61 delta_soil_storage = real(new_soil_storage - soil_storage, c_float)
62 soil_storage = new_soil_storage
63 net_infiltration = 0.0_c_float
64
65 endif
66
67 end subroutine calculate_soil_mass_balance
68
69end module mass_balance__soil
This module contains physical constants and convenience functions aimed at performing unit conversion...
real(c_float), parameter, public near_zero
elemental subroutine, public calculate_soil_mass_balance(net_infiltration, soil_storage, actual_et_soil, runoff, delta_soil_storage, reference_et0, soil_storage_max, infiltration)