@@ -212,15 +212,15 @@ bool OutputContainer::write() {
212
212
213
213
bool OutputContainer::read () {
214
214
215
- bool didWork = true ;
215
+ bool didWork = true ;
216
216
217
- if (output_type == binary_type)
218
- didWork = read_container_binary ();
217
+ if (output_type == binary_type)
218
+ didWork = read_container_binary ();
219
219
220
- if (output_type == netcdf_type)
221
- didWork = read_container_netcdf ();
220
+ if (output_type == netcdf_type)
221
+ didWork = read_container_netcdf ();
222
222
223
- return didWork;
223
+ return didWork;
224
224
}
225
225
226
226
@@ -307,62 +307,64 @@ bool OutputContainer::write_container_header() {
307
307
308
308
bool OutputContainer::read_container_binary () {
309
309
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);
317
313
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" ;
319
317
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);
324
319
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
+ }
330
324
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;
335
330
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;
338
335
339
- // Now, read and store variable-by-variable
336
+ std::ifstream binary;
337
+ binary.open (bin_filename, ios::binary | ios::in);
340
338
341
- for (iVar = 0 ; iVar < nVars; iVar++) {
339
+ // Now, read and store variable-by-variable
342
340
343
- // Read from the binary file
344
- binary.read ((char *) variable_array, iTotalSize * sizeof (float ));
341
+ for (iVar = 0 ; iVar < nVars; iVar++) {
345
342
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 ));
355
345
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];
360
352
}
353
+ }
354
+ }
361
355
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 " ;
363
361
}
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;
366
368
}
367
369
368
370
// ----------------------------------------------------------------------
0 commit comments