Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-lcc!styx!ptsfa!ihnp4!ihlpa!normt From: normt@ihlpa.ATT.COM (N. R Tiedemann) Newsgroups: comp.lang.fortran Subject: Re: Can a subroutine find the name of the calling routine? Message-ID: <3800@ihlpa.ATT.COM> Date: Fri, 1-May-87 10:42:40 EDT Article-I.D.: ihlpa.3800 Posted: Fri May 1 10:42:40 1987 Date-Received: Sun, 3-May-87 01:00:27 EDT References: <13160003@acf4.UUCP> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 23 In article <13160003@acf4.UUCP>, woo@acf4.UUCP (Alex C. Woo) writes: > Is there anything comparable to getarg and iargc for subroutines > or functions? How can a function determine the name of the function > which calls it or the number of calling arguments, either in C > or f77? > Alex Woo I'm not sure if this is standard or a specific implementation, but f77 on DEC machines uses a general purpose register (r5) as the argument pointer for both function and subroutine calls. The first thing on this list is the number of argument, then the address of each. The only real different between a function and subroutine in fortran is a function returns its value in r0. (again the r0 may be DEC specific.) I don't think there is any way to determine the calling function short of looking at the return address on the stack and comparing that to the loader map file, to see in which function that address lies. Not something to do in code. Hope this helps a little Norm Tiedemann ihnp4!ihlpa!normt AT&T Bell Labs Naperville, IL 60566