# Save code in a file "demo.r" and run with 2 processors by
# > mpiexec -np 2 Rscript demo.r
library(pbdBASE, quiet = TRUE)
init.grid()
# don't do this in production code
x <- matrix(1:16, ncol=4)
dx <- as.ddmatrix(x, bldim=2)
iown <- ownany(dx)
comm.print(iown, all.rank=T)
iown <- ownany(dim=c(4, 4), bldim=c(2, 2), CTXT=0)
comm.print(iown, all.rank=T)
# but NOT
# ownany(c(4,4), c(2,2), 0)
# ^this will produce an error
finalize()
Run the code above in your browser using DataLab