Skip to content
Snippets Groups Projects
Commit 43d2c7e0 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Check that the code and ICs have the same dimensitonality

parent 8f88c063
Branches
Tags
1 merge request!221Check that the code and ICs have the same dimensionality
Showing
with 40 additions and 2 deletions
......@@ -133,6 +133,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -83,7 +83,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0]
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -87,6 +87,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFileOutputsPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0]
grp.attrs["Dimension"] = 2
#Runtime parameters
grp = fileOutput.create_group("/RuntimePars")
......
......@@ -101,7 +101,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0]
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -120,6 +120,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFileOutputsPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0]
grp.attrs["Dimension"] = 2
#Runtime parameters
grp = fileOutput.create_group("/RuntimePars")
......
......@@ -61,6 +61,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, massDM, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -84,6 +84,7 @@ grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0]
grp.attrs["NumPart_Total"] = numPart
grp.attrs["Dimension"] = 2
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -86,6 +86,7 @@ grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0]
grp.attrs["NumPart_Total"] = numPart
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -70,6 +70,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 1
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -70,6 +70,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 2
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -70,6 +70,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -90,6 +90,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 1
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -96,6 +96,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 2
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -96,6 +96,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -94,6 +94,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0]
grp.attrs["Dimension"] = 2
#Runtime parameters
grp = fileOutput.create_group("/RuntimePars")
......
......@@ -83,6 +83,7 @@ grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0]
grp.attrs["NumPart_Total"] = numPart
grp.attrs["Dimension"] = 2
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -55,6 +55,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -51,6 +51,7 @@ grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, mass, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
......
......@@ -37,6 +37,7 @@
/* Local includes. */
#include "common_io.h"
#include "dimension.h"
#include "engine.h"
#include "error.h"
#include "gravity_io.h"
......@@ -383,6 +384,7 @@ void read_ic_parallel(char* fileName, const struct UnitSystem* internal_units,
size_t N[NUM_PARTICLE_TYPES] = {0};
long long N_total[NUM_PARTICLE_TYPES] = {0};
long long offset[NUM_PARTICLE_TYPES] = {0};
int dimension = 3; /* Assume 3D if nothing is specified */
/* Open file */
/* message("Opening file '%s' as IC.", fileName); */
......@@ -409,6 +411,15 @@ void read_ic_parallel(char* fileName, const struct UnitSystem* internal_units,
h_grp = H5Gopen(h_file, "/Header", H5P_DEFAULT);
if (h_grp < 0) error("Error while opening file header\n");
/* Check the dimensionality of the ICs (if the info exists) */
const hid_t hid_dim = H5Aexists(h_grp, "Dimension");
if (hid_dim < 0)
error("Error while testing existance of 'Dimension' attribute");
if (hid_dim > 0) readAttribute(h_grp, "Dimension", INT, &dimension);
if (dimension != hydro_dimension)
error("ICs dimensionality (%dD) does not match code dimensionality (%dD)",
dimension, (int)hydro_dimension);
/* Read the relevant information and print status */
int flag_entropy_temp[6];
readAttribute(h_grp, "Flag_Entropy_ICs", INT, flag_entropy_temp);
......
......@@ -37,6 +37,7 @@
/* Local includes. */
#include "common_io.h"
#include "dimension.h"
#include "engine.h"
#include "error.h"
#include "gravity_io.h"
......@@ -426,6 +427,7 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
size_t N[NUM_PARTICLE_TYPES] = {0};
long long N_total[NUM_PARTICLE_TYPES] = {0};
long long offset[NUM_PARTICLE_TYPES] = {0};
int dimension = 3; /* Assume 3D if nothing is specified */
struct UnitSystem* ic_units = malloc(sizeof(struct UnitSystem));
/* First read some information about the content */
......@@ -453,6 +455,15 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
h_grp = H5Gopen(h_file, "/Header", H5P_DEFAULT);
if (h_grp < 0) error("Error while opening file header\n");
/* Check the dimensionality of the ICs (if the info exists) */
const hid_t hid_dim = H5Aexists(h_grp, "Dimension");
if (hid_dim < 0)
error("Error while testing existance of 'Dimension' attribute");
if (hid_dim > 0) readAttribute(h_grp, "Dimension", INT, &dimension);
if (dimension != hydro_dimension)
error("ICs dimensionality (%dD) does not match code dimensionality (%dD)",
dimension, (int)hydro_dimension);
/* Read the relevant information and print status */
int flag_entropy_temp[6];
readAttribute(h_grp, "Flag_Entropy_ICs", INT, flag_entropy_temp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment