From 82132879666069387e9b64de5944fd642e998098 Mon Sep 17 00:00:00 2001 From: Michele Invernizzi Date: Wed, 28 Nov 2018 16:09:05 +0100 Subject: [PATCH] detect the number of available CPU for plumed make, as suggested by @akohlmey --- lib/plumed/Install.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/plumed/Install.py b/lib/plumed/Install.py index abead8deb8..b79108d2b4 100644 --- a/lib/plumed/Install.py +++ b/lib/plumed/Install.py @@ -186,14 +186,17 @@ if buildflag: subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) os.remove("%s/%s" % (homepath,filename)) -# build plumed + # build plumed + print("Building plumed ...") + try: + import multiprocessing + n_cpus = multiprocessing.cpu_count() + except: + n_cpus = 1 + cmd = 'cd %s/plumed-%s; ./configure --prefix=%s --enable-static-patch ; make -j%d ; make install' % (homepath,version,homedir,n_cpus) + txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + print(txt.decode('UTF-8')) -if buildflag: - print("Building plumed ...") - cmd = 'cd %s/plumed-%s; ./configure --prefix=%s --enable-static-patch ; make -j8 ; make install' % (homepath,version,homedir) - txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) - print(txt.decode('UTF-8')) -# # create 2 links in lib/plumed to plumed2 installation dir if linkflag: