Writes a scalar value to an HDF5 file.
Arguments:
loc_id: The group or dataset the attribute should be written to.
type_id: The datatype of the attribute.
name: The name that should be used for the attribute.
buf: The data that should be written.
Returns 0 upon success, otherwise -1.