Path: utzoo!utgpu!watmath!att!pacbell!ames!bionet!agate!root
From: jerry@violet.berkeley.edu ( Jerry Berkman )
Newsgroups: comp.lang.fortran
Subject: Scope of intrinsics
Message-ID: <1989Aug8.232014.9265@agate.berkeley.edu>
Date: 8 Aug 89 23:20:14 GMT
Reply-To: jerry@violet.berkeley.edu ( Jerry Berkman )
Organization: University of California, Berkeley
Lines: 41

According to the 1977 standard, pages 18-1 & 18-2, the symbolic
name of an external function is a global entity while the
symbolic name of an intrinsic function is a local entity.
And according to section 18.1.2:

	"a symbolic name that identifies a local entity may,
	 in a different program unit, identify an entity of
	 any class that is either local to that program unit
	 or global to the executable program."

Given that background, I expect the following program to print a 4 and a 2:

     intrinsic index
     character str*10
     str = 'abcdefghij'
     print *, index(str,'d')
     call sub(str)
     end

     subroutine sub(str)
     character str*(*)
     external index
     print *, index(str,'d')
     end

     function index(str,ch)
     character str*(*), ch*1
     index = 2
     end

It does using 4.3 BSD f77 on a VAX or DEC's VMS FORTRAN compiler.
However IBM's VS FORTRAN and Cray's CFT77 issue a warning during loading
and then print a 2 followed by a 2!  I.e. they do not distinguish the
intrinsic from the external!

This came up because I was trying to install the "generic UNIX" version
of NAG's help facility, which has a block data named "index" in one
program and a main program named "index" in another program, and things
just weren't working ...
	- Jerry Berkman, U.C.Berkeley
	  jerry@violet.berkeley.edu