! subroutine parseme(str,nt,begs,ends,typs,ints,vals,err) ! breakdown string str into nt tokens: ! delimiters are space and tab ! integer vectors begs & ends have 1st and last char position of each ! token; integer vector typs indicates type assigned to each: namely ! 0= not a num 2=integer 3=float 4=exp real -1=bad int ! int/real vectors (ints/vals) are converted data (if not error) ! integer err: 0 ok, else # of arg with first error ! integer nt # tokens found - ! to allow tokens with imbedded blanks, inclose in doublequotes "" "" subroutine parseme(str,nt,begs,ends,typs,ints,vals,err) implicit none character(*) str character(1) :: tab = char(9) character*1 :: dq ='"' !doublequote char character*1 cc,c1,c2 integer i,ll,nt,begs(*),ends(*),typs(*) integer int,ints(*),err,i1,i2 real vals(*),val logical in,inastr,surely_str(100) ll=len_trim(str) nt=0 in=.false. !init not in a token err=0 ; inastr=.false. surely_str=.false. do i=1,ll cc=str(i:i) if((.not.inastr).and.(cc.eq.',')) cc=' ' if(ichar(cc).lt.32) cc=' ' if(cc.eq.dq) then if(inastr) then ends(nt)=i-1 ; inastr=.false. ; in=.false. ; goto 600 !end str else nt=nt+1 ; inastr=.true.; begs(nt)=i+1 surely_str(nt)=.true. endif endif if(inastr) then ; ends(nt)=i ; goto 600 ; endif !in case end " missing if((cc.ne.' ').and.(cc.ne.tab)) then if(.not.in) then !start new token nt=nt+1 ; in=.true. begs(nt)=i !1st char loc typs(nt)=0 !default not a num endif ends(nt)=i else in=.false. !ready for next endif 600 continue enddo do i=1,nt !classify AND convert to num c1=str(begs(i):begs(i)) i1=ichar(c1) c2=str(ends(i):ends(i)) i2=ichar(c2) if(c1.eq.'!') then nt=max(1,i-1) typs(i)=0 exit endif !comment ends scan and resets ntokens if(c1.eq.'<') cycle if(c2.eq.'>') cycle !arrow labels if(i1.gt.57) then !probably a string if((c1.ne.'e').and.(c1.ne.'E')) then ; typs(i)=0 ; cycle ; endif if((c2.ne.'e').and.(c2.ne.'E')) then ; typs(i)=0 ; cycle ; endif endif if(surely_str(i)) then typs(i)=0 else call typify(str(begs(i):ends(i)),typs(i),ints(i),vals(i)) endif if(typs(i).lt.0) err=i !loc (end) of 1st error enddo return end