fix the output problems
This commit is contained in:
parent
214d1540e1
commit
2a694681b5
@ -1 +1,5 @@
|
||||
install.packages("RBBGCMuso_0.1.8.tar.gz")
|
||||
install.packages("RBBGCMuso_0.1.8.tar.gz")
|
||||
install.packages("RBBGCMuso_0.1.8.tar.gz")
|
||||
install.packages("RBBGCMuso_0.1.8.tar.gz")
|
||||
install.packages("RBBGCMuso_0.1.8.tar.gz")
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Package: RBBGCMuso
|
||||
Title: What the Package Does (one line, title case)
|
||||
Version: 0.1.8
|
||||
Version: 0.1.9.0-1
|
||||
Authors@R: person("Roland", "Hollos", , "hollorol@gmail.com", role = c("aut", "cre"))
|
||||
Description: What the package does (one paragraph)
|
||||
License: GPL-2
|
||||
|
||||
@ -14,6 +14,7 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf
|
||||
|
||||
##Copy the variables from settings
|
||||
inputloc <- settings$inputloc
|
||||
outputloc <- settings$outputloc
|
||||
executable <- settings$executable
|
||||
ininput <- settings$ininput
|
||||
epc <- settings$epcinput
|
||||
@ -32,7 +33,7 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf
|
||||
}
|
||||
|
||||
if(aggressive==TRUE){
|
||||
cleanupMuso()
|
||||
cleanupMuso(location=outputloc)
|
||||
}
|
||||
|
||||
##change the epc file if and only if there are given parameters
|
||||
@ -64,12 +65,12 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf
|
||||
|
||||
|
||||
|
||||
logspinup<-list.files(inputloc)[grep("log$",list.files(inputloc))]#load the logfiles
|
||||
logspinup<-list.files(outputloc)[grep("log$",list.files(outputloc))]#load the logfiles
|
||||
if(length(logspinup)==0){
|
||||
return("Modell Failure")#in that case the modell did not create even a logfile
|
||||
}
|
||||
|
||||
spincrash<-tail(readLines(paste(inputloc,logspinup,sep=""),-1),1)==0 #If the last line in the logfile is 0 There are mistakes so the spinup crashes
|
||||
spincrash<-tail(readLines(paste(outputloc,logspinup,sep="/"),-1),1)==0 #If the last line in the logfile is 0 There are mistakes so the spinup crashes
|
||||
|
||||
if(!spincrash){##If spinup did not crashed, run the normal run.
|
||||
|
||||
@ -102,13 +103,13 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf
|
||||
}
|
||||
|
||||
|
||||
logfiles <- list.files(inputloc)[grep("log$",list.files(inputloc))]#creating a vector for logfilenames
|
||||
logfiles <- list.files(outputloc)[grep("log$",list.files(outputloc))]#creating a vector for logfilenames
|
||||
|
||||
###############################################
|
||||
#############LOG SECTION#######################
|
||||
###############################################
|
||||
|
||||
perror<-as.numeric(as.vector(lapply(paste(inputloc,logfiles,sep=""),function(x) tail(readLines(x,-1),1)))) #vector of spinup and normalrun error
|
||||
perror<-as.numeric(as.vector(lapply(paste(outputloc,logfiles,sep="/"),function(x) tail(readLines(x,-1),1)))) #vector of spinup and normalrun error
|
||||
|
||||
if((debugging=="stamplog")|(debugging==TRUE)){#If debugging option turned on
|
||||
#If log or ERROR directory does not exists create it!
|
||||
@ -186,7 +187,7 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf
|
||||
|
||||
}}
|
||||
|
||||
cleanupMuso()
|
||||
cleanupMuso(location=outputloc)
|
||||
if(errorsign==1){
|
||||
return("Modell Failure")
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
cleanupMuso <- function(location=NULL,deep=FALSE){
|
||||
cleanupMuso <- function(location=NULL, simplicity=TRUE,deep=FALSE){
|
||||
|
||||
whereAmI <- getwd()
|
||||
if(!is.null(location)){
|
||||
@ -44,11 +44,13 @@ cleanupMuso <- function(location=NULL,deep=FALSE){
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
file.remove(
|
||||
grep("(out$)|(endpoint$)|(log$)",
|
||||
list.files(), value = T)
|
||||
)
|
||||
if(!simplicity){
|
||||
file.remove(
|
||||
grep("(out$)|(endpoint$)|(log$)",
|
||||
list.files(), value = T)
|
||||
)} else {
|
||||
file.remove(grep("log$",list.files(),value = T))
|
||||
}
|
||||
|
||||
setwd(whereAmI)
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ getthespecdata<-function(settings,colnumbers){
|
||||
}
|
||||
|
||||
getdailyout<-function(settings){
|
||||
binaryname<-paste(settings$inputloc,settings$outputname,".dayout",sep="")
|
||||
binaryname<-paste(settings$inputloc,settings$outputnames,".dayout",sep="")
|
||||
d<-file(binaryname,"rb")
|
||||
dayoutput<-matrix(readBin(d,"double",size=4,n=(settings$numdata[1])),(settings$numyears*365),byrow=TRUE)
|
||||
close(d)
|
||||
|
||||
@ -14,6 +14,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k
|
||||
|
||||
##Copy the variables from settings
|
||||
inputloc <- settings$inputloc
|
||||
outputloc <- settings$outputloc
|
||||
executable <- settings$executable
|
||||
ininput <- settings$ininput
|
||||
epc <- settings$epcinput
|
||||
@ -32,7 +33,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k
|
||||
}
|
||||
|
||||
if(aggressive==TRUE){
|
||||
cleanupMuso()
|
||||
cleanupMuso(location=outputloc)
|
||||
}
|
||||
|
||||
##We change the working directory becase of the model, but we want to avoid sideeffects, so we save the current location and after that we will change everything to it.
|
||||
@ -59,12 +60,12 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k
|
||||
|
||||
|
||||
|
||||
logspinup<-list.files(inputloc)[grep("log$",list.files(inputloc))]#load the logfiles
|
||||
logspinup<-list.files(outputloc)[grep("log$",list.files(outputloc))]#load the logfiles
|
||||
if(length(logspinup)==0){
|
||||
return("Modell Failure")#in that case the modell did not create even a logfile
|
||||
}
|
||||
|
||||
spincrash<-tail(readLines(paste(inputloc,logspinup,sep=""),-1),1)==0 #If the last line in the logfile is 0 There are mistakes so the spinup crashes
|
||||
spincrash<-tail(readLines(paste(outputloc,logspinup,sep="/"),-1),1)==0 #If the last line in the logfile is 0 There are mistakes so the spinup crashes
|
||||
|
||||
if(!spincrash){##If spinup did not crashed, run the normal run.
|
||||
|
||||
@ -97,13 +98,13 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k
|
||||
}
|
||||
|
||||
|
||||
logfiles <- list.files(inputloc)[grep("log$",list.files(inputloc))]#creating a vector for logfilenames
|
||||
logfiles <- list.files(outputloc)[grep("log$",list.files(outputloc))]#creating a vector for logfilenames
|
||||
|
||||
###############################################
|
||||
#############LOG SECTION#######################
|
||||
###############################################
|
||||
|
||||
perror<-as.numeric(as.vector(lapply(paste(inputloc,logfiles,sep=""),function(x) tail(readLines(x,-1),1)))) #vector of spinup and normalrun error
|
||||
perror<-as.numeric(as.vector(lapply(paste(outputloc,logfiles,sep="/"),function(x) tail(readLines(x,-1),1)))) #vector of spinup and normalrun error
|
||||
|
||||
if((debugging=="stamplog")|(debugging==TRUE)){#If debugging option turned on
|
||||
#If log or ERROR directory does not exists create it!
|
||||
@ -181,7 +182,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k
|
||||
|
||||
}}
|
||||
|
||||
cleanupMuso()
|
||||
cleanupMuso(location=outputloc)
|
||||
if(errorsign==1){
|
||||
return("Modell Failure")
|
||||
}
|
||||
|
||||
@ -26,8 +26,7 @@ setupMuso <- function(executable=NULL,
|
||||
|
||||
if(is.null(inputloc)){
|
||||
inputloc<- "./"
|
||||
}
|
||||
|
||||
} else {
|
||||
inp <- unlist(strsplit(inputloc,"")) #This is the charactervector of the given imput location
|
||||
|
||||
if(inp[length(inp)]!="/"){
|
||||
@ -37,10 +36,8 @@ setupMuso <- function(executable=NULL,
|
||||
}# If inp not ends in / paste one at the end, then make a string, that will be the new inputloc
|
||||
|
||||
##Example: "a/b/c ==> a/b/c/"
|
||||
|
||||
if(is.null(outputloc)){
|
||||
outputloc<-inputloc
|
||||
}
|
||||
inichangedp <- FALSE
|
||||
|
||||
if(is.null(ininput)){
|
||||
spinups<-grep("s.ini$",list.files(inputloc),value=TRUE)
|
||||
@ -60,7 +57,9 @@ setupMuso <- function(executable=NULL,
|
||||
##read the ini files for the further changes
|
||||
|
||||
inifiles<-lapply(ininput, function (x) readLines(x,-1))
|
||||
|
||||
inifiles[[1]] <- gsub("\\","/", inifiles[[1]],fixed=TRUE) #replacing \ to /
|
||||
inifiles[[2]] <- gsub("\\","/", inifiles[[2]],fixed=TRUE) #replacing \ to /
|
||||
|
||||
if(is.null(epcinput)){
|
||||
epcflag=TRUE
|
||||
epcinput[1] <- unlist(strsplit(grep(" EPC file name",inifiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
@ -230,6 +229,15 @@ setupMuso <- function(executable=NULL,
|
||||
|
||||
}
|
||||
## outputname<-unlist(read.table(ininput[2],skip=93,nrows = 1))[1]
|
||||
|
||||
|
||||
if(is.null(outputloc)){
|
||||
## outputloc<-paste((rev(rev(unlist(strsplit(outputname,"/")))[-1])),collapse="/")
|
||||
outputloc <- dirname(outputname)
|
||||
}
|
||||
|
||||
|
||||
|
||||
inputfiles<-c(ininput,epcinput,metinput)
|
||||
numdata<-rep(NA,3)
|
||||
numyears <- as.numeric(unlist(strsplit(grep("simulation years",inifiles[[2]],value=TRUE),"[\ \t]"))[1])
|
||||
@ -241,6 +249,11 @@ setupMuso <- function(executable=NULL,
|
||||
numdata[2]<-numyears*numvalues*12
|
||||
numdata[3]<-numyears*numvalues
|
||||
|
||||
##Writing out changed ini-file
|
||||
|
||||
writeLines(inifiles[[1]],ininput[1])
|
||||
writeLines(inifiles[[2]],ininput[2])
|
||||
|
||||
settings = list(executable = executable,
|
||||
calibrationpar = calibrationpar,
|
||||
outputloc=outputloc,
|
||||
|
||||
Binary file not shown.
BIN
RBBGCMuso_0.1.9.0-1.tar.gz
Normal file
BIN
RBBGCMuso_0.1.9.0-1.tar.gz
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user