[SciPy-User] writing data to binary for fortran

Gideon gideon.simpson at gmail.com
Wed May 12 18:05:55 EDT 2010


Yea, that worked for me on my OS X machine.  Thanks so much.

To be honest, in the 10 years I've been doing floating point
calculations for ODEs and PDEs, I don't think I've ever used single
precision arithmetic. So I am surprised it doesn't default to double
precision.  Obviously, different people have different needs.

On May 12, 4:21 pm, Neil Martinsen-Burrell <n... at wartburg.edu> wrote:
> On 2010-05-12 14:58, Gideon wrote:
>
> > Tried both, but I got the same error in both cases.
>
> If you want doubles in your file, you have to request them:
>
> F.writeReals(x, prec='d')
>
> makes everything work for me (Ubuntu 10.04, python 2.6.5, gfortran
> 4.4.3).  Note that looking at the size of the file that you would expect
> to have for the data you are expecting to read would have demonstrated
> this: 10 doubles at eight bytes per double plus two 4-byte integers
> would have given you 88 bytes for the file, rather than the 48 that were
> being produced.
>
> I use fortranfile most heavily for reading files, rather than writing
> them, so I may have missed this opportunity, but do you think that the
> precision used in writeReals should be auto-detected from the data type
> that it is passed.  That is, would
>
> def writeReals(self, reals, prec=None):
>      if prec is None:
>          prec = reals.dtype.char
>      ...
>
> be better for your use?  That would have made your original code work as
> written.
>
> -Neil
> _______________________________________________
> SciPy-User mailing list
> SciPy-U... at scipy.orghttp://mail.scipy.org/mailman/listinfo/scipy-user
>
> --
> You received this message because you are subscribed to the Google Groups "SciPy-user" group.
> To post to this group, send email to scipy-user at googlegroups.com.
> To unsubscribe from this group, send email to scipy-user+unsubscribe at googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/scipy-user?hl=en.



More information about the SciPy-User mailing list