mpi_hello_world.F90 2.1 KB
Newer Older
Femi Kadri's avatar
Femi Kadri committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
   program hello
   include 'mpif.h'
   integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)

   INTEGER :: local_LST_marker_count
   INTEGER :: local_LST_marker_reacted_count
   INTEGER :: local_LST_VOL_MASK_marker_count

   INTEGER :: mpi_error_code,rank_id

   INTEGER,ALLOCATABLE :: global_LST_marker_counts(:)
   INTEGER,ALLOCATABLE :: global_LST_marker_reacted_count(:)
   INTEGER,ALLOCATABLE :: global_LST_VOL_MASK_marker_count(:)



   call MPI_INIT(ierror)
   call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
   call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)
   print*, 'node', rank, ': Hello world'

	ALLOCATE( global_LST_marker_counts(0:size - 1) )
	ALLOCATE( global_LST_marker_reacted_count(0:size - 1) )
	ALLOCATE( global_LST_VOL_MASK_marker_count(0:size - 1) )


   local_LST_marker_count = rank

   local_LST_marker_reacted_count = rank * 2

   local_LST_VOL_MASK_marker_count = - rank 


	!MUST OCCUR BEFORE DIPLACEMENTS ARE CALCULATED!!
	!COMMUNICATE THE NUMBER OF LST MARKERS WHOSE POSITIONS WERE UPDATED BY THE LOCAL PROCESS TO ALL PROCESSES
	CALL MPI_Allgather(local_LST_marker_count,1,MPI_INTEGER,global_LST_marker_counts,1,&
	& MPI_INTEGER,MPI_COMM_WORLD,mpi_error_code)

	!MUST OCCUR BEFORE DIPLACEMENTS ARE CALCULATED!!
	!COMMUNICATE THE NUMBER OF LST MARKERS WHICH WERE consumed/reacted UPON CONTACT WITH SOLID WALL from THE LOCAL PROCESS TO ALL PROCESSES
	CALL MPI_Allgather(local_LST_marker_reacted_count,1,MPI_INTEGER,&
	& global_LST_marker_reacted_count,1,MPI_INTEGER,MPI_COMM_WORLD,mpi_error_code)

	CALL MPI_Allgather(local_LST_VOL_MASK_marker_count,1,MPI_INTEGER,&
	& global_LST_VOL_MASK_marker_count,1,MPI_INTEGER,&
	& MPI_COMM_WORLD,mpi_error_code)



	IF(rank.EQ.0) THEN

		DO rank_id = 0,size - 1

			PRINT*, 'rank_id',rank_id,&
			& 'global_LST_marker_counts',global_LST_marker_counts(rank_id),&
			& 'global_LST_marker_reacted_count',global_LST_marker_reacted_count(rank_id),&
			& 'global_LST_VOL_MASK_marker_count',global_LST_VOL_MASK_marker_count(rank_id)

		END DO !! rank_id = 0,size - 1

	ENDIF !rank.EQ.0

   call MPI_FINALIZE(ierror)
   end