people's expectations

Steve Kargl sgk@troutmask.apl.washington.edu
Thu Jan 17 03:28:00 GMT 2019


On Wed, Jan 16, 2019 at 06:08:05PM -0800, Jerry DeLisle wrote:
> On 1/16/19 8:21 AM, Steve Kargl wrote:
> > On Wed, Jan 16, 2019 at 09:41:32AM +0100, Manfred Schwarb wrote:
> >> Am 16.01.2019 um 01:47 schrieb Steve Kargl:
> >>> What are people's expectation for gfortran with this code:
> >>>
> >>> subroutine bar
> >>>     integer, external :: j
> >>>     read(*,*) j
> >>>     print *, j()
> >>> end subroutine bar
> >>>
> >>
> >> i would expect the very same error as for
> >>
> >>        subroutine bar
> >>        integer, external :: j
> >>        j=1
> >>        print *, j()
> >>        end subroutine bar
> >>
> >> Error: Illegal assignment to external procedure at (1)
> >>
> > 
> > Technically, it isn't an assignment.  The READ statement
> > causes an input-item to become defined.  Yes, I know it's
> > just semantics, but then again fixing the bug requires
> > following the standard.
> > 
> 
> If j is an external function as in C which takes no argument, such a 
> maybe a random number generator, shouldn't it resolve to a call of that 
> function and return a value that is printed?
> 
> Or even a fortran function I suppose.
> 
> Jerry

It's unclear which example code on which you are commenting.
In my original code, you have

  integer, external :: j
  read(*,*) j

There is no printing.  An input-item is a variable or expression. 
It is almost clear from the standard that j is not a variable, so
now one has to unwind standardese for when j can be an expression.

-- 
Steve



More information about the Fortran mailing list