Skip to content

Commit a621a5a

Browse files
authored
Merge pull request #36 from YifanCheng/merge_two_layer_module
Merge two layer module
2 parents a61899f + a30b81c commit a621a5a

16 files changed

+1569
-811
lines changed

src/Begin.f90

Lines changed: 223 additions & 176 deletions
Large diffs are not rendered by default.

src/Block_Energy.f90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ module Block_Energy
3434
real :: lvp,rb,rho
3535
real,parameter :: evap_coeff=1.5e-9 !Lake Hefner coefficient, 1/meters
3636
real,parameter :: pf=0.640,pi=3.14159
37-
real,parameter :: rfac=304.8 !rho/Cp kg/meter**3/Kilocalories/kg/Deg K
37+
real,parameter :: rfac=304.8 !rho/Cp kg/meter**3/Kilocalories/kg/Deg K
38+
real,parameter :: sec_day = 86400 !number of seconds in a day
39+
real,parameter :: a_z=0.408, b_z=0.392 !Leopold parameter for depth
40+
real,parameter :: a_w=4.346, b_w=0.520 !Leopold parameter for width
3841
!
3942
end module Block_Energy

src/Block_Hydro.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ module Block_Hydro
1111
real, dimension(:), allocatable :: dt
1212
real, dimension(:), allocatable :: dx
1313
real, dimension(:), allocatable :: Q_in
14+
real, dimension(:), allocatable :: Q_local
1415
real, dimension(:), allocatable :: Q_trib
1516
real, dimension(:), allocatable :: Q_out
1617
real, dimension(:), allocatable :: Q_diff
18+
real, dimension(:), allocatable :: delta_sto_flux ! Water flux provided by river storage
1719
real, dimension(:,:), allocatable :: Q_nps
1820
real, dimension(:,:), allocatable :: temp_trib
1921
real, dimension(:,:), allocatable :: temp_nps,thermal
2022
real, dimension(:,:), allocatable :: x_dist
2123
real, dimension(:,:,:), allocatable :: temp
24+
real, dimension(:,:,:), allocatable :: sto ! river transient storage for each river segment
25+
real, dimension(:,:,:), allocatable :: temp_sto ! temperature for river storage
2226

2327
end module Block_Hydro

src/Block_Reservoir.f90

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
!
2+
! Module for reservoir characteristic and parameters
3+
!
4+
module Block_Reservoir
5+
!
6+
! Logical
7+
!
8+
logical :: reservoir ! whether there is reservoir in the system
9+
logical, dimension(:), allocatable :: res_pres ! whether reservoir exists at specific grid cell
10+
logical, dimension(:), allocatable :: res_start !
11+
logical, dimension(:), allocatable :: initial_storage !
12+
logical, dimension(:), allocatable :: res_trib_calc !
13+
logical, dimension(:), allocatable :: res_stratif_start !
14+
logical, dimension(:), allocatable :: res_turnover !
15+
!
16+
!
17+
real, parameter :: depth_e_frac=0.4, depth_h_frac=0.6
18+
real, parameter :: ftsec_to_msec = 0.0283168, gravity = 9.8
19+
real, parameter :: density = 1000, heat_c = 4180
20+
real, parameter :: heat_c_kcal = 1
21+
real :: flow_in_epi_x, flow_in_hyp_x
22+
real :: flow_out_epi_x,flow_out_hyp_x
23+
real :: flow_epi_hyp_x, outflow_x
24+
real :: res_vol_delta_x, vol_change_hyp_x, vol_change_epi_x
25+
real :: res_storage_pre, res_storage_post
26+
real, dimension(:), allocatable :: K_z
27+
real, dimension(:), allocatable :: depth_e, depth_h
28+
real, dimension(:), allocatable :: density_epil, density_hypo
29+
real, dimension(:), allocatable :: density_in
30+
real, dimension(:), allocatable :: volume_e_x
31+
real, dimension(:), allocatable :: volume_h_x
32+
real, dimension(:), allocatable :: dV_dt_epi
33+
real, dimension(:), allocatable :: dV_dt_hyp
34+
real, dimension(:), allocatable :: dam_grid_lat
35+
real, dimension(:), allocatable :: dam_grid_lon
36+
real, dimension(:), allocatable :: res_depth_meter
37+
real, dimension(:), allocatable :: res_width_meter
38+
real, dimension(:), allocatable :: res_area_km2
39+
real, dimension(:), allocatable :: surface_area
40+
real, dimension(:), allocatable :: Q_res_inflow
41+
real, dimension(:), allocatable :: Q_res_outflow
42+
real, dimension(:), allocatable :: T_res_inflow
43+
real, dimension(:), allocatable :: T_res_in
44+
real, dimension(:), allocatable :: Q_res_in
45+
real, dimension(:), allocatable :: water_withdrawal
46+
real, dimension(:), allocatable :: temp_change_ep, temp_change_hyp
47+
real, dimension(:), allocatable :: T_epil
48+
real, dimension(:), allocatable :: T_hypo
49+
real, dimension(:), allocatable :: temp_out
50+
real, dimension(:), allocatable :: T_res
51+
real, dimension(:), allocatable :: diffusion_tot
52+
real, dimension(:), allocatable :: advec_hyp_tot
53+
real, dimension(:), allocatable :: advec_epi_tot
54+
real, dimension(:), allocatable :: qsurf_tot
55+
real, dimension(:), allocatable :: res_capacity_mcm
56+
real, dimension(:), allocatable :: volume_h_min
57+
real, dimension(:,:), allocatable :: res_storage
58+
!
59+
!
60+
integer :: nres
61+
integer, parameter :: km_to_m = 1000
62+
integer, dimension(:), allocatable :: res_num
63+
integer, dimension(:), allocatable :: dam_number
64+
integer, dimension(:), allocatable :: res_start_node
65+
integer, dimension(:), allocatable :: res_end_node
66+
integer, dimension(:), allocatable :: ns_res_start
67+
integer, dimension(:), allocatable :: ns_res_end
68+
69+
70+
end module Block_Reservoir

