summaryrefslogtreecommitdiff
path: root/lib/ft8var/ft8apsetvar.f90
blob: bffd2d9ede94e89be4572525fd4cb7c7b5cfdfa3 (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads,knowledge)

  use packjt77
  use ft8_codec_context, only: get_ft8_codec_state
  use ft8_mod1, only : apsym,mycall,hiscall,apsymsp,lhound,apsymdxns1,apsymdxnsrrr,mybcall,hisbcall,apcqsym,hisgrid4,     &
                       apsymdxnsrr73,apsymdxns73,apsymmyns1,apsymmyns2,apsymmynsrr73,apsymmyns73,apsymdxstd,apsymdxnsr73, &
                       apsymdxns732,apsymmynsrrr
  character*77 c77
  character*37 msg,msgchk
  character*12 hiscallt,mycallprev,hiscallprev
  integer :: i1,i3,n3,nlenmyc
  logical lnohiscall,unpk77_successvar,first
  logical(1) lhoundprev
  logical(1), intent(in) :: lmycallstd,lhiscallstd
  type(unpack77_options) :: no_record_options
  type(pack77_options) :: no_tx_hash_options
  type(pack77_state), target, optional, intent(inout) :: knowledge
  type(pack77_state), pointer :: codec
  data mycallprev/'QQ2QQ'/
  data hiscallprev/'QQ1QQ'/
  data lhoundprev/.false./
  data first/.true./
  save hiscallprev,mycallprev,lhoundprev,first

  go to 900
entry reset_ft8apsetvar()
  hiscallprev='QQ1QQ'
  mycallprev='QQ2QQ'
  lhoundprev=.false.
  first=.true.
  return
900 continue
  codec => get_ft8_codec_state()
  if(present(knowledge)) codec => knowledge

  i1=0
  i3=-1
  n3=-1
  nlenmyc=0
! AP mask generation packs and unpacks synthetic messages only to derive symbol
! masks; it must not teach those calls to the shared hash or recent-call state.
  no_record_options=unpack77_options(record_hashes=.false., &
       record_recent_calls=.false.)
  no_tx_hash_options=pack77_options(record_tx_hashes=.false.)

  if(hiscall.ne.hiscallprev .or. mycall.ne.mycallprev .or. (lhound.neqv.lhoundprev) .or. first) then ! first for lhound triggered

    first=.false.; mycallprev=mycall; lhoundprev=lhound

! shall hash both callsigns for making AP masks with nonstandard callsign message
    if(.not.lhound) call fold_queued_calls_for_state(codec,numthreads)

    lnohiscall=.false.
    hiscallt=hiscall
    if(len_trim(hiscallt).lt.3) then
      hiscallt=mycall  ! use mycall for dummy hiscall - mycall won't be hashed
      lnohiscall=.true.
    endif

    if(hiscall.ne.hiscallprev) then
      hiscallprev=hiscall
! Encode a dummy standard message: i3=1, 28 1 28 1 1 15
      if(len_trim(hiscall).gt.2) then
        if(lhiscallstd .and. len_trim(hisgrid4).eq.4) then; msg='CQ '//trim(hiscall)//' '//trim(hisgrid4)
        else; msg='CQ '//trim(hiscall)
        endif

        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
        if(lhiscallstd .and. i3.ne.1 .or. .not.lhiscallstd .and. i3.ne.4 .or. (msg.ne.msgchk) .or. .not.unpk77_successvar) go to 1
        read(c77,'(77i1)',err=1) apcqsym(1:77)
        apcqsym=2*apcqsym-1
      endif

      if(lhiscallstd .and. .not.lmycallstd) then
        msg=trim(hiscall)//' '//trim(hiscall)//' RRR'
        i3=0; n3=0
        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
        if(i3.ne.1 .or. (msg.ne.msgchk) .or. .not.unpk77_successvar) go to 2
        read(c77,'(58i1)',err=2) apsymdxstd(1:58)
        apsymdxstd=2*apsymdxstd-1
      endif

      if(.not.lhound .and. .not.lhiscallstd .and. len_trim(hiscall).gt.2) then
