1 |
module gensig_m |
2 |
|
3 |
implicit none |
4 |
|
5 |
contains |
6 |
|
7 |
SUBROUTINE gensig (str, sig) |
8 |
|
9 |
! Generate a signature from the first 30 characters of the string |
10 |
! This signature is not unique and thus when one looks for the one |
11 |
! needs to also verify the string. |
12 |
|
13 |
IMPLICIT NONE |
14 |
|
15 |
CHARACTER(LEN=*) str |
16 |
INTEGER sig |
17 |
|
18 |
INTEGER i |
19 |
INTEGER, DIMENSION(30):: prime = (/1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, & |
20 |
31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, & |
21 |
103, 107, 109/) |
22 |
|
23 |
!--------------------------------------------------------------------- |
24 |
|
25 |
sig = 0 |
26 |
DO i=1, MIN(len_trim(str), 30) |
27 |
sig = sig + prime(i)*IACHAR(str(i:i)) |
28 |
ENDDO |
29 |
|
30 |
END SUBROUTINE gensig |
31 |
|
32 |
end module gensig_m |