C+
C NAME:
C	Str2Flt_FmtNumbers
C PURPOSE:
C	(Internal use by Str2Flt only)
C	Adds component to format string
C CALLING SEQUENCE:
	subroutine Str2Flt_FmtNumbers(Init,iFmtCnt,cFmtSub,iFmtLen)
C INPUTS:
C	iFmtCnt		integer		# numbers collected
C	cFmtSub		character*(*)	format fitting numbers
C	iFmtLen		integer		# characters in number
C OUTPUTS:
C	iFmtCnt		integer		set to zero
C SEE ALSO:
C	Str2Flt
C MODIFICATION HISTORY:
C	SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    integer	Init
	    integer	iFmtCnt
	    character	cFmtSub*(*)
	    integer	iFmtLen

	    character	cStr*(*)
	    integer	iFirst
	    integer	iLast
	    logical	bXforA

	integer		Str2Str

	character	cFmtOut*(*)
	character	cFmt*100

	parameter	(MaxCrumbs = 20)

	integer		nCrumbs
	integer		lCrumbs
	character	cCrumbs   (MaxCrumbs)*20
	character	cCrumbsOut(MaxCrumbs)*20

	save		iLenFmt, lCrumbs, nCrumbs, cFmt, cCrumbs

	if (Init .eq. 1) then
	    cFmt    = ' '
	    iLenFmt = 0				! Not really needed, I think
	    nCrumbs = 0				! # crumbs (cCrumbs(I),I=1,nCrumbs)
	    lCrumbs = 0				! total # chars in all crumbs

	    Init = 0
	end if

	I = itrim(cFmt)

	if (iFmtCnt .gt. 0) then

	    I = I+Str2Str(','    ,cFmt(I+1:))
	    if (iFmtCnt .gt. 1) I = I+Int2Str(iFmtCnt,cFmt(I+1:))
	    I = I+Str2Str(cFmtSub,cFmt(I+1:))

	    iLenFmt = iLenFmt+iFmtCnt*iFmtLen
	    iFmtCnt = 0				! Reinitialize counter

	end if

	return
C+
C NAME:
C	Str2Flt_Format
C PURPOSE:
C	Extract format set up during last call to Str2Flt
C CALLING SEQUENCE:
	entry Str2Flt_Format(cFmtOut)
C INPUTS:
C	(none)
C OUTPUTS:
C	cFmtOut		character*(*)	format fitting input string to last Str2Flt call.
C PROCEDURE:
C	Entry point in subroutine href=Str2Flt_FmtNumbers=
C MODIFICATION HISTORY:
C	DEC-1992, Paul Hick (UCSD), converted from IDL
C-
	cFmtOut = '('//cFmt(2:itrim(cFmt))//')'	! Drop leading comma from cFmt

	return
C+
C NAME:
C	Str2Flt_FmtCrumbs
C PURPOSE:
C	(Internal use by Str2Flt only)
C	Adds component to crumbs array
C CALLING SEQUENCE:
	entry Str2Flt_FmtCrumbs(Init,cStr,iFirst,iLast,bXforA)
C INPUTS:
C	Init		integer		1: initialize new crumb collection
C					0: add to collection
C	cStr		character	string
C	iFirst		integer		first char of current number
C	iLast		integer		last char of previous number
C	bXforA		logical		add X to format instead of A
C					array of crumbs
C OUTPUTS:
C SEE ALSO:
C	Str2Flt
C PROCEDURE:
C	Entry point in subroutine href=Str2Flt_FmtNumbers=
C MODIFICATION HISTORY:
C	SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	if (Init .eq. 1) then
	    cFmt = ' '				! Output format string
	    iLenFmt = 0				! Not really needed, I think
	    nCrumbs = 0				! # crumbs (cCrumbs(I),I=1,nCrumbs)
	    lCrumbs = 0				! total # chars in all crumbs

	    Init = 0
	end if

	I = itrim(cFmt)

	iLen = iFirst-iLast-1			! # chars not in number

	if (iLen .gt. 0) then

	    if (bXforA) then			! Add '#X' to format string
		I = I+Str2Str(',' ,cFmt(I+1:))
		I = I+Int2Str(iLen,cFmt(I+1:))
		I = I+Str2Str('X' ,cFmt(I+1:))
	    else				! Add 'A#' to format string
		I = I+Str2Str(',A',cFmt(I+1:))
		I = I+Int2Str(iLen,cFmt(I+1:))
	    end if

	    nCrumbs = nCrumbs+1
	    lCrumbs = lCrumbs+iLen
	    if (nCrumbs .le. MaxCrumbs) cCrumbs(nCrumbs) = cStr(iLast+1:iFirst-1)

	end if

	iLast = iFirst-1

	return
C+
C NAME:
C	Str2Flt_Crumbs
C PURPOSE:
C	Extract parts of cStr that did not fit into any numbers
C CALLING SEQUENCE:
	entry Str2Flt_Crumbs(lCrumbsOut,nCrumbsOut,cCrumbsOut)
C INPUTS:
C	nCrumbs		integer		max # crumbs to be retrieved
C OUTPUTS:
C	nCrumbs		integer		# crumbs in cStr
C	cCrumbs		character(20)*20values of all crumbs in cStr
C	cCrumbs		integer		total length of all crumbs
C PROCEDURE:
C	Entry point in subroutine href=Str2Flt_FmtNumbers=
C
C	All substrings in cStr that can not be interpreted as part of a
C	valid number are stored in a string array.
C	This subroutine extracts this array. See href=Str2Flt=
C MODIFICATION HISTORY:
C	DEC-1992, Paul Hick (UCSD), converted from IDL
C-
	lCrumbsOut = lCrumbs
	nCrumbsOut = min(nCrumbsOut,nCrumbs)
	do iStr=1,nCrumbsOut
	    cCrumbsOut(iStr) = cCrumbs(iStr)
	end do

	return
	end
