Intel® oneAPI HPC Toolkit
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
2019 Discussions

Got "access violation" error while Calling MPI_GATHERV subroutine in Fortran using intel MPI

Lewis__Rubin
Novice
408 Views


​Hi, everyone.

I am a beginner of using intel MPI. So i write a testing FORTRAN program to understand how it works and to verify that the configuration of MPI environment is done well.

However, the testing somehow failed, according to the result of the following codes:

program main
    use mpi
    implicit none
    integer :: rank, root, ierr
    integer :: gsize, ssize, rsize, i, disp
    integer, allocatable :: buf(:)
    integer, allocatable :: displs(:), rcounts(:), sb(:)
    
    root = 0
    
    call MPI_INIT(ierr)
    call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
    call MPI_COMM_SIZE(MPI_COMM_WORLD, gsize, ierr)
    
    ssize = rank + 2*(rank+1)
    rsize = (3*gsize*gsize + gsize)/2
    
    allocate(buf(rsize))
    allocate(displs(gsize))
    allocate(rcounts(gsize))
    allocate(sb(ssize))
    
    do i = 1, ssize
        sb(i) = i-1 + ssize*rank
    enddo
    
    disp = 0	!disp = 1
    do i = 1, gsize
        displs(i) = disp
        rcounts(i) = 3*(i-1)+2
        disp = disp + rcounts(i)
    enddo
    
    call MPI_GatherV(sb, ssize, MPI_INT, buf, rcounts, displs, MPI_INT, root, MPI_COMM_WORLD)
    
    if (rank == 0) then
        print *, buf
    endif
    
    deallocate(buf, displs, rcounts, sb)
    call MPI_Finalize(ierr)
    
end program

When I run the testing program using command "mpiexec -n 4 test.exe", I got the "access violation" error and the receiving buffer variable "buf" did not gather the values either. What could probably be wrong with my codes?
 

forrtl: severe (157): Program Exception - access violation
Image              PC                Routine            Line        Source
impi.dll           00007FF98B2273D6  Unknown               Unknown  Unknown
test.exe           00007FF6412A1778  Unknown               Unknown  Unknown
test.exe           00007FF6412A1B5E  Unknown               Unknown  Unknown
test.exe           00007FF6412A3304  Unknown               Unknown  Unknown
test.exe           00007FF6412A320E  Unknown               Unknown  Unknown
test.exe           00007FF6412A30CE  Unknown               Unknown  Unknown
test.exe           00007FF6412A3319  Unknown               Unknown  Unknown
KERNEL32.DLL       00007FF9BC6A2D92  Unknown               Unknown  Unknown
ntdll.dll          00007FF9BE8A9F64  Unknown               Unknown  Unknown



And Visual Studio Comunity 2015 with Intel Parallel Studio Cluster 2016 (free software for students) was being tested.


Many THANKS in advance.


Rubin.

0 Kudos
1 Solution
Lewis__Rubin
Novice
408 Views


Finally, I found the answer elsewhere. It turns out that i forgot the "ierr" arguement in the subroutine "MPI_GATHERV".

Ah, what a stupid mistake i have made!

View solution in original post

1 Reply
Lewis__Rubin
Novice
409 Views


Finally, I found the answer elsewhere. It turns out that i forgot the "ierr" arguement in the subroutine "MPI_GATHERV".

Ah, what a stupid mistake i have made!

Reply