diff --git a/RBBGCMuso/NAMESPACE b/RBBGCMuso/NAMESPACE index fb30c3a..46458d0 100644 --- a/RBBGCMuso/NAMESPACE +++ b/RBBGCMuso/NAMESPACE @@ -9,6 +9,7 @@ export(getyearlycum) export(getyearlymax) export(musoDate) export(musoMapping) +export(musoMappingFind) export(musoMonte) export(musoRandomizer) export(musoSensi) diff --git a/RBBGCMuso/R/assistantFunctions.R b/RBBGCMuso/R/assistantFunctions.R index 06714d3..bcfdf23 100644 --- a/RBBGCMuso/R/assistantFunctions.R +++ b/RBBGCMuso/R/assistantFunctions.R @@ -12,7 +12,7 @@ getLogs <- function(outputLoc, outputNames, type = "spinup"){ switch(type, "spinup" = return(grep(paste0(outputNames[1], ".log"), list.files(outputLoc), value = TRUE)), "normal" = return(grep(paste0(outputNames[2], ".log"), list.files(outputLoc), value = TRUE)), - "both" = return(grep(paste0(outputNames[2], ".log"), list.files(outputLoc), value = TRUE))) + "both" = return(sapply(1:2, function (x){grep(paste0(outputNames[x], ".log"), list.files(outputLoc), value = TRUE)}))) } diff --git a/RBBGCMuso/R/calibMuso.R b/RBBGCMuso/R/calibMuso.R index 9501be2..ff43016 100644 --- a/RBBGCMuso/R/calibMuso.R +++ b/RBBGCMuso/R/calibMuso.R @@ -30,6 +30,7 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf ##Copy the variables from settings inputLoc <- settings$inputLoc outputLoc <- settings$outputLoc + outputNames <- settings$outputNames executable <- settings$executable iniInput <- settings$iniInput epc <- settings$epcInput @@ -219,7 +220,7 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf stop("Why are you playing with my nervs? Seriously? You hold your epc-s in different folders?") } else { - stampAndDir(stampDir=EPCS,wrongDir=WRONGEPC,names=epc,type="general",errorsign=errorsign,logfiles=logfiles) + stampAndDir(stampDir=EPCS, wrongDir=WRONGEPC, names=epc, type="general", errorsign=errorsign, logfiles=logfiles) } } diff --git a/RBBGCMuso/R/outputMapping.R b/RBBGCMuso/R/outputMapping.R index 45fc578..46fd27c 100644 --- a/RBBGCMuso/R/outputMapping.R +++ b/RBBGCMuso/R/outputMapping.R @@ -37,6 +37,17 @@ musoMapping <- function(code, mapData=NULL){ } } + +#' musoMappingFind +#' +#' musoMapping can give us the name of a muso outputcode +#' @author Roland Hollos +#' @param variable If null return the whole mapping, else search a variable code +#' @return The code of th specific name +#' @export +#' @usage musoMapping(code, mapData=NULL) + + musoMappingFind <- function(variable=NULL){ if(is.null(variable)){ return(mMapping) diff --git a/RBBGCMuso/R/runModell.R b/RBBGCMuso/R/runModell.R new file mode 100644 index 0000000..4e0ac8a --- /dev/null +++ b/RBBGCMuso/R/runModell.R @@ -0,0 +1,21 @@ +## runModell <- function(executable,) +## { + + +## if(silent){#silenc mode +## if(Linuxp){ +## #In this case, in linux machines +## tryCatch(system(paste(executable,iniInput[1],"> /dev/null",sep=" ")), +## error= function (e){stop("Cannot run the modell-check the executable!")}) +## } else { +## #In windows machines there is a show.output.on.console option +## tryCatch(system(paste(executable,iniInput[1],sep=" "),show.output.on.console = FALSE), +## error= function (e){stop("Cannot run the modell-check the executable!")}) +## } + +## } else { +## system(paste(executable,iniInput[1],sep=" ")) +## } + + +## } diff --git a/RBBGCMuso/R/setupMuso.R b/RBBGCMuso/R/setupMuso.R index b177367..97ad9b4 100644 --- a/RBBGCMuso/R/setupMuso.R +++ b/RBBGCMuso/R/setupMuso.R @@ -230,9 +230,9 @@ setupMuso <- function(executable=NULL, writeLines(iniFiles[[1]],iniInput[1]) writeLines(iniFiles[[2]],iniInput[2]) - suppressWarnings(file.remove(paste0(file.path(outputLoc,outputNames[1]),".log"))) + suppressWarnings(file.remove(paste0(file.path(outputLoc,outputName[1]),".log"))) ## I use file.path additionally because We do not know if outputLoc ends or not to "/" - suppressWarnings(file.remove(paste0(file.path(outputLoc,outputNames[2]),".log"))) + suppressWarnings(file.remove(paste0(file.path(outputLoc,outputName[2]),".log"))) settings = list(executable = executable, calibrationPar = calibrationPar, diff --git a/RBBGCMuso/R/spinupMuso.R b/RBBGCMuso/R/spinupMuso.R index 6d8374e..9e54714 100644 --- a/RBBGCMuso/R/spinupMuso.R +++ b/RBBGCMuso/R/spinupMuso.R @@ -25,6 +25,7 @@ spinupMuso <- function(settings, parameters=NULL, debugging=FALSE, logfilename=N ##Copy the variables from settings inputLoc <- settings$inputLoc outputLoc <- settings$outputLoc + outputNames <- settings$outputNames executable <- settings$executable iniInput <- settings$iniInput epc <- settings$epcInput @@ -52,8 +53,10 @@ spinupMuso <- function(settings, parameters=NULL, debugging=FALSE, logfilename=N ## changemulline(filename=epc[1], calibrationPar, parameters)} if(!is.null(parameters)){ switch(fileToChange, - "epc"=(changemulline(filename=epc[2],calibrationPar,parameters)), - "ini"=(changemulline(filename=iniInput[2],calibrationPar,parameters)), + "epc"=tryCatch(changemulline(filename=epc[2],calibrationPar,parameters), + error = function (e) {stop("Cannot change the epc file")}), + "ini"=tryCatch(changemulline(filename=iniInput[2],calibrationPar,parameters), + error = function (e) {stop("Cannot change the ini file")}), "both"=(stop("This option is not implemented yet, please choose epc or ini")) ) } @@ -64,18 +67,17 @@ spinupMuso <- function(settings, parameters=NULL, debugging=FALSE, logfilename=N setwd(inputLoc) ##Run the spinup - - + if(silent){#silenc mode if(Linuxp){ #In this case, in linux machines - system(paste(executable,iniInput[1],"> /dev/null",sep=" ")) + tryCatch(system(paste(executable,iniInput[1],"> /dev/null",sep=" ")), + error= function (e){stop("Cannot run the modell-check the executable!")}) } else { #In windows machines there is a show.output.on.console option - system(paste(executable,iniInput[1],sep=" "),show.output.on.console = FALSE)} - } else { - system(paste(executable,iniInput[1],sep=" "))} - + tryCatch(system(paste(executable,iniInput[1],sep=" "),show.output.on.console = FALSE), + error= function (e){stop("Cannot run the modell-check the executable!")}) + }} ############################################### #############LOG SECTION####################### ############################################### @@ -197,4 +199,3 @@ spinupMuso <- function(settings, parameters=NULL, debugging=FALSE, logfilename=N } -