WSJT-X/lib/jt9.f90
Bill Somerville 638b021216 Merged from trunk (r8085 thru r8170 inc.):
------------------------------------------------------------------------
r8085 | k9an | 2017-09-13 01:46:16 +0100 (Wed, 13 Sep 2017) | 1 line

Open up DT range to +/- 2.5 s for testing.
------------------------------------------------------------------------
r8086 | bsomervi | 2017-09-16 11:12:38 +0100 (Sat, 16 Sep 2017) | 1 line

Do not allow window manager events to close the astronomical data window
------------------------------------------------------------------------
r8087 | bsomervi | 2017-09-16 21:27:05 +0100 (Sat, 16 Sep 2017) | 4 lines

Fix regression in ADIF parser that caused failure with missing header

Improved  robustness  of  the  ADIF parser  and  re-factored  to  more
idiomatic C++.
------------------------------------------------------------------------
r8088 | bsomervi | 2017-09-16 21:27:13 +0100 (Sat, 16 Sep 2017) | 1 line

Update band limits as per ADIF 3.0.6 specification
------------------------------------------------------------------------
r8089 | bsomervi | 2017-09-16 21:27:20 +0100 (Sat, 16 Sep 2017) | 1 line

Use a single definition of band limits (Bands class)
------------------------------------------------------------------------
r8090 | bsomervi | 2017-09-16 21:27:33 +0100 (Sat, 16 Sep 2017) | 5 lines

Add button to the decoded text window context menu to erase the contents

Right-click  either decoded  text window  to erase  its contents.  The
"Erase" button on the main UI  still operates as before although it is
implemented differently now.
------------------------------------------------------------------------
r8091 | bsomervi | 2017-09-16 23:20:51 +0100 (Sat, 16 Sep 2017) | 1 line

Correct the actions taken when clearing decodes windows
------------------------------------------------------------------------
r8092 | bsomervi | 2017-09-16 23:20:59 +0100 (Sat, 16 Sep 2017) | 8 lines

Restore functionality of sending .WAV playback decodes to UDP

Extended  the Decode  and WSPRDecode  UDP messages  with an  "off air"
boolean  field indicating  the  decode  was derived  from  a .WAV  fle
playback rather than an on air reception.

Extended reference applications to use  the new off air decode message
field.
------------------------------------------------------------------------
r8093 | k9an | 2017-09-17 16:34:32 +0100 (Sun, 17 Sep 2017) | 1 line

Experimental tweak to FT8 decoder. Try a second symbol metric if
the first one fails - currently configured to use max-amplitude
and max-log.
------------------------------------------------------------------------
r8094 | k9an | 2017-09-17 21:43:30 +0100 (Sun, 17 Sep 2017) | 1 line

Restore the use of max-amplitude for ap passes.
------------------------------------------------------------------------
r8095 | k1jt | 2017-09-18 16:42:14 +0100 (Mon, 18 Sep 2017) | 2 lines

Allow specialized use of "x2 Tone Spacing" in FT8 mode.

------------------------------------------------------------------------
r8096 | k1jt | 2017-09-18 16:47:29 +0100 (Mon, 18 Sep 2017) | 2 lines

Allow X2 tone spacing also in JT9 (slow) modes.

------------------------------------------------------------------------
r8097 | k1jt | 2017-09-18 21:42:18 +0100 (Mon, 18 Sep 2017) | 2 lines

Change CRLF line endings to *nix style.

------------------------------------------------------------------------
r8098 | k1jt | 2017-09-19 17:04:10 +0100 (Tue, 19 Sep 2017) | 2 lines

Add a missing step to description of the Frequency Calibration procedure.

------------------------------------------------------------------------
r8099 | k1jt | 2017-09-20 17:31:04 +0100 (Wed, 20 Sep 2017) | 1 line

Insert a link to FT8_Operating_Tips.pdf.
------------------------------------------------------------------------
r8100 | k1jt | 2017-09-20 20:11:04 +0100 (Wed, 20 Sep 2017) | 3 lines

As an experiment, move "NA VHF Contest Mode" checkbox to main screen and
query operator if d>10000 km.

------------------------------------------------------------------------
r8101 | k1jt | 2017-09-20 20:19:47 +0100 (Wed, 20 Sep 2017) | 2 lines

Correct a tool-tip typo.

