- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is the INTEGER type a 64 bit integer by default ? I assume yes but want to be sure. Someone
suggested that its not automatically a 64bit, but I would think it is as I dont see a flag to choose otherwise.
Also what would be the point of it NOT being automatically 64 bit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
INTEGER is equivalent to INTEGER(4) on both ia32 and x86_64 architectures. INTEGER(POINTER_LEN), on the other hand, is equivalent to INTEGER(4) on ia32, and to INTEGER(8) on x86_64 ---so, it all comes down to having a range wide enough to store a memory address... which tends not to be very useful in Fortran.
The fact that the default INTEGER doesn't vary, is similar in other programming languages ---e.g., C's int is 32 bit for both ia32 ande x86_64, whereas long varies depending on both the architecture and operating system.
The relation between the number of bytes for default INTEGER and default REAL is also an important factor, but Intel certainly has flags to override it.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
INTEGER is equivalent to INTEGER(4) on both ia32 and x86_64 architectures. INTEGER(POINTER_LEN), on the other hand, is equivalent to INTEGER(4) on ia32, and to INTEGER(8) on x86_64 ---so, it all comes down to having a range wide enough to store a memory address... which tends not to be very useful in Fortran.
The fact that the default INTEGER doesn't vary, is similar in other programming languages ---e.g., C's int is 32 bit for both ia32 ande x86_64, whereas long varies depending on both the architecture and operating system.
The relation between the number of bytes for default INTEGER and default REAL is also an important factor, but Intel certainly has flags to override it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Needless to say, there have been non-Intel 64-bit platforms where default integer would be 64 bits (due to lack of efficient support for 32-bit integer), but those probably are no longer in widespread use.
As mentioned above, most Fortran compilers, including ifort, provide options to change the default data type sizes. The c_long interoperability type does change from 32 bits in ia32 mode to 64 bits in x86_64 linux, but in X64 Windows it remains 32 bits. The c_ interoperability types aren't affected by the default size command switches, which aren't present in most C compilers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May I just add a word of caution here on programming style.
Wherever possible declare the size of yourvariables within the code.
There is a project setting which allows you to change the default sizes. Unless you have a good reason to do soI would recommend that you don't use that facility. If you do use it then document it somewhere (possibly even in the code itself.) Ispent many a happy hourstaring atcode listings containingREAL
REAL X
and REAL(8) Y
specified variables of the same size.
as did
INTEGER K
and INTEGER(2) M
And yes, the debugger would have told me instantly the sizes of the variables but I was looking through a paper copy, in the days when we still had paper :-)
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page