subroutine CharToNumeric(astring,f) implicit none ! ! transform a string consisting all numbers in time representation (1234 or 12:34 or ! 12:23:15,or 12.19) into a number character*20 astring character*1,c character*2,HH,MM,SS character*4 MMSS double precision f,f11,f22,f33 integer ipos1,ipos2,ideci,k,j,ndigit,i ipos1=1 190 if(astring(ipos1:ipos1).ne.' ')goto 200 ipos1=ipos1+1 goto 190 200 ipos2=ipos1+1 202 if(astring(ipos2:ipos2).eq.' ')goto 204 ipos2=ipos2+1 goto 202 204 ipos2=ipos2-1 if(astring(ipos1:ipos1).eq.'-')then ipos1=ipos1+1 endif ideci=index(astring,'.') if(ideci.eq.0)then !1234 or 12:34 or 12:34:50 type f=-9999.0d0 if(index(astring,':').eq.0)then ! an integer number ndigit=ipos2-ipos1+1 if(ndigit.ge.3.and.ndigit.le.6)then f33=-99.0d0 c=astring(ipos2:ipos2) f11=dble(ichar(c)-48) c=astring(ipos2-1:ipos2-1) f11=f11+dble((ichar(c)-48)*10) c=astring(ipos2-2:ipos2-2) f22=dble(ichar(c)-48) if(ndigit.ge.4)then c=astring(ipos2-3:ipos2-3) f22=f22+dble((ichar(c)-48)*10) endif if(ndigit.ge.5)then c=astring(ipos2-4:ipos2-4) f33=dble(ichar(c)-48) endif if(ndigit.eq.6)then c=astring(ipos2-5:ipos2-5) f33=f33+dble((ichar(c)-48)*10) endif if(f33.lt.0.0d0)then if(f11.le.60.0d0.and.f22.le.24.0d0)then f=f22+f11/60.0d0 endif else if(f33.le.24.0d0.and.f22.le.60.0d0.and. & f11.le.60.0d0)then f=f33+f22/60.0d0+f11/3600.0d0 endif endif endif else !HH:MM or HH:MM:SS type k=index(astring,':') HH=astring(ipos1:k-1) MMSS=astring(k+1:ipos2) j=index(MMSS,':') if(j.eq.0)then MM=MMSS else MM=MMSS(1:j-1) SS=MMSS(j+1:) endif f33=dble((ichar(HH(1:1))-48)) if(HH(2:2).ne.' ')then f33=f33*10.0d0+dble(ichar(HH(2:2))-48) endif f22=dble((ichar(MM(1:1))-48)) if(MM(2:2).ne.' ')then f22=f22*10.0d0+dble(ichar(MM(2:2))-48) endif if(j.ne.0)then f11=dble((ichar(SS(1:1))-48)) if(SS(2:2).ne.' ')then f11=f11*10.0d0+dble(ichar(SS(2:2))-48) endif endif if(f33.le.24.0d0.and.f22.le.60.0d0)then f=f33+f22/60.0d0 if(j.ne.0)then if(f11.le.60.0d0)then f=f+f11/3600.0d0 endif endif endif endif else !18.27 type of character f=0.0d0 do i=ipos1,ideci-1 c=astring(i:i) f=f+dble(ichar(c)-48)* & dble(10**(ideci-ipos1-(i-ipos1)-1)) enddo do i=ideci+1,ipos2 c=astring(i:i) f=f+dble(ichar(c)-48)/dble(10**(i-ideci)) enddo endif if(index(astring,'-').ne.0)then f=-f endif return end