mpi_last: Properly end "mpi" workers before quitting R (e.g., at a...

Description Usage Arguments Notes Details


Properly end “mpi” workers before quitting R (e.g., at a crash)





A list with at least one named element p_has. p_has is a logical value and indicates whether call is from a parallel run.


Code is based on

Ideally, we use Rmpi::mpi.exit() on exit, but we cannot as of Rmpi v0.6.6. Because rSFSW2 does not attach Rmpi, the function mpi.exit throws an error when it executes detach(package:Rmpi) which results in "Error in detach(package:Rmpi) : invalid 'name' argument".

Rmpi::mpi.comm.size(1) crashes with a segfault if there are no workers running because of the call .Call("mpi_comm_is_null", as.integer(comm), PACKAGE = "Rmpi").

Ideally, we would use Rmpi::mpi.close.Rslaves(). However, this function hangs our R session because of its call to Rmpi::mpi.comm.disconnect(); even wrapping this in try doesn't prevent it from hanging.


gv will usually be the package-level global variable environment SFSW2_glovars. This is because this function is registered as finalizer to the object SFSW2_glovars.

Burke-Lauenroth-Lab/SoilWat_R_Wrapper documentation built on May 6, 2019, 8:52 a.m.