------------------------------------------------------------------------
r8102 | bsomervi | 2017-09-22 13:31:01 +0100 (Fri, 22 Sep 2017) | 1 line

UI tweaks to improve portability between platforms and font size changes
------------------------------------------------------------------------
r8103 | bsomervi | 2017-09-22 16:36:24 +0100 (Fri, 22 Sep 2017) | 5 lines

Extend UDP Reply message with keyboard modifiers

This allows UDP servers to  emulate keyboard modified double-clicks on
decoded messages,  E.g. ALT+double-click for  replying to a CQ  or QRZ
call without changing ones Tx frequency offset.
------------------------------------------------------------------------
r8104 | bsomervi | 2017-09-22 16:49:42 +0100 (Fri, 22 Sep 2017) | 1 line

Updated AD1C cty.dat file (21st Sept 2017)
------------------------------------------------------------------------
r8105 | k1jt | 2017-09-22 18:38:51 +0100 (Fri, 22 Sep 2017) | 2 lines

Another attempt at eliminating confusion when NA VHF Contest Mode is in use.

------------------------------------------------------------------------
r8106 | k9an | 2017-09-22 21:36:52 +0100 (Fri, 22 Sep 2017) | 1 line

Make sure that fastGrph is properly initialized.
------------------------------------------------------------------------
r8107 | bsomervi | 2017-09-22 23:08:41 +0100 (Fri, 22 Sep 2017) | 1 line

Improve performance of the UDP reference application message_aggregator
------------------------------------------------------------------------
r8108 | bsomervi | 2017-09-22 23:08:49 +0100 (Fri, 22 Sep 2017) | 1 line

Fix a regression in processing incoming Reply UDP messages
------------------------------------------------------------------------
r8109 | bsomervi | 2017-09-22 23:08:56 +0100 (Fri, 22 Sep 2017) | 4 lines

Better handling of worked before and country name display

Appended text is  added at a fixed column unless  the message overlaps
in which case the appended information floats to thr right.
------------------------------------------------------------------------
r8110 | bsomervi | 2017-09-22 23:09:04 +0100 (Fri, 22 Sep 2017) | 4 lines

Restore printing of MSK144 decode quality information

Now that a  way of dealing with worked before  and country information
without losing this information has been found.
------------------------------------------------------------------------
r8111 | bsomervi | 2017-09-22 23:09:11 +0100 (Fri, 22 Sep 2017) | 5 lines

Fix an issue with truncated free text messages being generated

This is an edge case when working  a call like RI9F/GM4WJS where it is
not possible to confirm receipt of the full compound callsign in a Tx5
73 message as "RI9F/GM4WJS 73" is 14 characters.
------------------------------------------------------------------------
r8112 | bsomervi | 2017-09-23 19:09:29 +0100 (Sat, 23 Sep 2017) | 1 line

Tidy up some ugly code
------------------------------------------------------------------------
r8113 | bsomervi | 2017-09-23 19:09:37 +0100 (Sat, 23 Sep 2017) | 1 line

Clean up some main window UI layout
------------------------------------------------------------------------
r8114 | k9an | 2017-09-23 20:39:42 +0100 (Sat, 23 Sep 2017) | 1 line

Comment out some diagnostic writes.
------------------------------------------------------------------------
r8115 | k9an | 2017-09-23 20:56:45 +0100 (Sat, 23 Sep 2017) | 1 line

Add some text for section 13.3 of the User Guide.
------------------------------------------------------------------------
r8116 | k9an | 2017-09-23 21:01:31 +0100 (Sat, 23 Sep 2017) | 1 line

Minor change to new_features.adoc.
------------------------------------------------------------------------
r8117 | bsomervi | 2017-09-23 23:02:24 +0100 (Sat, 23 Sep 2017) | 1 line

Minor additions to MSK144 phase eq docs
------------------------------------------------------------------------
r8118 | k9an | 2017-09-23 23:32:06 +0100 (Sat, 23 Sep 2017) | 1 line

Fix up Table 2 caption.
------------------------------------------------------------------------
r8119 | bsomervi | 2017-09-24 22:14:10 +0100 (Sun, 24 Sep 2017) | 1 line

Fix issues processing free text 73 messages
------------------------------------------------------------------------
r8120 | k1jt | 2017-09-25 18:02:52 +0100 (Mon, 25 Sep 2017) | 3 lines

First tests of "RR73 NOW ..." and "NIL NOW ..." (i3bit=1, 2) messages in FT8.
DO NOT USE THIS FEATURE ON THE AIR!

