+ /* Set free energy calculation frequency as the greatest common
+ * denominator of nstdhdl and repl_ex_nst.
+ * Check for nstcalclr with twin-range, since we need the long-range
+ * contribution to the free-energy at the correct (nstcalclr) steps.
+ */
+ nstfep = ir->fepvals->nstdhdl;
+ if (ir->bExpanded)
+ {
+ if (IR_TWINRANGE(*ir) &&
+ ir->expandedvals->nstexpanded % ir->nstcalclr != 0)
+ {
+ gmx_fatal(FARGS, "nstexpanded should be divisible by nstcalclr");
+ }
+ }
+ if (repl_ex_nst > 0)
+ {
+ nstfep = gmx_greatest_common_divisor(repl_ex_nst, nstfep);
+ }
+ /* We checked divisibility of repl_ex_nst and nstcalclr above */
+ if (IR_TWINRANGE(*ir) && nstfep % ir->nstcalclr != 0)
+ {
+ gmx_incons("nstfep not divisible by nstcalclr");
+ }