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~extdatautroot_gridcompmod->module~mapl module~varspecdescriptionmod VarspecDescriptionMod module~extdatautroot_gridcompmod->module~varspecdescriptionmod module~mapl->module~maplbase_mod module~mapl_genericmod MAPL_GenericMod module~mapl->module~mapl_genericmod module~mapl_capgridcompmod MAPL_CapGridCompMod module~mapl_capgridcompmod->module~mapl_locstreammod module~mapl_capgridcompmod->module~mapl_genericmod module~mapl_historygridcompmod MAPL_HistoryGridCompMod module~mapl_capgridcompmod->module~mapl_historygridcompmod module~mapl_extdatagridcomp2g MAPL_ExtDataGridComp2G module~mapl_capgridcompmod->module~mapl_extdatagridcomp2g module~mapl_extdatagridcompmod MAPL_ExtDataGridCompMod module~mapl_capgridcompmod->module~mapl_extdatagridcompmod module~mapl_genericmod->module~mapl_locstreammod module~mapl_genericmod->module~maplshared module~mapl_historygridcompmod->module~mapl_locstreammod module~mapl_historygridcompmod->module~mapl_genericmod module~mapl_nuopcwrappermod MAPL_NUOPCWrapperMod module~mapl_nuopcwrappermod->module~maplbase_mod module~mapl_capmod MAPL_CapMod module~mapl_nuopcwrappermod->module~mapl_capmod module~rutmod RUTMod module~rutmod->module~maplbase_mod module~rutmod->module~mapl_extdatagridcompmod 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~ut_extdata->module~rutmod program~ut_extdata->module~mapl_extdatagridcompmod program~utcfio utCFIO program~utcfio->module~maplbase_mod module~extdata_drivergridcompmod ExtData_DriverGridCompMod module~extdata_drivergridcompmod->module~mapl module~extdata_drivergridcompmod->module~mapl_historygridcompmod module~extdata_drivergridcompmod->module~mapl_extdatagridcomp2g module~extdata_drivergridcompmod->module~mapl_extdatagridcompmod module~extdatadrivermod ExtDataDriverMod module~extdatadrivermod->module~extdatautroot_gridcompmod module~extdatadrivermod->module~mapl module~extdatadrivermod->module~extdata_drivergridcompmod module~mapl_capmod->module~mapl_capgridcompmod module~mapl_extdatagridcomp2g->module~mapl_genericmod module~mapl_extdatagridcompmod->module~mapl_genericmod module~mapl_mod MAPL_Mod module~mapl_mod->module~mapl module~mapl_orbgridcompmod MAPL_OrbGridCompMod module~mapl_orbgridcompmod->module~mapl_genericmod module~regrid_util_support_mod regrid_util_support_mod module~regrid_util_support_mod->module~mapl module~varspecdescriptionmod->module~mapl program~comp_testing_driver comp_testing_driver program~comp_testing_driver->module~mapl program~comp_testing_driver->module~mapl_capgridcompmod program~comp_testing_driver->module~mapl_genericmod program~extdata_driver ExtData_Driver program~extdata_driver->module~extdatautroot_gridcompmod program~extdata_driver->module~mapl program~extdata_driver->module~extdata_drivergridcompmod program~extdata_driver->module~extdatadrivermod program~main~3 main program~main~3->module~mapl program~main~8 main program~main~8->module~mapl program~time_ave time_ave program~time_ave->module~mapl module~mapl_gridcompsmod MAPL_GridCompsMod module~mapl_gridcompsmod->module~mapl_capmod module~varspecdescriptionvectormod VarspecDescriptionVectorMod module~varspecdescriptionvectormod->module~varspecdescriptionmod program~regrid_util Regrid_Util program~regrid_util->module~regrid_util_support_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