Join/Login

Business Software

Open Source Software

For Vendors

Blog

About

More

Articles

Create

SourceForge Podcast

Site Documentation

Subscribe to our Newsletter

Support Request

For Vendors Help Create Join Login

Business Software

Open Source Software

SourceForge Podcast

Resources

Articles

Case Studies

Blog

Menu

Help

Create

Join

Login

Home

Browse

WSJT

WSPR

WSJT WSPR

Weak signal ham radio communication

Brought to you by: bsomervi, chetfenn, dg2ycb, k1jt

Summary

Files

Reviews

Support

Mailing Lists

Git ▾

WSJT-X

WSPR

WSPR-X

WSJT

Echo

FMT

MAP65

MAP65IQ

WSJT-X Superbuild

More...

Old SVN

Menu ▾ ▴

Browse Commits

Fork

Merge Requests 0

Forks 1

Branches

master

Tags

wspr212

[fc7db4]: / fmt.f90  Maximize  Restore  History

Download this file

133 lines (113 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

program fmt

! Conduct measurements for ARRL Frequency Measuring Test, etc.

  parameter (NMAX=180*48000)                 !Max length of 48 kHz waveform

  parameter (NMAX2=NMAX/4)                   !Max length at 12 kHz

  parameter (NFFT=65536)

  parameter (NH=NFFT/2)

  parameter (NQ=NFFT/4)

  integer*2 kwave(NMAX)                      !Raw data samples at 48 kHz

  integer*2 iwave(NMAX2)                     !Downsampled data, 12 kHz

  character arg*12                           !Command-line arg

  character cmnd*120                         !Command to set rig frequency

  character cflag*1

  real x(NFFT)                               !Real data for FFT

  real w(NFFT)                               !Window function

  complex c(0:NH-1)                          !Complex FFT result

  real s(NQ)                                !Power spectrum

  integer time,soundin                       !External functions

  equivalence (x,c)

  nargs=iargc()

  if(nargs.lt.4) then

     print*,'Usage: fmt kHz offset tsec cal'

     go to 999

  endif

  call getarg(1,arg)

  read(arg,*) nkhz                     !Nominal frequency to be measured (kHz)

  call getarg(2,arg)

  read(arg,*) noffset                  !Offset (Hz)

  call getarg(3,arg)

  read(arg,*) ntsec                    !Length of measurement (s)

  call getarg(4,arg)

  read(arg,*) ncal                     !1=cal, 0=meas

  open(10,file='fmt.ini',status='old',err=910)

  read(10,'(a120)') cmnd              !Get rigctl command to set frequency

  read(10,*) ndevin

  close(10)

  open(12,file='fmt.out',status='unknown')

  open(13,file='fmt.all',status='unknown',position='append')

  nHz=1000*nkhz - noffset

  i1=index(cmnd,' F ')

  write(cmnd(i1+2:),*) nHz            !Insert the desired frequency

  iret=system(cmnd)

  if(iret.ne.0) then

     print*,'Error executing rigctl command to set frequency:'

     print*,cmnd

     go to 999

  endif

  df=12000.d0/NFFT

  do i=1,NFFT

     w(i)=sin(i*3.14159/NFFT)

  enddo

  call soundinit                             !Initialize Portaudio

  npts=ntsec*48000

  iqmode=0

  nsec0=mod(time(),86400)

  ierr=soundin(ndevin,kwave,npts,iqmode)  !Get audio data, 48 kHz rate

  if(ierr.ne.0) then

     print*,'Error in soundin',ierr

     stop

  endif

  call fil1(kwave,npts,iwave,n2)          !Fiilter and downsample to 12 kHz

  nrpt=n2/NH - 1

  fac=1.0/float(NFFT)**2

  ia=(noffset-500)/df

  ib=(noffset+500)/df

  if(ncal.eq.0) ib=(noffset+1000)/df

  do irpt=0,nrpt

     k=irpt*NH

     t0=nsec0 + k/12000.0

     do i=1,NFFT

        k=k+1

        x(i)=w(i)*iwave(k)

     enddo

     call four2a(x,NFFT,1,-1,0)              !Compute spectrum

     do i=1,nq

        s(i)=fac * (real(c(i))**2 + aimag(c(i))**2)

     enddo

     smax=0.

     do i=ia,ib                              !Find fpeak

        if(s(i).gt.smax) then

           smax=s(i)

           ipk=i

        endif

     enddo

     call peakup(s(ipk-1),s(ipk),s(ipk+1),dx)

     fpeak=df * (ipk+dx)

     sum=0.

     nsum=0

     do i=ia,ib

        if(abs(i-ipk).gt.10) then

           sum=sum+s(i)

           nsum=nsum+1

        endif

     enddo

     ave=sum/nsum

     n=nint(mod(t0,86400.0))

     nhr=n/3600

     nmin=mod(n/60,60)

     nsec=mod(n,60)

     pave=db(ave)

     snr=db(smax/ave)

     ferr=fpeak-noffset

     cflag=' '

     if(snr.lt.18.0) cflag='*'

     write(*,1100)  nhr,nmin,nsec,nkhz,noffset,fpeak,ferr,ncal,pave,snr,cflag

     write(12,1100) nhr,nmin,nsec,nkhz,noffset,fpeak,ferr,ncal,pave,snr,cflag

     write(13,1100) nhr,nmin,nsec,nkhz,noffset,fpeak,ferr,ncal,pave,snr,cflag

1100 format(i2.2,':',i2.2,':',i2.2,i7,i6,2f10.3,i3,2f7.1,2x,a1)

     call flush(12)

     call flush(13)

  enddo

  go to 999

910 print*,'Cannot open file: fmt.ini'

999 end program fmt

SourceForge

Create a Project

Open Source Software

Business Software

Top Downloaded Projects

Company

About

Team

SourceForge Headquarters
225 Broadway Suite 1600
San Diego, CA 92101
+1 (858) 422-6466

Resources

Support

Site Documentation

Site Status

SourceForge Reviews

© 2025 Slashdot Media. All Rights Reserved.

Terms Privacy Opt Out Advertise

×
Want the latest updates on software, tech news, and AI?

Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.

Submit