SimpleSocket.F90 Source File


This file depends on

sourcefile~~simplesocket.f90~~EfferentGraph sourcefile~simplesocket.f90 SimpleSocket.F90 sourcefile~abstractdatareference.f90 AbstractDataReference.F90 sourcefile~simplesocket.f90->sourcefile~abstractdatareference.f90 sourcefile~abstractmessage.f90 AbstractMessage.F90 sourcefile~simplesocket.f90->sourcefile~abstractmessage.f90 sourcefile~abstractrequesthandle.f90 AbstractRequestHandle.F90 sourcefile~simplesocket.f90->sourcefile~abstractrequesthandle.f90 sourcefile~abstractsocket.f90 AbstractSocket.F90 sourcefile~simplesocket.f90->sourcefile~abstractsocket.f90 sourcefile~basethread.f90 BaseThread.F90 sourcefile~simplesocket.f90->sourcefile~basethread.f90 sourcefile~dummymessage.f90 DummyMessage.F90 sourcefile~simplesocket.f90->sourcefile~dummymessage.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~simplesocket.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~abstractdatareference.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~pfio_constants.f90 pFIO_Constants.F90 sourcefile~abstractdatareference.f90->sourcefile~pfio_constants.f90 sourcefile~pfio_utilities.f90 pFIO_Utilities.F90 sourcefile~abstractdatareference.f90->sourcefile~pfio_utilities.f90 sourcefile~abstractmessage.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~abstractrequesthandle.f90->sourcefile~abstractdatareference.f90 sourcefile~basethread.f90->sourcefile~abstractrequesthandle.f90 sourcefile~basethread.f90->sourcefile~abstractsocket.f90 sourcefile~basethread.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~integerrequestmap.f90 IntegerRequestMap.F90 sourcefile~basethread.f90->sourcefile~integerrequestmap.f90 sourcefile~messagevisitor.f90 MessageVisitor.F90 sourcefile~basethread.f90->sourcefile~messagevisitor.f90 sourcefile~pfio_base.f90 pfio_base.F90 sourcefile~basethread.f90->sourcefile~pfio_base.f90 sourcefile~dummymessage.f90->sourcefile~abstractmessage.f90 sourcefile~dummymessage.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~mapl_errorhandling.f90 MAPL_ErrorHandling.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_errorhandling.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_throw.f90 sourcefile~integerrequestmap.f90->sourcefile~abstractrequesthandle.f90 sourcefile~mapl_errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~messagevisitor.f90->sourcefile~abstractmessage.f90 sourcefile~messagevisitor.f90->sourcefile~abstractrequesthandle.f90 sourcefile~messagevisitor.f90->sourcefile~dummymessage.f90 sourcefile~messagevisitor.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~addextcollectionmessage.f90 AddExtCollectionMessage.F90 sourcefile~messagevisitor.f90->sourcefile~addextcollectionmessage.f90 sourcefile~addhistcollectionmessage.f90 AddHistCollectionMessage.F90 sourcefile~messagevisitor.f90->sourcefile~addhistcollectionmessage.f90 sourcefile~collectiveprefetchdatamessage.f90 CollectivePrefetchDataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~collectiveprefetchdatamessage.f90 sourcefile~collectiveprefetchdonemessage.f90 CollectivePrefetchDoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~collectiveprefetchdonemessage.f90 sourcefile~collectivestagedatamessage.f90 CollectiveStageDataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~collectivestagedatamessage.f90 sourcefile~collectivestagedonemessage.f90 CollectiveStageDoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~collectivestagedonemessage.f90 sourcefile~donemessage.f90 DoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~donemessage.f90 sourcefile~handshakemessage.f90 HandShakeMessage.F90 sourcefile~messagevisitor.f90->sourcefile~handshakemessage.f90 sourcefile~idmessage.f90 IDMessage.F90 sourcefile~messagevisitor.f90->sourcefile~idmessage.f90 sourcefile~modifymetadatamessage.f90 ModifyMetadataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~modifymetadatamessage.f90 sourcefile~prefetchdatamessage.f90 PrefetchDataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~prefetchdatamessage.f90 sourcefile~prefetchdonemessage.f90 PrefetchDoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~prefetchdonemessage.f90 sourcefile~replacemetadatamessage.f90 ReplaceMetadataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~replacemetadatamessage.f90 sourcefile~stagedatamessage.f90 StageDataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~stagedatamessage.f90 sourcefile~stagedonemessage.f90 StageDoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~stagedonemessage.f90 sourcefile~terminatemessage.f90 TerminateMessage.F90 sourcefile~messagevisitor.f90->sourcefile~terminatemessage.f90 sourcefile~pfio_base.f90->sourcefile~mapl_errorhandling.f90 sourcefile~pfio_utilities.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~pfio_utilities.f90->sourcefile~pfio_constants.f90

Files dependent on this one

sourcefile~~simplesocket.f90~~AfferentGraph sourcefile~simplesocket.f90 SimpleSocket.F90 sourcefile~baseserver.f90 BaseServer.F90 sourcefile~baseserver.f90->sourcefile~simplesocket.f90 sourcefile~clientthread.f90 ClientThread.F90 sourcefile~clientthread.f90->sourcefile~simplesocket.f90 sourcefile~directoryservice.f90 DirectoryService.F90 sourcefile~directoryservice.f90->sourcefile~simplesocket.f90 sourcefile~mockclientthread.f90 MockClientThread.F90 sourcefile~mockclientthread.f90->sourcefile~simplesocket.f90 sourcefile~pfio.f90 pFIO.F90 sourcefile~pfio.f90->sourcefile~simplesocket.f90 sourcefile~serverthread.f90 ServerThread.F90 sourcefile~serverthread.f90->sourcefile~simplesocket.f90 sourcefile~test_simplesocket.pf Test_SimpleSocket.pf sourcefile~test_simplesocket.pf->sourcefile~simplesocket.f90

