Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

MAX,MIN,ABS,MOD functions for long integer

Adam_J_1
Beginner
1,123 Views

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

 

0 Kudos
7 Replies
TimP
Honored Contributor III
1,123 Views

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.

0 Kudos
Adam_J_1
Beginner
1,123 Views

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

0 Kudos
Steven_L_Intel1
Employee
1,123 Views

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.

0 Kudos
Adam_J_1
Beginner
1,123 Views

Thanks for info!

 

0 Kudos
Steven_L_Intel1
Employee
1,123 Views

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.

0 Kudos
Adam_J_1
Beginner
1,123 Views

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?

0 Kudos
Steven_L_Intel1
Employee
1,123 Views

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).

0 Kudos
Reply