From abed8b0be77b568353dbae0cf3bd2ebd9dbd5634 Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 04:42:43 -0700 Subject: [PATCH 01/10] Update Job.md --- docs/Subcommand/Job.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/Subcommand/Job.md b/docs/Subcommand/Job.md index bd66d0d44..3998f58b5 100644 --- a/docs/Subcommand/Job.md +++ b/docs/Subcommand/Job.md @@ -5,13 +5,13 @@ Shell: ~~~ -host% gridlabd job [-v|--verbose] [-q|--quiet] [-d|--debug] [-j|--jobfile JOBFILE] [-w|--workdir FOLDER] [-c|--configfile CONFIG] [-T|--threadcount NTHREADS] FILE1 ... +host% gridlabd job [-v|--verbose] [-q|--quiet] [-d|--debug] [-j|--jobfile JOBFILE] [-w|--workdir FOLDER] [-c|--configfile CONFIG] [-m|--modifyfile MODIFY] [-T|--threadcount NTHREADS] FILE1 ... ~~~ GLM: ~~~ -#job [-v|--verbose] [-q|--quiet] [-d|--debug] [-j|--jobfile JOBFILE] [-w|--workdir FOLDER] [-c|--configfile CONFIG] [-T|--threadcount NTHREADS] FILE1 ... +#job [-v|--verbose] [-q|--quiet] [-d|--debug] [-j|--jobfile JOBFILE] [-w|--workdir FOLDER] [-c|--configfile CONFIG] [-m|--modifyfile MODIFY] [-T|--threadcount NTHREADS] FILE1 ... ~~~ # Description @@ -32,18 +32,22 @@ Specifies the name of the configuration file to use instead of `gridlabd-config. Enables debugging output. -### `-T|--threadpool NTHREADS` - -Enables parallel processing of jobs using a threadpool using the specified number of threads. - ### `-j|--jobfile JOBFILE` Specifies the name of the job control file to use instead of `gridlabd-job.csv`. +### `-m|--modifyfile MODIFY` + +Specifies the name of the modify file to use instead of `gridlabd-modify.glm`. + ### `-q|--quiet` Disables all but error output. +### `-T|--threadpool NTHREADS` + +Enables parallel processing of jobs using a threadpool using the specified number of threads. + ### `-v|--verbose` Enable additional output (useful to diagnose problem). From ccd597f04a0372aef8802f65facbe3f311692aa6 Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 04:42:47 -0700 Subject: [PATCH 02/10] Create job-clock.glm --- gldcore/scripts/autotest/job-clock.glm | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 gldcore/scripts/autotest/job-clock.glm diff --git a/gldcore/scripts/autotest/job-clock.glm b/gldcore/scripts/autotest/job-clock.glm new file mode 100644 index 000000000..b9a6b0cb1 --- /dev/null +++ b/gldcore/scripts/autotest/job-clock.glm @@ -0,0 +1,5 @@ +clock +{ + starttime "2020-01-01 00:00:00"; + stoptime "2021-01-01 00:00:00"; +} \ No newline at end of file From 71cba700656b9b4b75b6ed904861d6e95e586880 Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 04:43:02 -0700 Subject: [PATCH 03/10] Create test_job_modfile.glm --- gldcore/scripts/autotest/test_job_modfile.glm | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 gldcore/scripts/autotest/test_job_modfile.glm diff --git a/gldcore/scripts/autotest/test_job_modfile.glm b/gldcore/scripts/autotest/test_job_modfile.glm new file mode 100644 index 000000000..bd48ef411 --- /dev/null +++ b/gldcore/scripts/autotest/test_job_modfile.glm @@ -0,0 +1,8 @@ +#ifndef TEST1 +#ifexist ../gridlabd-job.csv +#define TESTDIR=.. +#endif +#job -T 0 ${modelname} -j ${TESTDIR:-.}/gridlabd-job.csv -m ${TESTDIR:-.}/job-clock.glm +#else +#print TEST ${TEST1}: ${TEST2},${TEST3},${TEST4} +#endif From ba22cef2c4d744d476a8f108f059d3973d637c44 Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 04:43:04 -0700 Subject: [PATCH 04/10] Create test_job_modfile_err.glm --- gldcore/scripts/autotest/test_job_modfile_err.glm | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 gldcore/scripts/autotest/test_job_modfile_err.glm diff --git a/gldcore/scripts/autotest/test_job_modfile_err.glm b/gldcore/scripts/autotest/test_job_modfile_err.glm new file mode 100644 index 000000000..9c69ecc41 --- /dev/null +++ b/gldcore/scripts/autotest/test_job_modfile_err.glm @@ -0,0 +1,8 @@ +#ifndef TEST1 +#ifexist ../gridlabd-job.csv +#define TESTDIR=.. +#endif +#job -T 0 ${modelname} -j ${TESTDIR:-.}/gridlabd-job.csv -m ${TESTDIR:-.}/not-found.glm +#else +#print TEST ${TEST1}: ${TEST2},${TEST3},${TEST4} +#endif From 07e680a3893bbf85b2fe06742de407f20a66246a Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 04:43:06 -0700 Subject: [PATCH 05/10] Update gridlabd-job --- gldcore/scripts/gridlabd-job | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gldcore/scripts/gridlabd-job b/gldcore/scripts/gridlabd-job index 92d479f6a..ba41c435f 100755 --- a/gldcore/scripts/gridlabd-job +++ b/gldcore/scripts/gridlabd-job @@ -9,13 +9,14 @@ import subprocess from multiprocessing import pool, freeze_support import curses -SYNTAX="Syntax: gridlabd job [-v|--verbose] [-q|--quiet] [-d|--debug] [-j|--jobfile JOBFILE] [-w|--workdir FOLDER] [-c|--configfile CONFIG] [-T|--threadcount NTHREADS] FILE1 ..." +SYNTAX="Syntax: gridlabd job [-v|--verbose] [-q|--quiet] [-d|--debug] [-j|--jobfile JOBFILE] [-w|--workdir FOLDER] [-c|--configfile CONFIG] [-m|--modifyfile MODIFY] [-T|--threadcount NTHREADS] FILE1 ..." VERBOSE=False DEBUG=False QUIET=False DEBUG=False JOBFILE="gridlabd-job.csv" CFGFILE="gridlabd-config.glm" +MODFILE="gridlabd-modify.glm" WORKDIR=os.getcwd() THREADS=1 JOBPOOL=None @@ -58,6 +59,10 @@ def runjob(jobid): print(f"#define {var}={value}",file=cfg) args = ["gridlabd",cfgfile] args.extend(GLMLIST) + if os.path.exist(MODFILE): + args.extend(MODFILE) + elif MODFILE != "gridlabd-modify.glm": + error(f"{MODFILE} does not exist") verbose(f"running '{' '.join(args)}'") result = subprocess.run(args,capture_output=True,encoding="utf-8") if result.stdout: @@ -66,7 +71,7 @@ def runjob(jobid): error(None,result.stderr.strip()) return result -def initializer(verbose,debug,quiet,jobfile,cfgfile,workdir,glmlist,jobdata): +def initializer(verbose,debug,quiet,jobfile,cfgfile,modfile,workdir,glmlist,jobdata): global VERBOSE VERBOSE = verbose global DEBUG @@ -77,6 +82,8 @@ def initializer(verbose,debug,quiet,jobfile,cfgfile,workdir,glmlist,jobdata): JOBFILE = jobfile global CFGFILE CFGFILE = cfgfile + global MODFILE + MODFILE = modfile global WORKDIR WORKDIR = workdir global GLMLIST @@ -105,11 +112,15 @@ if __name__ == "__main__": elif sys.argv[n] in ["-j","--jobfile"]: n+=1 JOBFILE=sys.argv[n] - verbose(f"using control file {CFGFILE}") + verbose(f"using control file {JOBFILE}") elif sys.argv[n] in ["-c","--configfile"]: n+=1 CFGFILE=sys.argv[n] - verbose(f"using GLM file {GLMFILE}") + verbose(f"using GLM configuration file {CFGFILE}") + elif sys.argv[n] in ["-m","--modifyfile"]: + n+=1 + MODFILE=sys.argv[n] + verbose(f"using GLM modify file {MODFILE}") elif sys.argv[n] in ["-w","--workdir"]: n+=1 WORKDIR=sys.argv[n] @@ -138,6 +149,7 @@ if __name__ == "__main__": QUIET, JOBFILE, CFGFILE, + MODFILE, WORKDIR, GLMLIST, JOBDATA, From 066b90aa2f4fe053c09f2f4b16212b19e72fe303 Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 04:48:58 -0700 Subject: [PATCH 06/10] Update Job.md --- docs/Subcommand/Job.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Subcommand/Job.md b/docs/Subcommand/Job.md index 3998f58b5..91051539f 100644 --- a/docs/Subcommand/Job.md +++ b/docs/Subcommand/Job.md @@ -26,7 +26,7 @@ The default configuration file name is `gridlabd-config.glm`. ### `-c|--configfile CONFIG` -Specifies the name of the configuration file to use instead of `gridlabd-config.glm`. +Specifies the name of the configuration file name to use instead of `gridlabd-config.glm`. The configuration file is created from the job entry in the job control file and loaded before the main GLM file is loaded. ### `-d|--debug` @@ -38,7 +38,7 @@ Specifies the name of the job control file to use instead of `gridlabd-job.csv`. ### `-m|--modifyfile MODIFY` -Specifies the name of the modify file to use instead of `gridlabd-modify.glm`. +Specifies the name of the modify file to use instead of `gridlabd-modify.glm`. The modification file is loaded after the main GLM file is loaded. ### `-q|--quiet` From 3242b9b167945b468b3bed14294c1c6b94dbe68a Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 04:53:52 -0700 Subject: [PATCH 07/10] Update gridlabd-job --- gldcore/scripts/gridlabd-job | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gldcore/scripts/gridlabd-job b/gldcore/scripts/gridlabd-job index ba41c435f..e0773453e 100755 --- a/gldcore/scripts/gridlabd-job +++ b/gldcore/scripts/gridlabd-job @@ -59,7 +59,7 @@ def runjob(jobid): print(f"#define {var}={value}",file=cfg) args = ["gridlabd",cfgfile] args.extend(GLMLIST) - if os.path.exist(MODFILE): + if os.path.exists(MODFILE): args.extend(MODFILE) elif MODFILE != "gridlabd-modify.glm": error(f"{MODFILE} does not exist") From d2e4deb8eda3e7adf8d7fd4c4b2d9032de2facef Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 04:56:17 -0700 Subject: [PATCH 08/10] Update gridlabd-version --- gldcore/scripts/gridlabd-version | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gldcore/scripts/gridlabd-version b/gldcore/scripts/gridlabd-version index 9e3e5c6e1..54c628c72 100755 --- a/gldcore/scripts/gridlabd-version +++ b/gldcore/scripts/gridlabd-version @@ -49,8 +49,9 @@ function version-check() branch=$(${BIN} --version=git-branch) remote=$( (curl -sL "https://raw.githubusercontent.com/slacgismo/gridlabd/$branch/gldcore/version.h" | grep '#define REV_' | cut -f3 -d' ' | tr '\n' . | cut -f-3 -d.) || echo "none" ) if [ "$remote" == "none" -o -z "$remote" ]; then - [ "$1" != "-q" ] && error 2 "$version ($branch) remote not found" - exit 2 + [ "$1" != "-q" -a "$1" != "-w" ] && error 2 "$version ($branch) remote not found" + [ "$1" != "-q" ] && warning "$version ($branch) remote not found" + exit 0 fi [ "$1" == "-v" ] && echo "REMOTE/$branch $remote" ${BIN} --version="-ge $remote" 2>/dev/null || ( ( [ "$1" != "-q" ] && error 1 "$version ($branch) is outdated" ) ; exit 1 ) From 25a3e50e730d422ea52c30c62ffba588acbe3c3a Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 05:08:14 -0700 Subject: [PATCH 09/10] Update gridlabd-job --- gldcore/scripts/gridlabd-job | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gldcore/scripts/gridlabd-job b/gldcore/scripts/gridlabd-job index e0773453e..81c76c521 100755 --- a/gldcore/scripts/gridlabd-job +++ b/gldcore/scripts/gridlabd-job @@ -60,7 +60,7 @@ def runjob(jobid): args = ["gridlabd",cfgfile] args.extend(GLMLIST) if os.path.exists(MODFILE): - args.extend(MODFILE) + args.append(MODFILE) elif MODFILE != "gridlabd-modify.glm": error(f"{MODFILE} does not exist") verbose(f"running '{' '.join(args)}'") From 2b6d494fbf1ad6952826f207c5763cc180931a1f Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Fri, 1 Oct 2021 05:08:16 -0700 Subject: [PATCH 10/10] Update job-clock.glm --- gldcore/scripts/autotest/job-clock.glm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gldcore/scripts/autotest/job-clock.glm b/gldcore/scripts/autotest/job-clock.glm index b9a6b0cb1..868bb0f41 100644 --- a/gldcore/scripts/autotest/job-clock.glm +++ b/gldcore/scripts/autotest/job-clock.glm @@ -2,4 +2,6 @@ clock { starttime "2020-01-01 00:00:00"; stoptime "2021-01-01 00:00:00"; -} \ No newline at end of file +} +#set suppress_repeat_messages=FALSE +#print clock modified in ${modelname}