[lammps-users] Access to environment variables


I was wondering if it would be possible to extend LAMMPS such that one can
use environment variables in LAMMPS input scripts. For example, one could
extend the parser to evaluate a construction like '%{foo}' to be
'getenv("foo")'. Another possibility would be to extend the variable
command to convert environment variables to LAMMPS variables (something
like "variable myvar environment foo").

I could see many uses for such a construct, a trivial one being to use the
bash environment variable RANDOM to seed the random number generator in
LAMMPS. Could this be done in a portable way for all platforms that LAMMPS
runs on?



LAMMPS allows you to pass variable values via command-line
switches (-var foo 100), so you could pass in an environment
var that way (evaluated in the mpirun command-line).