Fix RelWithDebInfo name bugs, and use full optimization.

Gromacs was previously using a different name (RelWithDebugInfo) in
a few places, which caused the build types not to match, and
flags did not propagate correctly. Second, we now add our own
optimization flags at the end of the flag variables, to make it more
likely they override the CMake default choices. Otherwise, the -O2
flag at the end of the default RelWithDebInfo flags might revert our flags.

Change-Id: I4b7e220fbb2d625416e939e71d44412601394c0f
Fix message about incorrect usage of dihedral type 9

The warning printed the wrong type number: 4 instead of 9. Also it
didn't clarify that 9 only combines consecutive lines.

Change-Id: Ie65a050c978f162acf9f9a2329dde286c068438c
Fixes potential bug in neighborsearching.

From put_in_list we first call new_i_nblist, then add some
j particles and then close_i_nblist

In new_i_nblist the number of i particles is typically
increased by one, that is nblist->nri is increased.

However, in case that there are no j particles, the nri
is not decreased again, which can lead to reading garbage
data from e.g. nblist->jjindex. In addition there is a
left-over variable (len) that computes the number of
j particles added, but this value is not used.

Change-Id: I38601a6865f6a4d879bec55246deded40943afb7
Fix incorrect assertion statement

Copy-paste bug that was totally harmless as we've always had more
electrostatics than VdW kernel types, but it did render the assertion
incorrect.

Change-Id: I996bef6342cbb9bb8ce8994f38cac61924f6af1f
Fix calc_grid avoiding PME grid factor 84

Due to an indexing issue, it was unlikely that calc_grid, and thus
grompp, would choose a PME grid of 84*2^n and instead use a factor 96.
For a cubic box, this could increase the FFT cost by a factor 1.5.
Fixes #1605.

Change-Id: I8d6a85a98267af053b66867722fc5626ef907964
Merge release-4-6 into release-5-0

Change-Id: Ie72eccf57febab7b7ac8092ce55988b9cb2737af
Avoid PME tuning decreasing rcoulomb

With mdrun input with the grid much finer than fourier-spacing,
PME tuning could reduce rcoulomb below the starting value.
Fixes #1606.

Change-Id: I3ae7fe38a4240251aadb96336199b306fc7dce40
Merge "Merge release-4-6 into release-5-0" into release-5-0
SIMD acceleration for RB dihedrals

RB dihedrals now use SIMD acceleration analogous to proper dihedrals
when no energy and virial is required. This also significantly
improves load balancing (issues) for systems with proper+RB dihedrals.
Refs #1598.

Change-Id: I07000125d19db45fc35e1a0c28149c8a19443680
Clarify GCC+Win+AVX warning

Message was accidentally not printed for Cygwin.
Message was printed even for GCC version which are OK.

Change-Id: I4560908317919bc36f33f6e430e6b7a34853ae73
Domain decomposition now checks the rlist buffer

When a large pair-list buffer, which will appear with large nstlist,
atoms are allowed to displace the buffer size, i.e. a lot, in nstlist
steps. The limit this puts on the DD cell size is now checked.
Also updated cg_move_error, which now no longer prints the old atom
coordinates with the Verlet scheme, where the "old" coordinates are
actually the new ones.
Fixes #1607.

Change-Id: I784afa5ee620b51f555f4d1107f38cbbae2c55d1
Avoid using function calls in OpenMP directives

The direct calls to gmx_omp_nthreads_get() that were
included in some OpenMP pragmas caused memory
corruption and later segfaults on PGI compilers. This
is likely a compiler bug, but we can work around it
by assigning the function return value to a variable
that we use in the pragma.

Such variables are unused when OpenMP is not in use, which might
offend some compiler some time, so adding a gmx_unused attribute is
useful. However, uncrustify needs to be taught about our custom
attributes, which is also done here.

Change-Id: I3b482bdc2401b40a043975ffd4a741f65efd0cfc
Added GPU local wait to load balancing

The GPU local wait time was not included in the load imbalance timing.
This could lead to incorrect load imbalance reporting and dynamic
load balancing, especially with CUDA stream priorities.
Note that we can't accurately measure the GPU time, when it finishes
during dd_move_f.

Change-Id: If4bb0f867593450cc025c8593672b0569397b1d6
Avoid DLB with overloaded PME ranks

When separate PME ranks have more load than the PP ranks, DLB can
not improve improve performance. It will actually make it worse,
because the PME x/f redistribution time goes up. Now with -dlb=auto
DLB is not turned on in this situation.
Also DLB is not activated during PME tuning with GPUs and separate
PME nodes, since it then nearly always deteriorates the performance.

Change-Id: I1f5e649a9562fdca9ba538196f41a12feb0a4a24
Fix incorrect LJ cut-off with GPU + PME tuning

Due to the mismatch of the macro used in generating and implementing the
twin cut-off CUDA kernels (used with PP-PME load balancing), the VdW
cut-off check was not generated and the (larger) electrostatics cut-off
was enforced instead, causing incorrect results with PME tuning.

Fixes #1603

Change-Id: I43ae19968b30843cfe407e927a5cf0bd35c62881
Allow gmx tune_pme to skip the check for command-line health

Therefore, this patch adds the "-check" command line option, which is
TRUE by default, but can be switched to FALSE in problematic cases.
Documented its main use case in the error message that it would
circumvent.

Also corrected a few typos.

Fixes part of #1609

Change-Id: Id1cadd620438c36c123ff075c9a98ea7d1534d4d
Version 5.0.2

Removed -dev tags from versions. regressiontest repo has not changed
since 5.0.1, but somehow the hash differs from the one used then.

Change-Id: I0f632262e4dd11875479d4f6a0c932169a699eb9
Version bumps after new release

Numbers bumped, -dev tag replaced.

Change-Id: I9aa220cc837b126ad694786178901db336d7121d
Merge release-5-0 into master

Conflicts:
	CMakeLists.txt
Version numbers not bumped; fixed to use the right
name for RelWithDebInfo.

	cmake/gmxCFlags.cmake
Fixed to use the right name for RelWithDebInfo.

	src/gromacs/listed-forces/bonded.cpp
New RB SIMD function in bonded.cpp had unused variables, now
eliminated

	src/gromacs/mdlib/domdec.cpp
Bug fixes from release-5-0 incorporated. std::max now used in code
newly arrived from release-5-0.

md.cpp had no conflict, but fr->nbv->bUseGPU had to
be replaced by use_GPU(fr->nbv) to work in master branch.

Change-Id: I65326b691745111fbdaa9435be6c92fa1acf6e7d