(file) Return to get_values.f CVS log (file) (dir) Up to [HallC] / Analyzer / UTILSUBS

File: [HallC] / Analyzer / UTILSUBS / get_values.f (download)
Revision: 1.1, Tue Feb 22 20:00:24 1994 UTC (30 years, 7 months ago) by cdaq
Branch: MAIN
CVS Tags: spring03, sep0596, sep-26-2002, sep-25-2002, sep-24-2002, sep-09-2002, sane, pionct, online07, online04, online03, oct1199, oct1194, nov2894, nov2696, mduality, may2495, may1894, mar1495, mar-24-2003, jun1794, jun1594, jun1394, jun0794, jul2895, jul0794, jan2795, jan2496, jan1896, jan1796, gep_online, gep3, fpi2, emc, e01004, dec0694, bigcal, baryon, aug1794, aug0394, aug-12-2003, apr3096, apr1594, apr0695, apr-02-2003, Initial-CVS-Release, HEAD, Extra_Shower_Tubes_on_HMS_not_SOS
Initial revision

        SUBROUTINE get_values(string,n,values,ok) 
*
* $Log: get_values.f,v $
* Revision 1.1  1994/02/22 20:00:24  cdaq
* Initial revision
*
*
        IMPLICIT NONE 
        CHARACTER*(*) string
        INTEGER*4 n,values(*),v(2),divider
        INTEGER*4 i,j,k,m,value4,cycle,step
        INTEGER*2 last_binary,last_oct,last_hex,dummy2
        LOGICAL*2 ok,hex,oct,bin
        CHARACTER*132 orig,line,this
        INTEGER*4 important_length        !FUNCTION 
        INTEGER*4 INDEX                   !FUNCTION 
        CHARACTER*1 quote 
        PARAMETER (quote='''')
c................................................................ 
        n=0
	orig= string
        CALL no_tabs(orig)			!remove tabs
        DO WHILE (INDEX(orig,quote).ne.0)	!remove quote marks 
          i=INDEX(orig,quote) 
          orig(i:i)=' ' 
        ENDDO 
        DO WHILE (INDEX(orig,'::').ne.0) 	!replace sequence marks
          i=INDEX(orig,'::') 
          orig(i:i+1)='^ '
        ENDDO 
        DO WHILE (INDEX(orig,':').ne.0) 	!replace seperator marks
          i=INDEX(orig,':') 
          orig(i:i)=','
        ENDDO 
        CALL NO_blanks(orig)			!remove blanks
	CALL UP_case(ORIG)			!shift to upper case
        IF(orig.EQ.' ') THEN
          ok=.false.				!nothing to read
          RETURN
        ENDIF 
c
        line= orig
	j= INDEX(line,',')
	IF(j.gt.0) line(j:)=' '		!get first line
c
        DO WHILE (orig.NE.' ')
c
	  divider= INDEX(line,'*')			!duplicate
	  If(divider.eq.0) divider= INDEX(line,'^')	!sequence
c
	  If(divider.eq.0) Then
		cycle=1
		this= line
	  ElseIf(divider.eq.1) Then
                GOTO 2222 			!illegal
	  Else
		cycle=2
		this= line(1:divider-1)
	  EndIf
c
	  Do j=1,cycle
c
            last_binary= INDEX(this,'B')
            bin= last_binary.ne.0 
            last_hex= INDEX(this,'H') 
            If(last_hex.EQ.0) last_hex= INDEX(this,'X') 
            hex= last_hex.ne.0
            last_oct= INDEX(this,'O') 
            oct= last_oct.ne.0
c
            if(hex) then
              this(last_hex:)=' ' 
              CALL squeeze(this,i)
              IF(this.eq.' ') goto 2222
              READ(this(1:i),'(z)',err=2222) v(j)
            elseif(oct) then
              this(last_oct:)=' ' 
              CALL squeeze(this,i)
              IF(this.eq.' ') goto 2222
              READ(this(1:i),'(o)',err=2222) v(j)
            elseif(bin) then
              this(last_binary:)=' '
              CALL squeeze(this,i)
              IF(this.eq.' ') goto 2222
              value4= 0 
              DO k=1,i
                value4= 2*value4
                If(this(k:k).EQ.'1') Then
                  value4= value4+1
                ElseIf(this(k:k).NE.'0') Then
                  GOTO 2222 
                EndIf 
              ENDDO
	      v(j)= value4			!only take lowest bits
            else
              CALL squeeze(this,i)
              IF(this.eq.' ') goto 2222
              READ(this(1:i),'(i)',err=2222) v(j)
            endif
c
	    this= line(divider+1:)	 
          EndDo
c
	  ok=.true.
	  If(cycle.eq.2) Then
	    if(line(divider:divider).eq.'^') then	!sequence "^"
	      DO k=v(1),v(2),MAX(MIN(v(2)-v(1),1),-1)
		n= n+1
		values(n)= k
	      ENDDO	
	    else					!duplicate "*"
	      DO k=1,v(1)
		n=n+1
		values(n)= v(2)
	      ENDDO	
            endif
	  Else						!just single value
	    n=n+1 
            values(n)= v(1)
	  EndIf
c
          m= INDEX(orig,',')		!find next line
          If(m.EQ.0) Then 	!done
            orig=' '
          Else			!another line
            orig(1:m)=' ' 
            CALL no_leading_blanks(orig)
            line= orig 
	    m= INDEX(line,',')
	    if(m.ne.0) line(m:)=' '
	  EndIf
        ENDDO 
        RETURN
c
 2222   ok=.false.
        RETURN
        END 

Analyzer/Replay: Mark Jones, Documents: Stephen Wood
Powered by
ViewCVS 0.9.2-cvsgraph-1.4.0