src/Leap_Year.f90

100644100755
File mode changed.

src/Particle_Track.f90

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,59 @@
1-
SUBROUTINE Particle_Track(nr,ns,nx_s,nx_head)
2-
USE Block_Hydro
3-
USE Block_Network
4-
IMPLICIT NONE
5-
integer, intent(IN):: nr,ns
6-
integer:: ncell, nx_head, nx_part, nx_s,count_steps
7-
real:: dt_total,dt_xcess
8-
!
9-
! First do the reverse particle tracking
10-
!
11-
! Segment is in cell SEGMENT_CELL(NC)
12-
nx_s=0
13-
nx_part=ns
14-
dt_total=0.0
15-
!
16-
! Determine if the total elapsed travel time is equal to the
17-
! computational interval
18-
!
19-
do while(dt_total.lt.dt_comp.and.nx_part.gt.0)
20-
nx_s=nx_s+1
21-
x_part(nx_s)=x_dist(nr,nx_part-1)
22-
ncell=segment_cell(nr,nx_part)
23-
dt_part(nx_s)=dt(ncell)
24-
dt_total=dt_total+dt_part(nx_s)
25-
!
26-
! Increment the segment counter if the total time is less than the
27-
! computational interval
28-
!
29-
nx_part=nx_part-1
30-
end do
31-
!
32-
! If the elapsed time is greater than the computational interval and
33-
! the parcel has not exceeded the boundary
34-
!
35-
36-
do while (dt_total.lt.dt_comp.and.nx_part.gt.0)
37-
nx_s=nx_s+1
38-
x_part(nx_s)=x_dist(nr,nx_part-1)
39-
ncell=segment_cell(nr,nx_part)
40-
dt_part(nx_s)=dt(ncell)
41-
nx_part=nx_part-1
42-
dt_total=dt_total+dt(ncell)
1+
SUBROUTINE Particle_Track(nr,ns,nx_s,nx_head,ns_res_pres,ns_res_num)
2+
USE Block_Hydro
3+
USE Block_Network
4+
USE Block_Reservoir
5+
IMPLICIT NONE
6+
integer, intent(IN):: nr,ns
7+
integer:: ncell, nx_head, nx_part, nx_s,count_steps, nx_part_next
8+
integer:: ns_res_num
9+
real :: dt_total,dt_xcess
10+
logical:: ns_res_pres
11+
!
12+
! First do the reverse particle tracking
13+
!
14+
! Segment is in cell SEGMENT_CELL(NC)
15+
nx_s=0
16+
nx_part=ns
17+
nx_part_next=ns
18+
dt_total=0.0
19+
ns_res_pres=.FALSE.
20+
ns_res_num = 0
21+
!
22+
! Determine if the total elapsed travel time is equal to the
23+
! computational intervasl
24+
!
25+
do while(dt_total.lt.dt_comp.and.nx_part.gt.0.and.nx_part_next.gt.0 &
26+
.and. .NOT. ns_res_pres)
27+
nx_s=nx_s+1
28+
x_part(nx_s)=x_dist(nr,nx_part_next)
29+
ncell=segment_cell(nr,nx_part_next)
30+
dt_part(nx_s)=dt(ncell)
31+
dt_total=dt_total+dt_part(nx_s)
32+
!
33+
! Increment the segment counter if the total time is less than the
34+
! computational interval
35+
!
36+
if (nx_s.gt.1) nx_part=nx_part-1
37+
nx_part_next=nx_part_next-1
38+
ns_res_pres = res_pres(segment_cell(nr,nx_part_next))
4339
end do
40+
! If water particle travels back to a reservoir,
41+
! ns_res_num denotes the number of the grid cell.
42+
!
43+
if (ns_res_pres) then
44+
ns_res_num=res_num(segment_cell(nr,nx_part_next))
45+
end if
46+
!
47+
! If the elapsed time is greater than the computational interval and
48+
! the parcel has not exceeded the boundary
49+
!
4450
if (dt_total.gt.dt_comp) then
45-
dt_xcess=dt_total-dt_comp
46-
dt_part(nx_s)=dt_part(nx_s)-dt_xcess
47-
x_part(nx_s)=x_dist(nr,nx_part+1)+u(ncell)*dt_part(nx_s)
48-
end if
51+
dt_xcess=dt_total-dt_comp
52+
dt_part(nx_s)=dt_part(nx_s)-dt_xcess
53+
x_part(nx_s)=x_dist(nr,nx_part+1)+u(ncell)*dt_part(nx_s)
54+
end if
4955
nx_head=nx_part
5056
nx_part=max(1,nx_part)
5157
nstrt_elm(ns)=nx_part
52-
no_dt(ns)=nx_s
58+
no_dt(ns)=nx_s
5359
END SUBROUTINE Particle_Track
54-
!END MODULE P_Track

0 commit comments

Comments
 (0)