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")
|
||||||
|
install.packages("RBBGCMuso_0.1.8.tar.gz")
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
Package: RBBGCMuso
|
Package: RBBGCMuso
|
||||||
Title: What the Package Does (one line, title case)
|
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"))
|
Authors@R: person("Roland", "Hollos", , "hollorol@gmail.com", role = c("aut", "cre"))
|
||||||
Description: What the package does (one paragraph)
|
Description: What the package does (one paragraph)
|
||||||
License: GPL-2
|
License: GPL-2
|
||||||
|
|||||||
@ -14,6 +14,7 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf
|
|||||||
|
|
||||||
##Copy the variables from settings
|
##Copy the variables from settings
|
||||||
inputloc <- settings$inputloc
|
inputloc <- settings$inputloc
|
||||||
|
outputloc <- settings$outputloc
|
||||||
executable <- settings$executable
|
executable <- settings$executable
|
||||||
ininput <- settings$ininput
|
ininput <- settings$ininput
|
||||||
epc <- settings$epcinput
|
epc <- settings$epcinput
|
||||||
@ -32,7 +33,7 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(aggressive==TRUE){
|
if(aggressive==TRUE){
|
||||||
cleanupMuso()
|
cleanupMuso(location=outputloc)
|
||||||
}
|
}
|
||||||
|
|
||||||
##change the epc file if and only if there are given parameters
|
##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){
|
if(length(logspinup)==0){
|
||||||
return("Modell Failure")#in that case the modell did not create even a logfile
|
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.
|
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#######################
|
#############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((debugging=="stamplog")|(debugging==TRUE)){#If debugging option turned on
|
||||||
#If log or ERROR directory does not exists create it!
|
#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){
|
if(errorsign==1){
|
||||||
return("Modell Failure")
|
return("Modell Failure")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
cleanupMuso <- function(location=NULL,deep=FALSE){
|
cleanupMuso <- function(location=NULL, simplicity=TRUE,deep=FALSE){
|
||||||
|
|
||||||
whereAmI <- getwd()
|
whereAmI <- getwd()
|
||||||
if(!is.null(location)){
|
if(!is.null(location)){
|
||||||
@ -44,11 +44,13 @@ cleanupMuso <- function(location=NULL,deep=FALSE){
|
|||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(!simplicity){
|
||||||
file.remove(
|
file.remove(
|
||||||
grep("(out$)|(endpoint$)|(log$)",
|
grep("(out$)|(endpoint$)|(log$)",
|
||||||
list.files(), value = T)
|
list.files(), value = T)
|
||||||
)
|
)} else {
|
||||||
|
file.remove(grep("log$",list.files(),value = T))
|
||||||
|
}
|
||||||
|
|
||||||
setwd(whereAmI)
|
setwd(whereAmI)
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ getthespecdata<-function(settings,colnumbers){
|
|||||||
}
|
}
|
||||||
|
|
||||||
getdailyout<-function(settings){
|
getdailyout<-function(settings){
|
||||||
binaryname<-paste(settings$inputloc,settings$outputname,".dayout",sep="")
|
binaryname<-paste(settings$inputloc,settings$outputnames,".dayout",sep="")
|
||||||
d<-file(binaryname,"rb")
|
d<-file(binaryname,"rb")
|
||||||
dayoutput<-matrix(readBin(d,"double",size=4,n=(settings$numdata[1])),(settings$numyears*365),byrow=TRUE)
|
dayoutput<-matrix(readBin(d,"double",size=4,n=(settings$numdata[1])),(settings$numyears*365),byrow=TRUE)
|
||||||
close(d)
|
close(d)
|
||||||
|
|||||||
@ -14,6 +14,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k
|
|||||||
|
|
||||||
##Copy the variables from settings
|
##Copy the variables from settings
|
||||||
inputloc <- settings$inputloc
|
inputloc <- settings$inputloc
|
||||||
|
outputloc <- settings$outputloc
|
||||||
executable <- settings$executable
|
executable <- settings$executable
|
||||||
ininput <- settings$ininput
|
ininput <- settings$ininput
|
||||||
epc <- settings$epcinput
|
epc <- settings$epcinput
|
||||||
@ -32,7 +33,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(aggressive==TRUE){
|
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.
|
##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){
|
if(length(logspinup)==0){
|
||||||
return("Modell Failure")#in that case the modell did not create even a logfile
|
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.
|
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#######################
|
#############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((debugging=="stamplog")|(debugging==TRUE)){#If debugging option turned on
|
||||||
#If log or ERROR directory does not exists create it!
|
#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){
|
if(errorsign==1){
|
||||||
return("Modell Failure")
|
return("Modell Failure")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,8 +26,7 @@ setupMuso <- function(executable=NULL,
|
|||||||
|
|
||||||
if(is.null(inputloc)){
|
if(is.null(inputloc)){
|
||||||
inputloc<- "./"
|
inputloc<- "./"
|
||||||
}
|
} else {
|
||||||
|
|
||||||
inp <- unlist(strsplit(inputloc,"")) #This is the charactervector of the given imput location
|
inp <- unlist(strsplit(inputloc,"")) #This is the charactervector of the given imput location
|
||||||
|
|
||||||
if(inp[length(inp)]!="/"){
|
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
|
}# 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/"
|
##Example: "a/b/c ==> a/b/c/"
|
||||||
|
|
||||||
if(is.null(outputloc)){
|
|
||||||
outputloc<-inputloc
|
|
||||||
}
|
}
|
||||||
|
inichangedp <- FALSE
|
||||||
|
|
||||||
if(is.null(ininput)){
|
if(is.null(ininput)){
|
||||||
spinups<-grep("s.ini$",list.files(inputloc),value=TRUE)
|
spinups<-grep("s.ini$",list.files(inputloc),value=TRUE)
|
||||||
@ -60,6 +57,8 @@ setupMuso <- function(executable=NULL,
|
|||||||
##read the ini files for the further changes
|
##read the ini files for the further changes
|
||||||
|
|
||||||
inifiles<-lapply(ininput, function (x) readLines(x,-1))
|
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)){
|
if(is.null(epcinput)){
|
||||||
epcflag=TRUE
|
epcflag=TRUE
|
||||||
@ -230,6 +229,15 @@ setupMuso <- function(executable=NULL,
|
|||||||
|
|
||||||
}
|
}
|
||||||
## outputname<-unlist(read.table(ininput[2],skip=93,nrows = 1))[1]
|
## 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)
|
inputfiles<-c(ininput,epcinput,metinput)
|
||||||
numdata<-rep(NA,3)
|
numdata<-rep(NA,3)
|
||||||
numyears <- as.numeric(unlist(strsplit(grep("simulation years",inifiles[[2]],value=TRUE),"[\ \t]"))[1])
|
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[2]<-numyears*numvalues*12
|
||||||
numdata[3]<-numyears*numvalues
|
numdata[3]<-numyears*numvalues
|
||||||
|
|
||||||
|
##Writing out changed ini-file
|
||||||
|
|
||||||
|
writeLines(inifiles[[1]],ininput[1])
|
||||||
|
writeLines(inifiles[[2]],ininput[2])
|
||||||
|
|
||||||
settings = list(executable = executable,
|
settings = list(executable = executable,
|
||||||
calibrationpar = calibrationpar,
|
calibrationpar = calibrationpar,
|
||||||
outputloc=outputloc,
|
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