------------------------------------------------------------------------
r8121 | k1jt | 2017-09-25 20:21:25 +0100 (Mon, 25 Sep 2017) | 2 lines

Make bDXped a member variable, default to false.

------------------------------------------------------------------------
r8122 | bsomervi | 2017-09-26 00:38:19 +0100 (Tue, 26 Sep 2017) | 1 line

Fix regression in handling double-clicked CQ and QRZ calls
------------------------------------------------------------------------
r8123 | bsomervi | 2017-09-26 00:38:27 +0100 (Tue, 26 Sep 2017) | 1 line

Fix a regression handling compound calls in 73 messages
------------------------------------------------------------------------
r8124 | k1jt | 2017-09-27 13:26:33 +0100 (Wed, 27 Sep 2017) | 2 lines

Additions to Section 13.3 of WSJT-X User Guide: "Phase Equalkization".

------------------------------------------------------------------------
r8125 | k1jt | 2017-09-27 13:39:50 +0100 (Wed, 27 Sep 2017) | 31 lines

Experimental new behavior for "Lock Tx=Rx" and for clicking on waterfall and decoded text.

1. Checkbox "Lock Tx=Rx" is now labeled "Lock Tx Freq", and its meaning is
quite different.  If checked, the audio Tx frequency cannot be changed.
It's like the "Lock" function on some transceivers.

2. Clicking on the Wide Graph waterfall and on lines of decoded text now
behave as follows:

Click on       Action
---------------------------------------------------------------------
Waterfall:     Click to set Rx frequency
               Shift-click to set Tx frequency
               Ctrl-click to set Rx and Tx frequencies
               If Lock Tx Freq is checked, Tx freq does not move
               Double-click to set Rx frequency and decode there

Decoded Text:  Double-click to copy transmitting callsign to DX Call
               and locator to DX Grid; change Rx frequency to decoded
               signal's frequency; generate standard messages.
               Tx frequency is not changed unless Ctrl is held down
               and Lock Tx Freq not checked.

If this experimental behavior is adopted, some descriptions in the
User Guide and Special Mouse Commands will need to be updated.

3. Starting to implement a new function on the Tools menu,
"Solve for calibration parameters".  This is not yet finished;
DO NOT USE in its present form.


------------------------------------------------------------------------
r8126 | k1jt | 2017-09-27 13:50:21 +0100 (Wed, 27 Sep 2017) | 2 lines

Add missing routine.

------------------------------------------------------------------------
r8127 | k1jt | 2017-09-28 02:35:09 +0100 (Thu, 28 Sep 2017) | 1 line

Functional 'Solve for calibration parameters' on Tools menu.
------------------------------------------------------------------------
r8128 | k1jt | 2017-09-28 13:30:52 +0100 (Thu, 28 Sep 2017) | 1 line

dummy
------------------------------------------------------------------------
r8129 | k9an | 2017-09-28 16:00:57 +0100 (Thu, 28 Sep 2017) | 1 line

Correct a typo in the docs.
------------------------------------------------------------------------
r8130 | k1jt | 2017-09-28 16:05:41 +0100 (Thu, 28 Sep 2017) | 1 line

Minor edits in User Guide.
------------------------------------------------------------------------
r8131 | k1jt | 2017-09-28 16:09:46 +0100 (Thu, 28 Sep 2017) | 3 lines

Fix two ways that Loxk Tx Freq could be circumvented; display Echo Graph
automatically when Echo mode is started; clean up display of FreqCal parameters.

------------------------------------------------------------------------
r8132 | k1jt | 2017-09-28 16:46:36 +0100 (Thu, 28 Sep 2017) | 2 lines

Clean up the display of "Controls" checkbox on Wide Graph.

------------------------------------------------------------------------
r8133 | k1jt | 2017-09-28 16:55:24 +0100 (Thu, 28 Sep 2017) | 2 lines

Display "NIL NOW ", etc., only for test cases.

------------------------------------------------------------------------
r8134 | k1jt | 2017-09-28 20:51:04 +0100 (Thu, 28 Sep 2017) | 2 lines

Add some FreqCal info to User Guide.

------------------------------------------------------------------------
r8135 | k1jt | 2017-09-29 00:34:13 +0100 (Fri, 29 Sep 2017) | 1 line

