Compute used in variable between runs is not current

Hi!

At the very end of my script, I attmept to calculate and print out the
following:

  compute PairForces all pair/local force
  compute PairFMag all reduce sumsq c_PairForces
  variable PairFScale equal "sqrt(c_PairFMag)"
  print ${PairFScale}

But in doing so, I get the error message:

  ERROR: Variable PairFScale: Compute used in variable between runs is
not current (src/variable.cpp:1366)
  Last command: print ${PairFScale}

What am I doing wrong? Why is the compute not 'current' when I print it?

Thanks!
Vishnu

Please help us avoid having the same questions asked (and answered) over and over again and first do a web search.
This question has been raised many times and answered and thus there are detailed explanations about why this happens and what you have to do in the mailing list archives.

Please have a look at our recommendations for posting to the mailing list at: https://lammps.sandia.gov/guidelines.html

Thanks,
Axel.

Hi Axel,

Yes, I did attempt to sift through mailinglist before I sent this, but there
are so many emails with the same error message but slght variations on the
actual issue, that I could not figure it out.

So I do understand that computes need to be used in some manner for them to
work, but I assumed that the 'equal' style variable definition is enough. And I
only need the value of that at the very end. So should I unnecessarily compute
it during the run?

I added the equal-style variable to my thermo output like so, and it works
now.

        thermo_style custom step etotal pe temp v_PairFScale

Thanks!
Vishnu

Hi Axel,

Yes, I did attempt to sift through mailinglist before I sent this, but there

then why don’t you say so? and especially also explain why you believe that your situation is so different from that of others, which - in fact - the second part of your e-mail confirms that it is not?

are so many emails with the same error message but slght variations on the
actual issue, that I could not figure it out.

that makes no sense.
the situation is always that you need to “consume” a compute so that it is current (there is only one place in the code that does the check) and for that you need a consumer. now what is a suitable consumer of the data can vary, but that doesn’t change the fundamental issue and how you resolve it. some data is only current during a run and thus you need to cache it with a fix.

So I do understand that computes need to be used in some manner for them to
work, but I assumed that the ‘equal’ style variable definition is enough.

it obviously isn’t. an equal style variable is only executed when it is expanded. so all you are doing is shifting the problem from needing a consumer for the compute to needing a consumer for the variable.

And I
only need the value of that at the very end. So should I unnecessarily compute
it during the run?

no. you can just add something that consumes the compute, then do a “run 0 post no” and have your updated compute data computed only once.

axel.

> And I
> only need the value of that at the very end. So should I unnecessarily
> compute
> it during the run?

no. you can just add something that consumes the compute, then do a "run 0
post no" and have your updated compute data computed only once.

Ah! So how does one "consume" a compute once? Obviously just a 'print' isn't
sufficient.

now you are seriously irritating me. the answer to your question is in the paragraph you quoted just above the question.

axel.