Skip to content

Commit 1370867

Browse files
committed
STY: Astyle, yo
1 parent f007ead commit 1370867

File tree

4 files changed

+56
-51
lines changed

4 files changed

+56
-51
lines changed

src/containers_io.cpp

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,15 @@ bool OutputContainer::write() {
212212

213213
bool OutputContainer::read() {
214214

215-
bool didWork = true;
215+
bool didWork = true;
216216

217-
if (output_type == binary_type)
218-
didWork = read_container_binary();
217+
if (output_type == binary_type)
218+
didWork = read_container_binary();
219219

220-
if (output_type == netcdf_type)
221-
didWork = read_container_netcdf();
220+
if (output_type == netcdf_type)
221+
didWork = read_container_netcdf();
222222

223-
return didWork;
223+
return didWork;
224224
}
225225

226226

@@ -307,62 +307,64 @@ bool OutputContainer::write_container_header() {
307307

308308
bool OutputContainer::read_container_binary() {
309309

310-
std::string function = "OutputContainer::read_container_binary";
311-
static int iFunction = -1;
312-
report.enter(function, iFunction);
313-
314-
bool didWork = true;
315-
std::string bin_filename = directory + "/" + filename + ".bin";
316-
std::string json_filename = directory + "/" + filename + ".json";
310+
std::string function = "OutputContainer::read_container_binary";
311+
static int iFunction = -1;
312+
report.enter(function, iFunction);
317313

318-
json header = read_json(json_filename);
314+
bool didWork = true;
315+
std::string bin_filename = directory + "/" + filename + ".bin";
316+
std::string json_filename = directory + "/" + filename + ".json";
319317

320-
if (report.test_verbose(2)) {
321-
std::cout << "reading binary restart\n --> json header is here:\n";
322-
std::cout << std::setw(2) << header;
323-
}
318+
json header = read_json(json_filename);
324319

325-
int64_t iVar, nVars = header["nVars"];
326-
int64_t iX, nX = header["nX"];
327-
int64_t iY, nY = header["nY"];
328-
int64_t iZ, nZ = header["nZ"];
329-
int64_t iTotalSize = nX * nY * nZ;
320+
if (report.test_verbose(2)) {
321+
std::cout << "reading binary restart\n --> json header is here:\n";
322+
std::cout << std::setw(2) << header;
323+
}
330324

331-
float *variable_array = new float[iTotalSize];
332-
arma_cube value_scgc;
333-
value_scgc.set_size(nX, nY, nZ);
334-
int64_t index;
325+
int64_t iVar, nVars = header["nVars"];
326+
int64_t iX, nX = header["nX"];
327+
int64_t iY, nY = header["nY"];
328+
int64_t iZ, nZ = header["nZ"];
329+
int64_t iTotalSize = nX * nY * nZ;
335330

336-
std::ifstream binary;
337-
binary.open(bin_filename, ios::binary | ios::in);
331+
float *variable_array = new float[iTotalSize];
332+
arma_cube value_scgc;
333+
value_scgc.set_size(nX, nY, nZ);
334+
int64_t index;
338335

339-
// Now, read and store variable-by-variable
336+
std::ifstream binary;
337+
binary.open(bin_filename, ios::binary | ios::in);
340338

341-
for (iVar = 0; iVar < nVars; iVar++) {
339+
// Now, read and store variable-by-variable
342340

343-
// Read from the binary file
344-
binary.read((char *) variable_array, iTotalSize * sizeof(float));
341+
for (iVar = 0; iVar < nVars; iVar++) {
345342

346-
for (iZ = 0; iZ < nZ; iZ++) {
347-
for (iY = 0; iY < nY; iY++) {
348-
for (iX = 0; iX < nX; iX++) {
349-
// Python ordering!
350-
index = iX + iY * nX + iZ * nY * nX;
351-
value_scgc(iX, iY, iZ) = variable_array[index];
352-
}
353-
}
354-
}
343+
// Read from the binary file
344+
binary.read((char *) variable_array, iTotalSize * sizeof(float));
355345

356-
// Store in the container:
357-
if (report.test_verbose(2)) {
358-
std::cout << "Storing Variable : ";
359-
std::cout << header["variables"][iVar] << " : " << value_scgc(int(nX/2), int(nY/2), int(nZ/2)) << "\n";
346+
for (iZ = 0; iZ < nZ; iZ++) {
347+
for (iY = 0; iY < nY; iY++) {
348+
for (iX = 0; iX < nX; iX++) {
349+
// Python ordering!
350+
index = iX + iY * nX + iZ * nY * nX;
351+
value_scgc(iX, iY, iZ) = variable_array[index];
360352
}
353+
}
354+
}
361355

362-
store_variable(header["variables"][iVar], header["units"][iVar], value_scgc);
356+
// Store in the container:
357+
if (report.test_verbose(2)) {
358+
std::cout << "Storing Variable : ";
359+
std::cout << header["variables"][iVar] << " : " << value_scgc(int(nX / 2),
360+
int(nY / 2), int(nZ / 2)) << "\n";
363361
}
364-
report.exit(function);
365-
return didWork;
362+
363+
store_variable(header["variables"][iVar], header["units"][iVar], value_scgc);
364+
}
365+
366+
report.exit(function);
367+
return didWork;
366368
}
367369

368370
//----------------------------------------------------------------------

src/exchange_messages.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
// -----------------------------------------------------------------------------
3232
// This is the main exchange messages for the neutrals.
33-
// We are exchanging densities, temperatures, and velocities
33+
// We are exchanging densities, temperatures, and velocities
3434
// -----------------------------------------------------------------------------
3535

3636

@@ -1116,6 +1116,7 @@ bool test_ghostcell_interpolation(Grid &grid) {
11161116
}
11171117
}
11181118
}
1119+
11191120
report.exit(function);
11201121
return didWork;
11211122
}

src/init_geo_grid.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,9 @@ bool Grid::init_geo_grid(Quadtree quadtree,
955955
DidWork = read_restart(input.get_restartin_dir());
956956
} else {
957957
if (input.get_is_cubesphere()) {
958-
if (input.get_do_restart())
958+
if (input.get_do_restart())
959959
report.print(0, "Not restarting the grid - it is too complicated!");
960+
960961
create_cubesphere_grid(quadtree);
961962
} else
962963
create_sphere_grid(quadtree);

src/output.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ bool output(const Neutrals &neutrals,
328328
AllOutputContainers[iOutput].clear_variables();
329329

330330
}
331+
331332
if (!didWork)
332333
break;
333334
}

0 commit comments

Comments
 (0)