summaryrefslogtreecommitdiff
path: root/lib/testEchoCall.f90
diff options
context:
space:
mode:
authorhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
committerhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
commitc25cbdf6fb6d946175f4335fab77bfea601b56db (patch)
tree6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /lib/testEchoCall.f90
parent71f5689252c9f13e70e1c24856904475b2307809 (diff)
parent0685fcada9f95fe90f70b387cd7d757da8209624 (diff)
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'lib/testEchoCall.f90')
-rw-r--r--lib/testEchoCall.f90108
1 files changed, 94 insertions, 14 deletions
diff --git a/lib/testEchoCall.f90 b/lib/testEchoCall.f90
index 72059f7f..5f493791 100644
--- a/lib/testEchoCall.f90
+++ b/lib/testEchoCall.f90
@@ -1,17 +1,27 @@
program testEchoCall
+ use, intrinsic :: iso_fortran_env, only: error_unit
+ use readwav, only: wav_header
+
parameter (NSPS=4096,NH=NSPS/2,NZ=3*12000)
integer*2 iwave(NZ) !Raw data, 12000 Hz sample rate
- integer ihdr(11)
- integer*1 itone(6)
- character*120 fname
- character*6 rxcall,hhmmss
+ integer*4 itone(6)
+ type(wav_header) wav
+ character(:), allocatable :: fname
+ character*256 iomsg
+ character*6 rxcall,hhmmss,txcall
+ character*4 extension
+ logical*1 bDiskData,bEchoCall
+ logical valid_time
+ integer argument_length,i,ich,ios,name_length,nerrors,samples_read
common/echocom/nclearave,nsum,blue(4096),red(4096)
common/echocom2/fspread_self,fspread_dx
- narg=iargc()
+ nerrors=0
+ narg=command_argument_count()
if(narg.lt.1) then
print*,'Usage: testEchoCall fname1 [fname2, ...]'
+ nerrors=1
go to 999
endif
@@ -23,21 +33,90 @@ program testEchoCall
navg=10
nauto=1
nqual=0
+ bDiskData=.true.
+ bEchoCall=.false.
+ txcall=' '
do ifile=1,narg
- call getarg(ifile,fname)
- open(10,file=trim(fname),access='stream',status='unknown')
- read(10) ihdr,iwave
- close(10)
+ call get_command_argument(ifile,length=argument_length,status=ios)
+ if(ios.ne.0) then
+ write(error_unit,'(a,i0)') 'testEchoCall: cannot read argument ',ifile
+ nerrors=nerrors+1
+ cycle
+ endif
+ if(allocated(fname)) deallocate(fname)
+ allocate(character(len=max(1,argument_length)) :: fname)
+ call get_command_argument(ifile,value=fname,status=ios)
+ if(ios.ne.0) then
+ write(error_unit,'(a,i0)') 'testEchoCall: cannot read argument ',ifile
+ nerrors=nerrors+1
+ cycle
+ endif
+ name_length=len_trim(fname)
+ valid_time=.false.
+ if(name_length.ge.10) then
+ extension=fname(name_length-3:name_length)
+ do i=1,len(extension)
+ ich=iachar(extension(i:i))
+ if(ich.ge.iachar('A') .and. ich.le.iachar('Z')) then
+ extension(i:i)=achar(ich + iachar('a') - iachar('A'))
+ endif
+ enddo
+ hhmmss=fname(name_length-9:name_length-4)
+ if(extension.eq.'.wav' .and. verify(hhmmss,'0123456789').eq.0) then
+ read(hhmmss,'(3i2)',iostat=ios) ih,im,is
+ if(ios.eq.0) then
+ valid_time=ih.le.23 .and. im.le.59 .and. is.le.59
+ endif
+ endif
+ endif
+ if(.not.valid_time) then
+ write(error_unit,'(a)') &
+ 'testEchoCall: filename must end with a valid HHMMSS.wav timestamp: '//trim(fname)
+ nerrors=nerrors+1
+ cycle
+ endif
+
+ call wav%read(trim(fname),ios,iomsg)
+ if(ios.ne.0) then
+ if(trim(iomsg).eq.'cannot open file') then
+ write(error_unit,'(a)') 'testEchoCall: cannot open '//trim(fname)//': '//trim(iomsg)
+ else
+ write(error_unit,'(a)') 'testEchoCall: cannot read '//trim(fname)//': '//trim(iomsg)
+ endif
+ nerrors=nerrors+1
+ cycle
+ endif
+
+ if(wav%audio_format%sample_rate.ne.12000) then
+ close(wav%lun)
+ write(error_unit,'(a)') &
+ 'testEchoCall: cannot read '//trim(fname)//': expected a 12000 Hz WAV file'
+ nerrors=nerrors+1
+ cycle
+ endif
+
+ call wav%read_samples(iwave,samples_read,ios,iomsg)
+ close(wav%lun)
+ if(ios.ne.0) then
+ write(error_unit,'(a)') &
+ 'testEchoCall: cannot read '//trim(fname)//': '//trim(iomsg)
+ nerrors=nerrors+1
+ cycle
+ endif
+ if(samples_read.lt.NZ) then
+ write(error_unit,'(a,i0,a,i0)') 'testEchoCall: cannot read '//trim(fname)// &
+ ': expected ',NZ,' samples, found ',samples_read
+ nerrors=nerrors+1
+ cycle
+ endif
! Retrieve params known at time of transmissiion and saved in iwave
call save_echo_params(nDop,nDopAudio,nfrit,f1,fspread,ndf,itone,iwave,-1)
fspread_self=fspread
+ width=fspread
- call avecho(iwave,0,nfrit,ndf,nauto,navg,nqual,f1,xlevel,snrdb,db_err,dfreq, &
+ call avecho(iwave,0,nfrit,nauto,navg,nqual,f1,xlevel,snrdb,db_err,dfreq, &
width,bDiskData,bEchoCall,txcall,rxcall)
- i1=index(fname,'.wav')
- hhmmss=fname(i1-6:i1-1)
- read(hhmmss,'(3i2)') ih,im,is
hour=ih + im/60.0 + is/3600.0
write(*,1110) hhmmss,hour,xlevel,ndop,fspread,nsum,nqual,nint(dfreq), &
snrdb,db_err,rxcall
@@ -45,4 +124,5 @@ program testEchoCall
nclearave=0
enddo
-999 end program testEchoCall
+999 if(nerrors.gt.0) stop 1
+end program testEchoCall