Move 'Controls' checkbox a few pixels to the right.
------------------------------------------------------------------------
r8136 | bsomervi | 2017-09-29 11:46:43 +0100 (Fri, 29 Sep 2017) | 1 line

Fix accidental regression in UDP Reply message handling
------------------------------------------------------------------------
r8137 | bsomervi | 2017-09-29 11:57:22 +0100 (Fri, 29 Sep 2017) | 1 line

Minor clarification for the User Guide waterfall controls description
------------------------------------------------------------------------
r8138 | k1jt | 2017-09-29 14:27:55 +0100 (Fri, 29 Sep 2017) | 2 lines

Minor change to make shift/ctrl double-click logic more consistent.

------------------------------------------------------------------------
r8139 | k1jt | 2017-09-29 14:47:26 +0100 (Fri, 29 Sep 2017) | 1 line

Remove a diagnostic qDebug().
------------------------------------------------------------------------
r8140 | k1jt | 2017-09-29 14:59:16 +0100 (Fri, 29 Sep 2017) | 2 lines

Additional instructions for using the FreqCal procedure.

------------------------------------------------------------------------
r8141 | k1jt | 2017-09-29 17:53:28 +0100 (Fri, 29 Sep 2017) | 2 lines

Many updates to User Guide, mostly to reflect changes in "click behavior".

------------------------------------------------------------------------
r8142 | k1jt | 2017-09-29 17:53:57 +0100 (Fri, 29 Sep 2017) | 1 line

Update mouse_sommands.txt.
------------------------------------------------------------------------
r8143 | k1jt | 2017-09-29 17:58:05 +0100 (Fri, 29 Sep 2017) | 3 lines

Previous commit message should have mentioned a fix to "stdmsg.f90" that was
preventing double-click on a JT65 "OOO" message from populating message fields.

------------------------------------------------------------------------
r8144 | k1jt | 2017-09-29 18:40:30 +0100 (Fri, 29 Sep 2017) | 2 lines

Add an option to enforce simplex operation (moving both Tx and Rx
frequency) when double-clicking on a decoded text line.

------------------------------------------------------------------------
r8145 | k1jt | 2017-09-30 14:56:33 +0100 (Sat, 30 Sep 2017) | 1 line

Fix a regression that prevented double-click on call from working as in r8123.
------------------------------------------------------------------------
r8146 | k1jt | 2017-09-30 18:48:46 +0100 (Sat, 30 Sep 2017) | 21 lines

Another try at optimizing the GUI for simplex and split behavior.  Details below:

1. Checkbox "Double-click on call sets Tx and Rx freqs" has been removed
from the Settings -> General tab.

2. Checkbox "Lock Tx Freq" on main window is relabled "Hold Tx Freq".

3. Behavior now defaults to the "simplex" behavior in use up to code
revision r8123.  In particular, double-clicking on decoded mesages
that do not contain your own call moves both Rx and Tx frequencies.
If the first callsign is your own call, only Rx freq moves.

4. If "Hold Tx Freq" is checked, double-clicking on decoded messages
moves the Rx frequency; Tx frequency is moved only if CTRL was held
down.

5. Clicking on the waterfall moves Rx and Tx frequencies as before:
Rx only on a simple click, Tx only on SHIFT-click, and both on
CTRL-click.  This happens even if "Hold Tx Freq" is checked (which
is why this box is no longer labeled "Lock Tx Freq").

------------------------------------------------------------------------
r8147 | k1jt | 2017-09-30 20:25:01 +0100 (Sat, 30 Sep 2017) | 1 line

Fix behavior with double-click on 'CQ <AA-ZZ> <call> <grid>.'
------------------------------------------------------------------------
r8148 | k1jt | 2017-10-01 13:35:43 +0100 (Sun, 01 Oct 2017) | 1 line

Correct an improper disabling of TxFreqSpinBox.
------------------------------------------------------------------------
r8149 | k1jt | 2017-10-01 15:03:16 +0100 (Sun, 01 Oct 2017) | 1 line

Update mouse_commands.txt and tool tips.
------------------------------------------------------------------------
r8150 | k1jt | 2017-10-01 15:58:10 +0100 (Sun, 01 Oct 2017) | 1 line

Update 'blank line' band ID at 4*TRperiod/5.
------------------------------------------------------------------------
r8151 | bsomervi | 2017-10-01 22:43:59 +0100 (Sun, 01 Oct 2017) | 1 line

