Examples C and Fortran language using R and MPI with Rhpc

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[   ]Makefile2014-06-10 17:55 1.3K 
[TXT]Rhpc_pic.c2014-06-10 15:56 688  
[TXT]Rhpc_pic.c.diff2014-06-10 18:36 2.6K 
[TXT]Rhpc_picall.c2014-06-10 16:02 793  
[TXT]Rhpc_picall.c.diff2014-06-10 18:36 2.8K 
[   ]Rhpc_pif.f2014-06-10 16:31 1.0K 
[TXT]Rhpc_pif.f.diff2014-06-10 18:36 3.3K 
[   ]mpipic.R2014-06-10 18:35 240  
[   ]mpipicall.R2014-06-10 18:36 263  
[   ]mpipif.R2014-06-10 18:35 265  
[   ]pi.R2014-06-10 18:37 491  
[   ]pi.Rout2014-06-10 18:36 1.2K 
[TXT]pic.c2014-06-10 16:33 718  
[   ]pif.f2014-06-10 16:30 1.2K 

Calling foreign SPMD programs from R with Rhpc

C and/or Fortran programs using MPI adopt SPMD programming, in which Master(rank0) communicates with Workers(their ranks are more than using communicators. Therefore, when Rhpc, which uses MPI, call such programs, exchanging MPI communicators is required. Rhpc provides Rhpc_worker_noback function to support it.
Rhpc sets global variable _options_ (see options function):

Rhpc.mpi.f.comm
Comuunicator for Fortran (R type: integer)
Rhpc.mpi.c.comm
Communicator for C (R type: external pointer)
Rhpc.mpi.procs
Communication size in MPI
Rhpc.mpi.rank
Rank in MPI


Using `.Fortran', `.C' and `.Call' in R

Foreign programs (Fortran or C) using MPI are called in R

Note that `.C' cannot receive external pointer and integer comunicater for Fortran should be used. Thus . `.Call' is preferable for C programs.

Changing MPI Fortran code for `.Fortran' in R

Rhpc_pif.f.diff

Changing MPI C code for `.C' in R.

Rhpc_pic.c.diff

Changing MPI C code for `.Call' in R.

Rhpc_picall.c.diff

Call foreign MPI program from R

pi.R