diff --git a/patches/gromacs-2018.5.diff/src/programs/mdrun/runner.cpp b/patches/gromacs-2018.5.diff/src/programs/mdrun/runner.cpp
index 25a8230eb42715d61e272b2852b176ef3d812a33..f8a336a638e6e3c0f11e89df143be3730b159b82 100644
--- a/patches/gromacs-2018.5.diff/src/programs/mdrun/runner.cpp
+++ b/patches/gromacs-2018.5.diff/src/programs/mdrun/runner.cpp
@@ -1342,7 +1342,10 @@ int Mdrunner::mdrunner()
           /* detect plumed API version */
           int pversion=0;
           plumed_cmd(plumedmain,"getApiVersion",&pversion);
-          if(pversion>5) plumed_cmd(plumedmain,"setNumOMPthreads",&hw_opt.nthreads_omp);
+          if(pversion>5) {
+             int nth = gmx_omp_nthreads_get(emntDefault);
+             if(pversion>5) plumed_cmd(plumedmain,"setNumOMPthreads",&nth);
+          }
         }
         /* END PLUMED */