optimization is working now
This commit is contained in:
parent
8af4ca86fb
commit
75b4c8baa7
@ -24,7 +24,7 @@
|
|||||||
#' @import utils
|
#' @import utils
|
||||||
#' @export
|
#' @export
|
||||||
|
|
||||||
calibMuso <- function(settings=NULL, calibrationPar=NULL,
|
calibMuso <- function(settings=setupMuso(), calibrationPar=NULL,
|
||||||
parameters=NULL, outVars = NULL, timee="d",
|
parameters=NULL, outVars = NULL, timee="d",
|
||||||
debugging=FALSE, logfilename=NULL,
|
debugging=FALSE, logfilename=NULL,
|
||||||
keepEpc=FALSE, export=FALSE,
|
keepEpc=FALSE, export=FALSE,
|
||||||
@ -32,16 +32,22 @@ calibMuso <- function(settings=NULL, calibrationPar=NULL,
|
|||||||
keepBinary=FALSE,
|
keepBinary=FALSE,
|
||||||
binaryPlace = "./", fileToChange = "epc",
|
binaryPlace = "./", fileToChange = "epc",
|
||||||
skipSpinup = TRUE, modifyOriginal = FALSE, prettyOut = FALSE,
|
skipSpinup = TRUE, modifyOriginal = FALSE, prettyOut = FALSE,
|
||||||
postProcString = NULL){ #
|
postProcString = NULL,
|
||||||
|
doBackup=TRUE
|
||||||
|
){ #
|
||||||
########################################################################
|
########################################################################
|
||||||
###########################Set local variables and places###############
|
###########################Set local variables and places###############
|
||||||
########################################################################
|
########################################################################
|
||||||
|
if(doBackup){
|
||||||
|
file.copy(eval(parse(text = sprintf("settings$%sInput[2]", fileToChange))),file.path(settings$inputLoc),overwrite=FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
|
bck <- file.path(settings$inputLoc, "bck",
|
||||||
|
basename(eval(parse(text = sprintf("settings$%sInput[2]", fileToChange)))))
|
||||||
|
|
||||||
if(!silent){
|
if(!silent){
|
||||||
cat("Biome-BGC simulation started\n") # ZOLI
|
cat("Biome-BGC simulation started\n") # ZOLI
|
||||||
}
|
}
|
||||||
if(is.null(settings)){
|
|
||||||
settings <- setupMuso()
|
|
||||||
}
|
|
||||||
|
|
||||||
Linuxp <-(Sys.info()[1]=="Linux")
|
Linuxp <-(Sys.info()[1]=="Linux")
|
||||||
##Copy the variables from settings
|
##Copy the variables from settings
|
||||||
@ -104,7 +110,7 @@ calibMuso <- function(settings=NULL, calibrationPar=NULL,
|
|||||||
}
|
}
|
||||||
|
|
||||||
toModif <- c(epc[2],iniInput[2])
|
toModif <- c(epc[2],iniInput[2])
|
||||||
|
names(toModif) <- c("epc","ini")
|
||||||
# if(!modifyOriginal & (!is.null(parameters) | !is.null(outVars)))
|
# if(!modifyOriginal & (!is.null(parameters) | !is.null(outVars)))
|
||||||
# {
|
# {
|
||||||
|
|
||||||
@ -115,10 +121,15 @@ calibMuso <- function(settings=NULL, calibrationPar=NULL,
|
|||||||
})
|
})
|
||||||
|
|
||||||
# }
|
# }
|
||||||
|
origsourceFiles <- sourceFiles <- c(epc=epc[2], ini=iniInput[2])
|
||||||
|
names(origsourceFiles) <- names(sourceFiles) <- c("epc","ini")
|
||||||
|
if(file.exists(bck)){
|
||||||
|
sourceFiles[fileToChange] <- bck
|
||||||
|
}
|
||||||
|
|
||||||
##change the epc file if and only if there are given parameters
|
##change the epc file if and only if there are given parameters
|
||||||
if(!is.null(parameters)){
|
if(!is.null(parameters)){
|
||||||
changemulline(filePaths = c(epc[2], iniInput[2]),
|
changemulline(filePaths = sourceFiles,
|
||||||
calibrationPar = calibrationPar,
|
calibrationPar = calibrationPar,
|
||||||
contents = parameters,
|
contents = parameters,
|
||||||
fileOut = toModif,
|
fileOut = toModif,
|
||||||
@ -149,16 +160,14 @@ calibMuso <- function(settings=NULL, calibrationPar=NULL,
|
|||||||
outputVarChanges <- putOutVars(iniInput[2], outputVars = outVars, modifyOriginal = !modifyOriginal)
|
outputVarChanges <- putOutVars(iniInput[2], outputVars = outVars, modifyOriginal = !modifyOriginal)
|
||||||
settings$outputVars[[1]]<-outputVarChanges[[1]]
|
settings$outputVars[[1]]<-outputVarChanges[[1]]
|
||||||
settings$numData <- round(settings$numData*outputVarChanges[[2]])
|
settings$numData <- round(settings$numData*outputVarChanges[[2]])
|
||||||
}
|
|
||||||
|
|
||||||
# if(modifyOriginal){
|
|
||||||
# suppressWarnings(dir.create())
|
|
||||||
# sapply(c(iniInput,epc),)
|
|
||||||
#
|
|
||||||
# }
|
|
||||||
if(modifyOriginal){
|
if(modifyOriginal){
|
||||||
iniInput[2] <- toModif[2]
|
iniInput[2] <- toModif[2]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(modifyOriginal){
|
||||||
|
file.copy(toModif[fileToChange], origsourceFiles[fileToChange], overwrite = TRUE)
|
||||||
|
}
|
||||||
|
|
||||||
if(!skipSpinup) {
|
if(!skipSpinup) {
|
||||||
|
|
||||||
|
|||||||
@ -33,10 +33,6 @@ changemulline <- function(filePaths, calibrationPar, contents, fileOut, fileToCh
|
|||||||
changeMusoC(inFile = filePaths[selectFileToWrite(filePaths, fileToChange)],
|
changeMusoC(inFile = filePaths[selectFileToWrite(filePaths, fileToChange)],
|
||||||
outFile = fileOut[selectFileToWrite(filePaths, fileToChange)],
|
outFile = fileOut[selectFileToWrite(filePaths, fileToChange)],
|
||||||
parMat)
|
parMat)
|
||||||
if(modifyOriginal){
|
|
||||||
# browser()
|
|
||||||
file.copy(fileOut[selectFileToWrite(filePaths, fileToChange)],filePaths[selectFileToWrite(filePaths, fileToChange)],overwrite = TRUE)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileToChange == "both"){
|
if(fileToChange == "both"){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user