- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I’m relatively new to Fortran and to this community. I’m trying to write some code that performs some calculations on a multidimensional array using MPI. And for the life of me I can’t get MPI_Gather to work, and I’m sure it’s something very obvious that I’m missing here.
My code is:
program test USE mpi USE netcdf IMPLICIT NONE INTEGER,ALLOCATABLE,DIMENSION(:,:,:) :: array, global_array INTEGER :: j_start, j_end, i_start, i_end, J, I, t ! MPI INTEGER :: mpirank, mpisize, mpierr ! Initialize MPI call MPI_INIT(mpierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, mpisize, mpierr) call MPI_COMM_RANK(MPI_COMM_WORLD, mpirank, mpierr) ALLOCATE(array(4,4,2)) ALLOCATE(global_array(4,4,2)) j_start = 1 j_end = 4 i_start = 1 + (mpirank*4/mpisize) i_end = (mpirank + 1)*4/mpisize DO t=1,2 DO J=j_start,j_end DO I=i_start,i_end array(J,I,t) = J+I+t END DO END DO ! J END DO ! t IF (mpirank==0) WRITE(*,*) 'before MPI_Gather...' WRITE(*,*) mpirank, array(1,:,1) CALL MPI_Barrier(MPI_COMM_WORLD, mpierr) CALL MPI_Gather(array(:,i_start:i_end,:), 4*2*2, MPI_INTEGER, & global_array(:,i_start:i_end,:), 4*2*2, MPI_INTEGER, & 0, MPI_COMM_WORLD, mpierr) IF (mpirank == 0) THEN WRITE(*,*) 'AFTER MPI_Gather...' DO J=1,4 WRITE(*,*) (global_array(J,I,t), I=1,4,1) END DO END IF DEALLOCATE(array) DEALLOCATE(global_array) ! Finalise MPI CALL MPI_FINALIZE(mpierr) end program test
And I get these results, which are obviously wrong:
before MPI_Gather... 1 0 0 5 6 0 3 4 0 0 AFTER MPI_Gather... 0 5289440 0 0 0 0 0 0 225 0 0 0 0 0 0 0
I’m using Intel Fortran 2022, and I compile the program with mpiifort
Any help/comment/advice will be truly appreciated!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel Communities.
Could you please provide the command that you used to run your mpi code?
Could you also elaborate on what you are trying to do in the sample code that you provided?
And What is your Input & expected output?
Thanks And Regards,
Aishwarya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm moving this over to the HPC Toolkit Forum. MPI questions are answered there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We haven't heard back from you,Could you please provide us with the requested details?
Thanks & Regards,
Aishwarya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have not heard back from you. This thread will no longer be monitored by Intel. If you need further assistance, please post a new question.
Thanks and Regards,
Aishwarya
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page