Skip to content

Commit

Permalink
Auto-initialize MPI on loading and auto-finalize on detach
Browse files Browse the repository at this point in the history
  • Loading branch information
rocanale committed Jul 28, 2016
1 parent b9db77e commit cc0ac8a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ Collate:
Classes.R
Methods.R
Operators.R
pkgname.R
pkgname.R
zzz.R
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
exportPattern("^[[:alpha:]]+")
export(".onLoad")
export(".onDetach")
useDynLib(RElem)
2 changes: 0 additions & 2 deletions R/Environment.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ Initialize<-function(){
Finalize<-function(){
if( Initialized() )
.Call("finalize")
else
cat("Not initialized\n");
}

WorldRank<-function(){
Expand Down
8 changes: 8 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.onLoad <- function(library = find.package("RElem"), package = "RElem"){
Initialize()
}

.onDetach <- function(library = find.package("RElem"), package = "RElem"){
cat("MPI finalized")
Finalize()
}

0 comments on commit cc0ac8a

Please sign in to comment.