program timrpt cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c TIMRPT - 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 for a given month c c Author: Don Rubin Version: 1.0 November 1981 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) integer*2 iqios(2),cputim(2) 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 unkno(32),accton(numacc),subtot real*4 month(12),contim(numacc),cpu(numacc),heltim(numacc),t 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 type 96 96 format('$Enter the date for this report (in the form MM,YY) ') accept 95,today(2),today(3) 95 format(3i5) c today(1)=1 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 today(1)=monend(today(2)) !get last day of month call dayend(ibuf,today,ok) !check to see if past stop date if(.not.ok)goto 9990 c c save start time for CO: statistics c tt=(float(ihr)*3600.)+float(imin*60)+float(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 if(irec.ne.5)goto 120 if(iacnt.le.0)goto 100 uichel(iacnt)=.true. heltim(iacnt)=(float(ihr)*3600.)+float(imin*60)+float(isec) c type*,'iacnt,hello',iacnt,ihr,imin,isec,heltim(iacnt) goto 100 c c bye record c 120 if(irec.ne.6)goto 130 if(.not.uichel(iacnt))goto 100 !ignore if no hello record if(iacnt.le.0)goto 100 t=(float(ihr)*3600.)+float(imin*60)+float(isec) c type*,'iacnt,bye',iacnt,ihr,imin,isec,t contim(iacnt)=contim(iacnt)+(t-heltim(iacnt)) heltim(iacnt)=t !save time of BYE for next hello cpu(iacnt)=cpu(iacnt)+float(cputim(1)) goto 100 c c CO: record c 130 if(irec.ne.8)goto 100 cpu(5)=cpu(5)+float(cputim(1)) goto 100 c c end of file c 150 type 9122,month(today(2)),today(3) 9122 format('1',t20,'Account listing for ',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 contim(5)=t-tt c subtot=.false. do 200 jacnt=1,numacc if(.not.accton(jacnt))goto 199 !make sure its an active account t=(contim(jacnt)*conrat)+(cpu(jacnt)*cpurat) tcharg=tcharg+t !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+t !keep sub-total subtot=.true. 180 type909,jacnt,(name(n,jacnt),n=1,32),contim(jacnt),cpu(jacnt),t 909 format(i4,t7,32a1,t40,2f10.0,f10.2) if(.not.subtot)type919 919 format(' ') goto 200 199 if(cpu(jacnt).LE.0.)goto 200 t=(contim(jacnt)*conrat)+(cpu(jacnt)*cpurat) tcharg=tcharg+t !keep total charges if(subtot)type9125,total subtot=.false. tbill=tbill+total total=0. type909,jacnt,unkno,contim(jacnt),cpu(jacnt),t 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