diff --git a/models/lpjguess/R/model2netcdf.LPJGUESS.R b/models/lpjguess/R/model2netcdf.LPJGUESS.R index c520283310..d01ef7010a 100644 --- a/models/lpjguess/R/model2netcdf.LPJGUESS.R +++ b/models/lpjguess/R/model2netcdf.LPJGUESS.R @@ -20,7 +20,7 @@ model2netcdf.LPJGUESS <- function(outdir, sitelat, sitelon, start_date, end_date PEcAn.logger::logger.error("No output files found at ", outdir) } - lpjguess.output <- lapply(file.path(outdir, lpjguess.out.files), read.table, header = TRUE, sep = "") + lpjguess.output <- lapply(file.path(outdir, lpjguess.out.files), utils::read.table, header = TRUE, sep = "") # n.outputs <- length(lpjguess.output) m.to.s <- 2592000 diff --git a/models/lpjguess/R/readStateBinary.LPJGUESS.R b/models/lpjguess/R/readStateBinary.LPJGUESS.R index ffba146ac5..c8cab86015 100644 --- a/models/lpjguess/R/readStateBinary.LPJGUESS.R +++ b/models/lpjguess/R/readStateBinary.LPJGUESS.R @@ -208,13 +208,13 @@ readStateBinary <- function(out.path, npft){ nofpatch <- readBin(zz, integer(), 1, size = 4) for(pat in 1:nofpatch){ - Patchpft_list[[pat]] <- getClass_Patchpft() - Vegetation_list[[pat]] <- getClass_Vegetation() - Individual_list[[pat]] <- getClass_Individual(Vegetation_list[[pat]]$indv) - Soil_list[[pat]] <- getClass_Soil() - Sompool_list[[pat]] <- getClass_Sompool() - SompoolCent_list[[pat]] <- getClass_SompoolCent() - Fluxes_list[[pat]] <- getClass_Fluxes() + Patchpft_list[[pat]] <- getClass_Patchpft(zz, npft) + Vegetation_list[[pat]] <- getClass_Vegetation(zz) + Individual_list[[pat]] <- getClass_Individual(Vegetation_list[[pat]]$indv, zz) + Soil_list[[pat]] <- getClass_Soil(zz) + Sompool_list[[pat]] <- getClass_Sompool(zz) + SompoolCent_list[[pat]] <- getClass_SompoolCent(zz) + Fluxes_list[[pat]] <- getClass_Fluxes(zz) } # close connection to the binary state file @@ -226,7 +226,7 @@ readStateBinary <- function(out.path, npft){ ##################### Class : Patchpft ##################### -getClass_Patchpft <- function(){ +getClass_Patchpft <- function(zz, npft){ Patchpft <- list() @@ -370,7 +370,7 @@ getClass_Patchpft <- function(){ } ##################### Class : Vegetation ##################### -getClass_Vegetation <- function(){ +getClass_Vegetation <- function(zz){ Vegetation <- list() Vegetation$indv <- readBin(zz, integer(), 1, size = 4) @@ -380,7 +380,7 @@ getClass_Vegetation <- function(){ ##################### Class : Individual ##################### -getClass_Individual <- function(nind){ # nind <- Vegetation$indv +getClass_Individual <- function(nind, zz){ # nind <- Vegetation$indv Individual <- list() @@ -670,7 +670,7 @@ getClass_Individual <- function(nind){ # nind <- Vegetation$indv } ##################### Class : Soil ##################### -getClass_Soil <- function(){ +getClass_Soil <- function(zz){ Soil <- list() # water content of soil layers [0=upper layer] as fraction of available water holding capacity; @@ -748,7 +748,7 @@ getClass_Soil <- function(){ ##################### Class : Sompool ##################### -getClass_Sompool <- function(){ +getClass_Sompool <- function(zz){ Sompool <- list() npools <- 12 @@ -807,7 +807,7 @@ getClass_Sompool <- function(){ ##################### Class : Sompool, CENTURY ##################### -getClass_SompoolCent <- function(){ +getClass_SompoolCent <- function(zz){ SompoolCent <- list() # daily percolation (mm) @@ -869,7 +869,7 @@ getClass_SompoolCent <- function(){ ##################### Class : Fluxes ##################### -getClass_Fluxes <- function(){ +getClass_Fluxes <- function(zz){ Fluxes <- list() #f.bytes <- bytes[1570:1667,] Fluxes$f1 <- readBin(zz, double(), 1, size = 8) diff --git a/models/lpjguess/R/write.config.LPJGUESS.R b/models/lpjguess/R/write.config.LPJGUESS.R index 43251103d1..680223fa38 100644 --- a/models/lpjguess/R/write.config.LPJGUESS.R +++ b/models/lpjguess/R/write.config.LPJGUESS.R @@ -98,8 +98,8 @@ write.insfile.LPJGUESS <- function(settings, trait.values, rundir, outdir, run.i guessins <- gsub("@GRID_FILE@", grid.file, guessins) pft_names <- sapply(settings$pfts, `[[`,"name") - load(system.file("lpjguess_params.Rdata",package = "PEcAn.LPJGUESS")) - + lpjguess_param_data <- PEcAn.utils::load_local(system.file("lpjguess_params.Rdata",package = "PEcAn.LPJGUESS")) + lpjguess_param_list <- lpjguess_param_data$lpjguess_param_list # name and unit conversion trait.values <- pecan2lpjguess(trait.values) @@ -183,7 +183,9 @@ write.insfile.LPJGUESS <- function(settings, trait.values, rundir, outdir, run.i if (end.year < 1850) { CO2 <- data.frame(start.year:end.year, rep(280, n.year)) } else if (end.year < 2021) { - data(co2.1850.2020, package = "PEcAn.LPJGUESS") + co2_data <- new.env() + utils::data(co2.1850.2020, package = "PEcAn.LPJGUESS", envir = co2_data) + co2.1850.2020 <- co2_data$co2.1850.2020 if (start.year < 1850) { CO2_preind <- data.frame(year = start.year:1849, ppm = rep(280, length(start.year:1849))) CO2_postind <- co2.1850.2020[1:which(co2.1850.2020[, 1] == end.year), ] @@ -194,7 +196,7 @@ write.insfile.LPJGUESS <- function(settings, trait.values, rundir, outdir, run.i } else { PEcAn.logger::logger.severe("End year should be < 2021 for CO2") } - write.table(CO2, file = co2.file, row.names = FALSE, col.names = FALSE, sep = "\t", eol = "\n") + utils::write.table(CO2, file = co2.file, row.names = FALSE, col.names = FALSE, sep = "\t", eol = "\n") guessins <- gsub("@CO2_FILE@", co2.file, guessins) # write soil file path diff --git a/models/lpjguess/tests/Rcheck_reference.log b/models/lpjguess/tests/Rcheck_reference.log index 15fb246439..c351d8e6d9 100644 --- a/models/lpjguess/tests/Rcheck_reference.log +++ b/models/lpjguess/tests/Rcheck_reference.log @@ -45,35 +45,7 @@ Strong dependencies not in mainstream repositories: * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK -* checking R code for possible problems ... NOTE -getClass_Fluxes: no visible binding for global variable ‘zz’ -getClass_Individual: no visible binding for global variable ‘zz’ -getClass_Patchpft: no visible binding for global variable ‘npft’ -getClass_Patchpft: no visible binding for global variable ‘zz’ -getClass_Soil: no visible binding for global variable ‘zz’ -getClass_Sompool: no visible binding for global variable ‘zz’ -getClass_SompoolCent: no visible binding for global variable ‘zz’ -getClass_Vegetation: no visible binding for global variable ‘zz’ -model2netcdf.LPJGUESS: no visible binding for global variable - ‘read.table’ -write.insfile.LPJGUESS: no visible binding for global variable - ‘lpjguess_param_list’ -write.insfile.LPJGUESS: no visible global function definition for - ‘data’ -write.insfile.LPJGUESS: no visible binding for global variable - ‘co2.1850.2020’ -write.insfile.LPJGUESS: no visible global function definition for - ‘write.table’ -Undefined global functions or variables: - co2.1850.2020 data lpjguess_param_list npft read.table write.table zz -Consider adding - importFrom("utils", "data", "read.table", "write.table") -to your NAMESPACE file. - -Found the following calls to data() loading into the global environment: -File ‘PEcAn.LPJGUESS/R/write.config.LPJGUESS.R’: - data(co2.1850.2020, package = "PEcAn.LPJGUESS") -See section ‘Good practice’ in ‘?data’. +* checking R code for possible problems ... OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK