cannt use environment variables in non-stringy parameters

Issue #1525 closed
Roland Haas created an issue

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).

Keyword:

Comments (10)

  1. Steven R. Brandt
    • removed comment

    Conversion functions, real(), and int() are available (and documented in B3.2 of the User Guide!). Does this address your concern?

  2. Roland Haas reporter
    • removed comment

    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)?

  3. Roland Haas reporter
    • changed status to open
    • removed 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, in C++ I do not know.

  4. Roland Haas reporter
    • changed status to open
    • removed comment

    The current patch seems fine. Please apply. Thank you for the quick fixes.

  5. Roland Haas reporter
    • removed comment

    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.

  6. Log in to comment