Fix an invalid iterator increment when there are no FreqCal frequencies
------------------------------------------------------------------------
r8152 | bsomervi | 2017-10-01 22:44:07 +0100 (Sun, 01 Oct 2017) | 1 line

Fix cty.dat lookups that were not honouring exact match flags
------------------------------------------------------------------------
r8153 | bsomervi | 2017-10-01 22:44:15 +0100 (Sun, 01 Oct 2017) | 6 lines

Add "Apply" button to calibration solution message box

Make calibration  solution application iterative so  that calibrations
can be applied sequentially if desired.

Tidy up calibration solution messages boxes and make i18n friendly.
------------------------------------------------------------------------
r8154 | k1jt | 2017-10-02 14:49:37 +0100 (Mon, 02 Oct 2017) | 2 lines

Update User Guide and "mouse_commands".

------------------------------------------------------------------------
r8155 | k1jt | 2017-10-02 15:15:15 +0100 (Mon, 02 Oct 2017) | 2 lines

Special DXpedition messages must not have the FreeText bit set.

------------------------------------------------------------------------
r8156 | k1jt | 2017-10-02 19:27:08 +0100 (Mon, 02 Oct 2017) | 2 lines

Add more on Copyright protections.

------------------------------------------------------------------------
r8157 | k1jt | 2017-10-02 19:33:17 +0100 (Mon, 02 Oct 2017) | 2 lines

Update the list of keyboard shortcuts.

------------------------------------------------------------------------
r8158 | k1jt | 2017-10-02 19:35:06 +0100 (Mon, 02 Oct 2017) | 2 lines

Minor edits.

------------------------------------------------------------------------
r8159 | k1jt | 2017-10-03 02:23:24 +0100 (Tue, 03 Oct 2017) | 1 line

Correct a misspelling; add quote marks; push 'About' to bottom of Tools menu.
------------------------------------------------------------------------
r8160 | k1jt | 2017-10-03 16:59:47 +0100 (Tue, 03 Oct 2017) | 2 lines

Add KA9Q to the copyright notice.

------------------------------------------------------------------------
r8161 | k1jt | 2017-10-04 14:14:51 +0100 (Wed, 04 Oct 2017) | 2 lines

Update an image; fix a typo.

------------------------------------------------------------------------
r8162 | k1jt | 2017-10-05 19:27:34 +0100 (Thu, 05 Oct 2017) | 2 lines

Fix a bug involving "firstcall contains mycall" but not equal to mycall.

------------------------------------------------------------------------
r8163 | bsomervi | 2017-10-06 17:18:17 +0100 (Fri, 06 Oct 2017) | 1 line

Add an accessor method to Configuration to get the current calibration parameters
------------------------------------------------------------------------
r8164 | bsomervi | 2017-10-06 17:18:25 +0100 (Fri, 06 Oct 2017) | 5 lines

Rename the fmt.all calibration measurements file after accepting a solution

This  allows those  who want  to keep  their calibration  measurements
after finding a solution to  calibrate their station. The fmt.all file
used to find and accept a solution is renamed to fmt.bak.
------------------------------------------------------------------------
r8165 | k1jt | 2017-10-13 15:36:10 +0100 (Fri, 13 Oct 2017) | 2 lines

Update the Tool Tip displayed for Frequency Calibration parameters.

------------------------------------------------------------------------
r8166 | bsomervi | 2017-10-13 23:34:10 +0100 (Fri, 13 Oct 2017) | 1 line

Fix an issue with editing IARU regions in the working frequencies table
------------------------------------------------------------------------
r8167 | bsomervi | 2017-10-13 23:34:21 +0100 (Fri, 13 Oct 2017) | 32 lines

Improved frequency calibration

Measure check  box added to FreqCal  mode, check to record  to fmt.all
with  current  calibration correction  disabled,  uncheck  to see  the
impact of the current calibration parameters.

The  fmt.all  file  is  now  optionally  renamed  to  fmt.bak  when  a
calibration solution  is accepted.  This allows  users to  preserve an
fmt.all file that they might have edited for best fit.

A calibration procedure might proceed thus:-

1) select FreqCal mode,

2) step through suggested  calibration test frequencies deleting those
that have no usable signal,

3) enable "Menu->Tools->Execute frequency calibration cycle" and check
that suitable signals are present,

4) select a suitable FTol and T/R period,

