hasty_test_caf_get_clone Program

program~~hasty_test_caf_get_clone~~UsesGraph program~hasty_test_caf_get_clone hasty_test_caf_get_clone module~hasty hasty module~hasty->program~hasty_test_caf_get_clone iso_fortran_env iso_fortran_env iso_fortran_env->program~hasty_test_caf_get_clone module~penf_stringify penf_stringify iso_fortran_env->module~penf_stringify module~hasty_dictionary_node hasty_dictionary_node module~hasty_dictionary_node->module~hasty module~hasty_dictionary hasty_dictionary module~hasty_dictionary_node->module~hasty_dictionary module~hasty_hash_table hasty_hash_table module~hasty_hash_table->module~hasty module~hasty_content_adt hasty_content_adt module~hasty_content_adt->module~hasty module~hasty_content_adt->module~hasty_dictionary_node module~hasty_content_adt->module~hasty_hash_table module~hasty_dictionary->module~hasty module~hasty_dictionary->module~hasty_hash_table module~hasty_key_base hasty_key_base module~hasty_key_base->module~hasty module~hasty_key_base->module~hasty_dictionary_node module~hasty_key_base->module~hasty_hash_table module~hasty_key_base->module~hasty_dictionary module~hasty_key_morton hasty_key_morton module~hasty_key_base->module~hasty_key_morton module~hasty_key_morton->module~hasty module~penf penf module~penf->module~hasty_dictionary_node module~penf->module~hasty_hash_table module~penf->module~hasty_dictionary module~penf->module~hasty_key_base module~penf->module~hasty_key_morton module~penf_global_parameters_variables penf_global_parameters_variables module~penf_global_parameters_variables->module~penf module~penf_b_size penf_b_size module~penf_global_parameters_variables->module~penf_b_size module~penf_global_parameters_variables->module~penf_stringify module~penf_b_size->module~penf module~penf_b_size->module~penf_stringify module~penf_stringify->module~penf
Help


HASTY test hash table CAF basic.



Variables

Type AttributesNameInitial
type(hash_table) :: a_table

A table.

class(*), allocatable:: a_content

A content.


Subroutines

subroutine print_content_iterator(key, content, done)

Iterator that print contents.

Arguments

Type IntentOptional AttributesName
class(*), intent(in) :: key

The node key.

class(*), intent(in), pointer:: content

The generic content.

logical, intent(out) :: done

Flag to set to true to stop traversing.

Source Code

program hasty_test_caf_get_clone
!-----------------------------------------------------------------------------------------------------------------------------------
!< HASTY test hash table CAF basic.
!-----------------------------------------------------------------------------------------------------------------------------------
use, intrinsic :: iso_fortran_env, only : int32, int64, error_unit
use hasty
!-----------------------------------------------------------------------------------------------------------------------------------

!-----------------------------------------------------------------------------------------------------------------------------------
type(hash_table)      :: a_table   !< A table.
class(*), allocatable :: a_content !< A content.
!-----------------------------------------------------------------------------------------------------------------------------------

!-----------------------------------------------------------------------------------------------------------------------------------
call a_table%initialize(buckets_number=13)

#ifdef CAF

sync all
if (mod(this_image(), 2) /= 0) call a_table%add_clone(key=1_int32, content=int(this_image(), int32))
if (mod(this_image(), 2) == 0) call a_table%add_clone(key=2_int32, content=int(this_image(), int32))
if (mod(this_image(), 2) /= 0) call a_table%add_clone(key=3_int32, content=int(this_image(), int32))
if (mod(this_image(), 2) == 0) call a_table%add_clone(key=4_int32, content=int(this_image(), int32))
if (mod(this_image(), 2) /= 0) call a_table%add_clone(key=5_int32, content=int(this_image(), int32))
if (mod(this_image(), 2) == 0) call a_table%add_clone(key=6_int32, content=int(this_image(), int32))
sync all

print*, 'hello from image: ', this_image()
call a_table%traverse(iterator=print_content_iterator)

if (this_image()==2) then
  print*, 'getting key=3 from image 2'
  call a_table%get_clone(key=3_int32, content=a_content)
  if (allocated(a_content)) then
    select type(a_content)
    type is(integer(int32))
      print*, 'content: ', a_content
    endselect
  else
    print*, 'getting failed!'
  endif
endif

#endif
!-----------------------------------------------------------------------------------------------------------------------------------
contains
  subroutine print_content_iterator(key, content, done)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Iterator that print contents.
  !---------------------------------------------------------------------------------------------------------------------------------
  class(*),          intent(in)  :: key     !< The node key.
  class(*), pointer, intent(in)  :: content !< The generic content.
  logical,           intent(out) :: done    !< Flag to set to true to stop traversing.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  if (associated(content)) then
    select type(content)
    type is(integer(int32))
      select type(key)
      type is(key_base)
#ifdef CAF
        write(error_unit, *) '  image: ', this_image(), 'key: ', key%stringify(), ' content: ', content
#endif
      endselect
    endselect
  endif
  done = .false.
  !---------------------------------------------------------------------------------------------------------------------------------
  endsubroutine print_content_iterator
endprogram hasty_test_caf_get_clone