WOMBAT – A program for Mixed Model Analyses by Restricted Maximum Likelihood

hash_example.f90
program xxx
 
use hash_tables
 
implicit none
integer, parameter      :: nex = 10
integer, dimension(nex) :: my_ids =(/ 772, 9999, 263643, 789, 1281, 66661, &
&                                    55,  12132,  789, 111111 /)
integer                 :: i, idorig, idnew, ipos
 
! define how many lists
  mlists = 1
 
! allocate arrays
  call hash_setup
 
! recode in running order
  do i = 1, nex
     idorig = my_ids(i)
     call hash_it(idorig, 1, idnew, ipos, .false.)
 
!    call hash_it(idorig, ivar, idnew, ipos, noadd)
!       idorig = ID to be recoded
!       ivar   = list no. (1, 2, ..., mlists)
!       idnew  = new ID
!       ipos   = position in hash table (rarely used)
!       noadd  = option: .false. adds new IDs
!                  .true.  does not add new IDs, just looks up position
 
end do
 
print *,'no. of elements in hash table', nlevels
 
do i = 1, nlevels(1)
   idnew = hash_idorig(i,1)
   print *,i, idnew
end do
 
! look up the original ID for a given position
! function  hashid_orig(idnew, ivar)
 
! deallocate hash tables
  call hash_deall
 
end program xxx
Print/export
QR Code
QR Code fortran:hashfront (generated for current page)