[comp.lang.fortran] entry statements

trh@eagle.ukc.ac.uk (T.R.Hopkins) (01/28/88)

I want to be able to refer to an external function by two
different names without the overhead of duplicated code.

The following seems to work on all compilers I've tried

      REAL FUNCTION NAME1(arg list)
      REAL NAME2
      ENTRY NAME2(same arg list as name1)
      .
      .
      .
      NAME1 = result
      END

i.e. nowhere do I assign a value to NAME2. Is this legal Fortran 77?
I've had a good look through the standard but can't find a ruling
either way. Only section 18.2.2 looks sort of hopeful.

Can anyone give me chapter and verse either way please?

firth@sei.cmu.edu (Robert Firth) (01/28/88)

In article <4266@eagle.ukc.ac.uk> trh@eagle.ukc.ac.uk (T.R.Hopkins) writes:
>I want to be able to refer to an external function by two
>different names without the overhead of duplicated code.
>
>The following seems to work on all compilers I've tried

      REAL FUNCTION NAME1(arg list)
      REAL NAME2
      ENTRY NAME2(same arg list as name1)
      .
      .
      .
      NAME1 = result
      END

>i.e. nowhere do I assign a value to NAME2. Is this legal Fortran 77?

Yes.  See ANSI X3.9-1978 15.5.1

	"The symbolic name of a function subprogram OR an
	 associated entry name of the same type... must become
	 defined..."

In other words, you may indifferently assign to either NAME1 or NAME2.

bct@its63b.ed.ac.uk (B Tompsett) (01/28/88)

In article <4266@eagle.ukc.ac.uk> trh@eagle.ukc.ac.uk (T.R.Hopkins) writes:
>Can anyone give me chapter and verse either way please?

 ANSI X3.9-1978, 17.1.3 Association of Entities, Page 17-2, Lines 7-10:

 "In a function subprogram, an ENTRY statement causes the entry name to
become assocated with the name of the function subprogram which appears
in the FUNCTION statement. "

-- 
> Brian Tompsett. Department of Computer Science, University of Edinburgh,
> JCMB, The King's Buildings, Mayfield Road, EDINBURGH, EH9 3JZ, Scotland, U.K.
> Telephone:         +44 31 667 1081 x2711.
> JANET:  bct@uk.ac.ed.ecsvax  ARPA: bct%ed.ecsvax@nss.cs.ucl.ac.uk
> USENET: bct@ecsvax.ed.ac.uk  UUCP: ...!mcvax!ukc!ed.ecsvax!bct
> BITNET: ukacrl.earn!ed.ecsvax!bct or bct%ed.ecsvax@uk.ac