- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a question regarding the use of integers of different kind. I am using a library (Intel MKL) which requires INTEGER(4). However, calling this library with variables of kind INTEGER(8) produces identical results.
I have also tested this myself by calling my own method taking an INTEGER(4) with an INTEGER(8).
However, the other way around does not work: calling a method taking an INTEGER(8) with an INTEGER(4).
Is this behavior guaranteed with Intel Fortran?
Jens
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apparently the routine you are calling does not have an explicit interface (via a module for instance), otherwise I would have expected the compiler to complain about the mismatch. The problem with passing an INTEGER(8) variable where an INTEGER(4) variable is expected is that this works by coincidence only. It would go wrong if you were to pass an array: the four extra bytes in the INTEGER(8) variable are now interpreted as the second element of the INTEGER(4) array.
So: do not do that!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, in this case there is no explicit interface.
I was just looking for a logical explanation to why I see this behavior - thanks.
Jens
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>> I am using a library (Intel MKL) which requires INTEGER(4). However, calling this library with variables of kind INTEGER(8) produces identical results.
If the argument was INTENT(IN) .AND. the value was less than (+/-) 2G, then it may work... but fix your code, and use the MKL module defined interfaces.
If the argument was INTENT(OUT) .OR. INTENT(INOUT), then for the IN portion of the call see above, but for the out portion of the call the 4 bytes of the most significant bytes of your supplied arguments would remain unchanged. Example, if you pass in an argument of less than +2G, you would not be able to receive a result of -nn.
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page