gandalfcode / gandalf

GANDALF (Graphical Astrophysics code for N-body Dynamics And Lagrangian Fluids)
GNU General Public License v2.0
44 stars 12 forks source link

Problem reading iorig with double precision python snap #153

Open rbooth200 opened 7 years ago

rbooth200 commented 7 years ago

Currently the code to read iorig in python assumes we are using a 32bit float, but this can now be double precision depending on the compilation options. I think this needs to be fixed at both ends.

In c++ we probably need to cast to an int of the right size before reinterpretting it as a float, and in python we need to detect the itemsize of the float and use that to generate the int. Otherwise we could implement an actual int type data transfer...

giovanni-rosotti commented 7 years ago

iorig is an int. Is there any machine where an int is 64 bit?

On Tue, Jun 13, 2017 at 2:01 PM, Richard Booth notifications@github.com wrote:

Currently the code to read iorig in python assumes we are using a 32bit float, but this can now be double precision depending on the compilation options. I think this needs to be fixed at both ends.

In c++ we probably need to cast to an int of the right size before reinterpretting it as a float, and in python we need to detect the itemsize of the float and use that to generate the int. Otherwise we could implement an actual int type data transfer...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gandalfcode/gandalf/issues/153, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdSguFIe-i6twLwc-WTEjyO1E-6OSJOks5sDnoKgaJpZM4N4Yzp .

rbooth200 commented 7 years ago

Sure, but we copy reinterpret it as either a 32 or 64 bit floating point number...

On Tue, 13 Jun 2017, 14:53 giovanni-rosotti, notifications@github.com wrote:

iorig is an int. Is there any machine where an int is 64 bit?

On Tue, Jun 13, 2017 at 2:01 PM, Richard Booth notifications@github.com wrote:

Currently the code to read iorig in python assumes we are using a 32bit float, but this can now be double precision depending on the compilation options. I think this needs to be fixed at both ends.

In c++ we probably need to cast to an int of the right size before reinterpretting it as a float, and in python we need to detect the itemsize of the float and use that to generate the int. Otherwise we could implement an actual int type data transfer...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gandalfcode/gandalf/issues/153, or mute the thread < https://github.com/notifications/unsubscribe-auth/ABdSguFIe-i6twLwc-WTEjyO1E-6OSJOks5sDnoKgaJpZM4N4Yzp

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gandalfcode/gandalf/issues/153#issuecomment-308106016, or mute the thread https://github.com/notifications/unsubscribe-auth/AOqItKjIkFkHcxMAF542xpYdR-2C-Ztjks5sDoZlgaJpZM4N4Yzp .

giovanni-rosotti commented 7 years ago

ah ah, it didn't occur to me. yes it means that when using double precision outputs we get back double the number of iorigs, half which are the correct ones and half which are zero...

On Tue, Jun 13, 2017 at 3:06 PM, Richard Booth notifications@github.com wrote:

Sure, but we copy reinterpret it as either a 32 or 64 bit floating point number...

On Tue, 13 Jun 2017, 14:53 giovanni-rosotti, notifications@github.com wrote:

iorig is an int. Is there any machine where an int is 64 bit?

On Tue, Jun 13, 2017 at 2:01 PM, Richard Booth <notifications@github.com

wrote:

Currently the code to read iorig in python assumes we are using a 32bit float, but this can now be double precision depending on the compilation options. I think this needs to be fixed at both ends.

In c++ we probably need to cast to an int of the right size before reinterpretting it as a float, and in python we need to detect the itemsize of the float and use that to generate the int. Otherwise we could implement an actual int type data transfer...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gandalfcode/gandalf/issues/153, or mute the thread < https://github.com/notifications/unsubscribe-auth/ABdSguFIe-i6twLwc- WTEjyO1E-6OSJOks5sDnoKgaJpZM4N4Yzp

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gandalfcode/gandalf/issues/ 153#issuecomment-308106016, or mute the thread https://github.com/notifications/unsubscribe-auth/ AOqItKjIkFkHcxMAF542xpYdR-2C-Ztjks5sDoZlgaJpZM4N4Yzp .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gandalfcode/gandalf/issues/153#issuecomment-308109378, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdSgvE7tl-bcWaav7g6z28PhVXe15HZks5sDoldgaJpZM4N4Yzp .