program timlog cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c TIMLOG - Accounting file time log display program c c This program scans the accounting file created by the KMS c accounting system and lists a report for each account. c c Author: Don Rubin Version: 1.0 November 1981 c Modified: Don Rubin 1.1 January 1982 c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c parameter (numacc=200) !highest account number real*8 unknow(4) integer*2 ibuf(13),today(3),stdate(3),stpdat(3),monend(12),cputim integer*4 iqios,cpu(numacc) logical*1 lfile(24),totals,sumday,termid(2),uic(2),q,ok logical*1 ddate(9),buffer(32),name(32,numacc),uichel(numacc) logical*1 accton(numacc),unkno(32),subtot integer*4 month(12),contim(numacc),heltim(numacc),t,tt,jhr equivalence (unknow,unkno) data monend/31,28,31,30,31,30,31,31,30,31,30,31/ data unknow/'Unknown ','or inval','id accou','nt'/ data month/'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP' * ,'OCT','NOV','DEC'/ c c -- start record c equivalence (irec,ibuf(1)) equivalence (ihr,ibuf(2)) equivalence (imin,ibuf(3)) equivalence (isec,ibuf(4)) equivalence (iyear,ibuf(5)) equivalence (imonth,ibuf(6)) equivalence (iday,ibuf(7)) c c -- hel/bye record c equivalence (termid,ibuf(5)) equivalence (iacnt,ibuf(6)) equivalence (uic,ibuf(7)) equivalence (cputim,ibuf(8)) ! i*4 word matches 2 bfr words for CO: only equivalence (iqios,ibuf(10)) ! i*4 word matches 2 bfr words equivalence (irunct,ibuf(12)) equivalence (insct,ibuf(13)) c conrat=.039/3600. cpurat=1.603/3600. c open(unit=1,name='LB:[1,4]TIMLOG.DAT',type='OLD',err=9000) read(1,97)stdate,stpdat !get date to start report 97 format(6i2) c type 96,stdate(1),month(stdate(2)),stdate(3), * stpdat(1),month(stpdat(2)),stpdat(3) 96 format(' The last report generated was for ',i2,'-',a3,'-',i2, * ', (which was run on ',i2,'-',a3,'-',i2,')'//, * '$Enter the date for this report (in the form DD,MM,YY) ') accept 95,today 95 format(3i5) c if(today(3).gt.stdate(3))goto 7 if(today(2).gt.stdate(2))goto 7 if(today(1).gt.stdate(1))goto 7 type*,'Warning- Day requested is before date of last report' goto 6 7 rewind 1 call idate(stpdat(2),stpdat(1),stpdat(3)) !todays month,day,year write(1,97)today,stpdat !date to start next report 6 close (unit=1) c encode(20,90,lfile)month(today(2)),today(3) !get filename for datafile 90 format('LB:[1,4]SYS',A3,I2,'.LOG') lfile(21)=0 c open(unit = 1, - name = lfile, - form = 'UNFORMATTED', - type = 'OLD', - shared, - readonly, - access = 'SEQUENTIAL', - err = 9000) c c position file to the start date c 11 read(1,err=9100,end=9990) ibuf if(irec.gt.1)goto 11 call daybeg(ibuf,today,ok) !check date if(.not.ok)goto 11 !branch if not at start date yet c call dayend(ibuf,today,ok) !check to see if past stop date if(.not.ok)goto 9990 jhr=ihr !convert to i*4 c c save start time for CO: statistics c tt=(jhr*3600)+(imin*60)+isec c open(unit=2,name='LB:[1,4]TIMLOG.ACC',type='OLD',readonly,shared) do 20 j=1,numacc 4 read(2,80,end=21)n,l,buffer 80 format(q,i4,32a1) if(n.le.0.or.l.le.0)goto 20 do 22 n=1,32 name(n,l)=buffer(n) 22 continue accton(l)=.true. !flag account active if(l.gt.lmax)lmax=l !find greatest account 20 continue 21 close (unit=2) goto 110 c c loop for each record in the input file c 100 nrec=nrec+1 !bump number of records read read(1,end=150,err=9100)ibuf c if(irec.gt.1)goto 110 call dayend(ibuf,today,ok) !check to see if past stop date if(.not.ok)goto 150 goto 100 !ignore multiple startups c c hello record c 110 jhr=ihr !convert to i*4 if(irec.ne.5)goto 120 if(iacnt.le.0)goto 100 uichel(iacnt)=.true. heltim(iacnt)=(jhr*3600)+(imin*60)+isec goto 100 c c bye record c 120 if(irec.ne.6)goto 130 if(iacnt.le.0)goto 100 if(.not.uichel(iacnt))goto 100 !ignore if no hello record t=(jhr*3600)+(imin*60)+isec if(t.gt.heltim(iacnt))then contim(iacnt)=contim(iacnt)+(t-heltim(iacnt)) else contim(iacnt)=contim(iacnt)+(86400+t-heltim(iacnt)) endif heltim(iacnt)=t !save time of BYE for next hello cpu(iacnt)=cpu(iacnt)+cputim goto 100 c c CO: record c 130 if(irec.ne.8)goto 100 cpu(5)=cpu(5)+cputim goto 100 c c end of file c 150 type 9122,today(1),month(today(2)),today(3) 9122 format('1',t20,'Account listing for ',i2,'-',a3,'-19',i2//) type9126 9126 format(t49,'Seconds',t69,'Hours') type 9123 9123 format(' Acct #',t10,'User Name',t43,'Connect',t56,'CPU',t65, * 'Equiv. Billable'/) c c calculate connect time for CO: (system overhead time) c if(t.gt.tt)then contim(5)=t-tt else contim(5)=86400+t-tt endif c subtot=.false. do 200 jacnt=1,numacc if(.not.accton(jacnt))goto 199 !make sure its an active account tot=(contim(jacnt)*conrat)+(cpu(jacnt)*cpurat) tcharg=tcharg+tot !keep total charges c c determine subtotals c if(.not.subtot)goto 170 if(name(1,jacnt).gt.'9')goto 173 num=(jacnt/10)*10 if(num.ne.jacnt)goto 175 173 type9125,total 9125 format(t42,'Subtotal for this account is',f10.2/) subtot=.false. tbill=tbill+total total=0. 170 if(name(1,jacnt).gt.'9')goto 180!alphanumeric account 175 total=total+tot !keep sub-total subtot=.true. 180 type909,jacnt,(name(n,jacnt),n=1,32),contim(jacnt), 1 cpu(jacnt),tot 909 format(i4,t7,32a1,t40,2i10,f10.2) if(.not.subtot)type919 919 format(' ') goto 200 199 if(cpu(jacnt).LE.0.)goto 200 tot=(contim(jacnt)*conrat)+(cpu(jacnt)*cpurat) tcharg=tcharg+tot !keep total charges if(subtot)type9125,total subtot=.false. tbill=tbill+total total=0. type909,jacnt,unkno,contim(jacnt),cpu(jacnt),tot type919 200 continue type9124,tcharg,tbill 9124 format(//' Total equivalent hours=',f10.2,' which includes',f10.2, * ' billable hours'/,'1') close (unit=1) call exit 9100 stop 'error during read' 9000 stop 'error during open' 9990 stop 'requested date not in file' end