;
; Copyright (c) 1997, Forschungszentrum Juelich GmbH ICG-1
; All rights reserved.
; Unauthorized reproduction prohibited.
; This software may be used, copied, or redistributed as long as it is not
; sold and this copyright notice is reproduced on each copy made.  This
; routine is provided as is without any express or implied warranties
; whatsoever.
;
;+
; NAME:
;  is_tag
;
; PURPOSE:
;   Test if tagname is defined
;
; CATEGORY:
;   PROG_TOOLS/STRUCTURES
;
; CALLING SEQUENCE:
;   Result=is_tag(structure,tagname)
;
; INPUTS:
;   structure:  the structure
;   tagname:    the tagname as string which should be searched in structure
;
; OUTPUTS:
;   Result will be 1 or 0
;
; KEYWORD PARAMETERS:
;   part: if is set strpos is used to find a part of a string
;
; EXAMPLE:
;   print,is_tag(inhalt,'param')
;   1
;
; MODIFICATION HISTORY:
; 	Written by:	R.Bauer (ICG-1) , Sep. 2 1996
;               F.Rohrer (ICG-3), Mai 15 1997 downgrade to idl 3.6.1
;               R.Bauer 1998-Jul-05 previously named as find_tag now renamed for better consistens
;               R.Bauer 1998-Jul-05 upgraded to idl 5.1
;               R.Bauer 1998-Nov-19 goto removed additional test of tag_name is string added
;               R.Bauer 1999-Mar-26 keyword part is added
;
;-


FUNCTION is_tag,struct,tag_name,part=part


   tagname=STRUPCASE(tag_name)

   tags=TAG_NAMES(struct)
   if keyword_set(part) then begin
   a=WHERE(strpos(tags, tagname) eq 0,count)
   if count gt 1 then message,'WARNING: count: '+strtrim(string(count),2),/info
   endif else a=WHERE(tags EQ tagname,count)

   RETURN, count
END



