From eb9c4bc9404fd9d20194982ace599e59abfb519f Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 12 Dec 2022 16:13:00 -0500 Subject: [PATCH 01/11] ensure line isn't cut off --- models/ed/R/write.configs.ed.R | 2 +- .../ed/tests/testthat/test.write.configs.ed.R | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/models/ed/R/write.configs.ed.R b/models/ed/R/write.configs.ed.R index 16d839e5dd2..13e5ad42b26 100644 --- a/models/ed/R/write.configs.ed.R +++ b/models/ed/R/write.configs.ed.R @@ -647,7 +647,7 @@ write.config.jobsh.ED2 <- function(settings, run.id) { jobsh <- gsub("@BINARY@", settings$model$binary, jobsh) pft_names <- extract_pfts(settings$pfts) - pft_names <- deparse(dput(pft_names)) + pft_names <- deparse1(dput(pft_names)) jobsh <- gsub("@PFT_NAMES@", pft_names, jobsh) return(jobsh) diff --git a/models/ed/tests/testthat/test.write.configs.ed.R b/models/ed/tests/testthat/test.write.configs.ed.R index 50d68af26b5..c114ac90a98 100644 --- a/models/ed/tests/testthat/test.write.configs.ed.R +++ b/models/ed/tests/testthat/test.write.configs.ed.R @@ -21,6 +21,7 @@ testdir <- tempfile() dir.create(testdir) withr::defer(unlink(testdir, recursive = TRUE)) unzip("data/outdir.zip", exdir = testdir) +# unzip("models/ed/tests/testthat/data/outdir.zip", exdir = testdir) outdir <- file.path(testdir, "outdir") test_that("write.config.jobsh.ED2() writes correct model2netcdf.ED2() args", { @@ -32,6 +33,22 @@ test_that("write.config.jobsh.ED2() writes correct model2netcdf.ED2() args", { expect_true(any(stringr::str_detect(job.sh, stringr::fixed(expect)))) }) +test_that("write.config.jobsh.ED2() works with long list of PFTs", { + settings <- + PEcAn.settings::read.settings(file.path(outdir, "pecan_checked.xml")) + more_pfts <- list( + pft = list(name = "tempconif", ed2_pft_number = 7), + pft = list(name = "temperate.Evergreen_Hardwood", ed2_pft_number = 8), + pft = list(name = "temperate.Early_Hardwood", ed2_pft_number = 9), + pft = list(name = "temperate.North_Mid_Hardwood", ed2_pft_number = 10), + pft = list(name = "temperate.Late_Hardwood", ed2_pft_number = 11) + ) + settings$pfts <- append(settings$pfts, more_pfts) + job.sh <- write.config.jobsh.ED2(settings, run.id = "test_run") + expect <- deparse(dput(extract_pfts(settings$pfts))) + expect_true(any(stringr::str_detect(job.sh, stringr::fixed(expect)))) +}) + test_that("New ED2IN tags get added at bottom of file", { #1. read in pecan.xml in data/pecan_checked.xml settings <- PEcAn.settings::read.settings("data/pecan_checked.xml") From 26cc9c436222c4bd048e72e42a1a73184163fc77 Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 12 Dec 2022 16:13:09 -0500 Subject: [PATCH 02/11] add bread crumb note --- models/ed/inst/template.job | 2 ++ 1 file changed, 2 insertions(+) diff --git a/models/ed/inst/template.job b/models/ed/inst/template.job index 425632210ca..9296951e60d 100644 --- a/models/ed/inst/template.job +++ b/models/ed/inst/template.job @@ -1,5 +1,7 @@ #!/bin/bash -l +# Generated by PEcAn.ED2::write.config.jobsh.ED2() + # create output folder mkdir -p "@OUTDIR@" @SCRATCH_MKDIR@ From 98b5e96515f04ef0f0255b243d0611763c3c63fc Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 12 Dec 2022 16:22:09 -0500 Subject: [PATCH 03/11] added NEWS.md --- models/ed/NEWS.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 models/ed/NEWS.md diff --git a/models/ed/NEWS.md b/models/ed/NEWS.md new file mode 100644 index 00000000000..ff14c8327f4 --- /dev/null +++ b/models/ed/NEWS.md @@ -0,0 +1,7 @@ +# PEcAn.ED2 (development version) + +* Fixed a bug effecting the generation of job.sh for runs with many PFTs (#3075) + +# PEcAn.ED2 1.7.2 + +* Added a `NEWS.md` file to track changes to the package. Prior to this point, PEcAn.ED2 development was tracked in the main PEcAn NEWS file. From 88b9c592dbdd4188bbf9e75f8794b23c7af311fe Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 12 Dec 2022 16:22:20 -0500 Subject: [PATCH 04/11] bump version --- models/ed/DESCRIPTION | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/models/ed/DESCRIPTION b/models/ed/DESCRIPTION index 86448aa3dd1..421d5a1c8f5 100644 --- a/models/ed/DESCRIPTION +++ b/models/ed/DESCRIPTION @@ -1,7 +1,7 @@ Package: PEcAn.ED2 Type: Package Title: PEcAn Package for Integration of ED2 Model -Version: 1.7.2 +Version: 1.7.2.9000 Date: 2021-10-04 Authors@R: c(person("Mike", "Dietze", role = c("aut", "cre"), email = "dietze@bu.edu"), @@ -66,4 +66,3 @@ Encoding: UTF-8 RoxygenNote: 7.1.2 Roxygen: list(markdown = TRUE) Config/testthat/edition: 2 - From 5b651afad644096b773ec705224f2772efd52fe3 Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 12 Dec 2022 16:24:34 -0500 Subject: [PATCH 05/11] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 676124bb687..7cb8766dd5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ convert data for a single PFT fixed (#1329, #2974, #2981) the cdo_setup argument in the template job file. In detail, people will need to specify cdosetup = "module load cdo/2.0.6" in the host section. More details are in the Create_Multi_settings.R script. (#3052) +- Fixed a bug causing the model2netcdf.ED2() step in jobs.sh to be incorrectly written (#3075) ### Changed From 7abbac4b4512b7fce6db930800b7b2896f736a2c Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 12 Dec 2022 16:25:21 -0500 Subject: [PATCH 06/11] add self to second author list --- models/ed/DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/ed/DESCRIPTION b/models/ed/DESCRIPTION index 421d5a1c8f5..f3e7805785d 100644 --- a/models/ed/DESCRIPTION +++ b/models/ed/DESCRIPTION @@ -23,7 +23,7 @@ Authors@R: c(person("Mike", "Dietze", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7430-7879")), person("University of Illinois, NCSA", role = c("cph"))) Author: David LeBauer, Mike Dietze, Xiaohui Feng, Dan Wang, Carl - Davidson, Rob Kooper, Shawn Serbin, Alexey Shiklomanov + Davidson, Rob Kooper, Shawn Serbin, Alexey Shiklomanov, Eric R. Scott Maintainer: Mike Dietze Description: The Predictive Ecosystem Carbon Analyzer (PEcAn) is a scientific workflow management tool that is designed to simplify the management of From d249b934319b1cad3fac160705bae6c9b6329541 Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 12 Dec 2022 17:01:56 -0500 Subject: [PATCH 07/11] document() totally unrelated function --- modules/data.atmosphere/man/cos_solar_zenith_angle.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/data.atmosphere/man/cos_solar_zenith_angle.Rd b/modules/data.atmosphere/man/cos_solar_zenith_angle.Rd index faf57b64313..26fdc9f3fd5 100644 --- a/modules/data.atmosphere/man/cos_solar_zenith_angle.Rd +++ b/modules/data.atmosphere/man/cos_solar_zenith_angle.Rd @@ -21,7 +21,7 @@ cos_solar_zenith_angle(doy, lat, lon, dt, hr) `numeric(1)` of cosine of solar zenith angle } \description{ -For explanations of formulae, see http://www.itacanet.org/the-sun-as-a-source-of-energy/part-3-calculating-solar-angles/ +For explanations of formulae, see https://web.archive.org/web/20180307133425/http://www.itacanet.org/the-sun-as-a-source-of-energy/part-3-calculating-solar-angles/ } \author{ Alexey Shiklomanov From 7142306d3e30759ddf31e579d3b6ffa684d8ebe2 Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 12 Dec 2022 18:12:06 -0500 Subject: [PATCH 08/11] fix test --- models/ed/tests/testthat/test.write.configs.ed.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/ed/tests/testthat/test.write.configs.ed.R b/models/ed/tests/testthat/test.write.configs.ed.R index c114ac90a98..bd9b2794285 100644 --- a/models/ed/tests/testthat/test.write.configs.ed.R +++ b/models/ed/tests/testthat/test.write.configs.ed.R @@ -45,7 +45,7 @@ test_that("write.config.jobsh.ED2() works with long list of PFTs", { ) settings$pfts <- append(settings$pfts, more_pfts) job.sh <- write.config.jobsh.ED2(settings, run.id = "test_run") - expect <- deparse(dput(extract_pfts(settings$pfts))) + expect <- deparse1(dput(extract_pfts(settings$pfts))) expect_true(any(stringr::str_detect(job.sh, stringr::fixed(expect)))) }) From f63c2a453724ec93a07e8e322c09bd41c7992aba Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 12 Dec 2022 18:20:42 -0500 Subject: [PATCH 09/11] ensure that logger level is set to DEBUG before capturing test output --- models/ed/tests/testthat/test.write.configs.ed.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/models/ed/tests/testthat/test.write.configs.ed.R b/models/ed/tests/testthat/test.write.configs.ed.R index bd9b2794285..705c67c55f9 100644 --- a/models/ed/tests/testthat/test.write.configs.ed.R +++ b/models/ed/tests/testthat/test.write.configs.ed.R @@ -106,6 +106,7 @@ test_that("New ED2IN tags get added at bottom of file", { posteriorid = 9000001416 ) ) + old_level <- PEcAn.logger::logger.setLevel("DEBUG") x <- capture.output( write.config.ED2( trait.values = trait.values, @@ -116,12 +117,15 @@ test_that("New ED2IN tags get added at bottom of file", { ), type = "message" ) + PEcAn.logger::logger.setLevel(old_level) + #5. check if new tag exists ed2in_out <- read_ed2in(file.path(rundir, run.id, "ED2IN")) expect_equal(ed2in_out$NEW_TAG, 0) #check that info is printed + expect_true(any(stringr::str_detect(x, "NEW_TAG"))) #check that last non-comment line of ED2IN is "$END" From dce78f1bb5a2892884f5902e6093e221ef3af3df Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Mon, 19 Dec 2022 16:19:51 -0500 Subject: [PATCH 10/11] Update models/ed/inst/template.job Co-authored-by: David LeBauer --- models/ed/inst/template.job | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/ed/inst/template.job b/models/ed/inst/template.job index 9296951e60d..838e15aecf2 100644 --- a/models/ed/inst/template.job +++ b/models/ed/inst/template.job @@ -1,6 +1,6 @@ #!/bin/bash -l -# Generated by PEcAn.ED2::write.config.jobsh.ED2() +# Parsed by PEcAn.ED2::write.config.jobsh.ED2() to generate job.sh files # create output folder mkdir -p "@OUTDIR@" From 346c2c38c0ced69b34ac3528fe374a412bdb4646 Mon Sep 17 00:00:00 2001 From: David LeBauer Date: Sat, 7 Jan 2023 13:21:49 -0700 Subject: [PATCH 11/11] Update models/ed/NEWS.md --- models/ed/NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/ed/NEWS.md b/models/ed/NEWS.md index 9c2f471706d..2c10c16a2d7 100644 --- a/models/ed/NEWS.md +++ b/models/ed/NEWS.md @@ -1,6 +1,6 @@ # PEcAn.ED2 (development version) -* Fixed a bug effecting the generation of job.sh for runs with many PFTs (#3075) +* Fixed a bug affecting the generation of job.sh for runs with many PFTs (#3075) * Added optional `process_partial` argument to `model2netcdf.ED2()` to allow it to process existing output from failed runs. # PEcAn.ED2 1.7.2