js8call/lib/ft8_decode.f90

144 lines
4.3 KiB
Fortran
Raw Normal View History

2018-02-08 21:28:33 -05:00
module ft8_decode
2018-03-05 14:49:51 -05:00
parameter (MAXFOX=1000)
character*12 c2fox(MAXFOX)
character*4 g2fox(MAXFOX)
integer nsnrfox(MAXFOX)
integer nfreqfox(MAXFOX)
integer n30fox(MAXFOX)
integer n30z
integer nfox
2018-02-08 21:28:33 -05:00
type :: ft8_decoder
procedure(ft8_decode_callback), pointer :: callback
contains
procedure :: decode
end type ft8_decoder
abstract interface
subroutine ft8_decode_callback (this,sync,snr,dt,freq,decoded,nap,qual)
import ft8_decoder
implicit none
class(ft8_decoder), intent(inout) :: this
real, intent(in) :: sync
integer, intent(in) :: snr
real, intent(in) :: dt
real, intent(in) :: freq
2018-03-05 14:49:51 -05:00
character(len=37), intent(in) :: decoded
2018-02-08 21:28:33 -05:00
integer, intent(in) :: nap
real, intent(in) :: qual
end subroutine ft8_decode_callback
end interface
contains
2018-03-05 14:49:51 -05:00
subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, &
nutc,nfa,nfb,nexp_decode,ndepth,nagain,lft8apon,lapcqonly,napwid, &
mycall12,mygrid6,hiscall12,hisgrid6)
2018-02-08 21:28:33 -05:00
! use wavhdr
use timer_module, only: timer
2018-03-05 14:49:51 -05:00
include 'ft8/ft8_params.f90'
2018-02-08 21:28:33 -05:00
! type(hdr) h
class(ft8_decoder), intent(inout) :: this
procedure(ft8_decode_callback) :: callback
real s(NH1,NHSYM)
real sbase(NH1)
real candidate(3,200)
Squashed commit of the following: commit dbca224ee15f598ba86b860c19e902b594f6b888 Author: Jordan Sherer <jordan@widefido.com> Date: Wed Aug 14 21:10:17 2019 -0400 Cleanup decoder with easy parameters commit 427a6ac6bf02a7de80e76b921bbd48ec23dab0c4 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 22:56:32 2019 -0400 Working on downsampling commit ef5e1fb9cdafb6069b6f67377c3bc9e073d2785e Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 22:01:34 2019 -0400 Fixed NN parameters commit 216dbc83a931127540fb028d3365a205b4ef1d28 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 21:40:20 2019 -0400 Fixed dupe during sync commit 9505d50ba6c42b05e5fff1a059864a643d9e7558 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 16:54:37 2019 -0400 Tweaking downsampling commit 86cd07e1ac8ce8d64cdd2d4321cf295cd867f80e Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 10:11:07 2019 -0400 Working with logging commit 0de3849a442d20081f545c6fef5fadf2def6e0d2 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:46:51 2019 -0400 250 millisecond startup delay commit a35cc5302b6f8532a424d504a4e2feaacf74ef99 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:39:20 2019 -0400 1200 sps, 10 seconds, 80Hz commit 6f36db20f90c510336b497605d9d7667d6f0f44f Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:27:12 2019 -0400 Working word count commit 741c55ac0840512d68e1fbdb2f1fff6adfcd4612 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 02:40:40 2019 -0400 Updated LDPC simulator commit ce0992644315402503f44bdae4131bacf2cc3e21 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 02:34:01 2019 -0400 Weird. Apparently symbol stop is the only way to get decodes to work in app...need to figure out why commit 8b330fbff6574f2ee6d7a471dd93a2cb57b492dd Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 01:50:37 2019 -0400 More parameter fixups (downsampling) and first decode commit 37c780b45e6579294b5a4692b8e8d0602d9bd8b1 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 23:20:58 2019 -0400 More params fixing commit bc8547e1e8f55bfb4bce5f95890f3cf6798e36d7 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 22:48:00 2019 -0400 Fixed params in fortran code commit 10fbf9f4a78c6244e0082a31819ee26aeae39325 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 16:08:32 2019 -0400 Using constants in place of literals in a few places to make it easier to change
2019-08-14 21:11:06 -04:00
real dd(NMAX)
2018-03-05 14:49:51 -05:00
logical, intent(in) :: lft8apon,lapcqonly,nagain
2018-02-08 21:28:33 -05:00
logical newdat,lsubtract,ldupe,bcontest
character*12 mycall12, hiscall12
character*6 mygrid6,hisgrid6
Squashed commit of the following: commit dbca224ee15f598ba86b860c19e902b594f6b888 Author: Jordan Sherer <jordan@widefido.com> Date: Wed Aug 14 21:10:17 2019 -0400 Cleanup decoder with easy parameters commit 427a6ac6bf02a7de80e76b921bbd48ec23dab0c4 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 22:56:32 2019 -0400 Working on downsampling commit ef5e1fb9cdafb6069b6f67377c3bc9e073d2785e Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 22:01:34 2019 -0400 Fixed NN parameters commit 216dbc83a931127540fb028d3365a205b4ef1d28 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 21:40:20 2019 -0400 Fixed dupe during sync commit 9505d50ba6c42b05e5fff1a059864a643d9e7558 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 16:54:37 2019 -0400 Tweaking downsampling commit 86cd07e1ac8ce8d64cdd2d4321cf295cd867f80e Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 10:11:07 2019 -0400 Working with logging commit 0de3849a442d20081f545c6fef5fadf2def6e0d2 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:46:51 2019 -0400 250 millisecond startup delay commit a35cc5302b6f8532a424d504a4e2feaacf74ef99 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:39:20 2019 -0400 1200 sps, 10 seconds, 80Hz commit 6f36db20f90c510336b497605d9d7667d6f0f44f Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:27:12 2019 -0400 Working word count commit 741c55ac0840512d68e1fbdb2f1fff6adfcd4612 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 02:40:40 2019 -0400 Updated LDPC simulator commit ce0992644315402503f44bdae4131bacf2cc3e21 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 02:34:01 2019 -0400 Weird. Apparently symbol stop is the only way to get decodes to work in app...need to figure out why commit 8b330fbff6574f2ee6d7a471dd93a2cb57b492dd Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 01:50:37 2019 -0400 More parameter fixups (downsampling) and first decode commit 37c780b45e6579294b5a4692b8e8d0602d9bd8b1 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 23:20:58 2019 -0400 More params fixing commit bc8547e1e8f55bfb4bce5f95890f3cf6798e36d7 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 22:48:00 2019 -0400 Fixed params in fortran code commit 10fbf9f4a78c6244e0082a31819ee26aeae39325 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 16:08:32 2019 -0400 Using constants in place of literals in a few places to make it easier to change
2019-08-14 21:11:06 -04:00
integer*2 iwave(NMAX)
2018-02-08 21:28:33 -05:00
integer apsym(KK)
2018-03-05 14:49:51 -05:00
character datetime*13,message*22,msg37*37
2018-02-08 21:28:33 -05:00
character*22 allmessages(100)
integer allsnrs(100)
save s,dd
bcontest=iand(nexp_decode,128).ne.0
this%callback => callback
write(datetime,1001) nutc !### TEMPORARY ###
1001 format("000000_",i6.6)
2018-08-10 03:58:50 -04:00
call ft8apset(mycall12,mygrid6,hiscall12,hisgrid6,bcontest,apsym,iaptype)
2018-02-08 21:28:33 -05:00
dd=iwave
ndecodes=0
allmessages=' '
allsnrs=0
ifa=nfa
ifb=nfb
if(nagain) then
ifa=nfqso-10
ifb=nfqso+10
endif
! For now:
! ndepth=1: no subtraction, 1 pass, belief propagation only
! ndepth=2: subtraction, 3 passes, belief propagation only
! ndepth=3: subtraction, 3 passes, bp+osd
if(ndepth.eq.1) npass=1
if(ndepth.ge.2) npass=3
do ipass=1,npass
newdat=.true. ! Is this a problem? I hijacked newdat.
syncmin=1.5
if(ipass.eq.1) then
lsubtract=.true.
if(ndepth.eq.1) lsubtract=.false.
elseif(ipass.eq.2) then
n2=ndecodes
if(ndecodes.eq.0) cycle
lsubtract=.true.
elseif(ipass.eq.3) then
if((ndecodes-n2).eq.0) cycle
lsubtract=.false.
endif
call timer('sync8 ',0)
call sync8(dd,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call timer('sync8 ',1)
Squashed commit of the following: commit dbca224ee15f598ba86b860c19e902b594f6b888 Author: Jordan Sherer <jordan@widefido.com> Date: Wed Aug 14 21:10:17 2019 -0400 Cleanup decoder with easy parameters commit 427a6ac6bf02a7de80e76b921bbd48ec23dab0c4 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 22:56:32 2019 -0400 Working on downsampling commit ef5e1fb9cdafb6069b6f67377c3bc9e073d2785e Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 22:01:34 2019 -0400 Fixed NN parameters commit 216dbc83a931127540fb028d3365a205b4ef1d28 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 21:40:20 2019 -0400 Fixed dupe during sync commit 9505d50ba6c42b05e5fff1a059864a643d9e7558 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 16:54:37 2019 -0400 Tweaking downsampling commit 86cd07e1ac8ce8d64cdd2d4321cf295cd867f80e Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 10:11:07 2019 -0400 Working with logging commit 0de3849a442d20081f545c6fef5fadf2def6e0d2 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:46:51 2019 -0400 250 millisecond startup delay commit a35cc5302b6f8532a424d504a4e2feaacf74ef99 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:39:20 2019 -0400 1200 sps, 10 seconds, 80Hz commit 6f36db20f90c510336b497605d9d7667d6f0f44f Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:27:12 2019 -0400 Working word count commit 741c55ac0840512d68e1fbdb2f1fff6adfcd4612 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 02:40:40 2019 -0400 Updated LDPC simulator commit ce0992644315402503f44bdae4131bacf2cc3e21 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 02:34:01 2019 -0400 Weird. Apparently symbol stop is the only way to get decodes to work in app...need to figure out why commit 8b330fbff6574f2ee6d7a471dd93a2cb57b492dd Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 01:50:37 2019 -0400 More parameter fixups (downsampling) and first decode commit 37c780b45e6579294b5a4692b8e8d0602d9bd8b1 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 23:20:58 2019 -0400 More params fixing commit bc8547e1e8f55bfb4bce5f95890f3cf6798e36d7 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 22:48:00 2019 -0400 Fixed params in fortran code commit 10fbf9f4a78c6244e0082a31819ee26aeae39325 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 16:08:32 2019 -0400 Using constants in place of literals in a few places to make it easier to change
2019-08-14 21:11:06 -04:00
!open(99, file="./js8.log", status="old", position="append", action="write")
!write(99,*) ncand, "candidates"
!close(99)
2018-02-08 21:28:33 -05:00
do icand=1,ncand
sync=candidate(3,icand)
f1=candidate(1,icand)
xdt=candidate(2,icand)
Squashed commit of the following: commit dbca224ee15f598ba86b860c19e902b594f6b888 Author: Jordan Sherer <jordan@widefido.com> Date: Wed Aug 14 21:10:17 2019 -0400 Cleanup decoder with easy parameters commit 427a6ac6bf02a7de80e76b921bbd48ec23dab0c4 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 22:56:32 2019 -0400 Working on downsampling commit ef5e1fb9cdafb6069b6f67377c3bc9e073d2785e Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 22:01:34 2019 -0400 Fixed NN parameters commit 216dbc83a931127540fb028d3365a205b4ef1d28 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 21:40:20 2019 -0400 Fixed dupe during sync commit 9505d50ba6c42b05e5fff1a059864a643d9e7558 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 16:54:37 2019 -0400 Tweaking downsampling commit 86cd07e1ac8ce8d64cdd2d4321cf295cd867f80e Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 10:11:07 2019 -0400 Working with logging commit 0de3849a442d20081f545c6fef5fadf2def6e0d2 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:46:51 2019 -0400 250 millisecond startup delay commit a35cc5302b6f8532a424d504a4e2feaacf74ef99 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:39:20 2019 -0400 1200 sps, 10 seconds, 80Hz commit 6f36db20f90c510336b497605d9d7667d6f0f44f Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 03:27:12 2019 -0400 Working word count commit 741c55ac0840512d68e1fbdb2f1fff6adfcd4612 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 02:40:40 2019 -0400 Updated LDPC simulator commit ce0992644315402503f44bdae4131bacf2cc3e21 Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 02:34:01 2019 -0400 Weird. Apparently symbol stop is the only way to get decodes to work in app...need to figure out why commit 8b330fbff6574f2ee6d7a471dd93a2cb57b492dd Author: Jordan Sherer <jordan@widefido.com> Date: Tue Aug 13 01:50:37 2019 -0400 More parameter fixups (downsampling) and first decode commit 37c780b45e6579294b5a4692b8e8d0602d9bd8b1 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 23:20:58 2019 -0400 More params fixing commit bc8547e1e8f55bfb4bce5f95890f3cf6798e36d7 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 22:48:00 2019 -0400 Fixed params in fortran code commit 10fbf9f4a78c6244e0082a31819ee26aeae39325 Author: Jordan Sherer <jordan@widefido.com> Date: Mon Aug 12 16:08:32 2019 -0400 Using constants in place of literals in a few places to make it easier to change
2019-08-14 21:11:06 -04:00
xbase=10.0**(0.1*(sbase(nint(f1/(12000.0/NFFT1)))-40.0)) ! 3.125Hz
2018-02-08 21:28:33 -05:00
nsnr0=min(99,nint(10.0*log10(sync) - 25.5)) !### empirical ###
call timer('ft8b ',0)
2018-03-05 14:49:51 -05:00
call ft8b(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12,mygrid6, &
hiscall12,bcontest,sync,f1,xdt,xbase,apsym,nharderrors,dmin, &
nbadcrc,iappass,iera,msg37,xsnr)
message=msg37(1:22) !###
2018-02-08 21:28:33 -05:00
nsnr=nint(xsnr)
xdt=xdt-0.5
hd=nharderrors+dmin
call timer('ft8b ',1)
if(nbadcrc.eq.0) then
ldupe=.false.
do id=1,ndecodes
if(message.eq.allmessages(id).and.nsnr.le.allsnrs(id)) ldupe=.true.
enddo
if(.not.ldupe) then
ndecodes=ndecodes+1
allmessages(ndecodes)=message
allsnrs(ndecodes)=nsnr
endif
if(.not.ldupe .and. associated(this%callback)) then
qual=1.0-(nharderrors+dmin)/60.0 ! scale qual to [0.0,1.0]
2018-03-05 14:49:51 -05:00
call this%callback(sync,nsnr,xdt,f1,msg37,iaptype,qual)
2018-02-08 21:28:33 -05:00
endif
endif
enddo
enddo
return
end subroutine decode
end module ft8_decode