- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have noticedin some example codes that integer*4 isused for variables that will always be small, such as do loop counters that will always be less than200 or parameters with values of single digits. Very rarely have I seen (or maybe I haven't been looking close enough) declarations of variables with mixed KIND. I thought this may have something to do with naturally aligning data in memory, but after reading theIVF on line user manual's sectionon aligning data Iam not sure.
Also, a related question: Is it possible to use the following as a Global variable when the rest of the Global variables (real and integer)are KIND = 4:
INTEGER(1), DIMENSION(999) :: giVariable
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
INTEGER*4, or "default integer", is used most often because it is the most efficient integer type for the processor. The examples may use *4 out of habit (really should be (4) anyway) or to protect against the user modifying the default integer kind. It doesn't have much at all to do with alignment. Integer kinds of 2 or 1 require additional instructions to process and should be used sparingly.
You certainly CAN use such a declaration if it is appropriate for your application. It doesn't matter what you mix it with. The compiler will automatically chose allocation to naturally align local variables unless you override that with EQUIVALENCE or SEQUENCE.
You certainly CAN use such a declaration if it is appropriate for your application. It doesn't matter what you mix it with. The compiler will automatically chose allocation to naturally align local variables unless you override that with EQUIVALENCE or SEQUENCE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Although the *4 notation is not supported by standard Fortran, it will work on more compilers than the (4) notation. The standard actually requires use of selected_kind syntax to find out supported KINDs for a given compiler. There is no guarantee about KIND numbers being related to storage size.
As Steve says, integer(1) and integer*1 always work with ifort, with some efficiency tradeoffs, but in general, selected_int_kind(2) would be needed to find the smallest storage KIND which accepts -99 .le. n .le. 99.
As Steve says, integer(1) and integer*1 always work with ifort, with some efficiency tradeoffs, but in general, selected_int_kind(2) would be needed to find the smallest storage KIND which accepts -99 .le. n .le. 99.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the info and explanation.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page