New command-line program hash22calc will print the 22-bit hash value of a valid callsign.

This commit is contained in:
Steven Franke 2023-02-16 09:00:29 -06:00
parent f79e52a655
commit 53bf3f4de1

40
lib/77bit/hash22calc.f90 Normal file
View File

@ -0,0 +1,40 @@
program hash22calc
! Given a valid callsign, calculate and print its 22-bit hash.
use packjt77
character*13 callsign
character*1 c
character*6 basecall
logical cok
nargs=iargc()
if(nargs.ne.1) then
print*,'Given a valid callsign, print its 22-bit hash.'
print*,'Usage: hashcalc <callsign>'
go to 999
endif
call getarg(1,callsign)
! convert to upper case
ilen=len(trim(callsign))
do i=1, ilen
c=callsign(i:i)
if(c.ge.'a' .and. c.le.'z') c=char(ichar(c)-32) !Force upper case
callsign(i:i)=c
enddo
! check for a valid callsign
call chkcall(callsign,basecall,cok)
if(.not.cok) then
print*,'Invalid callsign'
goto 999
endif
! calculate the hash
n22 = ihashcall(callsign,22)
write(*,'(a,i7.7)') callsign,n22
999 end program hash22calc
include '../chkcall.f90'