;-------------------------------------------------------------
;+
; NAME:
;        ROUTINE_NAME  (function)
;
; PURPOSE:
;        return the name of the routine which calls this function.
;
; CATEGORY
;        Tools
;
; CALLING SEQUENCE:
;        rname = ROUTINE_NAME()
;
; INPUTS:
;        none
;
; KEYWORD PARAMETERS:
;        none
;
; OUTPUTS:
;        The name of the caller routine is returned in lowercase
;        characters (can be used to construct a filename by adding
;        ".pro")
;
; SUBROUTINES:
;
; REQUIREMENTS:
;
; NOTES:
;
; EXAMPLE:
;        From the command line:
;             print,routine_name()
;        results in   $main$
;
;        Very useful in conjunction with USAGE.PRO:
;             usage,routine_name()
;        displays help information on the current routine.
;
; MODIFICATION HISTORY:
;        mgs, 27 Mar 1998: VERSION 1.00
;
;-
; Copyright (C) 1998, Martin Schultz, Harvard University
; This software is provided as is without any warranty
; whatsoever. It may be freely used, copied or distributed
; for non-commercial purposes. This copyright notice must be
; kept with any copy of this software. If this software shall
; be used commercially or sold as part of a larger package,
; please contact the author to arrange payment.
; Bugs and comments should be directed to mgs@io.harvard.edu
; with subject "IDL routine routine_name"
;-------------------------------------------------------------


function routine_name
 
   ; extract the name of the current routine from the caller stack
   ; the first element will always be ROUTINE_NAME ;-)
   help,call=c
 
   thisroutine = str_sep(c(1)," ")
   
 
return,strlowcase(thisroutine(0))
end
 

