read: add input dataset validation and buffering
with GCC-10 and -O3 on Windows, under certain conditions it was observed that reading datasets with implied type coercion would fail by giving random data, changing run to run of the same program/data. This was observed on scalars only.
To solve this issue and add general robustness to reading, we now get the dataset type from disk and compare it with the variable datatype, raising an error if the variable type and size do not match the dataset type and size.