This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, fortran] PR31154 and PR31229 - use associated and imported function kind parameters
Craig Powers wrote:
> Tobias Burnus wrote:
>> module mod1
>> integer, parameter :: r8 = kind(0d0)
>> end module mod1
>>
>> real(r8) function func2()
>> use mod1, only: r8
>> func2 = 0.0_r8
>> end function func2
>
> If I remember and understand recent discussion of this point on
> comp.lang.fortran correctly, it was concluded that this usage is
> nonstandard.
Well, it is accepted by several compilers (g95, ifort, NAG f95) and if I
understood the discussion correctly, only the following is invalid
(PARAMETER defined later):
real(r8) function func2()
integer, parameter :: r8 = kind(0d0)
func2 = 0.0_r8
end function func2
This program is rejected by g95, NAG f95 and ifort on the basis that:
"A named constant shall not be referenced unless it has been defined
previously in the same statement, defined in a prior statement, or made
accessible by use or host association."
I would claim that in my first example (= example (b) in c.l.f) the
parameter is host associated and thus this example is valid.
For the full discussion, see:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/11acfc0d9e65566e/
Tobias