Personal tools

Difference between revisions of "Fortran implementation of the Actor Model using MPI"

From MohidWiki

Jump to: navigation, search
m
Line 6: Line 6:
 
         type(T_pingPong), pointer :: pingPong
 
         type(T_pingPong), pointer :: pingPong
 
         integer :: STAT_CALL
 
         integer :: STAT_CALL
−
 
 
         STAT_CALL = UNDEFINED
 
         STAT_CALL = UNDEFINED
−
 
 
         pingPong => constructPingPong()
 
         pingPong => constructPingPong()
−
 
 
         STAT_CALL = startGame(pingPong)
 
         STAT_CALL = startGame(pingPong)
 
         if (STAT_CALL .NE. SUCCESS) then
 
         if (STAT_CALL .NE. SUCCESS) then
Line 16: Line 13:
 
             stop "subroutine main, error calling startGame, ERR01"
 
             stop "subroutine main, error calling startGame, ERR01"
 
         end if  
 
         end if  
−
 
 
         call loop(pingPong)
 
         call loop(pingPong)
−
 
 
         call EXIT(SUCCESS)
 
         call EXIT(SUCCESS)
−
 
 
     end subroutine main
 
     end subroutine main

Revision as of 18:33, 30 November 2014

A very simple ping-pong program is shown here. There are 2 programs, ping and pong, that shoot messages among them, starting each with a random number of plays. The first program reaching 0 will send a message for the other program to stop and stops itself. File moduleMPImanagement is necessary to compile both programs.

If you examine the code there is no single MPI_BARRIER or any other explicit synchronization point. The main routine is:

   subroutine main()
       type(T_pingPong), pointer :: pingPong
       integer :: STAT_CALL
       STAT_CALL = UNDEFINED
       pingPong => constructPingPong()
       STAT_CALL = startGame(pingPong)
       if (STAT_CALL .NE. SUCCESS) then
           print*, "STAT_CALL = ", STAT_CALL
           stop "subroutine main, error calling startGame, ERR01"
       end if 
       call loop(pingPong)
       call EXIT(SUCCESS)
   end subroutine main