cholla-hydro / cholla

A GPU-based hydro code
https://github.com/cholla-hydro/cholla/wiki
MIT License
60 stars 32 forks source link

Add a 'cholla' header attribute #278

Closed evaneschneider closed 9 months ago

evaneschneider commented 1 year ago

In order to make the yt cholla frontend more robust, it would be useful to have a header attribute in cholla output files uniquely identifying them as cholla datasets. I suggest adding the header attribute 'cholla' to achieve this purpose.

bcaddy commented 1 year ago

From personal experience, writing strings to HDF5 files is a PITA. Here's the code for it so no one has to struggle like I did

attribute_id = H5Acreate(file_id, "HEADER ATTRIBUTE NAME", stringType, dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
// STRING_TO_WRITE needs to be of type const char *. 
// There's probably a way to get that type out of a std::string with the .data() method
status = H5Awrite(attribute_id, stringType, &STRING_TO_WRITE);
H5Aclose(attribute_id);
evaneschneider commented 9 months ago

Resolved in PR #341