Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Clive Page <junk@xxxxxxxxxxxx>
- Date: Tue, 30 Jan 2007 21:33:56 +0000
Thanks to all of you who responded. I take the point made so forcefully by Richard Maine that the type definitions and specialised I/O routines need to be encapsulated in a module. I didn't mention this as I'd taken it as read, and my posting was already rather long.
Actually the encapsulation is a little less straight-forward it one has to include the run-time checks with BIT_SIZE that I put forward in my option (D), but on reflection perhaps this is just a bit over the top. The listing of current compiler properties on the very valuable website of Messrs Polyhedron shows that *every* compiler listed there supports both 8-bit and 16-bit integer types.
I'd also like to thank Arjen Markus for his clever coding of run-time checks for the desired sizes, which are certainly better than a run-time check.
The other topic I deliberately did not mention is that of endian differences, which can be a problem when using multi-byte integers. However with a single-byte data type I've always found it quite hard to distinguish between big-endian and little-endian systems, for some reason. :-)
The conclusion I've drawn is that one ought to use SELECTED_INT_KIND for portability, and that this should work on every current Fortran system.
The main drawback is that it looks a bit cumbersome and the meaning is not all that obvious - but even so not too difficult to explain.
Now to a more difficult topic: how to get the effect of LOGICAL*1 in the absence of a SELECTED_LOGICAL_KIND function? :-)
--
Clive Page
.
- Follow-Ups:
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Paul van Delst
- Re: Declaration to get 8-bit (or 16-bit) integer?
- References:
- Declaration to get 8-bit (or 16-bit) integer?
- From: Clive Page
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Terence
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Richard E Maine
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: glen herrmannsfeldt
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Richard Maine
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Gordon Sande
- Declaration to get 8-bit (or 16-bit) integer?
- Prev by Date: Re: F77 -> F95 Intro Presentation Material
- Next by Date: Re: F77 -> F95 Intro Presentation Material
- Previous by thread: Re: Declaration to get 8-bit (or 16-bit) integer?
- Next by thread: Re: Declaration to get 8-bit (or 16-bit) integer?
- Index(es):