! nonstandard DXCall searching
        msg='<W9XYZ> '//trim(hiscall)//' RR73'
        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
        if(i3.ne.4 .or. .not.unpk77_successvar) go to 3
        read(c77,'(77i1)',err=3) apsymdxnsrr73(1:77)
        apsymdxnsrr73=2*apsymdxnsrr73-1

        msg='<W9XYZ> '//trim(hiscall)//' 73'
        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
        if(i3.ne.4 .or. .not.unpk77_successvar) go to 4
        read(c77,'(77i1)',err=4) apsymdxns73(1:77)
        apsymdxns73=2*apsymdxns73-1
      endif
    endif

    if(.not.lhound .and. .not.lmycallstd .and. len_trim(mycall).gt.2) then
      if(lhiscallstd) then
        msg='<'//trim(mycall)//'> '//trim(hiscall)//' -15'
        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
        if(i3.ne.1 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 5
        read(c77,'(58i1)',err=5) apsymmyns2(1:58)
        apsymmyns2=2*apsymmyns2-1

        nlenmyc=len_trim(mycall)
        msg=trim(mycall)//' <'//trim(hiscall)//'> RR73'
        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
        if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 6
        read(c77,'(77i1)',err=6) apsymmynsrr73(1:77)
        apsymmynsrr73=2*apsymmynsrr73-1
        msg=trim(mycall)//' <'//trim(hiscall)//'> 73'
        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
        if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 7
        read(c77,'(77i1)',err=7) apsymmyns73(1:77)
        apsymmyns73=2*apsymmyns73-1
        msg=trim(mycall)//' <'//trim(hiscall)//'> RRR'
        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
        if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 15
        read(c77,'(77i1)',err=15) apsymmynsrrr(1:77)
        apsymmynsrrr=2*apsymmynsrrr-1

      else if(lnohiscall) then

        msg='<'//trim(mycall)//'> ZZ1ZZZ -15'
        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
        if(i3.ne.1 .or. msgchk.ne.msg .or. .not.unpk77_successvar) go to 8
        read(c77,'(29i1)',err=8) apsymmyns1(1:29)
        apsymmyns1=2*apsymmyns1-1
      endif
    endif

    if(len_trim(mycall).lt.3) return

    if(.not.lhound .and. lmycallstd .and. (lhiscallstd .or. lnohiscall)) then
      msg=trim(mycall)//' '//trim(hiscallt)//' RRR'
      i3=0; n3=0
      call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
      call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
      if(i3.ne.1 .or. (msg.ne.msgchk) .or. .not.unpk77_successvar) go to 9
      read(c77,'(58i1)',err=9) apsym(1:58)
      apsym=2*apsym-1; if(lnohiscall) apsym(30)=99
    endif

    if(lhound) then
! standard messages from Fox, always base callsigns
      if(len_trim(hisbcall).gt.2 .and. len_trim(mybcall).gt.2) then
        msg=trim(mybcall)//' '//trim(hisbcall)//' -15'
        call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
        call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
        if(i3.ne.1 .or. (msg.ne.msgchk) .or. .not.unpk77_successvar) go to 9
        read(c77,'(58i1)',err=9) apsym(1:58)
        apsym=2*apsym-1
      else
        apsym(30)=99
      endif

! special messages
      msg=trim(mycall)//' RR73; '//trim(mycall)//' <'//trim(hiscallt)//'> -16'
      i3=0; n3=1
      call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
      call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
      i1=0; i1=index(msgchk,'<'); if(i1.lt.15) return
      if(i3.ne.0 .or. msg(1:i1).ne.msgchk(1:i1) .or. .not.unpk77_successvar) go to 10
      read(c77,'(66i1)',err=10) apsymsp(1:66)
      apsymsp=2*apsymsp-1!; if(lnohiscall) apsymsp(30)=99
    endif

    if(.not.lhound .and. lmycallstd .and. .not.lhiscallstd .and. len_trim(hiscall).gt.2) then
      msg=trim(mycall)//' <'//trim(hiscall)//'> -16' ! report, rreport
      call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
      call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
      if(i3.ne.1 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 11
      read(c77,'(58i1)',err=11) apsymdxns1(1:58)
      apsymdxns1=2*apsymdxns1-1

      msg='<'//trim(mycall)//'> '//trim(hiscall)//' RRR'
      call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
      call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
      if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 12
      read(c77,'(77i1)',err=12) apsymdxnsrrr(1:77)
      apsymdxnsrrr=2*apsymdxnsrrr-1

      msg='<'//trim(mycall)//'> '//trim(hiscall)//' RR73'
      call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
      call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
      if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 13
      read(c77,'(77i1)',err=13) apsymdxnsr73(1:77)
      apsymdxnsr73=2*apsymdxnsr73-1

      msg='<'//trim(mycall)//'> '//trim(hiscall)//' 73'
      call pack77_for_state(codec,msg,i3,n3,c77,no_tx_hash_options)
      call unpack77_configured_for_state(codec,c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
      if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 14
      read(c77,'(77i1)',err=14) apsymdxns732(1:77)
      apsymdxns732=2*apsymdxns732-1
    endif

  endif

  go to 32

1 apcqsym=0; apcqsym(1)=99; apcqsym(30)=99; go to 32
2 apsymdxstd=0; apsymdxstd(1)=99; apsymdxstd(30)=99; go to 32
3 apsymdxnsrr73=0; apsymdxnsrr73(1)=99; apsymdxnsrr73(30)=99; go to 32
4 apsymdxns73=0; apsymdxns73(1)=99; apsymdxns73(30)=99; go to 32
5 apsymmyns2=0; apsymmyns2(1)=99; apsymmyns2(30)=99; go to 32
6 apsymmynsrr73=0; apsymmynsrr73(1)=99; apsymmynsrr73(30)=99; go to 32
7 apsymmyns73=0; apsymmyns73(1)=99; apsymmyns73(30)=99; go to 32
8 apsymmyns1=0; apsymmyns1(1)=99; go to 32
9 apsym=0; apsym(1)=99; apsym(30)=99; go to 32
10 apsymsp=0; apsymsp(1)=99; apsymsp(30)=99; go to 32
11 apsymdxns1=0; apsymdxns1(1)=99; apsymdxns1(30)=99; go to 32
12 apsymdxnsrrr=0; apsymdxnsrrr(1)=99; apsymdxnsrrr(30)=99; go to 32
13 apsymdxnsr73=0; apsymdxnsr73(1)=99; apsymdxnsr73(30)=99; go to 32
14 apsymdxns732=0; apsymdxns732(1)=99; apsymdxns732(30)=99; go to 32
15 apsymmynsrrr=0; apsymmynsrrr(1)=99; apsymmynsrrr(30)=99; go to 32

32 continue

  return
end subroutine ft8apsetvar