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

Same treatment for the parallel i/o routines.

parent 981ae243
Branches
Tags
1 merge request!201i/o conversion
...@@ -211,9 +211,25 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile, ...@@ -211,9 +211,25 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile,
if (temp == NULL) error("Unable to allocate memory for temporary buffer"); if (temp == NULL) error("Unable to allocate memory for temporary buffer");
/* Copy particle data to temporary buffer */ /* Copy particle data to temporary buffer */
char* temp_c = temp; if (props.convert_part == NULL &&
for (size_t i = 0; i < N; ++i) props.convert_gpart == NULL) { /* No conversion */
memcpy(&temp_c[i * copySize], props.field + i * props.partSize, copySize);
char* temp_c = temp;
for (size_t i = 0; i < N; ++i)
memcpy(&temp_c[i * copySize], props.field + i * props.partSize, copySize);
} else if (props.convert_part != NULL) { /* conversion (for parts)*/
float* temp_f = temp;
for (size_t i = 0; i < N; ++i)
temp_f[i] = props.convert_part(&props.parts[i]);
} else if (props.convert_gpart != NULL) { /* conversion (for gparts)*/
float* temp_f = temp;
for (size_t i = 0; i < N; ++i)
temp_f[i] = props.convert_gpart(&props.gparts[i]);
}
/* Unit conversion if necessary */ /* Unit conversion if necessary */
const double factor = const double factor =
......
...@@ -298,9 +298,25 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile, ...@@ -298,9 +298,25 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile,
if (temp == NULL) error("Unable to allocate memory for temporary buffer"); if (temp == NULL) error("Unable to allocate memory for temporary buffer");
/* Copy particle data to temporary buffer */ /* Copy particle data to temporary buffer */
char* temp_c = temp; if (props.convert_part == NULL &&
for (size_t i = 0; i < N; ++i) props.convert_gpart == NULL) { /* No conversion */
memcpy(&temp_c[i * copySize], props.field + i * props.partSize, copySize);
char* temp_c = temp;
for (size_t i = 0; i < N; ++i)
memcpy(&temp_c[i * copySize], props.field + i * props.partSize, copySize);
} else if (props.convert_part != NULL) { /* conversion (for parts)*/
float* temp_f = temp;
for (size_t i = 0; i < N; ++i)
temp_f[i] = props.convert_part(&props.parts[i]);
} else if (props.convert_gpart != NULL) { /* conversion (for gparts)*/
float* temp_f = temp;
for (size_t i = 0; i < N; ++i)
temp_f[i] = props.convert_gpart(&props.gparts[i]);
}
/* Unit conversion if necessary */ /* Unit conversion if necessary */
const double factor = const double factor =
......
...@@ -183,14 +183,19 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile, ...@@ -183,14 +183,19 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile,
/* Copy particle data to temporary buffer */ /* Copy particle data to temporary buffer */
if (props.convert_part == NULL && if (props.convert_part == NULL &&
props.convert_gpart == NULL) { /* No conversion */ props.convert_gpart == NULL) { /* No conversion */
char* temp_c = temp; char* temp_c = temp;
for (size_t i = 0; i < N; ++i) for (size_t i = 0; i < N; ++i)
memcpy(&temp_c[i * copySize], props.field + i * props.partSize, copySize); memcpy(&temp_c[i * copySize], props.field + i * props.partSize, copySize);
} else if (props.convert_part != NULL) { /* conversion (for parts)*/ } else if (props.convert_part != NULL) { /* conversion (for parts)*/
float* temp_f = temp; float* temp_f = temp;
for (size_t i = 0; i < N; ++i) for (size_t i = 0; i < N; ++i)
temp_f[i] = props.convert_part(&props.parts[i]); temp_f[i] = props.convert_part(&props.parts[i]);
} else if (props.convert_part != NULL) { /* conversion (for gparts)*/
} else if (props.convert_gpart != NULL) { /* conversion (for gparts)*/
float* temp_f = temp; float* temp_f = temp;
for (size_t i = 0; i < N; ++i) for (size_t i = 0; i < N; ++i)
temp_f[i] = props.convert_gpart(&props.gparts[i]); temp_f[i] = props.convert_gpart(&props.gparts[i]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment