fixed segv in init_forcerec with fr->hwinfo=NULL
authorBerk Hess <hess@kth.se>
Mon, 4 Feb 2013 12:44:31 +0000 (13:44 +0100)
committerBerk Hess <hess@kth.se>
Mon, 4 Feb 2013 12:44:31 +0000 (13:44 +0100)
This caused genion and g_disre to segv with the Verlet scheme.
Fixes #1136

Change-Id: I9059b0e108c80ea86567a568e9f488b4db500eee

src/mdlib/forcerec.c

index d7b6c1297873a68cd572c91a012da55535e0c8bd..f110a9b9fd938b71522e2d6306b985685615017b 100644 (file)
@@ -75,6 +75,7 @@
 #include "nbnxn_consts.h"
 #include "statutil.h"
 #include "gmx_omp_nthreads.h"
+#include "gmx_detect_hardware.h"
 
 #ifdef _MSC_VER
 /* MSVC definition for __cpuid() */
@@ -2040,6 +2041,17 @@ void init_forcerec(FILE              *fp,
     t_nblists     *nbl;
     int           *nm_ind, egp_flags;
 
+    if (fr->hwinfo == NULL)
+    {
+        /* Detect hardware, gather information.
+         * In mdrun, hwinfo has already been set before calling init_forcerec.
+         * Here we ignore GPUs, as tools will not use them anyhow.
+         */
+        snew(fr->hwinfo, 1);
+        gmx_detect_hardware(fp, fr->hwinfo, cr,
+                            FALSE, FALSE, NULL);
+    }
+
     /* By default we turn acceleration on, but it might be turned off further down... */
     fr->use_cpu_acceleration = TRUE;