diff --git a/docs/Subcommand/Job.md b/docs/Subcommand/Job.md index bd66d0d44..91051539f 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 @@ -26,24 +26,28 @@ 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` 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`. The modification file is loaded after the main GLM file is loaded. + ### `-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). diff --git a/gldcore/scripts/autotest/job-clock.glm b/gldcore/scripts/autotest/job-clock.glm new file mode 100644 index 000000000..868bb0f41 --- /dev/null +++ b/gldcore/scripts/autotest/job-clock.glm @@ -0,0 +1,7 @@ +clock +{ + starttime "2020-01-01 00:00:00"; + stoptime "2021-01-01 00:00:00"; +} +#set suppress_repeat_messages=FALSE +#print clock modified in ${modelname} 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 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 diff --git a/gldcore/scripts/gridlabd-job b/gldcore/scripts/gridlabd-job index 92d479f6a..81c76c521 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.exists(MODFILE): + args.append(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, 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 )