diff --git a/lib/Makefile.msk b/lib/Makefile.msk index b58ca993f..1979152c9 100644 --- a/lib/Makefile.msk +++ b/lib/Makefile.msk @@ -32,7 +32,7 @@ CFLAGS = -O2 -I. ${FC} ${FFLAGS} -c $< #all: jt9code JTMSKcode -all: testmsk JTMSKcode +all: jtmsk JTMSKcode OBJS4 = jt9code.o packjt.o fmtmsg.o gen9.o deg2grid.o grid2deg.o \ entail.o encode232.o interleave9.o graycode.o igray.o @@ -44,11 +44,11 @@ OBJS5 = JTMSKcode.o packjt.o fmtmsg.o genmsk.o deg2grid.o grid2deg.o \ JTMSKcode: $(OBJS5) $(FC) -o JTMSKcode $(OBJS5) -OBJS6 = testmsk.o jtmsk.o analytic.o four2a.o db.o mskdf.o pctile.o \ +OBJS6 = jtmsk.o jtmsk.o analytic.o four2a.o db.o mskdf.o pctile.o \ sort.o tweak1.o syncmsk.o genmsk.o packjt.o fmtmsg.o indexx.o \ deg2grid.o grid2deg.o entail.o nhash.o tab.o vit213.o -testmsk: $(OBJS6) - $(FC) -o testmsk $(OBJS6) -lfftw3f +jtmsk: $(OBJS6) + $(FC) -o jtmsk $(OBJS6) -lfftw3f OBJS1 = t1.o four2a.o db.o t1: $(OBJS1) diff --git a/lib/Makefile.mskWin b/lib/Makefile.mskWin index 5a97d382b..2a2272f5c 100644 --- a/lib/Makefile.mskWin +++ b/lib/Makefile.mskWin @@ -32,7 +32,7 @@ CFLAGS = -O2 -I. ${FC} ${FFLAGS} -c $< #all: jt9code JTMSKcode.exe -all: testmsk.exe JTMSKsim.exe JTMSKcode.exe fixwav.exe +all: jtmsk.exe JTMSKsim.exe JTMSKcode.exe fixwav.exe OBJS3 = JTMSKsim.o wavhdr.o gran.o four2a.o db.o JTMSKsim.exe: $(OBJS3) @@ -48,12 +48,14 @@ OBJS5 = JTMSKcode.o packjt.o fmtmsg.o genmsk.o deg2grid.o grid2deg.o \ JTMSKcode.exe: $(OBJS5) $(FC) -o JTMSKcode.exe $(OBJS5) -OBJS6 = testmsk.o jtmsk.o analytic.o four2a.o db.o pctile.o \ +OBJS6 = jtmsk.o analytic.o four2a.o db.o pctile.o \ shell.o tweak1.o syncmsk.o genmsk.o packjt.o fmtmsg.o indexx.o \ deg2grid.o grid2deg.o entail.o hashing.o nhash.o tab.o vit213.o \ - mskdt.o timer.o rectify_msk.o -testmsk.exe: $(OBJS6) - $(FC) -o testmsk.exe $(OBJS6) C:\JTSDK\fftw3f\libfftw3f-3.dll + mskdt.o rectify_msk.o timer.o jtmsk_decode.o genmsk_short.o \ + jtmsk_short.o golay24_table.o hash.o + +jtmsk.exe: $(OBJS6) + $(FC) -o jtmsk.exe $(OBJS6) C:\JTSDK\fftw3f\libfftw3f-3.dll OBJS1 = fixwav.o wavhdr.o fixwav.exe: $(OBJS1) diff --git a/lib/testmsk.f90 b/lib/jtmsk.f90 similarity index 57% rename from lib/testmsk.f90 rename to lib/jtmsk.f90 index 3e62784e6..5d07e40cf 100644 --- a/lib/testmsk.f90 +++ b/lib/jtmsk.f90 @@ -1,22 +1,28 @@ -program testmsk +program jtmsk - use timer_module, only: timer - - parameter (NMAX=359424) + parameter (NMAX=359424) integer*2 id2(NMAX) - integer narg(0:11) + integer narg(0:13) + character*6 mycall,hiscall + character*22 msg,arg*8 character*80 line(100) + character*60 line0 character infile*80 nargs=iargc() - if(nargs.lt.1) then - print*,'Usage: testmsk infile1 [infile2 ...]' - print*,'Examples: testmsk ~/data/JTMSK3/150825_115515.wav' - print*,' testmsk C:/data/JTMSK3/150825_120245.wav' + if(nargs.lt.4) then + print*,'Usage: jtmsk MyCall HisCall ntol infile1 [infile2 ...]' go to 999 endif + call getarg(1,mycall) + call getarg(2,hiscall) + msg='<'//mycall//' '//hiscall//'> 26' + call fmtmsg(msg,iz) + call hash_calls(msg,narg(12)) + call getarg(3,arg) + read(arg,*) ntol - nfiles=nargs + nfiles=nargs-3 tsync1=0. tsync2=0. tsoft=0. @@ -24,10 +30,9 @@ program testmsk ttotal=0. ndecodes=0 - call init_timer() - call timer('testmsk ',0) + call timer('jtmsk ',0) do ifile=1,nfiles - call getarg(ifile,infile) + call getarg(ifile+3,infile) open(10,file=infile,access='stream',status='old') read(10) id2(1:22) !Skip 44 header bytes npts=179712 !### T/R = 15 s @@ -37,7 +42,6 @@ program testmsk read(infile(i1-6:i1-1),*) narg(0) nrxfreq=1500 - ntol=100 narg(1)=npts !npts narg(2)=0 !nsubmode narg(3)=1 !newdat @@ -56,12 +60,18 @@ program testmsk do i=1,narg(8) if(line(i)(1:1).eq.char(0)) exit ndecodes=ndecodes+1 - write(*,1002) line(i)(1:60),ndecodes + line0=line(i)(1:60) + i1=index(line(i)(1:60),'<...>') + if(i1.gt.0 .and. narg(13).eq.narg(12)) then + i2=index(msg,'>') + line0=line(i)(1:i1-1)//msg(1:i2)//line(i)(i1+5:i1+10) + endif + write(*,1002) line0,ndecodes 1002 format(a60,i10) enddo enddo - call timer('testmsk ',1) - call timer('testmsk ',101) + call timer('jtmsk ',1) + call timer('jtmsk ',101) -999 end program testmsk +999 end program jtmsk diff --git a/lib/jtmsk_decode.f90 b/lib/jtmsk_decode.f90 index becf6d9cd..5aacdf7d1 100644 --- a/lib/jtmsk_decode.f90 +++ b/lib/jtmsk_decode.f90 @@ -1,14 +1,14 @@ subroutine jtmsk_decode(id2,narg,line) -! Decoder for JTMSK +! Decoder for JTMSK mode parameter (NMAX=30*12000) parameter (NFFTMAX=512*1024) - parameter (NSPM=1404) !Samples per JTMSK message + parameter (NSPM=1404) !Samples per JTMSK long message integer*2 id2(0:NMAX) !Raw i*2 data, up to T/R = 30 s real d(0:NMAX) !Raw r*4 data - real ty(703) - real yellow(703) + real ty(NMAX/512) !Ping times + real yellow(NMAX/512) complex c(NFFTMAX) !Complex (analytic) data complex cdat(24000) !Short segments, up to 2 s complex cdat2(24000) @@ -16,7 +16,6 @@ subroutine jtmsk_decode(id2,narg,line) character*22 msg,msg0 !Decoded message character*80 line(100) !Decodes passed back to caller - limtrace=-1 ! Parameters from GUI are in narg(): nutc=narg(0) !UTC npts=min(narg(1),NMAX) !Number of samples in id2 (12000 Hz) @@ -38,13 +37,14 @@ subroutine jtmsk_decode(id2,narg,line) d(0:npts-1)=id2(0:npts-1) rms=sqrt(dot_product(d(0:npts-1),d(0:npts-1))/npts) - d(0:npts-1)=d(0:npts-1)/rms +!### Would it be better to set median rms to 1.0 ? + d(0:npts-1)=d(0:npts-1)/rms !Normalize so that rms=1.0 call mskdt(d,npts,ty,yellow,nyel) nyel=min(nyel,5) n=log(float(npts))/log(2.0) + 1.0 nfft=min(2**n,1024*1024) - call analytic(d,npts,nfft,c) !Convert to analytic signal + call analytic(d,npts,nfft,c) !Convert to analytic signal and filter nbefore=NSPM nafter=4*NSPM @@ -66,18 +66,21 @@ subroutine jtmsk_decode(id2,narg,line) if(abs(idf1).gt.ntol) exit fpk=idf1 + nrxfreq call tweak1(cdat2,iz,1500.0-fpk,cdat) - call syncmsk(cdat,iz,jpk,ipk,idf,rmax,snr,metric,msg) freq=fpk+idf if(metric.eq.-9999) cycle !No output if no significant sync t0=(ia+jpk)/12000.0 nsnr=nint(yellow(n)-2.0) + if(msg.eq.' ') then + call jtmsk_short(cdat,iz,narg,tbest,idfpk,msg) + endif + if(msg.ne.' ') then if(msg.ne.msg0) then nline=nline+1 nsnr0=-99 endif - if(nsnr.gt.nsnr0) then + if(nsnr.gt.nsnr0 .and. nline.gt.0) then call rectify_msk(cdat2(jpk:jpk+NSPM-1),msg,freq2) write(line(nline),1020) nutc,nsnr,t0,nint(freq2),msg 1020 format(i6.6,i4,f5.1,i5,' & ',a22) @@ -90,7 +93,9 @@ subroutine jtmsk_decode(id2,narg,line) enddo enddo -900 if(nline.eq.0) then +900 continue + nline=1 + if(nline.eq.0) then msg=' ' call jtmsk_short(c,npts,narg,tbest,idfpk,msg) diff --git a/lib/jtmsk_short.f90 b/lib/jtmsk_short.f90 index 885c60fbd..86ed30a86 100644 --- a/lib/jtmsk_short.f90 +++ b/lib/jtmsk_short.f90 @@ -14,7 +14,6 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,idfpk,decoded) real r1(0:NMAX-1) real r2(0:4095) real r1save(NSAVE) -! integer*8 count0,count1,clkfreq integer itone(234) !Message bits integer jgood(NSAVE) integer indx(NSAVE) @@ -24,8 +23,6 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,idfpk,decoded) data first/.true./,nrxfreq0/-1/,ttot/0.0/ save first,cw,cb11,nrxfreq0,ttot -! call system_clock(count0,clkfreq) - nrxfreq=narg(10) !Target Rx audio frequency (Hz) ntol=narg(11) !Search range, +/- ntol (Hz) nhashcalls=narg(12) @@ -66,6 +63,7 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,idfpk,decoded) maxdecodes=999 r1max=0. +! call timer('r1 ',0) do j=0,npts-210 !Find the B11 sync vectors z1=0. ss=0. @@ -80,6 +78,7 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,idfpk,decoded) jpk=j endif enddo +! call timer('r1 ',1) k=0 do j=1,npts-211 @@ -97,6 +96,7 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,idfpk,decoded) ibest2=-1 idfbest=0 u1best=0. +! call timer('kk ',0) do kk=1,min(kmax,10) k=indx(kmax+1-kk) j=jgood(k) @@ -109,6 +109,7 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,idfpk,decoded) do iidf=0,10 idf=20*((iidf+1)/2) + if(idf.gt.ntol) exit if(iand(iidf,1).eq.1) idf=-idf call tweak1(cdat(j-144:j+209),354,float(-idf),cd) cd(354:)=0. @@ -165,16 +166,13 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,idfpk,decoded) ! if(r1best.gt.0.0) write(*,3101) tbest,kk,nrxfreq+idfbest,ibest,nn, & ! r1best,u1best,u2best,u2best/u1best,r1_r2best,idfbest enddo +! call timer('kk ',1) + ! if(r1best.gt.0.0) then ! write(*,3101) tbest,kk,nrxfreq+idfbest,ibest,nn,r1best,u1best,u2best, & ! u2best/u1best,r1_r2best,idfbest !3101 format(f6.2,4i5,5f8.2,i6) ! endif -! call system_clock(count1,clkfreq) -! ttot=float(count1-count0)/float(clkfreq) -! write(*,3001) ttot -!3001 format('Execution time:',f7.3) - return end subroutine jtmsk_short diff --git a/lib/syncmsk.f90 b/lib/syncmsk.f90 index af84e567e..32c36ce36 100644 --- a/lib/syncmsk.f90 +++ b/lib/syncmsk.f90 @@ -74,7 +74,7 @@ subroutine syncmsk(cdat,npts,jpk,ipk,idf,rmax,snr,metric,decoded) dt=1.0/12000.0 f0=1000.0 f1=2000.0 - dphi=0 !quel compiler gripe + dphi=0 do i=1,11 if(b11(i).eq.0) dphi=twopi*f0*dt if(b11(i).eq.1) dphi=twopi*f1*dt @@ -182,9 +182,7 @@ subroutine syncmsk(cdat,npts,jpk,ipk,idf,rmax,snr,metric,decoded) call timer('sync2 ',1) kmax=k - call timer('indexx ',0) call indexx(rsave,kmax,indx) - call timer('indexx ',1) call timer('sync3 ',0) do kk=1,kmax @@ -197,7 +195,6 @@ subroutine syncmsk(cdat,npts,jpk,ipk,idf,rmax,snr,metric,decoded) smax=0. dfx=0. idfbest=0 - call timer('idf ',0) do itry=1,25 idf=itry/2 if(mod(itry,2).eq.0) idf=-idf @@ -216,9 +213,7 @@ subroutine syncmsk(cdat,npts,jpk,ipk,idf,rmax,snr,metric,decoded) call tweak1(cdat,npts,-dfx,cdat) cfac=cmplx(cos(phi),-sin(phi)) cdat=cfac*cdat - call timer('idf ',1) - call timer('softsym ',0) sig=0. ref=0. rdat(1:npts)=cdat @@ -266,7 +261,6 @@ subroutine syncmsk(cdat,npts,jpk,ipk,idf,rmax,snr,metric,decoded) symbol(n)=sym enddo snr=db(sig/ref-1.0) - call timer('softsym ',1) rdata(1:35)=symbol(12:46) rdata(36:104)=symbol(59:127) @@ -288,16 +282,10 @@ subroutine syncmsk(cdat,npts,jpk,ipk,idf,rmax,snr,metric,decoded) e1(j)=i1 rd2(j)=rdata(i+99) enddo -! call system_clock(count0,clkfreq) -! tsoft=tsoft + (count0-count1)/float(clkfreq) ! Decode the message nb1=87 - call timer('vit213 ',0) call vit213(e1,nb1,mettab,d8,metric) - call timer('vit213 ',1) -! call system_clock(count1,clkfreq) -! tvit=tvit + (count1-count0)/float(clkfreq) ihash=nhash(c_loc(d8),int(9,c_size_t),146) ihash=2*iand(ihash,32767) decoded=' '