summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortony mancill <tmancill@debian.org>2024-01-01 11:39:50 -0800
committertony mancill <tmancill@debian.org>2024-01-01 11:39:50 -0800
commitffea9660ba79a513401639a2f5d90e2fdc190fb8 (patch)
tree4e1abd6eca581d5baec48b86e213ae31138bcf5e /lib
parent393a486ee1d7e308a49f8e0b8c3a4b2f43223248 (diff)
New upstream version 2.7.0~rc3+repackupstream/2.7.0_rc3+repack
Diffstat (limited to 'lib')
-rwxr-xr-xlib/cablog.f90132
-rwxr-xr-xlib/fst4_decode.f902
-rwxr-xr-xlib/ft8/ldpcsim174_91.f90223
-rwxr-xr-xlib/pctile.f907
-rwxr-xr-xlib/qra/q65/q65.f9020
-rwxr-xr-xlib/sun.f902
-rwxr-xr-xlib/wsprd/wsprd.c1
7 files changed, 322 insertions, 65 deletions
diff --git a/lib/cablog.f90 b/lib/cablog.f90
new file mode 100755
index 00000000..5908fc35
--- /dev/null
+++ b/lib/cablog.f90
@@ -0,0 +1,132 @@
+program cablog
+
+ character*100 line,infile,outfile
+ character cband*4,cmode*2,cdate*10,cutc*4,callsign*10,mycall*10
+ character csent*3,crcvd*3,dsent*3,drcvd*3
+ character*3 cmo(12)
+ integer icomma(20)
+ logical map65
+ data cmo/'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep', &
+ 'Oct','Nov','Dec'/
+
+ nargs=iargc()
+ if(nargs.ne.4) then
+ print*,"Program cablog converts file 'wsjtx.log' written by WSJT-X"
+ print*,"(or wsjt.log written by MAP65) to a bare-bones Cabrillo"
+ print*,"log for the ARRL International EME Contest. You will"
+ print*,"certainly need to edit the header information, and you may"
+ print*,"edit the log elsewhere as required."
+ print*,' '
+ print*,'Usage: cablog <MyCall> <sent> <rcvd> <infile>'
+ print*,'Examples: cablog W2ZQ -15 -16 wsjtx.log'
+ print*,' cablog W2ZQ O O wsjt.log'
+ go to 999
+ endif
+ call getarg(1,mycall)
+ outfile=trim(mycall)//'.log'
+ call getarg(2,dsent)
+ call getarg(3,drcvd)
+ call getarg(4,infile)
+ open(10,file=trim(infile),status='old')
+ open(12,file=trim(outfile),status='unknown')
+
+ write(12,1000)
+1000 format('START-OF-LOG: 3.0'/ &
+ 'CONTEST: ARRL-EME'/ &
+ 'CALLSIGN: '/ &
+ 'CATEGORY-OPERATOR: '/ &
+ 'CATEGORY-BAND: '/ &
+ 'CATEGORY-MODE: '/ &
+ 'EMAIL: '/ &
+ 'OPERATORS: '/ &
+ 'CATEGORY-POWER: HIGH'/ &
+ 'CATEGORY-TRANSMITTER: ONE'/ &
+ 'CATEGORY-STATION: FIXED'/ &
+ 'CATEGORY-TIME: 24-HOURS'/ &
+ 'CATEGORY-ASSISTED: ASSISTED'/ &
+ 'LOCATION: SNJ'/ &
+ 'CLAIMED-SCORE: '/ &
+ 'CLUB: '/ &
+ 'NAME: '/ &
+ 'ADDRESS: '/ &
+ 'ADDRESS: '/ &
+ 'ADDRESS: '/ &
+ 'CREATED-BY: cablog (C) K1JT')
+
+ n=0
+ map65=.false.
+
+ do nn=1,9999
+ read(10,'(a100)',end=900) line
+ if(len(trim(line)).eq.0) cycle
+ if(line(6:6).ge.'A' .and. line(6:6).le.'Z') map65=.true.
+ n=n+1
+ k=0
+ do j=1,100
+ if(line(j:j).eq.',') then
+ k=k+1
+ icomma(k)=j
+ endif
+ enddo
+ cmode='DG'
+ if(index(line,',CW,').gt.10) cmode='CW'
+
+ if(map65) then
+ do i=1,12
+ if(cmo(i).eq.line(6:8)) write(cdate(6:7),'(i2.2)') i
+ enddo
+ cdate(1:5)=line(1:5)
+ cdate(8:10)=line(9:11)
+ cutc=line(13:14)//line(16:17)
+ i0=index(line(19:),',')
+ callsign=line(19:17+i0)
+ cband='144 '
+ csent=dsent
+ crcvd=drcvd
+ else
+ cdate=line(1:10)
+ cutc=line(32:33)//line(35:36)
+ i0=index(line(41:),',')
+ callsign=line(41:39+i0)
+ read(line(icomma(6)+1:icomma(7)-1),*,err=10,end=10) freq
+ go to 20
+10 print*,'***Error at line ',n
+ print*,trim(line)
+20 if(freq.ge.50.0 .and. freq.le.54.0) cband='50 '
+ if(freq.ge.144.0 .and. freq.le.148.0) cband='144 '
+ if(freq.ge.28.0 .and. freq.le.29.0) cband='144 '
+ if(freq.ge.222.0 .and. freq.le.225.0) cband='222 '
+ if(freq.ge.420.0 .and. freq.le.450.0) cband='432 '
+ if(freq.ge.902.0 .and. freq.le.928.0) cband='902 '
+ if(freq.ge.1240.0 .and. freq.le.1300.0) cband='1.2G'
+ if(freq.ge.2300.0 .and. freq.le.2450.0) cband='2.3G'
+ if(freq.ge.3300.0 .and. freq.le.3500.0) cband='3.4G'
+ if(freq.ge.5650.0 .and. freq.le.5925.0) cband='5.7G'
+ if(freq.ge.10000.0 .and. freq.le.10500.0) cband='10G '
+ if(freq.ge.24000.0 .and. freq.le.24250.0) cband='24G '
+ if(icomma(8).eq.icomma(9)-1) then
+ csent=dsent
+ else
+ csent=line(icomma(8)+1:icomma(9)-1)
+ endif
+ if(icomma(9).eq.icomma(10)-1) then
+ crcvd=drcvd
+ else
+ crcvd=line(icomma(9)+1:icomma(10)-1)
+ endif
+ endif
+
+ write(12,1030) cband,cmode,cdate,cutc,mycall,csent,callsign,crcvd
+1030 format('QSO: ',a4,1x,a2,1x,a10,1x,a4,1x,a6,1x,a3,5x,a10,1x,a3)
+ enddo
+
+900 write(12,1900)
+1900 format('END-OF-LOG:')
+ write(*,1910) n,trim(outfile)
+1910 format('Processed',i5,' QSOs.'/'Output file: ',a)
+
+999 end program cablog
+
+!2023-10-28,00:17:00,2023-10-28,00:21:00,G7TZZ,IO92,1296.083100,Q65,-17,-17,,,,
+!2023-Nov-30,20:31,W8WN,EM77,0,Q65A
+
diff --git a/lib/fst4_decode.f90 b/lib/fst4_decode.f90
index 2db64e27..f2ccd2da 100755
--- a/lib/fst4_decode.f90
+++ b/lib/fst4_decode.f90
@@ -996,7 +996,7 @@ contains
do i=-ia,ia !Find freq range that has 50% of signal power
sum2=sum2 + ss(i)-avg
if(sum2.ge.0.25*sum1 .and. xi1.eq.-999.0) then
- xi1=i - 1 + (sum2-0.25*sum1)/(sum2-sum2z)
+ xi1=i - 1 + (0.25*sum1-sum2)/(sum2-sum2z)
endif
if(sum2.ge.0.50*sum1 .and. xi2.eq.-999.0) then
xi2=i - 1 + (sum2-0.50*sum1)/(sum2-sum2z)
diff --git a/lib/ft8/ldpcsim174_91.f90 b/lib/ft8/ldpcsim174_91.f90
index fc2074f6..ae16fa43 100755
--- a/lib/ft8/ldpcsim174_91.f90
+++ b/lib/ft8/ldpcsim174_91.f90
@@ -2,38 +2,50 @@ program ldpcsim174_91
! End to end test of the (174,91)/crc14 encoder and decoder.
use packjt77
- integer, parameter:: N=174, K=91, M=N-K
- character*37 msg,msgsent,msgreceived
+ integer, parameter:: N=174, K=91, M=N-K, NN=58
+ character*37 msg,msgsent
character*77 c77
character*8 arg
- character*6 grid
- character*96 tmpchar
integer*1, allocatable :: codeword(:), decoded(:), message(:)
integer*1 msgbits(77)
- integer*1 message77(77),message91(91)
+ integer*1 message91(91)
integer*1 apmask(N), cw(N)
+ integer lmax(1)
+ integer modtype, itone(79), itonecw(58), graymap(0:7)
integer nerrtot(0:N),nerrdec(0:N)
+ integer channeltype
logical unpk77_success
+ logical one(0:511,0:8)
real*8, allocatable :: rxdata(:)
- real, allocatable :: llr(:)
+ real llr(174),llra(174),llrb(174),llrc(174),llrd(174)
+ real bmeta(174),bmetb(174),bmetc(174),bmetd(174)
+ complex cs(0:7,NN)
+ real s2(0:511)
+ data graymap/0,1,3,2,5,6,4,7/
nerrtot=0
nerrdec=0
+!
+
nargs=iargc()
- if(nargs.ne.6) then
- print*,'Usage: ldpcsim niter ndepth #trials s Keff nbposd'
- print*,'eg: ldpcsim 10 2 1000 0.84 91 1'
- print*,'niter: max BP iterations'
- print*,'ndepth: OSD order'
- print*,'s: noise sigma; if negative value is ignored and sigma is calculated from SNR.'
- print*,'nbposd=0, no coupling. nbposd>0, maxsuper=nbposd; nbposd<0, no OSD'
+ if(nargs.ne.7) then
+ print*,'Usage: ldpcsim maxosd norder #trials s Keff modtype channel'
+ print*,'eg: ldpcsim 10 2 1000 0.84 91 1 0'
+ print*,' maxosd<0: do bp only'
+ print*,' maxosd=0: do bp and then call osd once with channel llrs'
+ print*,' maxosd>1: do bp and then call osd maxosd times with saved bp outputs'
+ print*,' norder : osd decoding depth'
+ print*,' s : BPSK only, noise sigma, if s<0 value is ignored and sigma is calculated from SNR.'
+ print*,' Keff : Keff must be in the range [77,91]; Keff-77 is the # of bits to use as CRC.'
+ print*,' modtype : 0, coherent BPSK; 1 noncoherent 8FSK'
+ print*,' channel : 0, AWGN; 1, block Rayleigh (Rayleigh only works with 8FSK!)'
return
endif
call getarg(1,arg)
- read(arg,*) max_iterations
+ read(arg,*) maxosd
call getarg(2,arg)
- read(arg,*) ndepth
+ read(arg,*) norder
call getarg(3,arg)
read(arg,*) ntrials
call getarg(4,arg)
@@ -41,16 +53,24 @@ program ldpcsim174_91
call getarg(5,arg)
read(arg,*) Keff
call getarg(6,arg)
- read(arg,*) nbposd
+ read(arg,*) modtype
+ call getarg(7,arg)
+ read(arg,*) channeltype
! scale Eb/No for a (174,91) code
rate=real(K)/real(N)
write(*,*) "rate: ",rate
- write(*,*) "niter= ",max_iterations," s= ",s
allocate ( codeword(N), decoded(K), message(K) )
- allocate ( rxdata(N), llr(N) )
+ allocate ( rxdata(N) )
+
+ one=.false.
+ do i=0,511
+ do j=0,8
+ if(iand(i,2**j).ne.0) one(i,j)=.true.
+ enddo
+ enddo
msg="K9ABC K1ABC FN20"
i3=0
@@ -65,47 +85,144 @@ program ldpcsim174_91
call init_random_seed()
+ iq=1
+ if(modtype.gt.0) then ! MFSK - get tones
+ i3=-1
+ n3=-1
+ call genft8(msg,i3,n3,msgsent,msgbits,itone)
+ write(*,*) 'message tones'
+ write(*,'(79(i1,1x))') itone
+ itonecw(1:29)=itone(8:36)
+ itonecw(30:58)=itone(44:72)
+ iq=3 ! bits per symbol
+ endif
call encode174_91(msgbits,codeword)
write(*,*) 'crc14'
write(*,'(14i1)') codeword(78:91)
write(*,*) 'codeword'
write(*,'(22(8i1,1x))') codeword
-
- write(*,*) "Eb/N0 Es/N0 ngood nundetected sigma psymerr"
- do idb = 10,-4,-1
+ write(*,*) 'Eb/N0 Es/N0 SNR2500 ngood nundetected sigma psymerr pbiterr'
+ do idb = 20,-4,-1
+ nsymerr=0
+ nbiterr=0
db=idb/2.0-1.0
- sigma=1/sqrt( 2*rate*(10**(db/10.0)) )
+ sigma=1/sqrt( 2*rate*iq*(10**(db/10.0)) )
ngood=0
nue=0
nsumerr=0
-
do itrial=1, ntrials
! Create a realization of a noisy received word
- do i=1,N
- rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran()
- enddo
- nerr=0
- do i=1,N
- if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1
- enddo
- if(nerr.ge.1) nerrtot(nerr)=nerrtot(nerr)+1
-
- rxav=sum(rxdata)/N
- rx2av=sum(rxdata*rxdata)/N
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- if( s .lt. 0 ) then
- ss=sigma
+ if(modtype.eq.0) then
+ do i=1,N
+ rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran()
+ enddo
+ nerr=0
+ do i=1,N
+ if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1
+ enddo
+ if(nerr.ge.1) nerrtot(nerr)=nerrtot(nerr)+1
+
+ rxav=sum(rxdata)/N
+ rx2av=sum(rxdata*rxdata)/N
+ rxsig=sqrt(rx2av-rxav*rxav)
+ rxdata=rxdata/rxsig
+ if( s .lt. 0 ) then
+ ss=sigma
+ else
+ ss=s
+ endif
+ llr=2.0*rxdata/(ss*ss)
else
- ss=s
+! noncoherent MFSK
+ do i=1,58
+ do j=0,7
+ if(j.eq.itonecw(i)) then
+ if(channeltype.eq.0) then
+ A=1.0
+ elseif(channeltype.eq.1) then
+ xI=gran()**2 + gran()**2
+ A=sqrt(xI/2)
+ endif
+ cs(j,i)= A + sigma*gran() + cmplx(0,1)*sigma*gran()
+ elseif(j.ne.itonecw(i)) then
+ cs(j,i)= sigma*gran() + cmplx(0,1)*sigma*gran()
+ endif
+ enddo
+ lmax=maxloc(abs(cs(:,i)))
+ if(lmax(1)-1.ne.itonecw(i) ) nsymerr=nsymerr+1
+ enddo
+ do nsym=1,3
+ nt=2**(3*nsym)
+ do ks=1,58,nsym
+ amax=-1.0
+ do i=0,nt-1
+ i1=i/64
+ i2=iand(i,63)/8
+ i3=iand(i,7)
+ if(nsym.eq.1) then
+ s2(i)=abs(cs(graymap(i3),ks))
+ elseif(nsym.eq.2) then
+ s2(i)=abs(cs(graymap(i2),ks)+cs(graymap(i3),ks+1))
+ elseif(nsym.eq.3) then
+ if(ks.ne.58) then
+ s2(i)=abs(cs(graymap(i1),ks)+cs(graymap(i2),ks+1)+cs(graymap(i3),ks+2))
+ else
+ s2(i)=abs(cs(graymap(i1),ks))
+ endif
+ else
+ print*,"Error - nsym must be 1, 2, or 3."
+ endif
+ enddo
+
+ i32=1+(ks-1)*3
+ if(nsym.eq.1) ibmax=2
+ if(nsym.eq.2) ibmax=5
+ if(nsym.eq.3) ibmax=8
+ do ib=0,ibmax
+ bm=maxval(s2(0:nt-1),one(0:nt-1,ibmax-ib)) - &
+ maxval(s2(0:nt-1),.not.one(0:nt-1,ibmax-ib))
+ if(i32+ib .gt.174) cycle
+ if(nsym.eq.1) then
+ bmeta(i32+ib)=bm
+ den=max(maxval(s2(0:nt-1),one(0:nt-1,ibmax-ib)), &
+ maxval(s2(0:nt-1),.not.one(0:nt-1,ibmax-ib)))
+ if(den.gt.0.0) then
+ cm=bm/den
+ else ! erase it
+ cm=0.0
+ endif
+ bmetd(i32+ib)=cm
+ elseif(nsym.eq.2) then
+ bmetb(i32+ib)=bm
+ elseif(nsym.eq.3) then
+ bmetc(i32+ib)=bm
+ endif
+ enddo
+ enddo
+ enddo
+ call normalizebmet(bmeta,174)
+ call normalizebmet(bmetb,174)
+ call normalizebmet(bmetc,174)
+ call normalizebmet(bmetd,174)
+
+ scalefac=2.83
+ llra=scalefac*bmeta
+ llrb=scalefac*bmetb
+ llrc=scalefac*bmetc
+ llrd=scalefac*bmetd
+
+ llr=llrc
endif
- llr=2.0*rxdata/(ss*ss)
+ do i=1, 174
+ if(llr(i)*(codeword(i)-0.5).lt.0) nbiterr=nbiterr+1
+ enddo
+
nap=0 ! number of AP bits
llr(1:nap)=5*(2.0*msgbits(1:nap)-1.0)
apmask=0
apmask(1:nap)=1
- call decode174_91(llr,Keff,nbposd,ndepth,apmask,message91,cw,ntype,nharderrors,dmin)
+ call decode174_91(llr,Keff,maxosd,norder,apmask,message91,cw,ntype,nharderrors,dmin)
! If the decoder finds a valid codeword, nharderrors will be .ge. 0.
if( nharderrors.ge.0 ) then
nhw=count(cw.ne.codeword)
@@ -119,9 +236,12 @@ program ldpcsim174_91
nsumerr=nsumerr+nerr
enddo
- esn0=db+10.0*log10(rate)
- pberr=real(nsumerr)/(real(ntrials*N))
- write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,esn0,ngood,nue,ss,pberr
+ esn0=db+10.0*log10(iq*rate) ! iq=3 bits per symbol for 8FSK
+ snr2500=esn0-10.0*log10(2500/6.25)
+! pberr=real(nsumerr)/(real(ntrials*N))
+ psymerr=real(nsymerr)/(ntrials*174.0/iq)
+ pbiterr=real(nbiterr)/(ntrials*174.0)
+ write(*,"(f4.1,4x,f5.1,4x,f5.1,1x,i8,1x,i8,8x,f5.2,8x,e10.3,8x,e10.3)") db,esn0,snr2500,ngood,nue,ss,psymerr,pbiterr
enddo
@@ -132,3 +252,18 @@ program ldpcsim174_91
close(23)
end program ldpcsim174_91
+
+subroutine normalizebmet(bmet,n)
+ real bmet(n)
+
+ bmetav=sum(bmet)/real(n)
+ bmet2av=sum(bmet*bmet)/real(n)
+ var=bmet2av-bmetav*bmetav
+ if( var .gt. 0.0 ) then
+ bmetsig=sqrt(var)
+ else
+ bmetsig=sqrt(bmet2av)
+ endif
+ bmet=bmet/bmetsig
+ return
+end subroutine normalizebmet
diff --git a/lib/pctile.f90 b/lib/pctile.f90
index f7dba238..e5458ed9 100755
--- a/lib/pctile.f90
+++ b/lib/pctile.f90
@@ -3,6 +3,10 @@ subroutine pctile(x,npts,npct,xpct)
real x(npts)
real,allocatable :: tmp(:)
+ if(npts.lt.0 .or. npct.lt.0 .or. npct.gt.100) then
+ xpct=1.0
+ go to 900
+ endif
allocate(tmp(npts))
tmp=x
@@ -11,6 +15,7 @@ subroutine pctile(x,npts,npct,xpct)
if(j.lt.1) j=1
if(j.gt.npts) j=npts
xpct=tmp(j)
+ deallocate(tmp)
- return
+900 return
end subroutine pctile
diff --git a/lib/qra/q65/q65.f90 b/lib/qra/q65/q65.f90
index 49c0977b..fa5c6abf 100755
--- a/lib/qra/q65/q65.f90
+++ b/lib/qra/q65/q65.f90
@@ -17,7 +17,6 @@ module q65
integer navg(0:1)
logical lnewdat
real candidates(20,3) !snr, xdt, and f0 of top candidates
- real, allocatable :: s1raw(:,:) !Symbol spectra, 1/8-symbol steps
real, allocatable :: s1(:,:) !Symbol spectra w/suppressed peaks
real, allocatable :: s1w(:,:) !Symbol spectra w/suppressed peaks (W3SZ)
real, allocatable,save :: s1a(:,:,:) !Cumulative symbol spectra
@@ -106,8 +105,6 @@ subroutine q65_dec0(iavg,iwave,ntrperiod,nfqso,ntol,lclearave, &
allocate(s3(-64:LL-65,63))
allocate(ccf1(-ia2:ia2))
if(LL.ne.LL0 .or. iz.ne.iz0 .or. jz.ne.jz0 .or. lclearave) then
- if(allocated(s1raw)) deallocate(s1raw)
- allocate(s1raw(iz,jz))
if(allocated(s1)) deallocate(s1)
allocate(s1(iz,jz))
if(allocated(s1a)) deallocate(s1a)
@@ -146,19 +143,6 @@ subroutine q65_dec0(iavg,iwave,ntrperiod,nfqso,ntol,lclearave, &
endif
i0=nint(nfqso/df) !Target QSO frequency
- ii1=max(1,i0-64)
- ii2=i0-65+LL
- call pctile(s1(ii1:ii2,1:jz),ii2-ii1+1*jz,45,base)
-! s1=s1/base
- s1raw=s1
-
-! Apply fast AGC to the symbol spectra
-! s1max=20.0 !Empirical choice
-! do j=1,jz !### Maybe wrong way? ###
-! smax=maxval(s1(ii1:ii2,j))
-! if(smax.gt.s1max) s1(ii1:ii2,j)=s1(ii1:ii2,j)*s1max/smax
-! enddo
-
dat4=0
if(ncw.gt.0 .and. iavg.le.1) then
! Try list decoding via "Deep Likelihood".
@@ -506,12 +490,12 @@ subroutine q65_ccf_22(s1,iz,jz,nfqso,ntol,iavg,ipk,jpk, &
ia=max(nint(100/df),nint((nfqso-ntol)/df))
ib=min(nint(4900/df),nint((nfqso+ntol)/df))
endif
+ if(ia.ge.ib) ia=ib-ntol/df !Protect against wacky settings
do i=ia,ib
s1avg(i)=sum(s1(i,1:jz))
enddo
- call pctile(s1avg(ia:ib),ib-ia+1,40,base0)
ccfbest=0.
ibest=0
lagpk=0
@@ -788,7 +772,7 @@ subroutine q65_snr(dat4,dtdec,f0dec,mode_q65,snr2)
if(j.ge.1 .and. j.le.jz0) then
do i=1,iz0
ii=i+mode_q65*itone(k)
- if(ii.ge.1 .and. ii.le.iz0) spec(i)=spec(i) + s1raw(ii,j)
+ if(ii.ge.1 .and. ii.le.iz0) spec(i)=spec(i) + s1(ii,j)
enddo
endif
enddo
diff --git a/lib/sun.f90 b/lib/sun.f90
index db258bb2..cfdc3a13 100755
--- a/lib/sun.f90
+++ b/lib/sun.f90
@@ -50,7 +50,7 @@ subroutine sun(y,m,DD,UT,lon,lat,RA,Dec,LST,Az,El,mjd,day)
MM = mod(356.0470d0 + 0.9856002585d0 * d + 360000.d0,360.d0)
Ls = mod(w+MM+720.0,360.0)
- EE = MM + e*rad*sin(MM/rad) * (1.0 + e*cos(M/rad))
+ EE = MM + e*rad*sin(MM/rad) * (1.0 + e*cos(MM/rad))
EE = EE - (EE - e*rad*sin(EE/rad)-MM) / (1.0 - e*cos(EE/rad))
xv = cos(EE/rad) - e
diff --git a/lib/wsprd/wsprd.c b/lib/wsprd/wsprd.c
index 0f6e903e..484e4ecb 100755
--- a/lib/wsprd/wsprd.c
+++ b/lib/wsprd/wsprd.c
@@ -146,6 +146,7 @@ unsigned long readwavfile(char *ptr_to_infile, int ntrmin, float *idat, float *q
nr=fread(buf2,2,npoints,fp); //Read raw data
fclose(fp);
if( nr == 0 ) {
+ free(buf2);
fprintf(stderr, "No data in file '%s'\n", ptr_to_infile);
return 1;
}