2020-07-23 13:48:50 -04:00
|
|
|
program fst4sim
|
2020-06-16 13:28:56 -04:00
|
|
|
|
|
|
|
! Generate simulated signals for experimental slow FT4 mode
|
|
|
|
|
|
|
|
use wavhdr
|
|
|
|
use packjt77
|
2020-07-23 13:48:50 -04:00
|
|
|
include 'fst4_params.f90' !Set various constants
|
2020-06-16 13:28:56 -04:00
|
|
|
type(hdr) h !Header for .wav file
|
2020-07-17 14:09:21 -04:00
|
|
|
logical*1 wspr_hint
|
2020-06-16 13:28:56 -04:00
|
|
|
character arg*12,fname*17
|
|
|
|
character msg37*37,msgsent37*37,c77*77
|
|
|
|
complex, allocatable :: c0(:)
|
|
|
|
complex, allocatable :: c(:)
|
|
|
|
real, allocatable :: wave(:)
|
2020-06-17 11:44:29 -04:00
|
|
|
integer hmod
|
2020-06-16 13:28:56 -04:00
|
|
|
integer itone(NN)
|
|
|
|
integer*1 msgbits(101)
|
|
|
|
integer*2, allocatable :: iwave(:) !Generated full-length waveform
|
|
|
|
|
|
|
|
! Get command-line argument(s)
|
|
|
|
nargs=iargc()
|
2020-12-22 14:12:58 -05:00
|
|
|
if(nargs.ne.9) then
|
|
|
|
print*,'Need 9 arguments, got ',nargs
|
|
|
|
print*,'Usage: fst4sim "message" TRsec f0 DT fdop del nfiles snr W'
|
|
|
|
print*,'Examples: fst4sim "K1JT K9AN EN50" 60 1500 0.0 0.1 1.0 10 -15 F'
|
2020-07-17 14:09:21 -04:00
|
|
|
print*,'W (T or F) argument is hint to encoder to use WSPR message when there is abiguity'
|
2020-06-16 13:28:56 -04:00
|
|
|
go to 999
|
|
|
|
endif
|
|
|
|
call getarg(1,msg37) !Message to be transmitted
|
|
|
|
call getarg(2,arg)
|
2020-06-19 09:28:55 -04:00
|
|
|
read(arg,*) nsec !TR sequence length, seconds
|
2020-06-16 13:28:56 -04:00
|
|
|
call getarg(3,arg)
|
2020-06-19 11:57:49 -04:00
|
|
|
read(arg,*) f00 !Frequency (only used for single-signal)
|
2020-06-16 13:28:56 -04:00
|
|
|
call getarg(4,arg)
|
|
|
|
read(arg,*) xdt !Time offset from nominal (s)
|
|
|
|
call getarg(5,arg)
|
|
|
|
read(arg,*) fspread !Watterson frequency spread (Hz)
|
2020-12-22 14:12:58 -05:00
|
|
|
call getarg(6,arg)
|
2020-06-16 13:28:56 -04:00
|
|
|
read(arg,*) delay !Watterson delay (ms)
|
2020-12-22 14:12:58 -05:00
|
|
|
call getarg(7,arg)
|
2020-06-16 13:28:56 -04:00
|
|
|
read(arg,*) nfiles !Number of files
|
2020-12-22 14:12:58 -05:00
|
|
|
call getarg(8,arg)
|
2020-06-16 13:28:56 -04:00
|
|
|
read(arg,*) snrdb !SNR_2500
|
2020-12-22 14:12:58 -05:00
|
|
|
call getarg(9,arg)
|
2020-07-17 14:09:21 -04:00
|
|
|
read(arg,*) wspr_hint !0:break ties as 77-bit 1:break ties as 50-bit
|
2020-06-16 13:28:56 -04:00
|
|
|
|
|
|
|
nfiles=abs(nfiles)
|
|
|
|
twopi=8.0*atan(1.0)
|
|
|
|
fs=12000.0 !Sample rate (Hz)
|
|
|
|
dt=1.0/fs !Sample interval (s)
|
2020-06-19 09:28:55 -04:00
|
|
|
nsps=0
|
2020-06-29 16:06:11 -04:00
|
|
|
if(nsec.eq.15) nsps=720
|
2020-06-19 09:28:55 -04:00
|
|
|
if(nsec.eq.30) nsps=1680
|
2020-06-24 16:15:20 -04:00
|
|
|
if(nsec.eq.60) nsps=3888
|
|
|
|
if(nsec.eq.120) nsps=8200
|
2020-06-27 15:11:37 -04:00
|
|
|
if(nsec.eq.300) nsps=21504
|
2020-07-17 12:29:21 -04:00
|
|
|
if(nsec.eq.900) nsps=66560
|
|
|
|
if(nsec.eq.1800) nsps=134400
|
2020-06-19 09:28:55 -04:00
|
|
|
if(nsps.eq.0) then
|
|
|
|
print*,'Invalid TR sequence length.'
|
|
|
|
go to 999
|
|
|
|
endif
|
2020-06-19 11:57:49 -04:00
|
|
|
baud=12000.0/nsps !Keying rate (baud)
|
2020-06-19 09:28:55 -04:00
|
|
|
nmax=nsec*12000
|
2020-06-16 13:28:56 -04:00
|
|
|
nz=nsps*NN
|
2020-07-13 20:59:14 -04:00
|
|
|
txt=nz*dt !Transmission length (s)
|
2020-06-16 13:28:56 -04:00
|
|
|
tt=nsps*dt !Duration of symbols (s)
|
2020-07-17 18:44:14 -04:00
|
|
|
nwave=max(nmax,(NN+2)*nsps)
|
|
|
|
allocate( c0(0:nwave-1) )
|
|
|
|
allocate( c(0:nwave-1) )
|
|
|
|
allocate( wave(nwave) )
|
2020-06-16 13:28:56 -04:00
|
|
|
allocate( iwave(nmax) )
|
|
|
|
|
|
|
|
bandwidth_ratio=2500.0/(fs/2.0)
|
|
|
|
sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb)
|
|
|
|
if(snrdb.gt.90.0) sig=1.0
|
|
|
|
|
2020-07-17 14:09:21 -04:00
|
|
|
if(wspr_hint) then
|
|
|
|
i3=0
|
|
|
|
n3=6
|
|
|
|
else
|
|
|
|
i3=-1
|
|
|
|
n3=-1
|
|
|
|
endif
|
2020-06-16 13:28:56 -04:00
|
|
|
call pack77(msg37,i3,n3,c77)
|
2020-07-17 14:09:21 -04:00
|
|
|
if(i3.eq.0.and.n3.eq.6) iwspr=1
|
2020-07-23 13:48:50 -04:00
|
|
|
call genfst4(msg37,0,msgsent37,msgbits,itone,iwspr)
|
2020-06-16 13:28:56 -04:00
|
|
|
write(*,*)
|
2020-07-17 14:09:21 -04:00
|
|
|
write(*,'(a9,a37,a3,L2,a7,i2)') 'Message: ',msgsent37,'W:',wspr_hint,' iwspr:',iwspr
|
2020-12-22 14:12:58 -05:00
|
|
|
write(*,1000) f00,xdt,txt,snrdb
|
|
|
|
1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1)
|
2020-06-16 13:28:56 -04:00
|
|
|
write(*,*)
|
|
|
|
if(i3.eq.1) then
|
|
|
|
write(*,*) ' mycall hiscall hisgrid'
|
|
|
|
write(*,'(28i1,1x,i1,1x,28i1,1x,i1,1x,i1,1x,15i1,1x,3i1)') msgbits(1:77)
|
|
|
|
else
|
|
|
|
write(*,'(a14)') 'Message bits: '
|
2020-07-01 15:40:37 -04:00
|
|
|
write(*,'(77i1,1x,24i1)') msgbits
|
2020-06-16 13:28:56 -04:00
|
|
|
endif
|
|
|
|
write(*,*)
|
|
|
|
write(*,'(a17)') 'Channel symbols: '
|
|
|
|
write(*,'(10i1)') itone
|
|
|
|
write(*,*)
|
|
|
|
|
|
|
|
! call sgran()
|
|
|
|
|
2020-12-22 14:12:58 -05:00
|
|
|
fsample=12000.0
|
|
|
|
hmod=1
|
2020-06-16 13:28:56 -04:00
|
|
|
icmplx=1
|
2020-06-19 11:57:49 -04:00
|
|
|
f0=f00+1.5*hmod*baud
|
2020-07-23 13:48:50 -04:00
|
|
|
call gen_fst4wave(itone,NN,nsps,nwave,fsample,hmod,f0,icmplx,c0,wave)
|
2020-06-29 16:06:11 -04:00
|
|
|
k=nint((xdt+1.0)/dt)
|
|
|
|
if(nsec.eq.15) k=nint((xdt+0.5)/dt)
|
2020-06-16 13:28:56 -04:00
|
|
|
c0=cshift(c0,-k)
|
|
|
|
if(k.gt.0) c0(0:k-1)=0.0
|
|
|
|
if(k.lt.0) c0(nmax+k:nmax-1)=0.0
|
|
|
|
|
|
|
|
do ifile=1,nfiles
|
|
|
|
c=c0
|
2020-12-22 13:33:24 -05:00
|
|
|
if(fspread.gt.0.0 .or. delay.ne.0.0) call watterson(c,nwave,NZ,fs,delay,fspread)
|
|
|
|
if(fspread.lt.0.0) call lorentzian_fading(c,nwave,fs,-fspread)
|
2020-06-16 13:28:56 -04:00
|
|
|
c=sig*c
|
2021-01-18 14:47:54 -05:00
|
|
|
wave=aimag(c)
|
2020-06-16 13:28:56 -04:00
|
|
|
if(snrdb.lt.90) then
|
|
|
|
do i=1,nmax !Add gaussian noise at specified SNR
|
|
|
|
xnoise=gran()
|
|
|
|
wave(i)=wave(i) + xnoise
|
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
gain=100.0
|
|
|
|
if(snrdb.lt.90.0) then
|
|
|
|
wave=gain*wave
|
|
|
|
else
|
|
|
|
datpk=maxval(abs(wave))
|
|
|
|
fac=32766.9/datpk
|
|
|
|
wave=fac*wave
|
|
|
|
endif
|
|
|
|
if(any(abs(wave).gt.32767.0)) print*,"Warning - data will be clipped."
|
2020-07-17 18:44:14 -04:00
|
|
|
iwave=nint(wave(:size(iwave)))
|
2020-06-16 13:28:56 -04:00
|
|
|
h=default_header(12000,nmax)
|
2020-06-18 15:03:41 -04:00
|
|
|
if(nmax/12000.le.30) then
|
|
|
|
write(fname,1102) ifile
|
|
|
|
1102 format('000000_',i6.6,'.wav')
|
|
|
|
else
|
|
|
|
write(fname,1104) ifile
|
|
|
|
1104 format('000000_',i4.4,'.wav')
|
|
|
|
endif
|
|
|
|
open(10,file=trim(fname),status='unknown',access='stream')
|
2020-06-16 13:28:56 -04:00
|
|
|
write(10) h,iwave !Save to *.wav file
|
|
|
|
close(10)
|
2020-06-19 11:57:49 -04:00
|
|
|
write(*,1110) ifile,xdt,f00,snrdb,fname
|
2020-06-16 13:28:56 -04:00
|
|
|
1110 format(i4,f7.2,f8.2,f7.1,2x,a17)
|
|
|
|
enddo
|
|
|
|
|
2020-07-23 13:48:50 -04:00
|
|
|
999 end program fst4sim
|