On Sat, 05 Dec 2009 16:33:42 PST, "Tomas L. Byrnes" said: > Yes, and it you look at the real to integer, and integer to real, > assignments without conversion functions, you can see where the actual > assignment may be indeterminate. I don't have the datasets, and haven't > done Fortran since F77, but when I did Fortran, assignment without type > conversion produced unpredictable results. Specifically, in little > endian machines, assigning a real to an integer was a very workable > random number generator.
Admittedly, when I was doing Fortran IV, it was on a big-endian machine, but I don't remember real->int being a big problem. So I whomped up a quick test: % cat ftest.f program main dimension a(10) data a /1.0, 5.0, 10.0, 11938.0, -45.7, 9.2, 4.3, -99934.2, $ 1.0, 0.0/ do 20 i = 1, 10 j = a(i) write(6,10) i, j, a(i) 10 format(' ',i6, ' ',i6,' ', f9.2) 20 continue stop end % gfortran ftest.f % ./a.out 1 1 1.00 2 5 5.00 3 10 10.00 4 11938 11938.00 5 -45 -45.70 6 9 9.20 7 4 4.30 8 -99934 -99934.20 9 1 1.00 10 0 0.00 Nope, doesn't look like a random number generator to me... Tried with 'REAL*8 A(10)' and that didn't change the output at all. Nor did compiling for 32 or 64 bit make a difference, and this is on an Intel Core2, which is most certainly little-endian. Now mind you, if you started doing type punning in Fortran (i.e. something like this: subroutine z1 common /foo/ i(20) C i is implicitly an integer*4 end subroutine z2 common /foo/ a(20) C but here the same storage is implicit real*4 end you're in for trouble. But you do that in *any* language and you're in for trouble.
pgpfwtxsD2y7V.pgp
Description: PGP signature
_______________________________________________ Fun and Misc security discussion for OT posts. https://linuxbox.org/cgi-bin/mailman/listinfo/funsec Note: funsec is a public and open mailing list.