How Getenv Variable Style works?

Dear LAMMPS Users,

I am stuck with a problem with the variable getenv arg command and I would appreciate very much any suggestions.

I have been trying to import an environment variable to LAMMPS as a variable to be used for a directory name to save the results. However, despite the fact that I get no error from the process, the variable remains empty instead of having the appropriate string.

My code is:

shell . ./ (Creates folders and exports parent directory name to shell as $PMF - validated!)

variable test getenv PMF ( Doesn’t seem to work with neither PMF, {PMF}, %PMF, 'PMF' etc.) *print "{test} "* (In the end, it doesn’t plot anything, although the script ends correctly)

I don’t understand why it cannot import it. I suspect that the problem is in the syntax but I couldn’t find any relevant example with getenv. Do you have any ideas?

Thank you in advance,
Michalis Palaiokostas
PhD Student, Queen Mary University of London,
London, United Kingdom

It doesn't work because the shell command runs in a subshell. You have to run your shell script via source or using the . Command before you launch lammps.