Quantcast
Channel: Fortran
Viewing all articles
Browse latest Browse all 3108

MPI_BCAST fails with the error access violation only when the input is a string

$
0
0

Hi, all.

I am puzzled on MPI_BCAST function. It works okay when I broadcast an integer, but fails when the input is a string. The test enviroment is VS2010+IVF 12 +MSMPI(v5).

The error will be

Unhandled exception at 0x000007fee703a8b2 in MPItest1.exe: 0xC0000005: Access violation reading location 0x000000000000000a.

if I call MPI_BCAST twice. If I only call MPI_BCAST(mystring,....), the error will be "unresolved external symbol _MPI_BCAST@28 referenced in _MAIN_".

Could anybody help me with this weird problem?

Thanks a lot,

Yang

    program MPItest1
    implicit none

    ! Variables

      include 'mpif.h'
      integer status(MPI_STATUS_SIZE)
      integer, target:: idummy
      CHARACTER(len = 10) :: mystring
      integer, pointer ::p2
      integer :: root, ierror, mc, cw

      root = 0
      mc   = MPI_INT
      cw   = MPI_COMM_WORLD

      call MPI_Init(ierror)
      mystring = "1234567890"

      idummy = len(mystring)
      root = 0
      p2 =>idummy

!      call MPI_BCAST(idummy,1,MPI_CHARACTER,0,MPI_COMM_WORLD,ierror)
!      print *,mystring
      call MPI_BCAST(mystring,10,MPI_CHARACTER,0,MPI_COMM_WORLD,ierror)
      print *,' has mystring=',mystring

    end program MPItest1

Viewing all articles
Browse latest Browse all 3108

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>