From 5af73976412a01010d10a51161a5a6b4f1ca5895 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 29 Apr 2021 09:39:08 -0400 Subject: [PATCH] Use timer module from wsjt_fort library in MAP65. --- map65/libm65/CMakeLists.txt | 2 +- map65/libm65/decode0.f90 | 1 + map65/libm65/decode1a.f90 | 1 + map65/libm65/deep65.f90 | 1 + map65/libm65/extract.f90 | 1 + map65/libm65/fchisq.f90 | 1 + map65/libm65/filbig.f90 | 1 + map65/libm65/ftninit.f90 | 4 +- map65/libm65/m65.f90 | 15 +++-- map65/libm65/m65a.f90 | 7 ++- map65/libm65/map65a.f90 | 1 + map65/libm65/q65b.f90 | 1 + map65/libm65/timer.f90 | 114 ------------------------------------ 13 files changed, 28 insertions(+), 122 deletions(-) delete mode 100644 map65/libm65/timer.f90 diff --git a/map65/libm65/CMakeLists.txt b/map65/libm65/CMakeLists.txt index b8062c7ec..217b68a33 100644 --- a/map65/libm65/CMakeLists.txt +++ b/map65/libm65/CMakeLists.txt @@ -68,7 +68,7 @@ set (libm65_FSRCS smo.f90 sun.f90 symspec.f90 - timer.f90 +# timer.f90 timf2.f90 tm2.f90 toxyz.f90 diff --git a/map65/libm65/decode0.f90 b/map65/libm65/decode0.f90 index cdcf3c88c..3c422d415 100644 --- a/map65/libm65/decode0.f90 +++ b/map65/libm65/decode0.f90 @@ -1,5 +1,6 @@ subroutine decode0(dd,ss,savg,nstandalone) + use timer_module, only: timer parameter (NSMAX=60*96000) parameter (NFFT=32768) diff --git a/map65/libm65/decode1a.f90 b/map65/libm65/decode1a.f90 index d9a7a2e50..8e1f8e25e 100644 --- a/map65/libm65/decode1a.f90 +++ b/map65/libm65/decode1a.f90 @@ -5,6 +5,7 @@ subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & ! Apply AFC corrections to a candidate JT65 signal, then decode it. + use timer_module, only: timer parameter (NMAX=60*96000) !Samples per 60 s real*4 dd(4,NMAX) !92 MB: raw data from Linrad timf2 complex cx(NMAX/64), cy(NMAX/64) !Data at 1378.125 samples/s diff --git a/map65/libm65/deep65.f90 b/map65/libm65/deep65.f90 index 346c5f10e..d684cd15a 100644 --- a/map65/libm65/deep65.f90 +++ b/map65/libm65/deep65.f90 @@ -1,5 +1,6 @@ subroutine deep65(s3,mode65,neme,flip,mycall,hiscall,hisgrid,decoded,qual) + use timer_module, only: timer parameter (MAXCALLS=10000,MAXRPT=63) real s3(64,63) character callsign*12,grid*4,message*22,hisgrid*6,c*1,ceme*3 diff --git a/map65/libm65/extract.f90 b/map65/libm65/extract.f90 index a7c1b2284..677bf57f8 100644 --- a/map65/libm65/extract.f90 +++ b/map65/libm65/extract.f90 @@ -1,6 +1,7 @@ subroutine extract(s3,nadd,ncount,nhist,decoded,ltext) use packjt + use timer_module, only: timer real s3(64,63) character decoded*22 integer dat4(12) diff --git a/map65/libm65/fchisq.f90 b/map65/libm65/fchisq.f90 index b0005346d..7d0305831 100644 --- a/map65/libm65/fchisq.f90 +++ b/map65/libm65/fchisq.f90 @@ -1,5 +1,6 @@ real function fchisq(cx,cy,npts,fsample,nflip,a,ccfmax,dtmax) + use timer_module, only: timer parameter (NMAX=60*96000) !Samples per 60 s complex cx(npts),cy(npts) real a(5) diff --git a/map65/libm65/filbig.f90 b/map65/libm65/filbig.f90 index 4fc3e3b62..88e1b8174 100644 --- a/map65/libm65/filbig.f90 +++ b/map65/libm65/filbig.f90 @@ -3,6 +3,7 @@ subroutine filbig(dd,nmax,f0,newdat,nfsample,xpol,c4a,c4b,n4) ! Filter and downsample complex data stored in array dd(4,nmax). ! Output is downsampled from 96000 Hz to 1375.125 Hz. + use timer_module, only: timer parameter (MAXFFT1=5376000,MAXFFT2=77175) real*4 dd(4,nmax) !Input data complex ca(MAXFFT1),cb(MAXFFT1) !FFTs of input diff --git a/map65/libm65/ftninit.f90 b/map65/libm65/ftninit.f90 index dc75f3264..e57c932bc 100644 --- a/map65/libm65/ftninit.f90 +++ b/map65/libm65/ftninit.f90 @@ -2,7 +2,7 @@ ! ! 10 binary input data, *.tf2 files ! 11 prefixes.txt -! 12 timer.out +! 12 ! 13 map65.log ! 14 ! 15 @@ -22,6 +22,7 @@ !------------------------------------------------ ftn_init subroutine ftninit(appd) + use timer_module, only: timer character*(*) appd character firstline*30 character addpfx*8 @@ -29,7 +30,6 @@ subroutine ftninit(appd) addpfx=' ' call pfxdump(appd//'/prefixes.txt') - open(12,file=appd//'/timer_map65.out',status='unknown',err=920) open(13,file=appd//'/map65.log',status='unknown') open(19,file=appd//'/livecq.txt',status='unknown') open(21,file=appd//'/map65_rx.log',status='unknown',access='append',err=950) diff --git a/map65/libm65/m65.f90 b/map65/libm65/m65.f90 index b7017b5fd..8e56a0798 100644 --- a/map65/libm65/m65.f90 +++ b/map65/libm65/m65.f90 @@ -3,6 +3,9 @@ program m65 ! Decoder for map65. Can run stand-alone, reading data from *.tf2 files; ! or as the back end of map65, with data placed in a shared memory region. + use timer_module, only: timer + use timer_impl, only: init_timer, fini_timer + parameter (NSMAX=60*96000) parameter (NFFT=32768) parameter (NREAD=2048) @@ -84,7 +87,9 @@ program m65 endif call ftninit('.') - + call init_timer('timer.out') + call timer('m65 ',0) + do ifile=ifile1,nargs call getarg(ifile,infile) open(10,file=infile,access='stream',status='old',err=998) @@ -102,7 +107,7 @@ program m65 nch=2 if(nxpol.eq.1) nch=4 - if(ifile.eq.ifile1) call timer('m65 ',0) +! if(ifile.eq.ifile1) call timer('m65 ',0) do irec=1,9999999 read(10,end=10) i2 do i=1,NREAD,nch @@ -148,10 +153,12 @@ program m65 call timer('m65 ',1) call timer('m65 ',101) - call ftnquit go to 999 998 print*,'Cannot open file:' print*,infile -999 end program m65 +999 call fini_timer() + call ftnquit + +end program m65 diff --git a/map65/libm65/m65a.f90 b/map65/libm65/m65a.f90 index 5ef3c986c..48729ea9f 100644 --- a/map65/libm65/m65a.f90 +++ b/map65/libm65/m65a.f90 @@ -1,5 +1,8 @@ subroutine m65a - + + use timer_module, only: timer + use timer_impl, only: init_timer !, limtrace + interface function address_m65() integer*1, pointer :: address_m65 @@ -15,6 +18,8 @@ subroutine m65a call getcwd(cwd) call ftninit(trim(cwd)) + call init_timer (trim(cwd)//'/timer.out') + limtrace=0 lu=12 i1=attach_m65() diff --git a/map65/libm65/map65a.f90 b/map65/libm65/map65a.f90 index cf25204d2..0e0053466 100644 --- a/map65/libm65/map65a.f90 +++ b/map65/libm65/map65a.f90 @@ -5,6 +5,7 @@ subroutine map65a(dd,ss,savg,newdat,nutc,fcenter,ntol,idphi,nfa,nfb, & ! Processes timf2 data from Linrad to find and decode JT65 signals. + use timer_module, only: timer parameter (MAXMSG=1000) !Size of decoded message list parameter (NSMAX=60*96000) parameter (NFFT=32768) diff --git a/map65/libm65/q65b.f90 b/map65/libm65/q65b.f90 index c05478fc3..7701fe869 100644 --- a/map65/libm65/q65b.f90 +++ b/map65/libm65/q65b.f90 @@ -2,6 +2,7 @@ subroutine q65b(nutc,fcenter,nfcal,nfsample,ikhz,mousedf,ntol,xpol, & mycall0,hiscall0,hisgrid,mode_q65) use q65_decode + use timer_module, only: timer parameter (MAXFFT1=5376000) !56*96000 parameter (MAXFFT2=336000) !56*6000 (downsampled by 1/16) parameter (NMAX=60*12000) diff --git a/map65/libm65/timer.f90 b/map65/libm65/timer.f90 deleted file mode 100644 index ac4595956..000000000 --- a/map65/libm65/timer.f90 +++ /dev/null @@ -1,114 +0,0 @@ -subroutine timer(dname,k) - -! Times procedure number n between a call with k=0 (tstart) and with -! k=1 (tstop). Accumulates sums of these times in array ut (user time). -! Also traces all calls (for debugging purposes) if limtrace.gt.0 - - character*8 dname,name(50),space,ename - character*16 sname - logical on(50) - real ut(50),ut0(50),dut(50),tt(2) - integer ncall(50),nlevel(50),nparent(50) - integer onlevel(0:10) - integer*8 count0,clkfreq - common/tracer/ limtrace,lu - data eps/0.000001/,ntrace/0/ - data level/0/,nmax/0/,space/' '/ - data limtrace/0/,lu/-1/ - save - - if(limtrace.lt.0) go to 999 - if(lu.lt.1) lu=6 - if(k.gt.1) go to 40 !Check for "all done" (k>1) - onlevel(0)=0 - - do n=1,nmax !Check for existing name - if(name(n).eq.dname) go to 20 - enddo - - nmax=nmax+1 !This is a new one - n=nmax - ncall(n)=0 - on(n)=.false. - ut(n)=eps - name(n)=dname - -20 if(k.eq.0) then !Get start times (k=0) - if(on(n)) print*,'Error in timer: ',dname,' already on.' - level=level+1 !Increment the level - on(n)=.true. - call system_clock(count0,clkfreq) - ut0(n)=float(count0)/float(clkfreq) - ncall(n)=ncall(n)+1 - if(ncall(n).gt.1.and.nlevel(n).ne.level) then - nlevel(n)=-1 - else - nlevel(n)=level - endif - nparent(n)=onlevel(level-1) - onlevel(level)=n - - else if(k.eq.1) then !Get stop times and accumulate sums. (k=1) - if(on(n)) then - on(n)=.false. - call system_clock(count0,clkfreq) - ut1=float(count0)/float(clkfreq) - ut(n)=ut(n)+ut1-ut0(n) - endif - level=level-1 - endif - - ntrace=ntrace+1 - if(ntrace.lt.limtrace) write(lu,1020) ntrace,dname,k,level,nparent(n) -1020 format(i8,': ',a8,3i5) - go to 998 - -! Write out the timer statistics - -40 write(lu,1040) -1040 format(/' name time frac dtime', & - ' dfrac calls level parent'/75('-')) - - if(k.gt.100) then - ndiv=k-100 - do i=1,nmax - ncall(i)=ncall(i)/ndiv - ut(i)=ut(i)/ndiv - enddo - endif - - total=ut(1) - sum=0. - sumf=0. - do i=1,nmax - dut(i)=ut(i) - do j=i,nmax - if(nparent(j).eq.i) dut(i)=dut(i)-ut(j) - enddo - utf=ut(i)/total - dutf=dut(i)/total - sum=sum+dut(i) - sumf=sumf+dutf - kk=min(nlevel(i),8) - if(kk.lt.1) sname=name(i)//space - if(kk.ge.1) sname=space(1:kk)//name(i)//space(1:8-kk) - ename=space - if(i.ge.2) ename=name(nparent(i)) - write(lu,1060) float(i),sname,ut(i),utf,dut(i),dutf, & - ncall(i),nlevel(i),ename -1060 format(f4.0,a16,2(f10.2,f6.2),i7,i5,2x,a8) - enddo - - write(lu,1070) sum,sumf -1070 format(75('-')/36x,f10.2,f6.2) - nmax=0 - eps=0.000001 - ntrace=0 - level=0 - space=' ' - onlevel(0)=0 - -998 flush(lu) - -999 return -end subroutine timer