C+ C NAME: C ForeignArgFind C PURPOSE: C Check keyword arguments for consistency C (internal use only) C CALLING SEQUENCE: subroutine ForeignArgFind(id,cStr,cName,i,k) C INPUTS: C id integer if id=0 search for keyword followed C by equal sign. C if id=1 search for keyword alone C cStr*(*) character full list of keywords C cName*(*) character keyword to search for C OUTPUTS: C i integer location in cStr where cName C (possibly abbreviated) was C found. i=0 if keyword cName was C not found. C k integer if cName was found (i NOT equal zero) C this is the position in cStr after the C (possibly abbreviated) keyword cName C For id=0 it is the position after the C equal sign. C INCLUDE: include 'filparts.h' include 'dirspec.h' C CALLS: C itrim, LocFirst, Say C PROCEDURE: C If the keyword (or one of its abbreviations is found, but is not C unique then the program is aborted. C MODIFICATION HISTORY: C FEB-2005, Paul Hick (UCSD/CASS) C JUN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Added documentation. C- integer id character cStr *(*) character cName*(*) character c*(FIL__LENGTH) ! Check the string cStr for occurrences of - ! First check for the full name; if not found start ! dropping last char and look for abbreviated keyword. ! E.g. if cName='keyword' then search for ! -keyword ! -keywor ! -keywo ! -keyw ! -key ! until a match is found or until nothing is left to ! search for. For id=0 add a trailing equal sign. j = itrim(cName) ! Start search for full name i = 0 do while (j .gt. 0 .and. i .eq. 0) c = cSwitch(:iSwitch)//cName(:j) k = iSwitch+j ! Effective length of c if (id .eq. 0) then c(k+1:) = '=' ! Look for -= k = k+1 ! Adjust length end if i = LocFirst(c(:k),cStr) ! Look for c in cStr if (i .eq. 0) j = j-1 ! If not found drop trailing char end do if (i .ne. 0) then ! Found cName k = i+k ! Position after located string (after = for id=0) n = itrim(cStr) if (k .le. n) then ! Check trailing part of cStr for another occurrence c = cSwitch(:iSwitch)//cName(:j) m = LocFirst(c(:iSwitch+j),cStr(k:)) if (m .ne. 0) then ! Found abreviated keyword m = k-1+m+iSwitch+j ! Pos in cStr after abreviated keyword if (m .gt. n .or. cStr(m:m) .eq. '=' .or. cStr(m:m) .eq. cSwitch) & call Say('ForeignArgFind','E',cName(:j),'keyword abbreviation not unique') end if end if end if return end