Add needed routines.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/jtms3@2520 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2012-07-17 19:56:55 +00:00
parent 8b55eb3a28
commit 4fd7b18b47
5 changed files with 114 additions and 1 deletions

38
libm65/alignmsg.f90 Normal file
View File

@ -0,0 +1,38 @@
subroutine alignmsg(word0,nmin,msg,msglen,idone)
character*(*) word0
character*29 msg,word
word=word0//' '
idone=0
! Test for two (or more) <space> characters
if(word(1:2).eq.' ' .and. len(word).eq.2) then
i2=index(msg,' ')
if((i2.ge.1.and.i2.lt.msglen) .or. &
(msg(1:1).eq.' '.and.msg(msglen:msglen).eq.' ')) then
if(i2.eq.1) msg=msg(i2+2:msglen) !Align on EOM
if(i2.ge.2) msg=msg(i2+2:msglen)//msg(1:i2-1)
idone=1
endif
! Align on single <space> (as last resort)
else if(word(1:1).eq.' ' .and. len(word).eq.1) then
i3=index(msg,' ')
if(i3.ge.1 .and. i3.lt.msglen) msg=msg(i3+1:msglen)//msg(1:i3)
if(i3.eq.msglen) msg=msg(1:msglen)
msg=msg(1:msglen)//msg(1:msglen)
idone=1
! Align on specified word
else
call match(word,msg(1:msglen),nstart,nmatch)
if(nmatch.ge.nmin) then
if(nstart.eq.1) msg=msg(nstart:msglen)
if(nstart.gt.1) msg=msg(nstart:msglen)//msg(1:nstart-1)
idone=1
endif
endif
return
end subroutine alignmsg

23
libm65/hipass.f90 Normal file
View File

@ -0,0 +1,23 @@
subroutine hipass(y,npts,nwidth)
! Hipass filter for time-domain data. Removes an RC-type running
! mean (time constant nwidth) from array y(1:npts).
real y(npts)
c1=1.0/nwidth
c2=1.0-c1
s=0.
do i=1,nwidth !Get initial average
s=s+y(i)
enddo
ave=c1*s
do i=1,npts !Do the filtering
y0=y(i)
y(i)=y0-ave !Remove the mean
ave=c1*y0 + c2*ave !Update the mean
enddo
return
end subroutine hipass

28
libm65/match.f90 Normal file
View File

@ -0,0 +1,28 @@
subroutine match(s1,s2,nstart,nmatch)
character*(*) s1,s2
character s1a*29
nstart=-1
nmatch=0
n1=len_trim(s1)+1
n2=len(s2)
s1a=s1//' '
if(n2.ge.n1) then
do j=1,n2
n=0
do i=1,n1
k=j+i-1
if(k.gt.n2) k=k-n2
if(s2(k:k).eq.s1a(i:i)) n=n+1
enddo
if(n.gt.nmatch) then
nmatch=n
nstart=j
endif
enddo
endif
return
end subroutine match

24
libm65/tweak1.f90 Normal file
View File

@ -0,0 +1,24 @@
subroutine tweak1(ca,jz,f0,cb)
! Shift frequency of analytic signal ca, with output to cb
complex ca(jz),cb(jz)
real*8 twopi
complex*16 w,wstep
data twopi/0.d0/
save twopi
if(twopi.eq.0.d0) twopi=8.d0*atan(1.d0)
w=1.d0
dphi=twopi*f0/11025.d0
wstep=cmplx(cos(dphi),sin(dphi))
x0=0.5*(jz+1)
s=2.0/jz
do i=1,jz
x=s*(i-x0)
w=w*wstep
cb(i)=w*ca(i)
enddo
return
end subroutine tweak1

View File

@ -1,4 +1,4 @@
//-------------------------------------------------------------- MainWindow //--------------------------------------------------------------- MainWindow
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "devsetup.h" #include "devsetup.h"