5) check  "Measure" and let the  cycle complete a few  times to gather
data,

6) uncheck "Measure" to complete the data capture, optionally tidy the
fmt.all file with your favourite editor,

7) push "Menu->Tools->Solve for  calibration parameters" and accept if
you like what you see,

8) sit back and admire your accurately frequency calibrated station.
------------------------------------------------------------------------
r8168 | bsomervi | 2017-10-13 23:34:36 +0100 (Fri, 13 Oct 2017) | 4 lines

Generic handling of keyboard modifiers via UDP and double-clicks

This  change opens  up  all  keyboard modifier  options  to UDP  Reply
messages as well as double-clicks of decoded messages.
------------------------------------------------------------------------
r8169 | bsomervi | 2017-10-13 23:34:48 +0100 (Fri, 13 Oct 2017) | 3 lines

User guide updates for frequency calibration mode

Also some instances of non-italicized WSJT-X fixed.
------------------------------------------------------------------------
r8170 | k9an | 2017-10-14 02:02:38 +0100 (Sat, 14 Oct 2017) | 1 line

Don't open the false_decodes.txt file.
------------------------------------------------------------------------



git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.8@8171 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-10-14 09:09:10 +00:00

321 lines
12 KiB
Fortran

program jt9
! Decoder for JT9. Can run stand-alone, reading data from *.wav files;
! or as the back end of wsjt-x, with data placed in a shared memory region.
use options
use prog_args
use, intrinsic :: iso_c_binding
use FFTW3
use timer_module, only: timer
use timer_impl, only: init_timer, fini_timer
use readwav
include 'jt9com.f90'
integer(C_INT) iret
type(wav_header) wav
real*4 s(NSMAX)
character c
character(len=500) optarg, infile
character wisfile*80
!### ndepth was defined as 60001. Why???
integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, &
fhigh=4000,nrxfreq=1500,ntrperiod=1,ndepth=1,nexp_decode=0
logical :: read_files = .true., tx9 = .false., display_help = .false.
type (option) :: long_options(25) = [ &
option ('help', .false., 'h', 'Display this help message', ''), &
option ('shmem',.true.,'s','Use shared memory for sample data','KEY'), &
option ('tr-period', .true., 'p', 'Tx/Rx period, default MINUTES=1', &
'MINUTES'), &
option ('executable-path', .true., 'e', &
'Location of subordinate executables (KVASD) default PATH="."', &
'PATH'), &
option ('data-path', .true., 'a', &
'Location of writeable data files, default PATH="."', 'PATH'), &
option ('temp-path', .true., 't', &
'Temporary files path, default PATH="."', 'PATH'), &
option ('lowest', .true., 'L', &
'Lowest frequency decoded (JT65), default HERTZ=200', 'HERTZ'), &
option ('highest', .true., 'H', &
'Highest frequency decoded, default HERTZ=4007', 'HERTZ'), &
option ('split', .true., 'S', &
'Lowest JT9 frequency decoded, default HERTZ=2700', 'HERTZ'), &
option ('rx-frequency', .true., 'f', &
'Receive frequency offset, default HERTZ=1500', 'HERTZ'), &
option ('patience', .true., 'w', &
'FFTW3 planing patience (0-4), default PATIENCE=1', 'PATIENCE'), &
option ('fft-threads', .true., 'm', &
'Number of threads to process large FFTs, default THREADS=1', &
'THREADS'), &
option ('jt65', .false., '6', 'JT65 mode', ''), &
option ('jt9', .false., '9', 'JT9 mode', ''), &
option ('ft8', .false., '8', 'FT8 mode', ''), &
option ('jt4', .false., '4', 'JT4 mode', ''), &
option ('qra64', .false., 'q', 'QRA64 mode', ''), &
option ('sub-mode', .true., 'b', 'Sub mode, default SUBMODE=A', 'A'), &
option ('depth', .true., 'd', &
'JT9 decoding depth (1-3), default DEPTH=1', 'DEPTH'), &
option ('tx-jt9', .false., 'T', 'Tx mode is JT9', ''), &
option ('my-call', .true., 'c', 'my callsign', 'CALL'), &
option ('my-grid', .true., 'G', 'my grid locator', 'GRID'), &
option ('his-call', .true., 'x', 'his callsign', 'CALL'), &
option ('his-grid', .true., 'g', 'his grid locator', 'GRID'), &
option ('experience-decode', .true., 'X', &
'experience based decoding flags (1..n), default FLAGS=0', &
'FLAGS') ]
type(dec_data), allocatable :: shared_data
character(len=12) :: mycall, hiscall
character(len=6) :: mygrid, hisgrid
common/patience/npatience,nthreads
common/decstats/ntry65a,ntry65b,n65a,n65b,num9,numfano
data npatience/1/,nthreads/1/
nsubmode = 0
do
call getopt('hs:e:a:b:r:m:p:d:f:w:t:9864qTL:S:H:c:G:x:g:X:', &
long_options,c,optarg,arglen,stat,offset,remain,.true.)
if (stat .ne. 0) then
exit
end if
select case (c)
case ('h')
display_help = .true.
case ('s')
read_files = .false.
shm_key = optarg(:arglen)
case ('e')
exe_dir = optarg(:arglen)
case ('a')
data_dir = optarg(:arglen)
case ('b')
nsubmode = ichar (optarg(:1)) - ichar ('A')
case ('t')
temp_dir = optarg(:arglen)
case ('m')
read (optarg(:arglen), *) nthreads
case ('p')
read (optarg(:arglen), *) ntrperiod
case ('d')
read (optarg(:arglen), *) ndepth
case ('f')
read (optarg(:arglen), *) nrxfreq
case ('L')
read (optarg(:arglen), *) flow
case ('S')
read (optarg(:arglen), *) fsplit
case ('H')
read (optarg(:arglen), *) fhigh
case ('q')
mode = 164
case ('4')
mode = 4
case ('6')
if (mode.lt.65) mode = mode + 65
case ('9')
if (mode.lt.9.or.mode.eq.65) mode = mode + 9
case ('8')
mode = 8
case ('T')
tx9 = .true.
case ('w')
read (optarg(:arglen), *) npatience
case ('c')
read (optarg(:arglen), *) mycall
case ('G')
read (optarg(:arglen), *) mygrid
case ('x')
read (optarg(:arglen), *) hiscall
case ('g')
read (optarg(:arglen), *) hisgrid
case ('X')
read (optarg(:arglen), *) nexp_decode
end select
end do
if (display_help .or. stat .lt. 0 &
.or. (.not. read_files .and. remain .gt. 0) &
.or. (read_files .and. remain .lt. 1)) then
print *, 'Usage: jt9 [OPTIONS] file1 [file2 ...]'
print *, ' Reads data from *.wav files.'
print *, ''
print *, ' jt9 -s <key> [-w patience] [-m threads] [-e path] [-a path] [-t path]'
print *, ' Gets data from shared memory region with key==<key>'
print *, ''
print *, 'OPTIONS:'
print *, ''
do i = 1, size (long_options)
call long_options(i) % print (6)
end do
go to 999
endif
iret=fftwf_init_threads() !Initialize FFTW threading
! Default to 1 thread, but use nthreads for the big ones
call fftwf_plan_with_nthreads(1)
! Import FFTW wisdom, if available
wisfile=trim(data_dir)//'/jt9_wisdom.dat'// C_NULL_CHAR
iret=fftwf_import_wisdom_from_filename(wisfile)
ntry65a=0
ntry65b=0
n65a=0
n65b=0
num9=0
numfano=0
if (.not. read_files) then
call jt9a() !We're running under control of WSJT-X
go to 999
endif
allocate(shared_data)
nflatten=0
do iarg = offset + 1, offset + remain
call get_command_argument (iarg, optarg, arglen)
infile = optarg(:arglen)
call wav%read (infile)
nfsample=wav%audio_format%sample_rate
i1=index(infile,'.wav')
if(i1.lt.1) i1=index(infile,'.WAV')
if(infile(i1-5:i1-5).eq.'_') then
read(infile(i1-4:i1-1),*,err=1) nutc
else
read(infile(i1-6:i1-1),*,err=1) nutc
endif
go to 2
1 nutc=0
2 nsps=0
if(ntrperiod.eq.1) then
nsps=6912
shared_data%params%nzhsym=181
else if(ntrperiod.eq.2) then
nsps=15360
shared_data%params%nzhsym=178
else if(ntrperiod.eq.5) then
nsps=40960
shared_data%params%nzhsym=172
else if(ntrperiod.eq.10) then
nsps=82944
shared_data%params%nzhsym=171
else if(ntrperiod.eq.30) then
nsps=252000
shared_data%params%nzhsym=167
endif
if(nsps.eq.0) stop 'Error: bad TRperiod'
kstep=nsps/2
k=0
nhsym0=-999
npts=(60*ntrperiod-6)*12000
if(iarg .eq. offset + 1) then
call init_timer (trim(data_dir)//'/timer.out')
call timer('jt9 ',0)
endif
shared_data%id2=0 !??? Why is this necessary ???
do iblk=1,npts/kstep
k=iblk*kstep
if(mode.eq.8 .and. k.gt.179712) exit
call timer('read_wav',0)
read(unit=wav%lun,end=3) shared_data%id2(k-kstep+1:k)
go to 4
3 call timer('read_wav',1)
print*,'EOF on input file ',infile
exit
4 call timer('read_wav',1)
nhsym=(k-2048)/kstep
if(nhsym.ge.1 .and. nhsym.ne.nhsym0) then
if(mode.eq.9 .or. mode.eq.74) then
! Compute rough symbol spectra for the JT9 decoder
ingain=0
call timer('symspec ',0)
nminw=1
call symspec(shared_data,k,ntrperiod,nsps,ingain,nminw,pxdb, &
s,df3,ihsym,npts8,pxdbmax)
call timer('symspec ',1)
endif
nhsym0=nhsym
if(nhsym.ge.181) exit
endif
enddo
close(unit=wav%lun)
shared_data%params%nutc=nutc
shared_data%params%ndiskdat=.true.
shared_data%params%ntr=60
shared_data%params%nfqso=nrxfreq
shared_data%params%newdat=.true.
shared_data%params%npts8=74736
shared_data%params%nfa=flow
shared_data%params%nfsplit=fsplit
shared_data%params%nfb=fhigh
shared_data%params%ntol=20
shared_data%params%kin=64800
shared_data%params%nzhsym=181
shared_data%params%ndepth=ndepth
shared_data%params%lapon=.true.
shared_data%params%napwid=75
shared_data%params%dttol=3.
! shared_data%params%minsync=0 !### TEST ONLY
! shared_data%params%nfqso=1500 !### TEST ONLY
! mycall="G3WDG " !### TEST ONLY
! hiscall="VK7MO " !### TEST ONLY
! hisgrid="QE37 " !### TEST ONLY
if(mode.eq.164 .and. nsubmode.lt.100) nsubmode=nsubmode+100
shared_data%params%naggressive=0
shared_data%params%n2pass=2
! shared_data%params%nranera=8 !### ntrials=10000
shared_data%params%nranera=6 !### ntrials=3000
shared_data%params%nrobust=.false.
shared_data%params%nexp_decode=nexp_decode
shared_data%params%mycall=mycall
shared_data%params%mygrid=mygrid
shared_data%params%hiscall=hiscall
shared_data%params%hisgrid=hisgrid
if (shared_data%params%mycall == '') shared_data%params%mycall='K1ABC'
if (shared_data%params%hiscall == '') shared_data%params%hiscall='W9XYZ'
if (shared_data%params%hisgrid == '') shared_data%params%hiscall='EN37'
if (tx9) then
shared_data%params%ntxmode=9
else
shared_data%params%ntxmode=65
end if
if (mode.eq.0) then
shared_data%params%nmode=65+9
else
shared_data%params%nmode=mode
end if
shared_data%params%nsubmode=nsubmode
shared_data%params%datetime="2013-Apr-16 15:13" !### Temp
if(mode.eq.9 .and. fsplit.ne.2700) shared_data%params%nfa=fsplit
call multimode_decoder(shared_data%ss,shared_data%id2,shared_data%params,nfsample)
enddo
call timer('jt9 ',1)
call timer('jt9 ',101)
999 continue
! Output decoder statistics
call fini_timer ()
! open (unit=12, file=trim(data_dir)//'/timer.out', status='unknown', position='append')
! write(12,1100) n65a,ntry65a,n65b,ntry65b,numfano,num9
!1100 format(58('-')/' JT65_1 Tries_1 JT65_2 Tries_2 JT9 Tries'/ &
! 58('-')/6i8)
! Save wisdom and free memory
iret=fftwf_export_wisdom_to_filename(wisfile)
call four2a(a,-1,1,1,1)
call filbig(a,-1,1,0.0,0,0,0,0,0) !used for FFT plans
call fftwf_cleanup_threads()
call fftwf_cleanup()
end program jt9