summaryrefslogtreecommitdiff
path: root/map65/libm65/display.f90
blob: 811cea50f09d576162d54fd8676101332ef5ee20 (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
subroutine display(nkeep,ftol)

  parameter (MAXLINES=400,MX=400,MAXCALLS=500)
  integer indx(MAXLINES),indx2(MX)
  character*83 line(MAXLINES),line2(MX),line3(MAXLINES)
  character out*52,out0*52,cfreq0*3,livecq*58
  character*6 callsign,callsign0
  character*12 freqcall(MAXCALLS)
  real freqkHz(MAXLINES)
  integer utc(MAXLINES),utc2(MX),utcz
  real*8 f0
  save

  out0=' '
  rewind(26)

  do i=1,MAXLINES
     read(26,1010,end=10) line(i)
1010 format(a77)
     read(line(i),1020) f0,ndf,nh,nm
1020 format(f8.3,i5,25x,i3,i2)
     utc(i)=60*nh + nm
     freqkHz(i)=1000.d0*(f0-144.d0) + 0.001d0*ndf
  enddo

10 backspace(26)
  nz=i-1
  utcz=utc(nz)
  nz=nz-1
  if(nz.lt.1) go to 999
  nquad=max(nkeep/4,3)
  do i=1,nz
     nage=utcz-utc(i)
     if(nage.lt.0) nage=nage+1440
     iage=nage/nquad
     write(line(i)(73:74),1021) iage
1021 format(i2)
  enddo

  nage=utcz-utc(1)
  if(nage.lt.0) nage=nage+1440
  if(nage.gt.nkeep) then
     do i=1,nz
        nage=utcz-utc(i)
        if(nage.lt.0) nage=nage+1440
        if(nage.le.nkeep) go to 20
     enddo
20   i0=i
     nz=nz-i0+1
     rewind(26)
     if(nz.lt.1) go to 999
     do i=1,nz
        j=i+i0-1
        line(i)=line(j)
        utc(i)=utc(j)
        freqkHz(i)=freqkHz(j)
        write(26,1022) line(i)
1022    format(a77)
     enddo
  endif

  call flush(26)
  call indexx(freqkHz,nz,indx)

  nstart=1
  k3=0
  k=1
  m=indx(1)
  if(m.lt.1 .or. m.gt.MAXLINES) then
     print*,'Error in display.f90: ',nz,m
     m=1
  endif
  line2(1)=line(m)
  utc2(1)=utc(m)
  do i=2,nz
     j0=indx(i-1)
     j=indx(i)
     if(freqkHz(j)-freqkHz(j0).gt.2.0*ftol) then
        if(nstart.eq.0) then
           k=k+1
           line2(k)=""
           utc2(k)=-1
        endif
        kz=k
        if(nstart.eq.1) then
           call indexx(float(utc2(1:kz)),kz,indx2)
           k3=0
           do k=1,kz
              k3=min(k3+1,400)
              line3(k3)=line2(indx2(k))
           enddo
           nstart=0
        else
           call indexx(float(utc2(1:kz)),kz,indx2)
           do k=1,kz
              k3=min(k3+1,400)
              line3(k3)=line2(indx2(k))
           enddo
        endif
        k=0
     endif
     if(i.eq.nz) then
        k=k+1
        line2(k)=""
        utc2(k)=-1
     endif
     k=k+1
     line2(k)=line(j)
     utc2(k)=utc(j)
     j0=j
  enddo
  kz=k
  call indexx(float(utc2(1:kz)),kz,indx2)
  do k=1,kz
     k3=min(k3+1,400)
     line3(k3)=line2(indx2(k))
  enddo

  rewind 19
  rewind 20
  cfreq0='   '
  nc=0
  callsign0='      '
  do k=1,k3
     out=line3(k)(6:13)//line3(k)(28:31)//line3(k)(39:45)//       &
          line3(k)(35:38)//line3(k)(46:74)
     if(out(1:3).ne.'   ') then
        cfreq0=out(1:3)
        livecq=line3(k)(6:13)//line3(k)(28:31)//line3(k)(39:45)//       &
             line3(k)(23:27)//line3(k)(35:38)//line3(k)(46:70)//        &
             line3(k)(73:77)
        if(livecq(56:56).eq.':') livecq(56:58)=' '//livecq(56:57)
        if(index(livecq,' CQ ').gt.0 .or. index(livecq,' QRZ ').gt.0 .or.   &
           index(livecq,' QRT ').gt.0 .or. index(livecq,' CQV ').gt.0 .or.  &
           index(livecq,' CQH ').gt.0) write(19,1029) livecq
1029    format(a58)

! Suppress listing duplicate (same time, decoded message, and frequency)
        if(out(14:17).ne.out0(14:17) .or. out(26:50).ne.out0(26:50) .or.  &
             out(1:3).ne.out0(1:3)) then
           write(*,1030) out                  !Messages
1030       format('@',a52)
           out0=out
        endif

        i1=index(out(26:),' ')
        callsign=out(i1+26:)
        i2=index(callsign,' ')
        if(i2.gt.1) callsign(i2:)='      '
        if(callsign.ne.'      ' .and. callsign.ne.callsign0) then
           len=i2-1
           if(len.lt.0) len=6
           if(len.ge.4) then                        !Omit short "callsigns"
              if(nc.lt.MAXCALLS) nc=nc+1
              freqcall(nc)=cfreq0//' '//callsign//line3(k)(73:74)
              callsign0=callsign
           endif
        endif
        if(callsign.ne.'      ' .and. callsign.eq.callsign0) then
           freqcall(nc)=cfreq0//' '//callsign//line3(k)(73:74)
        endif
     endif
  enddo
  flush(19)
  if(nc.lt.MAXCALLS) nc=nc+1
  freqcall(nc)='            '
  if(nc.lt.MAXCALLS) nc=nc+1
  freqcall(nc)='            '
  freqcall(nc+1)='            '
  freqcall(nc+2)='            '

  do i=1,nc
  write(*,1042) freqcall(i)                         !Band Map
1042 format('&',a12)
  enddo

999  continue
  return
end subroutine display