summaryrefslogtreecommitdiff
path: root/lib/77bit
diff options
context:
space:
mode:
authorChristoph Berg <christoph.berg@credativ.de>2019-03-11 14:19:23 +0100
committerChristoph Berg <christoph.berg@credativ.de>2019-03-11 14:19:23 +0100
commit200de07a95209a55d6019ba87f0abc78d302bf4c (patch)
tree3b2922eb5d89b01ad214cae492e871c3bfb5df18 /lib/77bit
parente0737c56c1e384e05064a0c6e1ac46979371041b (diff)
New upstream version 2.0.1+repackupstream/2.0.1+repack
Diffstat (limited to 'lib/77bit')
-rw-r--r--lib/77bit/encode77.f902
-rw-r--r--lib/77bit/packjt77.f90203
2 files changed, 126 insertions, 79 deletions
diff --git a/lib/77bit/encode77.f90 b/lib/77bit/encode77.f90
index 987efc4f..4b2a1355 100644
--- a/lib/77bit/encode77.f90
+++ b/lib/77bit/encode77.f90
@@ -34,7 +34,7 @@ program encode77
i3=-1
n3=-1
call pack77(msg0(1:37),i3,n3,c77)
- call unpack77(c77,msg,unpk77_success)
+ call unpack77(c77,1,msg,unpk77_success)
cerr=' '
if(msg.ne.msg0(1:37)) cerr='*'
if(i3.eq.0) write(*,1004) i3,n3,cerr,msg0(1:37),msg
diff --git a/lib/77bit/packjt77.f90 b/lib/77bit/packjt77.f90
index 645da5bf..1ee37f5c 100644
--- a/lib/77bit/packjt77.f90
+++ b/lib/77bit/packjt77.f90
@@ -2,10 +2,15 @@ module packjt77
! These variables are accessible from outside via "use packjt77":
parameter (MAXHASH=1000,MAXRECENT=10)
- character*13 callsign(MAXHASH)
- integer ihash10(MAXHASH),ihash12(MAXHASH),ihash22(MAXHASH)
- integer n28a,n28b,nzhash
- character*13 recent_calls(MAXRECENT)
+ character (len=13), dimension(1:1024) :: calls10=''
+ character (len=13), dimension(1:4096) :: calls12=''
+ character (len=13), dimension(1:MAXHASH) :: calls22=''
+ character (len=13), dimension(1:MAXRECENT) :: recent_calls=''
+ character (len=13) :: mycall13=''
+ character (len=13) :: dxcall13=''
+ integer, dimension(1:MAXHASH) :: ihash22=-1
+ integer :: nzhash=0
+ integer n28a,n28b
contains
@@ -14,15 +19,13 @@ subroutine hash10(n10,c13)
character*13 c13
c13='<...>'
- do i=1,nzhash
- if(ihash10(i).eq.n10) then
- c13=callsign(i)
- c13='<'//trim(c13)//'>'//' '
- go to 900
- endif
- enddo
+ if(n10.lt.1 .or. n10.gt.1024) return
+ if(len(trim(calls10(n10))).gt.0) then
+ c13=calls10(n10)
+ c13='<'//trim(c13)//'>'
+ endif
+ return
-900 return
end subroutine hash10
subroutine hash12(n12,c13)
@@ -30,15 +33,13 @@ subroutine hash12(n12,c13)
character*13 c13
c13='<...>'
- do i=1,nzhash
- if(ihash12(i).eq.n12) then
- c13=callsign(i)
- c13='<'//trim(c13)//'>'//' '
- go to 900
- endif
- enddo
+ if(n12.lt.1 .or. n12.gt.4096) return
+ if(len(trim(calls12(n12))).gt.0) then
+ c13=calls12(n12)
+ c13='<'//trim(c13)//'>'
+ endif
+ return
-900 return
end subroutine hash12
@@ -49,8 +50,8 @@ subroutine hash22(n22,c13)
c13='<...>'
do i=1,nzhash
if(ihash22(i).eq.n22) then
- c13=callsign(i)
- c13='<'//trim(c13)//'>'//' '
+ c13=calls22(i)
+ c13='<'//trim(c13)//'>'
go to 900
endif
enddo
@@ -79,46 +80,37 @@ end function ihashcall
subroutine save_hash_call(c13,n10,n12,n22)
character*13 c13,cw
- logical first
- data first/.true./
- save first
-
- if(first) then
- ihash10=-1
- ihash12=-1
- ihash22=-1
- callsign=' '
- nzhash=0
- first=.false.
- endif
-
+
cw=c13
if(cw(1:1).eq.' ' .or. cw(1:5).eq.'<...>') return
if(cw(1:1).eq.'<') cw=cw(2:)
i=index(cw,'>')
if(i.gt.0) cw(i:)=' '
+ if(len(trim(cw)) .lt. 3) return
+
n10=ihashcall(cw,10)
+ if(n10.ge.1 .and. n10 .le. 1024 .and. cw.ne.mycall13) calls10(n10)=cw
+
n12=ihashcall(cw,12)
+ if(n12.ge.1 .and. n12 .le. 4096 .and. cw.ne.mycall13) calls12(n12)=cw
+
n22=ihashcall(cw,22)
- do i=1,nzhash
- if(ihash22(i).eq.n22) go to 900 !This one is already in the table
- enddo
+ if(any(ihash22.eq.n22)) then ! If entry exists, make sure callsign is the most recently received one
+ where(ihash22.eq.n22) calls22=cw
+ go to 900
+ endif
! New entry: move table down, making room for new one at the top
- ihash10(MAXHASH:2:-1)=ihash10(MAXHASH-1:1:-1)
- ihash12(MAXHASH:2:-1)=ihash12(MAXHASH-1:1:-1)
ihash22(MAXHASH:2:-1)=ihash22(MAXHASH-1:1:-1)
! Add the new entry
- callsign(MAXHASH:2:-1)=callsign(MAXHASH-1:1:-1)
- ihash10(1)=n10
- ihash12(1)=n12
+ calls22(MAXHASH:2:-1)=calls22(MAXHASH-1:1:-1)
ihash22(1)=n22
- callsign(1)=cw
+ calls22(1)=cw
if(nzhash.lt.MAXHASH) nzhash=nzhash+1
-
-900 return
+900 continue
+ return
end subroutine save_hash_call
subroutine pack77(msg0,i3,n3,c77)
@@ -154,7 +146,7 @@ subroutine pack77(msg0,i3,n3,c77)
! Check 0.5 (telemetry)
5 i0=index(msg,' ')
- c18=msg(1:i0-1)//' '
+ c18=msg(1:i0-1)
c18=adjustr(c18)
ntel=-99
read(c18,1005,err=6) ntel
@@ -190,8 +182,13 @@ subroutine pack77(msg0,i3,n3,c77)
900 return
end subroutine pack77
-subroutine unpack77(c77,msg,unpk77_success)
-
+subroutine unpack77(c77,nrx,msg,unpk77_success)
+!
+! nrx=1 when unpacking a received message
+! nrx=0 when unpacking a to-be-transmitted message
+! the value of nrx is used to decide when mycall13 or dxcall13 should
+! be used in place of a callsign from the hashtable
+!
parameter (NSEC=84) !Number of ARRL Sections
parameter (NUSCAN=65) !Number of US states and Canadian provinces
parameter (MAXGRID4=32400)
@@ -200,6 +197,7 @@ subroutine unpack77(c77,msg,unpk77_success)
character*77 c77
character*37 msg
character*13 call_1,call_2,call_3
+ character*13 mycall13_0,dxcall13_0
character*11 c11
character*3 crpt,cntx
character*3 cmult(NUSCAN)
@@ -207,7 +205,9 @@ subroutine unpack77(c77,msg,unpk77_success)
character*4 grid4,cserial
character*3 csec(NSEC)
character*38 c
+ integer hashmy10,hashmy12,hashmy22,hashdx10,hashdx12,hashdx22
logical unpk28_success,unpk77_success
+ logical dxcall13_set,mycall13_set
data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ/'/
data csec/ &
@@ -228,7 +228,32 @@ subroutine unpack77(c77,msg,unpk77_success)
"SD ","TN ","TX ","UT ","VT ","VA ","WA ","WV ","WI ","WY ", &
"NB ","NS ","QC ","ON ","MB ","SK ","AB ","BC ","NWT","NF ", &
"LB ","NU ","YT ","PEI","DC "/
+ data dxcall13_set/.false./
+ data mycall13_set/.false./
+ data mycall13_0/''/
+ data dxcall13_0/''/
+
+ save hashmy10,hashmy12,hashmy22,hashdx10,hashdx12,hashdx22
+
+ if(mycall13.ne.mycall13_0) then
+ if(len(trim(mycall13)).gt.2) then
+ mycall13_set=.true.
+ mycall13_0=mycall13
+ call save_hash_call(mycall13,hashmy10,hashmy12,hashmy22)
+ else
+ mycall13_set=.false.
+ endif
+ endif
+ if(dxcall13.ne.dxcall13_0) then
+ if(len(trim(dxcall13)).gt.2) then
+ dxcall13_set=.true.
+ dxcall13_0=dxcall13
+ hashdx10=ihashcall(dxcall13,10)
+ hashdx12=ihashcall(dxcall13,12)
+ hashdx22=ihashcall(dxcall13,22)
+ endif
+ endif
unpk77_success=.true.
! Check for bad data
@@ -261,13 +286,13 @@ subroutine unpack77(c77,msg,unpk77_success)
call unpack28(n28b,call_2,unpk28_success)
if(.not.unpk28_success .or. n28b.le.2) unpk77_success=.false.
call hash10(n10,call_3)
- if(call_3(1:1).eq.'<') then
- msg=trim(call_1)//' RR73; '//trim(call_2)//' '//trim(call_3)// &
- ' '//crpt
- else
- msg=trim(call_1)//' RR73; '//trim(call_2)//' <'//trim(call_3)// &
- '> '//crpt
- endif
+ if(nrx.eq.1 .and. &
+ dxcall13_set .and. &
+ hashdx10.eq.n10) call_3='<'//trim(dxcall13)//'>'
+ if(nrx.eq.0 .and. &
+ mycall13_set .and. &
+ n10.eq.hashmy10) call_3='<'//trim(mycall13)//'>'
+ msg=trim(call_1)//' RR73; '//trim(call_2)//' '//trim(call_3)//' '//crpt
else if(i3.eq.0 .and. n3.eq.2) then
! 0.2 PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 70 EU VHF contest
read(c77,1020) n28a,ip,ir,irpt,iserial,igrid6
@@ -275,7 +300,7 @@ subroutine unpack77(c77,msg,unpk77_success)
call unpack28(n28a,call_1,unpk28_success)
if(.not.unpk28_success .or. n28a.le.2) unpk77_success=.false.
nrs=52+irpt
- if(ip.eq.1) call_1=trim(call_1)//'/P'//' '
+ if(ip.eq.1) call_1=trim(call_1)//'/P'
write(cexch,1022) nrs,iserial
1022 format(i2,i4.4)
n=igrid6
@@ -438,14 +463,25 @@ subroutine unpack77(c77,msg,unpk77_success)
n58=n58/38
enddo
call hash12(n12,call_3)
- if(iflip.eq.0) then
- call_1=call_3
- call_2=adjustl(c11)//' '
+ if(iflip.eq.0) then ! 12 bit hash for TO call
+ call_1=call_3
+ call_2=adjustl(c11)//' '
call add_call_to_recent_calls(call_2)
- else
- call_1=adjustl(c11)//' '
- call_2=call_3
+ if(nrx.eq.1 .and. &
+ dxcall13_set .and. mycall13_set .and. &
+ call_2.eq.dxcall13 .and. &
+ n12.eq.hashmy12 ) call_1='<'//trim(mycall13)//'>'
+ if(nrx.eq.1 .and. &
+ mycall13_set .and. &
+ index(call_1,'<...>').gt.0 .and. &
+ n12.eq.hashmy12 ) call_1='<'//trim(mycall13)//'>'
+ else ! 12 bit hash for DE call
+ call_1=adjustl(c11)
+ call_2=call_3
call add_call_to_recent_calls(call_1)
+ if(nrx.eq.0 .and. &
+ mycall13_set .and. &
+ n12.eq.hashmy12) call_2='<'//trim(mycall13)//'>'
endif
if(icq.eq.0) then
if(nrpt.eq.0) msg=trim(call_1)//' '//trim(call_2)
@@ -523,7 +559,7 @@ subroutine pack28(c13,n28)
go to 900
endif
if(nlet.ge.1 .and. nlet.le.4 .and. nnum.eq.0) then
- c4=c13(4:n)//' '
+ c4=c13(4:n)
c4=adjustr(c4)
m=0
do i=1,4
@@ -541,6 +577,9 @@ subroutine pack28(c13,n28)
! Check for <...> callsign
if(c13(1:1).eq.'<')then
call save_hash_call(c13,n10,n12,n22) !Save callsign in hash table
+ i2=index(c13,'>')
+ c13=c13(2:i2-1)
+ n22=ihashcall(c13,22)
n28=NTOKENS + n22
go to 900
endif
@@ -566,6 +605,7 @@ subroutine pack28(c13,n28)
npdig.ge.iarea-1 .or. nslet.gt.3) then
! Treat this as a nonstandard callsign: compute its 22-bit hash
call save_hash_call(c13,n10,n12,n22) !Save callsign in hash table
+ n22=ihashcall(c13,n22)
n28=NTOKENS + n22
go to 900
endif
@@ -653,7 +693,7 @@ subroutine unpack28(n28_0,c13,success)
i5=n/27
i6=n-27*i5
c13=c1(i1+1:i1+1)//c2(i2+1:i2+1)//c3(i3+1:i3+1)//c4(i4+1:i4+1)// &
- c4(i5+1:i5+1)//c4(i6+1:i6+1)//' '
+ c4(i5+1:i5+1)//c4(i6+1:i6+1)
c13=adjustl(c13)
900 i0=index(c13,' ')
@@ -718,7 +758,7 @@ subroutine pack77_01(nwords,w,i3,n3,c77)
! Pack a Type 0.1 message: DXpedition mode
! Example message: "K1ABC RR73; W9XYZ <KH1/KH7Z> -11" 28 28 10 5
- character*13 w(19)
+ character*13 w(19),c13
character*77 c77
character*6 bcall_1,bcall_2
logical ok1,ok2
@@ -744,6 +784,9 @@ subroutine pack77_01(nwords,w,i3,n3,c77)
call pack28(w(1),n28a)
call pack28(w(3),n28b)
call save_hash_call(w(4),n10,n12,n22)
+ i2=index(w(4),'>')
+ c13=w(4)(2:i2-1)
+ n10=ihashcall(c13,10)
write(c77,1010) n28a,n28b,n10,n5,n3,i3
1010 format(2b28.28,b10.10,b5.5,2b3.3)
@@ -777,13 +820,14 @@ subroutine pack77_02(nwords,w,i3,n3,c77)
! Type 0.2: PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 70 EU VHF contest
i3=0
n3=2
- ip=0
- c13=w(1)
- i=index(w(1),'/P')
+ i=index(w(1)//' ','/P ')
if(i.ge.4) then
ip=1
- c13=w(1)(1:i-1)//' '
- endif
+ c13=w(1)(1:i-1)
+ else
+ ip=0
+ c13=w(1)
+ end if
call pack28(c13,n28a)
ir=0
if(w(2)(1:2).eq.'R ') ir=1
@@ -924,22 +968,24 @@ subroutine pack77_1(nwords,w,i3,n3,c77)
! 1 WA9XYZ/R KA1ABC/R R FN42 28 1 28 1 1 15 74 Standard msg
! 2 PA3XYZ/P GM4ABC/P R JO22 28 1 28 1 1 15 74 EU VHF contest
-10 if(nwords.eq.2 .or. nwords.eq.3 .or. (nwords.eq.4 .and. &
- w(3)(1:2).eq.'R ')) then
+10 i1psuffix=index(w(1)//' ' ,'/P ')
+ i2psuffix=index(w(2)//' ','/P ')
+ if(nwords.eq.2 .or. nwords.eq.3 .or. (nwords.eq.4 .and. &
+ w(3)(1:2).eq.'R ')) then
n3=0
i3=1 !Type 1: Standard message, possibly with "/R"
- if(index(w(1),'/P').ge.4 .or. index(w(2),'/P').ge.4) i3=2 !Type 2, with "/P"
+ if (i1psuffix.ge.4.or.i2psuffix.ge.4) i3=2 !Type 2, with "/P"
endif
- c13=bcall_1//' '
+ c13=bcall_1
if(c13(1:3).eq.'CQ_' .or. w(1)(1:1).eq.'<') c13=w(1)
call pack28(c13,n28a)
- c13=bcall_2//' '
+ c13=bcall_2
if(w(2)(1:1).eq.'<') c13=w(2)
call pack28(c13,n28b)
ipa=0
ipb=0
- if(index(w(1),'/P').ge.4 .or. index(w(1),'/R').ge.4) ipa=1
- if(index(w(2),'/P').ge.4 .or. index(w(2),'/R').ge.4) ipb=1
+ if(i1psuffix.ge.4.or.index(w(1)//' ','/R ').ge.4) ipa=1
+ if(i2psuffix.ge.4.or.index(w(2)//' ','/R ').ge.4) ipb=1
grid4=w(nwords)(1:4)
if(is_grid4(grid4)) then
@@ -1200,6 +1246,7 @@ subroutine add_call_to_recent_calls(callsign)
character*13 callsign
logical ladd
+
! only add if the callsign is not already on the list
ladd=.true.
do i=1,MAXRECENT-1 ! if callsign is at the end of the list add it again