finalize R 'wrapper' for stage 1; WARNING: changed series encoding. TODO: test
[epclust.git] / code / stage1 / wrapper.R
index 2549f1f..9bbb53b 100644 (file)
@@ -1,9 +1,15 @@
-ppam_exe = function(pathToExe, nbProcess, ...)
+ppam_exe = function(path=".", np=parallel::detectCores(), data=NULL, args="DontLetMeEmpty")
 {
-       command_line = paste("mpirun -np ",nbProcess," ",pathToExe,"/ppam.exe",sep="")
-       args = list(...)
-       for (i in 1:length(args))
-               command_line = paste(command_line, args[[i]])
-       print(paste("EXECUTE: '", command_line,"'",sep=""))
+       command_line = paste("mpirun -np ",np," ",path,"/ppam.exe",sep="")
+
+       #if data provided (as data.frame or matrix...): binarize it, and add it as first argument
+       if (!is.null(data))
+       {
+               write.csv(data, "/tmp/data_csv")
+               system(paste(path,"/ppam.exe serialize /tmp/data_csv /tmp/data_bin 0 0",sep=""))
+               command_line = paste(command_line," ","/tmp/data_bin",sep="")
+       }
+
+       command_line = paste(command_line," ",args,sep="")
        system(command_line)
 }