View Single Post
  #6  
Old October 22nd 04, 07:34 PM
Thomas McGlynn
external usenet poster
 
Posts: n/a
Default

Peter Teuben wrote:

I'm less clear about long integer support in Fortran. Fortran 90/95 I
believe does support this, but I don't recall seeing support for integer*8
in Fortran 77 (it is certainly not part of ANSI standard Fortran-77). So
this may boil down to a language divide: C/C++, Java, Fortran-90, and
probably most other new languages naturally support long integers, but
Fortran-77 doesn't.



indeed, there is no official support, since integer*8 isn't in the standard.
However, both the intel and gnu compiler support it, and I abuse this feature
(with caution). I also recall the Cray compiler used to have a flag to the
compiler that made floats become double's essentially, so something in this
direction may be implemented by compiler writers.

- peter
_______________________________________________
fitsbits mailing list

http://listmgr.cv.nrao.edu/mailman/listinfo/fitsbits



[I addressed this more briefly in a note I sent to sci.astro.fits, but
I gather that will take a while before it comes out...]

Since we're talking about standards....

The notations integer*2, integer*4 and integer*8 are all non-standard
Fortran and are not included in any of the Fortran standards F66, F77, F90, F95 or
the impending F2003. Integer*2 has never been standard Fortran.
The default (and in standard Fortran till F90 the only) integer type must occupy
the same amount of space as a single precision real.

Fortran (i.e., the standard) has no mechanism to specify the length in
bytes of the desired variable. The standard way to get different
kinds of integers is something like

integer (kind=n) i,j,k

where n is an integer. For many (but not all) compilers the kind
in used exactly the same way as in the integer*n extension,
integer(kind=4) are normal 4 byte integers. However,
it is perfectly standard to have have integer(kind=4) to be 1 byte
variable and integer(kind=303) to be 4 byte integers. There are
functions that allow one to select the kind index based upon
the desired range (and precision for reals). However the value
of these 'kinds' is implementation dependent.


So be careful trying to use 'Fortran' standards here... Fortran is
a higher level language than C or Java and has much less connection
(in the standard!) to the byte representations.
So most Fortran's do support eight byte (and two byte) integers
but the standard mechanism is rather more complex than many suppose.


Regards,
Tom McGlynn