Commit 4b2e3c09 authored by incardon's avatar incardon

Disable MPI writer on single core

parent b3fee8bc
...@@ -158,6 +158,76 @@ public: ...@@ -158,6 +158,76 @@ public:
H5Fclose(file); H5Fclose(file);
} }
/*! \brief Return the equivalent HDF5 type for T
*
* \return The HDF5 type equivalent to T
*
*/
template<typename T>
hid_t getType()
{
if (std::is_same<T,float>::value)
{return H5T_IEEE_F32LE;}
else if (std::is_same<T,double>::value)
{return H5T_IEEE_F64LE;}
else if (std::is_same<T,char>::value || std::is_same<T,unsigned char>::value)
{return H5T_STD_I8LE;}
else if (std::is_same<T,short>::value || std::is_same<T,unsigned short>::value)
{return H5T_STD_I16LE;}
else if (std::is_same<T,int>::value || std::is_same<T,unsigned int>::value)
{return H5T_STD_I32LE;}
else if (std::is_same<T,long int>::value || std::is_same<T,unsigned long int>::value)
{return H5T_STD_I64LE;}
}
/*! \brief It add an attribute to an already opened file
*
* \param dataset_id dataset_id
* \param name_ name of the attribute
* \param att_ attribute value
*/
template<typename value_type>
void addAttributeHDF5(hid_t dataset_id, std::string name_, value_type att_)
{
//create the data space for the scalar attibute
hid_t dataspace_id = H5Screate(H5S_SCALAR);
//create the dataset attribute (H5T_IEEE_F64BE: 64-bit float little endian)
hid_t attribute_id = H5Acreate2(dataset_id, name_.c_str(), H5T_IEEE_F32LE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
//write the attibute data
herr_t status = H5Awrite(attribute_id,H5T_NATIVE_DOUBLE, &att_);
//close the attribute
status = H5Aclose(attribute_id);
//close the dataspace
status = H5Sclose(dataspace_id);
}
/*! \brief It add an attribute to an already opened file
*
* \param dataset_id dataset_id
* \param name_ name of the attribute
* \param att_ attribute value
*/
template<typename value_type>
void addAttributeHDF5(std::string filename, std::string name_, value_type att_)
{
Vcluster<> & v_cl = create_vcluster();
MPI_Comm comm = v_cl.getMPIComm();
MPI_Info info = MPI_INFO_NULL;
// Set up file access property list with parallel I/O access
hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS);
hid_t file_id = H5Fopen(filename.c_str(),H5F_ACC_RDWR, plist_id);
hid_t dataset_id = H5Dopen2(file_id,"/vector_dist", H5P_DEFAULT);
addAttributeHDF5(dataset_id,name_.c_str(),att_);
//close the dataset
herr_t status = H5Dclose(dataset_id);
//close the file
status = H5Fclose(file_id);
}
}; };
......
...@@ -41,9 +41,9 @@ template <typename T> std::string getType() ...@@ -41,9 +41,9 @@ template <typename T> std::string getType()
else if (typeid(T) == typeid(unsigned int)) else if (typeid(T) == typeid(unsigned int))
return "unsigned_int"; return "unsigned_int";
else if (typeid(T) == typeid(long int)) else if (typeid(T) == typeid(long int))
return "long"; return "int";
else if (typeid(T) == typeid(unsigned long int)) else if (typeid(T) == typeid(unsigned long int))
return "unsigned_long"; return "unsigned_int";
else if (typeid(T) == typeid(bool)) else if (typeid(T) == typeid(bool))
return "bit"; return "bit";
...@@ -114,7 +114,14 @@ class VTKWriter ...@@ -114,7 +114,14 @@ class VTKWriter
#include "VTKWriter_vector_box.hpp" #include "VTKWriter_vector_box.hpp"
#include "VTKWriter_grids.hpp" #include "VTKWriter_grids.hpp"
#include "VTKWriter_grids_st.hpp" #include "VTKWriter_grids_st.hpp"
// This is only active if MPI compiler work
#ifndef DISABLE_MPI_WRITTERS
#include "VTKWriter_dist_graph.hpp" #include "VTKWriter_dist_graph.hpp"
#endif
#include "VTKWriter_point_set.hpp" #include "VTKWriter_point_set.hpp"
#endif /* VTKWRITER_HPP_ */ #endif /* VTKWRITER_HPP_ */
...@@ -309,13 +309,11 @@ struct meta_prop<I, ele_g,St,T[N1],is_writable> ...@@ -309,13 +309,11 @@ struct meta_prop<I, ele_g,St,T[N1],is_writable>
{ {
// Print the properties // Print the properties
for (size_t i1 = 0 ; i1 < N1 ; i1++) for (size_t i1 = 0 ; i1 < N1 ; i1++)
{ {v_out += std::to_string(vg.get(k).g.get_o(it.get()).template get<I::value>()[i1]) + " ";}
v_out += std::to_string(vg.get(k).g.get_o(it.get()).template get<I::value>()[i1]) + " ";
}
if (N1 == 2) if (N1 == 2)
{ {v_out += "0.0";}
v_out += "0.0";
}
v_out += "\n"; v_out += "\n";
} }
else else
...@@ -342,7 +340,7 @@ struct meta_prop<I, ele_g,St,T[N1],is_writable> ...@@ -342,7 +340,7 @@ struct meta_prop<I, ele_g,St,T[N1],is_writable>
} }
} }
if (ft == file_type::BINARY) if (ft == file_type::BINARY)
v_out += "\n"; {v_out += "\n";}
} }
} }
}; };
...@@ -466,7 +464,7 @@ template<unsigned int dims,typename T> inline void output_point(Point<dims,T> & ...@@ -466,7 +464,7 @@ template<unsigned int dims,typename T> inline void output_point(Point<dims,T> &
inline void output_vertex(size_t k,std::string & v_out, file_type ft) inline void output_vertex(size_t k,std::string & v_out, file_type ft)
{ {
if (ft == file_type::ASCII) if (ft == file_type::ASCII)
v_out += "1 " + std::to_string(k) + "\n"; {v_out += "1 " + std::to_string(k) + "\n";}
else else
{ {
int tmp; int tmp;
......
...@@ -239,9 +239,9 @@ class VTKWriter<pair,VECTOR_POINTS> ...@@ -239,9 +239,9 @@ class VTKWriter<pair,VECTOR_POINTS>
// write the number of vertex // write the number of vertex
if (ft == file_type::ASCII) if (ft == file_type::ASCII)
v_out += "POINTS " + std::to_string(get_total()) + " float" + "\n"; {v_out += "POINTS " + std::to_string(get_total()) + " float" + "\n";}
else else
v_out += "POINTS " + std::to_string(get_total()) + " " + getType<typename pair::first::value_type::coord_type>() + "\n"; {v_out += "POINTS " + std::to_string(get_total()) + " " + getType<typename pair::first::value_type::coord_type>() + "\n";}
// return the vertex properties string // return the vertex properties string
return v_out; return v_out;
...@@ -317,7 +317,7 @@ class VTKWriter<pair,VECTOR_POINTS> ...@@ -317,7 +317,7 @@ class VTKWriter<pair,VECTOR_POINTS>
//! In case of binary we have to add a new line at the end of the list //! In case of binary we have to add a new line at the end of the list
if (ft == file_type::BINARY) if (ft == file_type::BINARY)
v_out += "\n"; {v_out += "\n";}
// return the vertex list // return the vertex list
return v_out; return v_out;
...@@ -433,9 +433,9 @@ public: ...@@ -433,9 +433,9 @@ public:
prop_out_v< ele_vpp<typename pair::second>, typename pair::first::value_type::coord_type> pp(point_data, vpp, prop_names,ft); prop_out_v< ele_vpp<typename pair::second>, typename pair::first::value_type::coord_type> pp(point_data, vpp, prop_names,ft);
if (prp == -1) if (prp == -1)
boost::mpl::for_each< boost::mpl::range_c<int,0, pair::second::value_type::max_prop> >(pp); {boost::mpl::for_each< boost::mpl::range_c<int,0, pair::second::value_type::max_prop> >(pp);}
else else
boost::mpl::for_each< boost::mpl::range_c<int,prp, prp> >(pp); {boost::mpl::for_each< boost::mpl::range_c<int,prp, prp> >(pp);}
// Add the last property // Add the last property
pp.lastProp(); pp.lastProp();
......
...@@ -664,8 +664,8 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_grids) ...@@ -664,8 +664,8 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_grids)
Box<1,size_t> d1({1},{14}); Box<1,size_t> d1({1},{14});
// Create box grids // Create box grids
Point<1,float> offset2({5.0,7.0}); Point<1,float> offset2({5.0});
Point<1,float> spacing2({0.2,0.1}); Point<1,float> spacing2({0.2});
Box<1,size_t> d2({2},{13}); Box<1,size_t> d2({2},{13});
// Create box grids // Create box grids
......
...@@ -33,7 +33,7 @@ T swap_endian_lt(T u) ...@@ -33,7 +33,7 @@ T swap_endian_lt(T u)
source.u = u; source.u = u;
for (size_t k = 0; k < sizeof(T); k++) for (size_t k = 0; k < sizeof(T); k++)
dest.u8[k] = source.u8[sizeof(T) - k - 1]; {dest.u8[k] = source.u8[sizeof(T) - k - 1];}
return dest.u; return dest.u;
} }
......
...@@ -200,7 +200,7 @@ struct is_vtk_writable<unsigned int> ...@@ -200,7 +200,7 @@ struct is_vtk_writable<unsigned int>
template<> template<>
struct is_vtk_writable<long int> struct is_vtk_writable<long int>
{ {
typedef long base; typedef int base;
//! long int is vtk writable //! long int is vtk writable
enum enum
...@@ -213,7 +213,7 @@ struct is_vtk_writable<long int> ...@@ -213,7 +213,7 @@ struct is_vtk_writable<long int>
template<> template<>
struct is_vtk_writable<unsigned long int> struct is_vtk_writable<unsigned long int>
{ {
typedef unsigned long base; typedef unsigned int base;
//! unsigned long int is vtk writable //! unsigned long int is vtk writable
enum enum
......
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