Deduce HDF5 type automatically.

Use templates to deduce the HDF5 type of an attribute automatically
in write_hdf5_attribute.