Fixed exceptionhandling
This commit is contained in:
parent
b1ad1930e6
commit
ed2d0c7841
@ -26,59 +26,66 @@ SimuData *CosmoTool::loadFlashMulti(const char *fname, int id, int loadflags)
|
||||
const double kpc2cm = 3.08568025e21;
|
||||
const double km2cm = 1.e5;
|
||||
|
||||
if (id != 0)
|
||||
throw NoSuchFileException();
|
||||
|
||||
data = new SimuData;
|
||||
if (data == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
filename = fname;
|
||||
H5File file (filename, H5F_ACC_RDONLY);
|
||||
try {
|
||||
H5File file (filename, H5F_ACC_RDONLY);
|
||||
|
||||
// simulation info
|
||||
h5_read_flash3_header_info(&file, &time);
|
||||
data->time = time;
|
||||
// simulation info
|
||||
h5_read_flash3_header_info(&file, &time);
|
||||
data->time = time;
|
||||
|
||||
h5_read_runtime_parameters(&file, &lbox, &npart);
|
||||
data->NumPart = npart;
|
||||
data->BoxSize = lbox/kpc2cm;
|
||||
h5_read_runtime_parameters(&file, &lbox, &npart);
|
||||
data->NumPart = npart;
|
||||
data->BoxSize = lbox/kpc2cm;
|
||||
|
||||
// particle data
|
||||
for (int i = 0; i < 3; i++) {
|
||||
data->Pos[i] = new float[data->NumPart];
|
||||
if (data->Pos[i] == 0) {
|
||||
delete data;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
data->Vel[i] = new float[data->NumPart];
|
||||
if (data->Vel[i] == 0) {
|
||||
delete data;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
data->Id = new int[data->NumPart];
|
||||
if (data->Id == 0) {
|
||||
delete data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
h5_read_flash3_particles(&file, &npart, &npart, &offset,
|
||||
data->Pos[0], data->Pos[1], data->Pos[2],
|
||||
data->Vel[0], data->Vel[1], data->Vel[2],
|
||||
data->Id);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int n = 0; i < data->NumPart; i++) {
|
||||
data->Pos[n][i] = data->Pos[n][i] / kpc2cm;
|
||||
data->Vel[n][i] = data->Vel[n][i] / km2cm;
|
||||
// particle data
|
||||
for (int i = 0; i < 3; i++) {
|
||||
data->Pos[i] = new float[data->NumPart];
|
||||
if (data->Pos[i] == 0) {
|
||||
delete data;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
data->Vel[i] = new float[data->NumPart];
|
||||
if (data->Vel[i] == 0) {
|
||||
delete data;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
data->Id = new int[data->NumPart];
|
||||
if (data->Id == 0) {
|
||||
delete data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
h5_read_flash3_particles(&file, &npart, &npart, &offset,
|
||||
data->Pos[0], data->Pos[1], data->Pos[2],
|
||||
data->Vel[0], data->Vel[1], data->Vel[2],
|
||||
data->Id);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int n = 0; i < data->NumPart; i++) {
|
||||
data->Pos[n][i] = data->Pos[n][i] / kpc2cm;
|
||||
data->Vel[n][i] = data->Vel[n][i] / km2cm;
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
} catch (const FileIException& e) {
|
||||
throw NoSuchFileException();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user