@@ -24,63 +24,70 @@ int main() {
24
24
try {
25
25
// Create inputs (reading the input file):
26
26
input = Inputs (time);
27
+
27
28
if (!input.is_ok ())
28
29
throw std::string (" input initialization failed!" );
29
30
30
31
if (input.get_is_student ())
31
32
report.print (-1 , " Hello " +
32
- input.get_student_name () + " - welcome to Aether!" );
33
+ input.get_student_name () + " - welcome to Aether!" );
33
34
34
35
Quadtree quadtree;
36
+
35
37
if (!quadtree.is_ok ())
36
38
throw std::string (" quadtree initialization failed!" );
37
-
39
+
38
40
// Initialize MPI and parallel aspects of the code:
39
41
didWork = init_parallel (quadtree);
42
+
40
43
if (!didWork)
41
44
throw std::string (" init_parallel failed!" );
42
45
43
46
// Everything should be set for the inputs now, so write a restart file:
44
47
didWork = input.write_restart ();
48
+
45
49
if (!didWork)
46
50
throw std::string (" input.write_restart failed!" );
47
51
48
52
// Initialize the EUV system:
49
53
Euv euv;
54
+
50
55
if (!euv.is_ok ())
51
56
throw std::string (" EUV initialization failed!" );
52
57
53
58
// Initialize the planet:
54
59
Planets planet;
55
60
MPI_Barrier (aether_comm);
61
+
56
62
if (!planet.is_ok ())
57
63
throw std::string (" planet initialization failed!" );
58
64
59
65
// Initialize the indices, read the files, and perturb:
60
66
Indices indices;
61
67
didWork = read_and_store_indices (indices);
62
68
MPI_Barrier (aether_comm);
69
+
63
70
if (!didWork)
64
71
throw std::string (" read_and_store_indices failed!" );
65
-
72
+
66
73
// Perturb the inputs if user has asked for this
67
74
indices.perturb ();
68
75
MPI_Barrier (aether_comm);
69
-
76
+
70
77
// Initialize Geographic grid:
71
78
Grid gGrid (input.get_nLonsGeo (),
72
- input.get_nLatsGeo (),
73
- input.get_nAltsGeo (),
74
- nGeoGhosts);
79
+ input.get_nLatsGeo (),
80
+ input.get_nAltsGeo (),
81
+ nGeoGhosts);
75
82
didWork = gGrid .init_geo_grid (quadtree, planet);
76
83
MPI_Barrier (aether_comm);
84
+
77
85
if (!didWork)
78
- throw std::string (" init_geo_grid failed!" );
86
+ throw std::string (" init_geo_grid failed!" );
79
87
80
88
// Find interpolation coefs for the ghostcells if cubesphere grid
81
89
didWork = find_ghostcell_interpolation_coefs (gGrid );
82
90
83
-
84
91
// Calculate centripetal acceleration, since this is a constant
85
92
// vector on the grid:
86
93
if (input.get_cent_acc ())
@@ -100,7 +107,7 @@ int main() {
100
107
// Is simply adds nans and infinities in a few places, then
101
108
// checks for them to make sure the checking is working
102
109
// -----------------------------------------------------------------
103
-
110
+
104
111
if (input.get_nan_test ()) {
105
112
neutrals.nan_test (input.get_nan_test_variable ());
106
113
ions.nan_test (input.get_nan_test_variable ());
@@ -128,22 +135,25 @@ int main() {
128
135
// Initialize electrodynamics and check if electrodynamics times
129
136
// works with input time
130
137
Electrodynamics electrodynamics (time);
138
+
131
139
if (!electrodynamics.is_ok ())
132
140
throw std::string (" electrodynamics initialization failed!" );
133
141
134
142
// If the user wants to restart, then get the time of the restart
135
143
if (input.get_do_restart ()) {
136
144
report.print (1 , " Restarting! Reading time file!" );
137
145
didWork = time.restart_file (input.get_restartin_dir (), DoRead);
146
+
138
147
if (!didWork)
139
- throw std::string (" Reading Restart for time Failed!!!\n " );
148
+ throw std::string (" Reading Restart for time Failed!!!\n " );
140
149
}
141
150
142
151
// This is for the initial output. If it is not a restart, this will go:
143
152
if (time.check_time_gate (input.get_dt_output (0 )))
144
153
didWork = output (neutrals, ions, gGrid , time, planet);
154
+
145
155
if (!didWork)
146
- throw std::string (" output failed!" );
156
+ throw std::string (" output failed!" );
147
157
148
158
// This is advancing now... We are not coupling, so set dt_couple to the
149
159
// end of the simulation
@@ -158,26 +168,30 @@ int main() {
158
168
// be made into a library and run externally.
159
169
160
170
Logfile logfile (indices);
171
+
172
+ time.set_start_time_loop ();
173
+
161
174
while (time.get_current () < time.get_end ()) {
162
175
163
176
time.increment_intermediate (dt_couple);
164
177
165
178
// Increment until the intermediate time:
166
179
while (time.get_current () < time.get_intermediate ()) {
167
- didWork = advance (planet,
168
- gGrid ,
169
- time,
170
- euv,
171
- neutrals,
172
- ions,
173
- chemistry,
174
- electrodynamics,
175
- indices,
176
- logfile);
177
- if (!didWork)
178
- throw std::string (" Error in advance!" );
180
+ didWork = advance (planet,
181
+ gGrid ,
182
+ time,
183
+ euv,
184
+ neutrals,
185
+ ions,
186
+ chemistry,
187
+ electrodynamics,
188
+ indices,
189
+ logfile);
190
+
191
+ if (!didWork)
192
+ throw std::string (" Error in advance!" );
179
193
}
180
-
194
+
181
195
// Should write out some restart files every time we are done with
182
196
// intermediate times. Just so when we restart, we know that we can
183
197
// couple first thing and everything should be good. (Not sure if
@@ -189,19 +203,22 @@ int main() {
189
203
// wrote out restart files, so we only need to do this if we
190
204
// didn't just do it. So, check the negative here:
191
205
if (!time.check_time_gate (input.get_dt_write_restarts ())) {
192
- report.print (3 , " Writing restart files" );
206
+ report.print (3 , " Writing restart files" );
193
207
194
- didWork = neutrals.restart_file (input.get_restartout_dir (), DoWrite);
195
- if (!didWork)
196
- throw std::string (" Writing Restart for Neutrals Failed!!!\n " );
208
+ didWork = neutrals.restart_file (input.get_restartout_dir (), DoWrite);
197
209
198
- didWork = ions.restart_file (input.get_restartout_dir (), DoWrite);
199
- if (!didWork)
200
- throw std::string (" Writing Restart for Ions Failed!!!\n " );
210
+ if (!didWork)
211
+ throw std::string (" Writing Restart for Neutrals Failed!!!\n " );
201
212
202
- didWork = time.restart_file (input.get_restartout_dir (), DoWrite);
203
- if (!didWork)
204
- throw std::string (" Writing Restart for time Failed!!!\n " );
213
+ didWork = ions.restart_file (input.get_restartout_dir (), DoWrite);
214
+
215
+ if (!didWork)
216
+ throw std::string (" Writing Restart for Ions Failed!!!\n " );
217
+
218
+ didWork = time.restart_file (input.get_restartout_dir (), DoWrite);
219
+
220
+ if (!didWork)
221
+ throw std::string (" Writing Restart for time Failed!!!\n " );
205
222
}
206
223
207
224
// Do some coupling here. But we have no coupling to do. Sad.
@@ -213,13 +230,14 @@ int main() {
213
230
214
231
} catch (std::string error) {
215
232
report.report_errors ();
233
+
216
234
if (iProc == 0 ) {
217
235
std::cout << error << " \n " ;
218
236
std::cout << " ---- Must Exit! ----\n " ;
219
237
}
220
238
}
221
239
222
-
240
+
223
241
// End parallel tasks:
224
242
iErr = MPI_Finalize ();
225
243
0 commit comments