- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Is there any counterpart to the Fortran functions MAX,MIN,ABS,MOD which would return a long integer (integer(8)) number upon return
Thanks
Adam
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you mean the non-standard Fortran 66 style extensions like kmax0 documented in Intel Fortran User and Reference Guide? They don't extend the language beyond Fortran 90, where all f77 standard generic intrinsics work with integer(selected_real_kind(12)) (or Fortran 2008 kind=int64). These intrinsics return the same kind as their argument, regardless of whether you use the standard generic intrinsic or the non-standard "specific" one.
Intrinsics like kmax0 are vendor-specific extensions supplied only to make certain legacy applications work without source code edits. They are so rarely used that there seems little point in trying to find out which of them work with a given compiler.
If you intend to use them as "actual arguments" that might be a different story, but such usage with non-standard specific intrinsics is so rare that I wouldn't have any expectation of them working in general, even with a restriction to a certain vendor's compilers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No I was thinking of using standard functions. I see that for SIZE, UBOUND and INT function one can specify KIND parameter, I have not seen such and option for MAX, MIN, ABS, MOD and COUNT and I did not know that in Fortran 2008 it returns kind=int64 type.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Generally the generic intrinsics return the same type and kind as the argument(s). SIZE, UBOUND and INT always return integers no matter what type or kind their arguments are. Previously they always returned default integer, so we added KIND= to allow you to specify the kind you got back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for info!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A minor correction - INT always had KIND= - indeed, this is the way you could convert from one kind to the other. My comments about SIZE, UBOUND and other "inquiry" intrinsics holds. And while Intel Fortran did add KIND= to some of these earlier, by "we" I meant the Fortran standards committee.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks again for info. What happens if I pass two arguments to say MAX function with different kind - Integer and long integer. Will the MAX function choose the longer kind as a return?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That would be a violation of the standard, which requires that all the arguments have the same type and type parameters. An implementation may choose to allow this mismatch as an extension (we do).
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page