Newer
Older
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
function writeErosInputs(LEM)
% Writes the neccessary files for running Eros.exe
% define outputs to write
switch LEM.stress
case 1
LEM.str_write = strcat(LEM.str_write,'stress');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,'stress');
end
switch LEM.waters
case 1
LEM.str_write = strcat(LEM.str_write,':water');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,':water');
end
switch LEM.discharge
case 1
LEM.str_write = strcat(LEM.str_write,':discharge');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,':discharge');
end
switch LEM.downward
case 1
LEM.str_write = strcat(LEM.str_write,':downward');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,':downward');
end
switch LEM.slope
case 1
LEM.str_write = strcat(LEM.str_write,':slope');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,':slope');
end
switch LEM.qs
case 1
LEM.str_write = strcat(LEM.str_write,':qs');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,':qs');
end
switch LEM.capacity
case 1
LEM.str_write = strcat(LEM.str_write,':capacity');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,':capacity');
end
switch LEM.sediment
case 1
LEM.str_write = strcat(LEM.str_write,':sediment');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,':sediment');
end
switch LEM.flux
case 1
LEM.str_write = strcat(LEM.str_write,':precipiton_flux');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,':precipiton_flux');
end
switch LEM.stock
case 1
LEM.str_write = strcat(LEM.str_write,':stock');
case 0
LEM.str_nowrite = strcat(LEM.str_nowrite,':stock');
end
fileID = fopen([LEM.experiment,'.arg'],'w');
fprintf(fileID, ['dat=dat\\inputs.dat\n']);
fclose(fileID);
% write input file
fileID = fopen('./dat/inputs.dat','w');
fprintf(fileID, ['erosion_model=',LEM.erosion_model,'\n']);
fprintf(fileID, ['deposition_model=',LEM.deposition_model,'\n']);
% ALLUVIAL
fprintf(fileID, ['deposition_length_fluvial=',num2str(LEM.deposition_length),'\n']);
fprintf(fileID, ['sediment_grain=',num2str(LEM.sediment_grain),'\n']);
% Lateral erosion/deposition
fprintf(fileID, ['lateral_erosion_model=',num2str(LEM.lateral_erosion_model),'\n']);
fprintf(fileID, ['lateral_deposition_model=',num2str(LEM.lateral_deposition_model),'\n']);
fprintf(fileID, ['lateral_erosion_coefficient_fluvial=',num2str(LEM.fluvial_lateral_erosion_coefficient),'\n']);
fprintf(fileID, ['lateral_deposition_coefficient_fluvial=',num2str(LEM.fluvial_lateral_deposition_coefficient),'\n']);
% BEDROCK
fprintf(fileID, ['poisson_coefficient=',num2str(LEM.poisson_coefficient),'\n']);
fprintf(fileID, ['diffusion_coefficient=',num2str(LEM.diffusion_coefficient),'\n']);
fprintf(fileID, ['basement_grain=',num2str(LEM.basement_grain),'\n']);
fprintf(fileID, ['basement_erodibility=',num2str(LEM.fluvial_basement_erodability),':dir\n']);
% FLOW MODEL
fprintf(fileID, ['flow_model=',LEM.flow_model,'\n']);
fprintf(fileID, ['friction_coefficient=',num2str(LEM.friction_coefficient),'\n']);
fprintf(fileID, ['flow_boundary=',num2str(LEM.flow_boundary),'\n']);
fprintf(fileID, ['stress_model=',num2str(LEM.stress_model),'\n']);
% Boundary conditions
% Topo
fprintf(fileID, ['topo=Topo\\',LEM.dem.name,'.alt\n']);
if isfield(LEM,'rain')
fprintf(fileID, ['rain=Topo\\',LEM.dem.name,'.rain\n']);
end
if isfield(LEM,'water')
fprintf(fileID, ['water=Topo\\',LEM.dem.name,'.water\n']);
end
if isfield(LEM,'sed')
fprintf(fileID, ['sed=Topo\\',LEM.dem.name,'.sed\n']);
end
if isfield(LEM,'uplift')
fprintf(fileID, ['uplift=Topo\\',LEM.dem.name,'.uplift\n']);
end
if isfield(LEM,'cs')
fprintf(fileID, ['cs=Topo\\',LEM.dem.name,'.cs\n']);
end
% INFLOW/RAINFALL CONDITIONS
if isfield(LEM,'inflow')
fprintf(fileID, ['inflow=',num2str(LEM.inflow),':dir\n']);
end
if isfield(LEM,'rainfall')
fprintf(fileID, ['rainfall=',num2str(LEM.rainfall),':dir\n']);
end
fprintf(fileID, ['input_sediment_concentration=',num2str(LEM.initial_sediment_stock),'\n']);
% Time
fprintf(fileID, ['time:end=',num2str(LEM.end),':',LEM.end_option,'\n']);
fprintf(fileID, ['time:draw=',num2str(LEM.draw),':',LEM.draw_option,':dir\n']);
fprintf(fileID, ['time:step=',num2str(LEM.step),':dir:',LEM.step_option,'\n']);
fprintf(fileID, ['time:step:min=',num2str(LEM.stepmin),':max=',num2str(LEM.stepmax),'\n']);
fprintf(fileID, ['erosion_multiply=',num2str(LEM.erosion_multiply),':dir\n']);
fprintf(fileID, ['uplift_rate=',num2str(LEM.uplift_multiplier),':dir\n']);
% Default management
fprintf(fileID, ['limiter=',num2str(LEM.limiter),'\n']);
fprintf(fileID, 'default:model=all:min=20:max=10000:step=4:op=*:log10\n');
% Save parameters
fprintf(fileID, ['write=',LEM.str_write,'\n']);
fprintf(fileID, ['TU_coefficient=',num2str(LEM.TU_coefficient),'\n']); % unknown parameter
fprintf(fileID, ['flow_inertia_coefficient=',num2str(LEM.inertia),'\n']); % inertia in shallow water equation
fprintf(fileID, ['friction_model=',LEM.friction_model,'\n']); % floodos mode
fprintf(fileID, ['continue=',num2str(LEM.continue_run),'\n']); % continue from stage
fclose(fileID);
% write .bat file
fileID = fopen([LEM.experiment,'.bat'],'w');
fprintf(fileID, '@rem Run Eros program with following arguments\n');
fprintf(fileID, '@rem\n');
fprintf(fileID, '@echo off\n');
fprintf(fileID, ['@set EROS_PROG=',LEM.ErosPath,'\\bin\\',LEM.eros_version,'.exe\n']);
fprintf(fileID, '@set COMMAND=%%EROS_PROG%% %%*\n');
fprintf(fileID, '@echo on\n');
fprintf(fileID, '@rem\n\n');
fprintf(fileID, 'goto:todo\n\n');
fprintf(fileID, ':not_todo\n\n');
fprintf(fileID, ':todo\n\n\n');
fprintf(fileID, ['start /LOW %%COMMAND%% -dir=',LEM.outfolder,'\\ ',LEM.experiment,'.arg']);
fclose(fileID);