test_back_and_forth Subroutine

public subroutine test_back_and_forth(this)

Uses

  • proc~~test_back_and_forth~~UsesGraph proc~test_back_and_forth test_back_and_forth module~pfio_arrayreferencemod pFIO_ArrayReferenceMod proc~test_back_and_forth->module~pfio_arrayreferencemod iso_c_binding iso_c_binding module~pfio_arrayreferencemod->iso_c_binding iso_fortran_env iso_fortran_env module~pfio_arrayreferencemod->iso_fortran_env module~mapl_exceptionhandling MAPL_ExceptionHandling module~pfio_arrayreferencemod->module~mapl_exceptionhandling module~pfio_abstractdatareferencemod pFIO_AbstractDataReferenceMod module~pfio_arrayreferencemod->module~pfio_abstractdatareferencemod module~pfio_constantsmod pFIO_ConstantsMod module~pfio_arrayreferencemod->module~pfio_constantsmod module~mapl_errorhandlingmod MAPL_ErrorHandlingMod module~mapl_exceptionhandling->module~mapl_errorhandlingmod module~mapl_throwmod MAPL_ThrowMod module~mapl_exceptionhandling->module~mapl_throwmod module~pfio_abstractdatareferencemod->iso_c_binding module~pfio_abstractdatareferencemod->iso_fortran_env module~pfio_abstractdatareferencemod->module~mapl_exceptionhandling module~pfio_abstractdatareferencemod->module~pfio_constantsmod module~pfio_utilitiesmod pFIO_UtilitiesMod module~pfio_abstractdatareferencemod->module~pfio_utilitiesmod module~mapl_errorhandlingmod->module~mapl_throwmod mpi mpi module~mapl_errorhandlingmod->mpi module~pfio_utilitiesmod->iso_c_binding module~pfio_utilitiesmod->iso_fortran_env module~pfio_utilitiesmod->module~mapl_exceptionhandling module~pfio_utilitiesmod->module~pfio_constantsmod

Arguments

Type IntentOptional Attributes Name
class(MpiTestMethod), intent(inout) :: this

Calls

proc~~test_back_and_forth~~CallsGraph proc~test_back_and_forth test_back_and_forth assertequal assertequal proc~test_back_and_forth->assertequal get_type_id get_type_id proc~test_back_and_forth->get_type_id getmpicommunicator getmpicommunicator proc~test_back_and_forth->getmpicommunicator getprocessrank getprocessrank proc~test_back_and_forth->getprocessrank none~receive MpiSocket%receive proc~test_back_and_forth->none~receive none~send MpiSocket%send proc~test_back_and_forth->none~send mpi_get_count mpi_get_count none~receive->mpi_get_count mpi_probe mpi_probe none~receive->mpi_probe mpi_recv mpi_recv none~receive->mpi_recv none~decode ProtocolParser%decode none~receive->none~decode proc~mapl_return MAPL_Return none~receive->proc~mapl_return proc~mapl_verify MAPL_Verify none~receive->proc~mapl_verify mpi_send mpi_send none~send->mpi_send none~encode ProtocolParser%encode none~send->none~encode none~send->proc~mapl_return none~send->proc~mapl_verify deserialize deserialize none~decode->deserialize none~at~187 IntegerMessageMap%at none~decode->none~at~187 none~encode->get_type_id get_length get_length none~encode->get_length serialize serialize none~encode->serialize at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception none~find~49 IntegerMessageMap%find none~at~187->none~find~49

Enumerations

enum, bind(c)

Enumerators

enumerator:: collection1 = 0
enumerator:: collection2 = 1

enum, bind(c)

Enumerators

enumerator:: request_A = 0
enumerator:: request_B = 1
enumerator:: request_C = 2

Source Code

   subroutine test_back_and_forth(this)
      use pFIO_ArrayReferenceMod
      class (MpiTestMethod), intent(inout) :: this

      integer :: comm
      type (MpiSocket) :: s1, s2
      class (AbstractMessage), allocatable :: message
      type (ProtocolParser), target :: parser

      integer :: rank

      type (ArrayReference) :: ref
      integer, target :: fake_data

      enum, bind(c)
         enumerator :: collection1, collection2
      end enum
      enum, bind(c)
         enumerator :: request_A, request_B, request_C
      end enum
      
      comm = this%getMpiCommunicator()
      parser = ProtocolParser()

      rank = this%getProcessRank()

      ref = ArrayReference(fake_data)
      
      select case (rank)
      case (0) ! server
         s1 = MpiSocket(comm, 2, parser)
         s2 = MpiSocket(comm, 3, parser)

         allocate(message, source=s1%receive())
         @assertEqual(PrefetchData_ID, message%get_type_id())
         select type (message)
         type is (PrefetchDataMessage)
            @assertEqual(collection1,  message%collection_id)
         end select
         call s1%send(IdMessage(request_B))

         deallocate(message)
         allocate(message, source=s2%receive())
         @assertEqual(PrefetchData_ID, message%get_type_id())
         select type (message)
         type is (PrefetchDataMessage)
            @assertEqual(collection2,  message%collection_id)
         end select
         call s2%send(IdMessage(REQUEST_C))

         deallocate(message)
         allocate(message, source=s1%receive())
         @assertEqual(TERMINATE_ID, message%get_type_id())
         deallocate(message)
         allocate(message, source=s2%receive())
         @assertEqual(TERMINATE_ID, message%get_type_id())

      case (1)
         s1 = MpiSocket(comm, 4, parser)
         allocate(message, source=s1%receive())
         @assertEqual(PrefetchData_ID, message%get_type_id())
         select type (message)
         type is (PrefetchDataMessage)
            @assertEqual(collection1,  message%collection_id)
         end select
         call s1%send(IdMessage(request_A))

         deallocate(message)
         allocate(message, source=s1%receive())
         @assertEqual(TERMINATE_ID, message%get_type_id())

      case (2)
         s1 = MpiSocket(comm, 0, parser)
         !call s1%send(PrefetchDataMessage(1, collection1,'foo','u', ref, start=[]))
         call s1%send(PrefetchDataMessage(1, collection1,'foo','u', ref))
         allocate(message, source=s1%receive())
         @assertEqual(ID_ID, message%get_type_id())
         select type (message)
         type is (IdMessage)
            @assertEqual(request_B, message%id)
         end select
         call s1%send(TerminateMessage())

      case (3)
         s1 = MpiSocket(comm, 0, parser)
         !call s1%send(PrefetchDataMessage(2, collection2,'foo','v', ref, start=[]))
         call s1%send(PrefetchDataMessage(2, collection2,'foo','v', ref))
         allocate(message, source=s1%receive())
         @assertEqual(ID_ID, message%get_type_id())
         select type (message)
         type is (IdMessage)
            @assertEqual(request_C, message%id)
         end select
         call s1%send(TerminateMessage())

      case (4)
         s1 = MpiSocket(comm, 1, parser)
         !call s1%send(PrefetchDataMessage(3, collection1,'foo','w', ref, start=[]))
         call s1%send(PrefetchDataMessage(3, collection1,'foo','w', ref))
         allocate(message, source=s1%receive())
         @assertEqual(ID_ID, message%get_type_id())
         select type (message)
         type is (IdMessage)
            @assertEqual(request_A, message%id)
         end select
         call s1%send(TerminateMessage())
      end select

   end subroutine test_back_and_forth