#1525: cannt use environment variables in non-stringy parameters --------------------+------------------------------------------------------- Reporter: rhaas | Owner: Type: defect | Status: new Priority: minor | Milestone: Component: Cactus | Version: development version Keywords: | --------------------+------------------------------------------------------- the attached parfile, when run with {{{ TERMINATE_NEXT=no RUNTIME=12 TERMINATE=never RUNTITLE=test ~/data/postdoc/gr/Zelmani/exe/cactus_null env.par }}} produces an error {{{ WARNING level 0 in thorn Cactus processor 0 host horizon.tapir.caltech.edu (line 1 of env): -> Invalid assignment: Attempting to set a variable of type REAL with (STRING)"12" }}} preventing any number-valued parameter to be passed into the simulation via environment variables. In my case I wanted to use the runtime that I computed based on the information available in a qsub script (ie without using simfactory), which is useful to eg run several short Cactus runs in a single qsub script.
It would be useful if (as in eg awk for data read from files) environment variables are considered to be "numeric strings" which can be converted to numbers if required.
Boolean, string type parameters and keyword type parameters work fine. This is a regression compared to the old parser which did to the env expansion before the parsing stage so would allow env variables everywhere (though I think only on the RHS and not on the LHS of a parameter setting).
#1525: cannt use environment variables in non-stringy parameters ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: Type: defect | Status: new Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------
Comment (by sbrandt):
Conversion functions, real(), and int() are available (and documented in B3.2 of the User Guide!). Does this address your concern?
#1525: cannt use environment variables in non-stringy parameters ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: Type: defect | Status: new Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------
Comment (by rhaas):
Neither int() nor real() helps (had already tried this yesterday but not included in the example parfile, sorry). I get: {{{ WARNING level 0 in thorn Cactus processor 0 host horizon.tapir.caltech.edu (line 1 of env): -> Unknown func: int(STRING) }}} and the same for real(). If I directly put int(1.5) in the partfile then that works. Since the functions only accept numeric types, is real() pretty much a pass-through (like the unary "+" in C)?
#1525: cannt use environment variables in non-stringy parameters ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: accepted Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------ Changes (by sbrandt):
* owner: => sbrandt * status: new => accepted
#1525: cannt use environment variables in non-stringy parameters ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: review Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------ Changes (by sbrandt):
* status: accepted => review
Comment:
This patch adds the code to make real()/int()/bool() work on strings.
#1525: cannt use environment variables in non-stringy parameters ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: reopened Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------ Changes (by rhaas):
* status: review => reopened
Comment:
The patch lets me use ENV variables. However it also accepts: {{{ TERMINATE_NEXT=no RUNTIME="12 aa" TERMINATE=never RUNTITLE=test ~/data/postdoc/gr/Zelmani/exe/cactus_null env.par }}} where I added some extra characters " aa" at the end of the number. It should in this case fail. In C one can use the endptr argument of strtod, I C++ I do not know.
#1525: cannt use environment variables in non-stringy parameters ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: review Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------ Changes (by sbrandt):
* status: reopened => review
Comment:
This modification catches the problem with trailing characters.
#1525: cannt use environment variables in non-stringy parameters ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: reviewed_ok Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------ Changes (by rhaas):
* status: review => reviewed_ok
Comment:
The current patch seems fine. Please apply. Thank you for the quick fixes.
#1525: cannt use environment variables in non-stringy parameters ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: reviewed_ok Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------
Comment (by rhaas):
I just noticed that the error message reads: {{{ WARNING level 0 in thorn Cactus processor 0 host horizon.tapir.caltech.edu (line 1 of env): -> Invalid numerical value: 12e }}} ie the paramter file name is given as just "env" without the ".par" extension (which the function get_parfile actually strips). I think for error messages one should use the string returned by CCTK_ParameterFilename without further modifications. In particular get_parfile may or may not modify the returned value so one cannot just add ".par" to its returned string to restore the value returned by CCTK_ParameterFilename. This might affect other error messages as well.
#1525: cannt use environment variables in non-stringy parameters ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: closed Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: fixed | Keywords: ---------------------+------------------------------------------------------ Changes (by sbrandt):
* status: reviewed_ok => closed * resolution: => fixed
Comment:
Fixed in revision 5069.
trac@lists.einsteintoolkit.org