Anton,
I agree, my understanding too is both forms are allowed. And it's
been accepted as such by the Fortran team at one of the compiler
vendors at least and bug resolution tickets have long been filed with
them; users are awaiting resolution. Note this same compiler fails
also with a simpler variant of the code you show:
module m
integer, parameter :: ik = selected_int_kind( 8 )
interface
integer( kind=ik ) module function f()
end function f
end interface
end module m
and the workaround is the second form you show, or at an equivalent
one with the RESULT keyword:
module m
integer, parameter :: ik = selected_int_kind( 8 )
interface
module function f() result( r )
integer( kind=ik ) :: r
end function f
end interface
end module m
Regards,
Vipul Parekh<div class="gmail_extra"><br><div class="gmail_quote">On
Thu, Mar 8, 2018 at 11:06 AM, Anton Shterenlikht <span
dir="ltr"><<a href="mailto:[log in to unmask]"
target="_blank">[log in to unmask]</a>></span>
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">2 out of 3 compilers
reject this:<br>
<br>
module m<br>
implicit none<br>
integer, parameter :: iarr = selected_int_kind( 8 )<br>
interface<br>
integer( kind=iarr ) module function f( space )<br>
! module function f( space )<br>
integer( kind=iarr ), intent(in), allocatable ::
space(:,:,:) [:,:,:]<br>
! integer( kind=iarr ) :: f<br>
end function f<br>
end interface<br>
end module m<br>
<br>
claiming that "iarr" is not a constant:<br>
<br>
1) "IARR" is used in a constant expression, therefore it must be a constant.<br>
2) A kind type parameter must be a compile-time constant. [IARR]<br>
<br>
Changing the declaration to:<br>
<br>
module m<br>
implicit none<br>
integer, parameter :: iarr = selected_int_kind( 8 )<br>
interface<br>
! integer( kind=iarr ) module function f( space )<br>
module function f( space )<br>
integer( kind=iarr ), intent(in), allocatable ::
space(:,:,:) [:,:,:]<br>
integer( kind=iarr ) :: f<br>
end function f<br>
end interface<br>
end module m<br>
<br>
makes all 3 compilers happy.<br>
<br>
I think both forms are allowed,<br>
or have I missed something?<br>
<span class="HOEnZb"><font color="#888888"><br>
Anton<br>
</font></span></blockquote></div><br></div>
|