This is off topic here... wrong audience. Read the Posting Guide. -- Sent from my phone. Please excuse my brevity.
On February 27, 2016 12:00:23 PM PST, Erin Hodgess <erinm.hodg...@gmail.com> wrote: >Hello again. > >This time, I would like to add MPI to my Fortran program. Here are the >Fortran and C++ codes: > >program buzzy > use iso_c_binding > implicit none > include '/opt/openmpi/include/mpif.h' > > > > > integer :: rank,size,ierror,tag,status(MPI_STATUS_SIZE), i,np > integer :: argc = 1000000 > real :: x,tot1 > character(len=32) :: argv > > > INTERFACE > SUBROUTINE R_FUN(argc,argv) bind(C, name="buzzyC") > use iso_c_binding > character(kind=c_char), INTENT(INOUT) :: argv > INTEGER(kind=c_int), INTENT(IN) :: argc > > END SUBROUTINE R_FUN > END INTERFACE > > call MPI_INIT(ierror) > call MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierror) > call MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierror) > > > > > print *, "Fortran Calling RInside",rank > CALL R_FUN (argc,argv) > print *,rank > > call MPI_FINALIZE(ierror) > > end program buzzy > >and > >#include <iostream> >#include <RInside.h> > >void buzzyC_(int argc,char *argv[]); > >extern "C" void buzzyC(int argc,char *argv[]) { > > // create an embedded R instance > RInside R(argc,argv); > > // convert to string for RInside assignment > > > // eval the string, give R notice > R.parseEvalQ("cat(mean(rnorm(argc))"); >} > >Now my steps for compiling and linking are the following: > >erin@erin-Bonobo-Extreme:~$ mpif90 -c buzzy.f90 >erin@erin-Bonobo-Extreme:~$ mpic++ buzzyC.cpp -c >-I/home/erin/R/x86_64-pc-linux-gnu-library/3.2/RInside/include >-I/home/erin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include >-I/usr/share/R/include -libstdc++ >erin@erin-Bonobo-Extreme:~$ mpifort -o fcra buzzy.o buzzyC.o >-L/usr/lib/R/lib -lR -L >/home/erin/R/x86_64-pc-linux-gnu-library/3.2/RInside/lib -lRInside >-L/home/erin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/libs/ >-Wl,-rpath,/home/erin/R/x86_64-pc-linux-gnu-library/3.2/RInside/lib/ >-lRInside >-Wl,-rpath,/home/erin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/libs/ >-lstdc++ >/usr/lib/x86_64-linux-gnu/libstdc++.so.6 > >So far so good >But when I run this, disaster strikes: > >erin@erin-Bonobo-Extreme:~$ mpirun -np 4 ./fcra > Fortran Calling RInside 0 > Fortran Calling RInside 1 > Fortran Calling RInside 3 > Fortran Calling RInside 2 > >Program received signal SIGSEGV: Segmentation fault - invalid memory >reference. > >Backtrace for this error: > >Program received signal SIGSEGV: Segmentation fault - invalid memory >reference. > >Backtrace for this error: >#0 0x7FC59706CE48 >#1 0x7FC59706BFD0 >#2 0x7FC596AA52EF >#3 0x7FC596AFB69A >#4 0x7FC597C5E8E8 >#5 0x7FC5979671E8 >#6 0x7FC5979677A1 >#7 0x402A55 in buzzyC >#8 0x402891 in MAIN__ at buzzy.f90:? >#0 0x7F2482294E48 >#1 0x7F2482293FD0 >#2 0x7F2481CCD2EF >#3 0x7F2481D2369A >#4 0x7F2482E868E8 >#5 0x7F2482B8F1E8 >#6 0x7F2482B8F7A1 >#7 0x402A55 in buzzyC >#8 0x402891 in MAIN__ at buzzy.f90:? >-------------------------------------------------------------------------- >mpirun noticed that process rank 1 with PID 2188 on node >erin-Bonobo-Extreme exited on signal 11 (Segmentation fault). >-------------------------------------------------------------------------- >erin@erin-Bonobo-Extreme:~$ > >Maybe I should be asking: is this even possible, please? > >Thanks, >Erin > > >-- >Erin Hodgess >Associate Professor >Department of Mathematical and Statistics >University of Houston - Downtown >mailto: erinm.hodg...@gmail.com > > [[alternative HTML version deleted]] > >______________________________________________ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.