Refactor logical tests to avoid invalid memory access.
Refactor logical tests to avoid invalid memory access.

The test was relatively safe (unless it exceeded array bounds--unlikely!) but was
technically incorrect as Fortran can evaluate boolean statements in an arbitrary
order.  Remove this ambiguity to ensure no memory can be accessed outside of the array
bounds nor uninitialized memory can be accessed (in both cases the first test
prevents the incorrect memory access in the second test from occurring).

ruthfranklin/hande,hande-qmc/hande,hande-qmc/hande,hande-qmc/hande,hande-qmc/hande,hande-qmc/hande