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

F-95-standard: functions inside specification expressions

forall
Beginner
457 Views
The F-95 standard requires that functions appearing in specification expressions should return scalar integer results.

but since many F-95 intrinsic functions, such as count(), can return scalars or arrays depending on their arguments (eg, count(x,dim=1)), this can be a bit difficult to check.

Eg, is the function below fully compliant?

============
pure function tfunc(mask)
implicit none
logical,intent(in)::mask(:)
integer,dimension(count(mask))::tfunc
....
==============

the specification expression is always scalar in this specific case, but what about

============
pure function tfunc(mask)
implicit none
logical,intent(in)::mask(:,:)
integer,dimension(count(mask))::tfunc
....
==============

where the result of count is scalar only because the dim argument is omitted...

thanks in advance for any clarification of this,
dmitri
0 Kudos
2 Replies
Steven_L_Intel1
Employee
457 Views
The first function is fully compliant.

The second one is too because DIM is omitted. You know that. If you add DIM then it would not be compliant and our compiler complains. I don't see why this is "hard to check". The compiler always knows what the rank of MASK is. If MASK is rank 1, then DIM is ok to be specified, otherwise it is not.

It would be truly hard if DIM in this case was allowed to be a dummy argument that is OPTIONAL (a general concept that has given us fits in the past), but this combination is prohibited in a specification expression.
0 Kudos
forall
Beginner
457 Views
thanks for the fast replies Steve. Indeed I used "a bit difficult" rather than "difficult" since, being unfamiliar with compiler writing, I dont know whether these kind of checks are trivial/routine in compiler language. Clearly this other compiler I tried using found it difficult enough ... thankfully the intel compiler does this correctly and (presumably) easily :-).
0 Kudos
Reply