Source Code

#include "MAPL_ErrLog.h"
#include "unused_dummy.H"
! Implements a socket with direct procedure call.
!
! Data transfers are direct; put_data() immediately fills request.
! Asynchronous sockets will need additional interfaces to manage
! checking completion.

module pFIO_SimpleSocketMod
   use MAPL_ExceptionHandling
   use pFIO_AbstractSocketMod
   use pFIO_AbstractMessageMod
   use pFIO_DummyMessageMod
   use pFIO_BaseThreadMod
   use pFIO_AbstractRequestHandleMod
   use pFIO_AbstractDataReferenceMod

   implicit none
   private

   public :: SimpleSocket

   type, extends (AbstractSocket) :: SimpleSocket
      class(AbstractMessage),allocatable :: msg
      !private
      class (BaseThread), pointer :: visitor
   contains
      procedure :: receive
      procedure :: send
      procedure :: put
      procedure :: get
      procedure :: to_string
      procedure :: set_visitor
   end type SimpleSocket

   ! private type
   type, extends(AbstractRequestHandle) :: SimpleHandle
   contains
      procedure :: wait
   end type SimpleHandle

   interface SimpleSocket
      module procedure new_SimpleSocket_visitor
      module procedure new_SimpleSocket
   end interface SimpleSocket

   interface SimpleHandle
      module procedure new_SimpleHandle
   end interface SimpleHandle

contains

   function new_SimpleHandle(reference) result(handle)
      type(SimpleHandle) :: handle
      class(AbstractDataReference),intent(in) :: reference
      allocate(handle%data_reference,source=reference)
   end function new_SimpleHandle

   function new_SimpleSocket_visitor(visitor) result(socket)
      type (SimpleSocket), target :: socket
      class (BaseThread), target, intent(in) :: visitor

      socket%visitor => visitor

   end function new_SimpleSocket_visitor

   subroutine set_visitor(this,visitor)
      class (SimpleSocket), intent(inout) :: this
      class (BaseThread), target, intent(in) :: visitor

      this%visitor => visitor

   end subroutine set_visitor

   function new_SimpleSocket() result(socket)
      type (SimpleSocket), target :: socket
      socket%visitor => null()
   end function new_SimpleSocket

   function receive(this, rc) result(message)
      class (AbstractMessage), pointer:: message
      class (SimpleSocket), intent(inout) :: this
      integer, optional, intent(out) :: rc

      _ASSERT(allocated(this%msg),"simple socket receive nothing")
      allocate(message, source=this%msg)
      _RETURN(_SUCCESS)
   end function receive

   recursive subroutine send(this, message, rc)
      class (SimpleSocket), target, intent(inout) :: this
      class (AbstractMessage), intent(in) :: message
      class (AbstractSocket),pointer :: connection
      integer, optional, intent(out) :: rc

      integer :: status

      connection => this%visitor%get_connection()
      select type (connection)
      type is (SimpleSocket)
         if (allocated(connection%msg)) deallocate(connection%msg)
         allocate(connection%msg , source = message)
         call connection%msg%dispatch(this%visitor, _RC)
      class default
         _FAIL("Simple should connect Simple")
      end select
      _RETURN(_SUCCESS)
     ! call message%dispatch(this%visitor,_RC)
   end subroutine send

   function put(this, request_id, local_reference, rc) result(handle)
      class (SimpleSocket), intent(inout) :: this
      class (AbstractRequestHandle), allocatable :: handle
      integer, intent(in) :: request_id
      class (AbstractDataReference), intent(in) :: local_reference
      integer, optional, intent(out) :: rc

      class(AbstractRequestHandle),pointer :: visitor_handle
      integer :: status

      visitor_handle =>this%visitor%get_RequestHandle(request_id)
      call local_reference%copy_data_to(visitor_handle%data_reference, rc=status)
      _VERIFY(status)
      allocate(handle, source=SimpleHandle(local_reference))
      _RETURN(_SUCCESS)
   end function put

   function get(this, request_id, local_reference, rc) result(handle)
      class (AbstractRequestHandle), allocatable :: handle
      class (SimpleSocket), target, intent(inout) :: this
      class (AbstractDataReference), intent(in) :: local_reference
      integer, intent(in) :: request_id
      integer, optional, intent(out) :: rc
      allocate(handle, source=SimpleHandle(local_reference))
      _RETURN(_SUCCESS)
      _UNUSED_DUMMY(this)
      _UNUSED_DUMMY(request_id)
   end function get

   subroutine wait(this, rc)
      class (SimpleHandle), target, intent(inout) :: this
      integer, optional, intent(out) :: rc
      _RETURN(_SUCCESS)
      _UNUSED_DUMMY(this)
   end subroutine wait

   function to_string(this) result(string)
      class (SimpleSocket), intent(in) :: this
      character(len=:), allocatable :: string
      string = 'SimpleSocket::info'
      return
      _UNUSED_DUMMY(this)
   end function to_string

end module pFIO_SimpleSocketMod