summaryrefslogtreecommitdiff
path: root/lib/fst4/fst4sim.f90
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fst4/fst4sim.f90')
-rw-r--r--lib/fst4/fst4sim.f9037
1 files changed, 29 insertions, 8 deletions
diff --git a/lib/fst4/fst4sim.f90 b/lib/fst4/fst4sim.f90
index 936c4b6f..3476d097 100644
--- a/lib/fst4/fst4sim.f90
+++ b/lib/fst4/fst4sim.f90
@@ -13,11 +13,14 @@ program fst4sim
complex, allocatable :: c(:)
real, allocatable :: wave(:)
integer hmod
+ integer exit_status
+ integer pack_status
integer itone(NN)
integer*1 msgbits(101)
integer*2, allocatable :: iwave(:) !Generated full-length waveform
! Get command-line argument(s)
+ exit_status=0
nargs=iargc()
if(nargs.ne.9) then
print*,'Need 9 arguments, got ',nargs
@@ -76,15 +79,27 @@ program fst4sim
if(snrdb.gt.90.0) sig=1.0
if(wspr_hint) then
- i3=0
- n3=6
+ iwspr=1
else
- i3=-1
- n3=-1
+ iwspr=0
endif
- call pack77(msg37,i3,n3,c77)
- if(i3.eq.0.and.n3.eq.6) iwspr=1
call genfst4(msg37,0,msgsent37,msgbits,itone,iwspr)
+ if(trim(msgsent37).eq.'*** bad message ***') then
+ print*,'Cannot encode message: ',trim(msg37)
+ exit_status=1
+ go to 999
+ endif
+ if(iwspr.eq.1) then
+ call pack77(msgsent37,i3,n3,c77, &
+ pack77_options(prefer_wspr_50bit=.true.),pack_status)
+ else
+ call pack77(msgsent37,i3,n3,c77,status=pack_status)
+ endif
+ if(pack_status.ne.PACK77_STATUS_ENCODED) then
+ print*,'Cannot encode message: ',trim(msg37)
+ exit_status=1
+ go to 999
+ endif
write(*,*)
write(*,'(a9,a37,a3,L2,a7,i2)') 'Message: ',msgsent37,'W:',wspr_hint,' iwspr:',iwspr
write(*,1000) f00,xdt,txt,snrdb
@@ -149,11 +164,17 @@ program fst4sim
write(fname,1104) ifile
1104 format('000000_',i4.4,'.wav')
endif
- open(10,file=trim(fname),status='unknown',access='stream')
+ open(10,file=trim(fname),status='replace',access='stream')
write(10) h,iwave !Save to *.wav file
close(10)
write(*,1110) ifile,xdt,f00,snrdb,fname
1110 format(i4,f7.2,f8.2,f7.1,2x,a17)
enddo
-999 end program fst4sim
+999 if(allocated(c0)) deallocate(c0)
+ if(allocated(c)) deallocate(c)
+ if(allocated(wave)) deallocate(wave)
+ if(allocated(iwave)) deallocate(iwave)
+ if(exit_status.ne.0) stop 1
+
+end program fst4sim