Commit a8f5af22 authored by Matthieu Schaller's avatar Matthieu Schaller

Added support for output of 'char' fields in the snapshots.

parent 33476206
......@@ -74,7 +74,7 @@ hid_t io_hdf5_type(enum IO_DATA_TYPE type) {
case DOUBLE:
return H5T_NATIVE_DOUBLE;
case CHAR:
return H5T_C_S1;
return H5T_NATIVE_CHAR;
default:
error("Unknown type");
return 0;
......
......@@ -181,6 +181,50 @@ void xmf_write_groupfooter(FILE* xmfFile, enum part_type ptype) {
part_type_names[ptype]);
}
/**
* @brief Returns the precision of a given dataset type
*/
int xmf_precision(enum IO_DATA_TYPE type) {
switch (type) {
case FLOAT:
return 4;
break;
case DOUBLE:
return 8;
break;
case ULONGLONG:
return 8;
break;
case CHAR:
return 1;
break;
default:
error("Unsupported type");
}
return 0;
}
/**
* @brief Returns the Xdmf type name of a given dataset type
*/
const char* xmf_type(enum IO_DATA_TYPE type) {
switch (type) {
case FLOAT:
case DOUBLE:
return "Float";
break;
case ULONGLONG:
return "Int";
break;
case CHAR:
return "Char";
break;
default:
error("Unsupported type");
}
return "";
}
/**
* @brief Writes the lines corresponding to an array of the HDF5 output
*
......@@ -203,13 +247,15 @@ void xmf_write_line(FILE* xmfFile, const char* fileName,
name, dim == 1 ? "Scalar" : "Vector");
if (dim == 1)
fprintf(xmfFile,
"<DataItem Dimensions=\"%zu\" NumberType=\"Double\" "
"<DataItem Dimensions=\"%zu\" NumberType=\"%s\" "
"Precision=\"%d\" Format=\"HDF\">%s:%s/%s</DataItem>\n",
N, type == FLOAT ? 4 : 8, fileName, partTypeGroupName, name);
N, xmf_type(type), xmf_precision(type), fileName, partTypeGroupName,
name);
else
fprintf(xmfFile,
"<DataItem Dimensions=\"%zu %d\" NumberType=\"Double\" "
"<DataItem Dimensions=\"%zu %d\" NumberType=\"%s\" "
"Precision=\"%d\" Format=\"HDF\">%s:%s/%s</DataItem>\n",
N, dim, type == FLOAT ? 4 : 8, fileName, partTypeGroupName, name);
N, dim, xmf_type(type), xmf_precision(type), fileName,
partTypeGroupName, name);
fprintf(xmfFile, "</Attribute>\n");
}
......@@ -91,7 +91,7 @@ int main() {
printf("\nVector Output for kernel_deval_2_vec\n");
printf("-------------\n");
/* Test vectorised kernel that uses two vectors. */
for (int i = 0; i < numPoints; i += VEC_SIZE) {
......@@ -100,7 +100,7 @@ int main() {
vector vx_2, vx_h_2;
vector W_vec_2, dW_vec_2;
for (int j = 0; j < VEC_SIZE; j++) {
vx.f[j] = (i + j) * 2.25f / numPoints;
vx_2.f[j] = (i + j) * 2.25f / numPoints;
......@@ -127,7 +127,7 @@ int main() {
return 1;
}
}
/* Check second vector results. */
for (int j = 0; j < VEC_SIZE; j++) {
printf("%2d: h= %f H= %f x=%f W(x,h)=%f dW(x,h)=%f\n", i + j, h,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment