File: code426.f90

package info (click to toggle)
wsjtx 2.3.0%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 63,524 kB
  • sloc: cpp: 59,051; f90: 34,130; python: 27,241; ansic: 11,205; fortran: 2,051; sh: 132; makefile: 109
file content (62 lines) | stat: -rw-r--r-- 1,755 bytes parent folder | download | duplicates (4)
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
program code426

  parameter (MZ=26)                !Number of 4-FSK symbols
  parameter (JZMAX=64)             !Desired number of codewords
  integer ic(MZ,JZMAX),icsave(MZ)
  real c(MZ)
  character*12 arg

  nargs=iargc()
  if(nargs.ne.2) then
     print*,'Usage:   code426 <nmsgs> <iters>'
     print*,'Example: code426   64   10000000'
     go to 999
  endif
  call getarg(1,arg)
  read(arg,*) nmsgs
  call getarg(2,arg)
  read(arg,*) iters

  call init_random_seed()

  open(13,file='code426.out',status='unknown')

  write(*,1002) nmsgs,iters
  write(13,1002) nmsgs,iters
1002 format('Nmsgs:',i4,'   Iters:',i10/(66('-')))
  
  do i=1,MZ                     !Create 4 mutually orthogonal codewords
     ic(i,1)=mod(i-1,4)
     ic(i,2)=mod(i,4)
     ic(i,3)=mod(i+1,4)
     ic(i,4)=mod(i+2,4)
  enddo

  do j=1,4                      !Write them out
     write(*,1000) j,MZ,ic(1:MZ,j)
     write(13,1000) j,MZ,ic(1:MZ,j)
1000 format(2i5,3x,26i2)
  enddo
 
  do j=5,nmsgs                  !Find codewords up to j=nmsgs with maximum
     npk=0                      !distance from all the rest
     do i=1,iters
        call random_number(c)   !Generate a random codeword candidate
        ic(1:MZ,j)=int(4*c)     !Convert real to integer
!        nd=MZ
!        do k=1,j-1              !Test candidate against all others in list
!           n=count(ic(1:MZ,j).ne.ic(1:MZ,k))
!           nd=min(n,nd)
!        enddo
        call dist426(ic,j,mind)
        if(mind.gt.npk) then
           npk=mind
           icsave=ic(1:MZ,j)    !Best candidate so far, save it
!           if(npk.ge.19) exit   !It won't get any better...
        endif
     enddo
     write(*,1000) j,npk,ic(1:MZ,j)
     write(13,1000) j,npk,ic(1:MZ,j)
  enddo

999 end program code426