1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
pub mod fortran_modernized {
// type, bind(c) :: muskingum_cunge_input_t
// real(real32) :: dt ! routing period in seconds
// real(real32) :: qup ! flow upstream previous timestep
// real(real32) :: quc ! flow upstream current timestep
// real(real32) :: qdp ! flow downstream previous timestep
// real(real32) :: ql ! lateral inflow through reach (m^3/sec)
// real(real32) :: dx ! channel lngth (m)
// real(real32) :: bw ! bottom width (meters)
// real(real32) :: tw ! top width before bankfull (meters)
// real(real32) :: tw_cc ! top width of Compund (meters)
// real(real32) :: n ! mannings coefficient
// real(real32) :: n_cc ! mannings of compund
// real(real32) :: cs ! Channel side slope slope
// real(real32) :: s0 ! Channel bottom slope %
// real(real32) :: depthp ! depth of flow in channel
// end type
use crate::kernel::muskingum::{MuskingumCungeInput, MuskingumCungeResult};
unsafe extern "C" {
pub fn c_binding_muskingum_cunge_t_route(
input: *const MuskingumCungeInput,
result: *mut MuskingumCungeResult,
);
}
pub fn submuskingcunge(
qup: f32, // flow upstream previous timestep
quc: f32, // flow upstream current timestep
qdp: f32, // flow downstream previous timestep
ql: f32, // lateral inflow through reach (m^3/sec)
dt: f32, // routing period in seconds
so: f32, // channel bottom slope (as fraction, not %)
dx: f32, // channel length (m)
n: f32, // mannings coefficient
cs: f32, // channel side slope
bw: f32, // bottom width (meters)
tw: f32, // top width before bankfull (meters)
tw_cc: f32, // top width of compound (meters)
n_cc: f32, // mannings of compound
depth_p: f32, // depth of flow in channel
_calculate_courant: bool, // whether to calculate courant number
) -> MuskingumCungeResult {
let input = MuskingumCungeInput {
dt,
qup,
quc,
qdp,
ql,
dx,
bw,
tw,
tw_cc,
n,
n_cc,
cs,
s0: so,
velp: 0.0,
depthp: depth_p,
};
let mut result = MuskingumCungeResult::default();
unsafe {
c_binding_muskingum_cunge_t_route(&input, &mut result);
}
result
}
}
pub mod fortran_legacy {
use crate::kernel::muskingum::{MuskingumCungeInput, MuskingumCungeResult};
// type, bind(c) :: muskingum_cunge_result_t
// real(real32) :: qdc ! flow downstream current timestep
// real(real32) :: velc ! channel velocity
// real(real32) :: depthc ! depth of flow in channel
// real(real32) :: ck
// real(real32) :: cn
// real(real32) :: X
// end type
unsafe extern "C" {
pub fn c_binding_muskingum_cunge_t_route_legacy(
input: *const MuskingumCungeInput,
result: *mut MuskingumCungeResult,
);
}
pub fn submuskingcunge(
qup: f32, // flow upstream previous timestep
quc: f32, // flow upstream current timestep
qdp: f32, // flow downstream previous timestep
ql: f32, // lateral inflow through reach (m^3/sec)
dt: f32, // routing period in seconds
so: f32, // channel bottom slope (as fraction, not %)
dx: f32, // channel length (m)
n: f32, // mannings coefficient
cs: f32, // channel side slope
bw: f32, // bottom width (meters)
tw: f32, // top width before bankfull (meters)
tw_cc: f32, // top width of compound (meters)
n_cc: f32, // mannings of compound
depth_p: f32, // depth of flow in channel
_calculate_courant: bool, // whether to calculate courant number
) -> MuskingumCungeResult {
let input = MuskingumCungeInput {
dt,
qup,
quc,
qdp,
ql,
dx,
bw,
tw,
tw_cc,
n,
n_cc,
cs,
s0: so,
depthp: depth_p,
velp: 0.0,
};
let mut result = MuskingumCungeResult::default();
unsafe {
c_binding_muskingum_cunge_t_route_legacy(&input, &mut result);
}
result
}
}