I think I do it only once - the simInit is before the foreach, of course. Or what did you mean? Sorry if what I wrote is a bit confusing.. I described several things that I tested individually..
####
Hi,
Thank you! I don't specify anything for combine, my code looks something like
Packages
Paths, Module, etc
#SimInit wolfalps....
Getparworkers..
Doparallel...
print("hi")
Foreach (i=1..3) %dopar% print("hello")
I will post more details when I am home. Like this it works, but if I remove the # before simInit it only goes to the "hi". There is unfortunately no error message, it goes on until timeout. I don't really care how things are combined, only that it runs somehow.
Thanks a lot for your fast answers :)
####
I decided against experiment because when this works I also want to change parameters. But if I can't get foreach to work I will probable come back to it, so thank you for the reminder.
When I tried to really run the simulation I did include the packages in the dopar command, if I hadn't it would not have worked locally.
Could it be because of some R Version clash? I am very much guessing only because I don't get any error messages, it just goes to the foreach command and stays there forever without doing the things in it.
I will send you the exact Code I used as soon as posible, so maybe don't bother guessing if the above is too confusing.
Chao,
Clara
rm(list = ls(all.names = TRUE))
library(devtools)library(SpaDES)library(NetLogoR)library(doParallel)library(tictoc)library(plyr)library(data.table)
.libPaths("/home/mypath")
#tic("start initialization")
moduleName <- "wolfAlps"
workingDirectory <- file.path("/home/mypath/wolves_firstpackfuerPALMA", "wolfAlps")
times <- list(start = 0, end = 20, timeunit = "year") #start: 2000.
# These are the default parameters, none is being changed at the moment.wolfiparameters <- list( # .plotInitialTime = start(sim), # .plotInterval = 1, # .saveInitialTime = start(sim), # .saveInterval = 1, StartingNumberOfWolves = 2+4+2, #34.0+60+52, #Alps = 61, Germany = 34 MeanNpups = 3.387, #4.314 SdNpups = 1.210, #2.069 AdultMortalityRate = 0.18, JuvMortalityRate = 0.449, DispMortRatePerMove = 0.0353, #0.0353. MeanPackSize = 4.405, SdPackSize = 1.251, EndDispersal = 0.98, #0.98 CellWidth = 1.00, MoveStep = 10.929 * 1.25, #Alps = 1.25, Germany = 1.00 sigma = 21.802, MeanPixelQuality = 0.84, MinPixelQuality = 0.376, MinPackQuality = 89.288 * 1.25*1.25, PackArea = 256 * 1.25 * 1.25, PhaseTransitionLower = 0.198, #original 0.198, last run: 0.08 run.tests = FALSE)
modules <- list(moduleName)moduleDir <- file.path(workingDirectory)
paths <- list( modulePath = moduleDir, # modulePath = file.path(moduleDir, "wolfAlps"), inputPath = file.path(moduleDir, "wolfAlps", "data_Germany_firstpack"), outputPath = file.path(moduleDir, "outputR"))
# easier and more direct than via objects loadinginputs <- data.frame(file = c("wolves2008.asc", "packs2008.asc", ##### Germany: file ..2008.. has 2000/1 data. "CMR.asc", "HabitatSuitability.asc"))
# accept default parameters: put comment behind "times,"wolfModuleStart <- simInit(times = times, params = list(wolfAlps = wolfiparameters), modules = modules, inputs = inputs, paths = paths)
#toc()
registerDoParallel(cores=3) #32 pro nodegetDoParWorkers()
#tic("singlewolfoutput")
#singlewolfoutput<-spades(wolfModuleStart, progress = 20,debug=T)
################ this works, runs through, everything ok.
#toc()tic("combinedWolfAlpsOutput_2001")
combinedWolfAlpsOutput_2001 <- foreach(i=1:3, .packages = c("devtools", "NetLogoR", "SpaDES", "plyr", "data.table")) %dopar% spades(wolfModuleStart, progress =10,debug=T)
############ this does not run through. Starts (maybe?), but never stops, and ############ does not produce output or error or anything. But it works exactly like this, only changed paths, on my local ############ computer.
#simpletest <- foreach(i=1:3) %dopar% # print("gehtdas?") ############## does not work either. Does not seem to start. But it works if I do it without the ############SimInit call
toc()combinedWolfAlpsOutput_2001
save.image("/scratch/tmp/mypath/firstpack_3rep.Rdata")
What I want to do is the combinedWolfAlpsOutput_2001 but it does not run at all.