MAPL_HashMod Module

MODULE: MAPL_HashMod

Author: GMAO SI-Team

MAPL_HashMod – A utility to manage hash tables.

MAPL_HashMod is a FORTRAN binding to a simple C has facility.

The API is:

   ! Create a hash table with Nbuckets

       integer function MAPL_HashCreate(Nbuckets)
         integer, intent(IN) :: Nbuckets

   ! Update table Hash with integer[s] i[,j]
   ! The return value is the order of occurence of the integer[s].
   ! If i is new, the return value is the new hash size.

       integer function MAPL_HashIncrement(Hash,i,j)
         integer,           intent(IN) :: Hash
         integer,           intent(IN) :: i
         integer, optional, intent(IN) :: j

   ! Dump the list of integers or integer pairs in the hash.
   !  The list is in no particular order.
   ! If the arrays are not long enough, nothing is dumped and -1
   !  is returned; otherwise it returns the current hash size 
   !  (the length of the list).

       integer function MAPL_HashDump(Hash,i,j)
         integer,           intent(IN)  :: Hash
         integer,           intent(OUT) :: i(:)
         integer, optional, intent(OUT) :: j(:)

   ! Get the size of a hash

       integer function MAPL_HashSize(Hash)
         integer, intent(IN) :: Hash

   ! Destroy a hash table

       subroutine MAPL_HashDestroy(Hash)
         integer, intent(IN) :: Hash

The following is a sample usage that makes a list of unique integers in the large array II. It can similarly be used to find ordered pairs of integers. The asserts are put in to clarify the usage.

       integer :: Hash, k, II(100000), FoundOrder(10000)

       Hash = MAPL_HashCreate(1000)

       latest = 0
       do i=1,100000
         k = MAPL_HashIncrement(Hash,ii(i))
         if(k>latest) then
           latest   = k
           isnew    = .true.
           FoundOrder(k) = ii(i)
           if(MAPL_Assert(k==MAPL_HashSize(Hash),'needs informative message',1,"/home/runner/work/MAPL/MAPL/shared/MAPL_Hash.F90",76 ,rc)) return
         else
           isnew = .false.
           if(MAPL_Assert(FoundOrder(k)==ii(i),'needs informative message',1,"/home/runner/work/MAPL/MAPL/shared/MAPL_Hash.F90",79 ,rc)) return
         endif
       enddo

Uses

  • module~~mapl_hashmod~~UsesGraph module~mapl_hashmod MAPL_HashMod module~mapl_exceptionhandling MAPL_ExceptionHandling module~mapl_hashmod->module~mapl_exceptionhandling module~mapl_errorhandlingmod MAPL_ErrorHandlingMod module~mapl_exceptionhandling->module~mapl_errorhandlingmod module~mapl_throwmod MAPL_ThrowMod module~mapl_exceptionhandling->module~mapl_throwmod module~mapl_errorhandlingmod->module~mapl_throwmod mpi mpi module~mapl_errorhandlingmod->mpi

Used by

  • module~~mapl_hashmod~~UsedByGraph module~mapl_hashmod MAPL_HashMod module~mapl_locstreammod MAPL_LocStreamMod module~mapl_locstreammod->module~mapl_hashmod module~maplbase_mod MAPLBase_Mod module~maplbase_mod->module~mapl_hashmod module~maplbase_mod->module~mapl_locstreammod module~maplshared MaplShared module~maplshared->module~mapl_hashmod module~extdatautroot_gridcompmod ExtDataUtRoot_GridCompMod module~extdatautroot_gridcompmod->module~maplshared module~mapl MAPL module~mapl->module~maplbase_mod module~mapl_capgridcompmod MAPL_CapGridCompMod module~mapl_capgridcompmod->module~mapl_locstreammod module~mapl_genericmod MAPL_GenericMod module~mapl_genericmod->module~mapl_locstreammod module~mapl_genericmod->module~maplshared module~mapl_historygridcompmod MAPL_HistoryGridCompMod module~mapl_historygridcompmod->module~mapl_locstreammod module~mapl_nuopcwrappermod MAPL_NUOPCWrapperMod module~mapl_nuopcwrappermod->module~maplbase_mod module~rutmod RUTMod module~rutmod->module~maplbase_mod module~test_cfio_bundle Test_CFIO_Bundle module~test_cfio_bundle->module~maplbase_mod program~tstqsat tstqsat program~tstqsat->module~maplbase_mod program~ut_extdata ut_ExtData program~ut_extdata->module~maplbase_mod program~utcfio~2 utCFIO program~utcfio~2->module~maplbase_mod

Functions

public function MAPL_HashCreate(Nbuckets)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: Nbuckets

Return Value integer

public function MAPL_HashDump(Hash, i, j)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: Hash
integer, intent(out) :: i(:)
integer, intent(out), optional :: j(:)

Return Value integer

public function MAPL_HashIncrement(Hash, i, j, k)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: Hash
integer, intent(in) :: i
integer, intent(in), optional :: j
integer, intent(in), optional :: k

Return Value integer

public function MAPL_HashSize(Hash)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: Hash

Return Value integer


Subroutines

public subroutine MAPL_HashDestroy(Hash)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: Hash