avoid mdrun crash when rdtscp is not supported

When using rdtscp, mdrun now detects at runtime whether the CPU supports
this instruction and if this is not the case, it issues a fatal error
and instructs the user to recompile mdrun for the compute host. Note
that this will happen rarely, only when cross-compiling from a newer
host for a rather old one.

Additionally, when the user manually picks AVX, we also turn on RDTSCP
as all AVX-capable CPUs support it.

Also made CMake advanced cache option for GMX_USE_RDTSCP. This replaces
the previously hidden GMX_DISTRIBUTABLE_BUILD option.

Fixes #1428

Change-Id: I8bc884ef9ea8ea4661626b60490182ae2b302648
Fix aligned store to unaligned memory

Also fixes that unaligned store was used when not necessary.

Change-Id: I44bb222a07ec0af65198667787b8673b3c6cd2e7
added gmx_is_{single,double}_precision

* allows easy detection of the precision for cmake, autotools
  without parsing the output of gmx_print_version_info (no
  cross-compile support) or the output of strings command (unix
  only)
* linking against libgmx with/out -DGMX_DOUBLE will lead to
  unpredictable segfaults

Change-Id: I472f10ae374a1f42c94c55e156b53f8905bdf098
Reinstate shell code with DD

Further work on the complex/sw test case in the 5.0 regressiontests
branch reveals that the initial conditions may have been the reason
for the problems observed with DD and more than one node, rather than
the implementation.

Refs #1429

Change-Id: I26ff6d9f8c79605afa794cae4761b5643b712124
portability aspects in install guide + minor tweaks

Added information on portability aspects related to CPU instruction
sets, related to #1428.

Additionally, made several minor updates and tweaks related to
compilers, platforms, cmake, etc.

Change-Id: I621262c939c119e5bdd5e7c91dda0ae3ffc60b7b
Permit warning-free use of Andersen thermostat

Simulations using Andersen thermostat don't need to remove center of
mass motion, because that is intrinsic to the algorithm. Using it with
nstcomm > 1 generated a warning that center-of-mass removal is
unnecessary. Using it with nstcomm == 0 generated a warning that
ice-cube artifacts might be generated. Resolved by suppressing the
latter warning for both Andersen thermostats.

Change-Id: I6b2c1594cabd81964b3ba1ebc5dd61e0f1debb5e
Improved CUDA non-bonded kernel performance

Some old tweak which was supposed to improve performance had in fact
the opposite effect. Removing this tweak and with it eliminating 
shared memory bank conflicts it caused improved performance by up
to 2.5% in the force-only CUDA kernel.

Change-Id: I7fcb24defed2c68627457522c39805afc83b3276
Add fatal error for Andersen+constraints+DD

This combination produced a temperature that was 6.5 degrees higher
than the same with one domain, for a 1ns PME lysozyme in water
simulation.

Change-Id: I9f80276c47de955a5053bcabb6fe7c9bfdceaf0e
Fix incorrect grid cell size in g_sas -nopbc

Fixes #1445

Change-Id: I798fc8fe96608633f26d9a3500f83f39b44af008
The van der Waals radius must equal the Coulomb radius with Verlet

This patch fixes an issue that can occur when using g_tune_pme
with a Verlet pair-list .tpr input file. If the .tpr itself has
large cutoffs (e.g. 1.2 nm) and one asks g_tune_pme to scale
_down_ the Coulomb radius, the van der Waals radius is not
scaled down with the Coulomb radius (only upscaling worked).
One ends up with an unusable .tpr file because rVdW != rCoul.
This patch ensures that van der Waals and Coulomb radii
are always equal with Verlet pair-lists. Fixes #1460. Thanks
to Joao Rodrigues for reporting the issue!

Change-Id: I5ef30e71a35cd83838040057e16e52e09ea82e9a
Avoid cross product with zero vector in rotational pulling.

Fixes #1431 (rotation/flex-t regression test failing on BG/Q)

In do_flex_lowlevel() we checked (by mistake!) for xj-xcn being
zero, although we need to check for yj0-ycn being zero, since
we use yj0-ycn in a cross product in the following lines of code.
I now also replaced the direct check (0 == norm(...)) by checking
what gmx_numzero(norm(...)) returns. The latter replacement
was also applied in the do_flex2_lowlevel() routine. Note that there
the check for small xj-xcn was and is actually correct.

Change-Id: I972b6d67a81e30f297db286cd2224f66753a20aa
House-keeping for MTTK

Leapfrog + MTTK silently produced a .tpr that is probably broken;
certainly the documentation only states support for Velocity-verlet
integrators.

Added note about deprecation and planned removal of MTTK + constraints.

Refs #1292

Change-Id: Iec2cf0dd866242735ce04a954e585b2461f6e701
Fixed bug in parallel v/f constraining

Constraining v or f with 3 or more decomposition domains in one
or more dimensions could lead to modification of communicated
v and f components by the box size for inter charge-group constraints.
Fixes #1462

Change-Id: Idece9d2d0d8f48e65a654d5c2892fbe1ff836ba0
Adds cut-off checks for triclinic domain decomposition

With domain decomposition and 2 decomposition cells in a trilinic
dimension, the cut-off could be longer than the size of the
communicated domains. This could lead to some pairs close to cut-off
distance to be ignored in the force/energy calculations.
Fixes #1467

Change-Id: Id7e16d7f8fa0796d6adcf48ad6e8bbb0b88039ff
Make sure water optimization is disabled for esoteric interactions

This fixes a bug where the generic NB kernel could be called with
a water-water neighborlist for a few special combinations where
no C kernels existed (e.g. switch/shifted plain-cutoff coulomb).
This would typically lead to virtually no nonbonded interactions
being calculated and the simulation crashing rapidly, so it is
unlikely to have affected any results silently, but was noticed
when testing interaction forms.

Change-Id: I634fc4ab78b54281c89333299975e25883dc1f2c
Fix invalid dereference in g_tune_pme

Change-Id: If4c999e22799ab2087ff1a1d74d8e5b50ddddd57
Fixed g_rmsdist NOE calculation

This fix solve a series of bugs in NOE calculations:
1) incorrect number of frames in the calculation of the average distance
2) wrong selection of equivalent atoms
3) -equiv was wrongly documented

Change-Id: Icc6bbed0e1ba65774ad470c3edbd7a6a96e63ee6
Issue warnings for potential switch w/o defining switch regions.

If either older style switches or new potential-switch modifiers are
used, issue a warning if the PME regions is too long, resulting in
inaccurate energies. Also issue a warning if rvdw_switch is 0, which
occurs if no value is specified.

Discussion is in redmine #1463

Change-Id: I7a2c29f87ceb04712aab5076ac97f5f22f573671
Fix memory error in asc format IO

Found with cppcheck 1.64

Change-Id: I72e80cd2b11559be47d449d0a8d444857843979b
Removed truncation of nrdf in v-rescale thermostat

The resampling function for the v-rescale thermostat expected an
integer value for nrdf, but a real was passed, which was truncated.
With a single coupling coupling group nrdf is analytically an int,
but could be off by a bit. The could lead to incorrect kinetic
energy fluctuations (averages were correct).
Now fractional nrdf's are properly handled for nrdf > 3.
For nrdf < 3 a check is added for integer values with a small margin
for rounding.
Fixes #1218

Change-Id: I4c60c337f9874d0bff51220ad09429140be2a056